( 4- Hadoop Definitive Guide)

" , create() DistributedFileSystem ( 1
3-4). DistributedFileSystem RPC namenode
, ( 2).
namenode , , ,
. ,
; ,
IOException. DistributedFileSystem FSDataOutputStream
. , FSDataOutputStream
DFSOutputStream, datanodes namenode.
( 3), DFSOutputStream , , . "
:
HDFS ( Hadoop)
public class FileCopyWithProgress {
public static void main(String[] args) throws Exception {
String localSrc = args[0];
String dst = args[1];
InputStream in = new BufferedInputStream(new FileInputStream(localSrc));
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(dst), conf);
OutputStream out = fs.create(new Path(dst), new Progressable() {
public void progress() {
System.out.print(".");
}
});
IOUtils.copyBytes(in, out, 4096, true);
}
}
create() FileSystem, getDefaultBlockSize() , inturn , , ββnamenode.
, hadoop.
,