import org.apache.hadoop.conf.*
import org.apache.hadoop.fs.*
fs = FileSystem.get(
URI.create("hdfs://192.168.1.81:9000/"),
new Configuration(), "hadoop")
src = "/tmp/SF.JPG"
dst = "downloaded_SF.JPG"
FSDataInputStream fis = fs.open(new Path(src))
fos = new FileOutputStream(dst)
buf = new byte[8192]
try
{
while( (rs = fis.read(buf)) != -1 ){
fos.write(buf, 0, rs)
}
}
finally
{
if( fos != null )fos.close()
if( fis != null )fis.close()
}
※以下のjarを$GROOVY_HOME/libにコピー
hadoop-common-0.21.0.jar
hadoop-hdfs-0.21.0.jar
log4j-1.2.15.jar
動作環境
groovy 1.7.5, JDK6 Update22, Hadoop 0.21.0
関連情報
CentOS5.5にHadoop0.21.0をインストールする
http://serverarekore.blogspot.com/2010/10/centos55hadoop0210.html
0 件のコメント:
コメントを投稿