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");        
Comments
Post a Comment