hdfs - Unable to create file using Pail DFS -


newbie here. trying run code nathan marz's book big data dfs datastore using pail. doing wrong? trying connect hdfs vm. tried replacing hdfs file. appreciated.

public class apptest {     private app app = new app();     private string path = "hdfs:////192.168.0.101:8080/mypail";      @before     public void init() throws illegalargumentexception, ioexception{         filesystem fs = filesystem.get(new configuration());         fs.delete(new path(path), true);     }      @test public    void testappaccess() throws ioexception{         pail pail = pail.create(path);           typedrecordoutputstream os = pail.openwrite();           os.writeobject(new byte[] {1, 2, 3});           os.writeobject(new byte[] {1, 2, 3, 4});           os.writeobject(new byte[] {1, 2, 3, 4, 5});           os.close();       } } 

get error -

java.lang.illegalargumentexception: wrong fs: hdfs:/192.168.0.101:8080/mypail, expected: file:///     @ org.apache.hadoop.fs.filesystem.checkpath(filesystem.java:645)     @ org.apache.hadoop.fs.rawlocalfilesystem.pathtofile(rawlocalfilesystem.java:80)     @ org.apache.hadoop.fs.rawlocalfilesystem.deprecatedgetfilestatus(rawlocalfilesystem.java:529)     @ org.apache.hadoop.fs.rawlocalfilesystem.getfilelinkstatusinternal(rawlocalfilesystem.java:747) 

on replacing hdfs file file:///

java.io.ioexception: mkdirs failed create file:/192.168.0.101:8080/mypail (exists=false, cwd=file:/users/joshi/git/projectcsr/projectcsr)     @ org.apache.hadoop.fs.checksumfilesystem.create(checksumfilesystem.java:442)     @  

i came across same problem , solved it! should add core-site.xml hadoop configuration object, should work:

configuration cfg = new configuration(); path core_site_path = new path("path/to/your/core-site.xml"); cfg.addresource(core_site_path); filesystem fs = filesystem.get(cfg); 

i guess same programmatically adding property fs.defaultfs cfg object

source: http://opensourceconnections.com/blog/2013/03/24/hdfs-debugging-wrong-fs-expected-file-exception/


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -