Quantcast
Channel: Hortonworks » All Replies
Viewing all articles
Browse latest Browse all 3435

hdfs java file system API: creating Configuration object

$
0
0

I was trying to create a java program to write/read files from HDFS.

I saw some examples of Java API. With this, the following code works for me.

Configuration mConfiguration = new Configuration();
mConfiguration.set(“fs.default.name”, “hdfs://NAME_NODE_IP:9000″);

But my set up is changed to a Hadoop HA set up so hardcoded namenode addressing is not possible.

I saw some example where in we provide the path of configuration xmls like below.
mConfiguration.addResource(new Path(“/usr/local/hadoop/etc/hadoop/core-site.xml”));
mConfiguration.addResource(new Path(“/usr/local/hadoop/etc/hadoop/hdfs-site.xml”));

This code also works when running the application in the same system as of hadoop.

But it would not work when my application is not running on the same m/c as of hadoop.

So, what is the approach I should take so that the system works but direct namenode addressing is not done.

Any help would be appreciated.

Regards,
Subhankar


Viewing all articles
Browse latest Browse all 3435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>