サンプルプログラム
@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" def user = "hadoop25b" def httpclient = new DefaultHttpClient() httpclient.withCloseable { def method = new HttpGet( "http://${host}:${port}/webhdfs/v1${path}?op=LISTSTATUS&user.name=${user}" ) def response = httpclient.execute(method) println response.getStatusLine().getStatusCode() def json = new JsonSlurper().parseText(response.getEntity().getContent().text) for(status in json.FileStatuses.FileStatus){ println "type:${status.type}" println "pathSuffix:${status.pathSuffix}" } }動作環境
Hadoop 2.5.0
0 件のコメント:
コメントを投稿