hadoop - Writing file to HDFS using Java -


i'm trying write file hdfs, file created empty on cluster, when run code locally works charm.

here's code :

fsdataoutputstream recoutputwriter = null; filesystem fs = null; try {     //outputwriter = new filewriter(outputfilename,true);     configuration configuration = new configuration();     fs = filesystem.get(configuration);     path testoutfile = new path(outputfilename);     recoutputwriter = fs.create(testoutfile);      //outputwriter = new filewriter(outputfilename,true); } catch (ioexception e) {     e.printstacktrace(); } recoutputwriter.writebytes("======================================\n"); recoutputwriter.writebytes("ok\n"); recoutputwriter.writebytes("======================================\n");  if (recoutputwriter != null) {     recoutputwriter.close(); } fs.close(); 

did miss ?

in order write data file after creating on cluster had add :

system.setproperty("hadoop_user_name", "vagrant"); 

refrence - writing files hadoop hdfs using scala


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -