title: hdfs java file system API: creating Configuration object
body: <p>I was trying to create a java program to write/read files from HDFS.</p>
  
  <p>I saw some examples of Java API. With this, the following code works for me.</p>
  
  <pre><code>Configuration mConfiguration = new Configuration();
  mConfiguration.set(“fs.default.name”, “hdfs://NAME_NODE_IP:9000″);
  </code></pre>
  
  <p>But my set up has to be changed for a Hadoop HA set up so hardcoded namenode addressing is not possible.</p>
  
  <p>I saw some example where in we provide the path of configuration xmls like below.</p>
  
  <pre><code>mConfiguration.addResource(new Path(“/usr/local/hadoop/etc/hadoop/core-site.xml”));
  mConfiguration.addResource(new Path(“/usr/local/hadoop/etc/hadoop/hdfs-site.xml”));
  </code></pre>
  
  <p>This code also works when running the application in the same system as of hadoop.</p>
  
  <p>But it would not work when my application is not running on the same m/c as of hadoop.</p>
  
  <p>So, what is the approach I should take so that the system works but direct namenode addressing is not done.</p>
  
  <p>Any help would be appreciated.</p>