サンプルプログラム
@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 file = "01_2012.csv" def httpclient = new DefaultHttpClient() httpclient.withCloseable { def method = new HttpGet("http://${host}:${port}/webhdfs/v1${path}/${file}?op=OPEN&user.name=hadoop25b") def response = httpclient.execute(method) println response.getStatusLine().getStatusCode() new File(file).withOutputStream { os -> os << response.getEntity().getContent() } }動作環境
Hadoop 2.5.0
0 件のコメント:
コメントを投稿