title: Hadoop Ha namenode java client
body: <p>I am new to hdfs. I am writing Java client that can connect and write data to remote hadoop cluster.</p>
  
  <pre><code>String hdfsUrl = "hdfs://xxx.xxx.xxx.xxx:8020";
  FileSystem fs = FileSystem.get(hdfsUrl , conf);
  </code></pre>
  
  <p>This works fine. My problem is how to handle the HA enabled hadoop cluster. HA enabled hadoop cluster will have two namenodes-  one active namenode and standby namenode. How can I identify the active namenode from my client code at runtime. </p>
  
  <p><a href="http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.1.1/bk_system-admin-guide/content/ch_hadoop-ha-3-1.html" rel="noreferrer">http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.1.1/bk_system-admin-guide/content/ch_hadoop-ha-3-1.html</a> has following details about a java class that can be used to contact active namenodes
      dfs.client.failover.proxy.provider.[$nameservice ID]:</p>
  
  <pre><code>This property specifies the Java class that HDFS clients use to contact the Active NameNode. DFS     Client uses this Java class to determine which NameNode is the current Active and therefore which NameNode is currently serving client requests.
  
  Use the ConfiguredFailoverProxyProvider implementation if you are not using a custom implementation.
  </code></pre>
  
  <p>For example:</p>
  
  <pre><code>&lt;property&gt;
    &lt;name&gt;dfs.client.failover.proxy.provider.mycluster&lt;/name&gt;
    &lt;value&gt;org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider&lt;/value&gt;
  &lt;/property&gt;
  </code></pre>
  
  <p>How can I use this class in my java client or is there any other way to identify the active namenode...</p>