Hadoop Java - copy file from windows share folder server to HDFS -
i want upload multiple file windows share folder server (e.g. //server_name/folder/) hdfs using java
list of methods have tried
org.apache.hadoop.fs.fileutil set input path = //server_name/folder/ says java.io.filenotfoundexception: file //server_name/folder/ not exist
filesystem.copyfromlocalfile (i think local hadoop server hdfs server)
ioutils.copybytes same fileutil >> file not exist
a simple file.renameto same fileutil >> file not exist
string source_path = "\\server_name\folder\xxx.txt";
string hdfs_path = "hdfs://hadoop_server_name:port/myfile/xxx.txt";
file srcfile = new file(source_path);
file dstfile = new file(hdfs_path);
srcfile.renameto(dstfile);
do need create ftp or how using ftpfilesystem
?
or have better solution or sample code
thank you
filesystem has copyfromlocal method:
import org.apache.hadoop.conf.configuration; import org.apache.hadoop.fs.filesystem; configuration configuration = new configuration(); configuration.set("fs.defaultfs", "hdfs://abc:9000"); filesystem fs= filesystem.get(configuration); fs.copyfromlocalfile(new path("/source/directory/"), new path("/user/hadoop/dir"));
wiki
Comments
Post a Comment