unable to execute hadoop fs -put command from Java -
unable to execute hadoop fs -put command from Java -
i trying execute hadoop fs -put <source> <destination>
java code. when execute command straight terminal, works fine when seek execute command within java code using
string[] str = {"/usr/bin/hadoop","fs -put", source, dest}; runtime.getruntime().exec(str);
i error error: not find or load main class fs
. tried execute non-hadoop commands ls,mkdir commands java , worked fine hadoop commands not getting executed though work fine terminal.
what possible reason , how can solve it?
java api try: tried utilize java api perform re-create operation error. java code :
string source = "/home/tmpe/file1.csv"; string dest = "/user/tmpe/file1.csv"; configuration conf = new configuration(); conf.set("fs.defaultfs", "hdfs://node1:8020"); filesystem fs = filesystem.get(conf); path targetpath = new path(dest); path sourcepath = new path(source); fs.copyfromlocalfile(false,true,sourcepath,targetpath);
the error is:
exception in thread "main" java.io.ioexception: mkdirs failed create /user/tmpe @ org.apache.hadoop.fs.checksumfilesystem.create(checksumfilesystem.java:378) @ org.apache.hadoop.fs.checksumfilesystem.create(checksumfilesystem.java:364) @ org.apache.hadoop.fs.filesystem.create(filesystem.java:564) @ org.apache.hadoop.fs.filesystem.create(filesystem.java:545) @ org.apache.hadoop.fs.filesystem.create(filesystem.java:452) @ org.apache.hadoop.fs.fileutil.copy(fileutil.java:229) @ org.apache.hadoop.fs.filesystem.copyfromlocalfile(filesystem.java:1230)
i have created /user/tmpe
folder , has total read-write permissions still error comes. unable issue resolved
i guess not have hadoop_home
environment variable set.
but since you're in java, why on earth want haddop fs -put
in external process when java api more friendly shell ?
java hadoop
Comments
Post a Comment