サンプルプログラム
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.3.5') import org.apache.http.client.methods.* import org.apache.http.impl.client.* import org.apache.http.message.* import org.apache.http.auth.* import groovy.json.* def host = "192.168.206.132" // replace this def port = 50070 def path = "/user/hadoop25b/newdir" def user = "hadoop25b" def httpclient = new DefaultHttpClient() httpclient.withCloseable { def method = new HttpPut("http://${host}:${port}/webhdfs/v1${path}?op=MKDIRS&user.name=${user}") def response = httpclient.execute(method) println response.getStatusLine().getStatusCode() def json = new JsonSlurper().parseText(response.getEntity().getContent().text) println json.boolean }動作環境
Hadoop 2.5.0
0 件のコメント:
コメントを投稿