Support Questions
Find answers, ask questions, and share your expertise

How to connect HBase in HDinsight using java api

How to connect HBase in HDinsight using java api

Rising Star

I want to connect HBase in HDinsight using java api. My client machine is located at outside of HDInsight cluster. I am getting below error

Mon Feb 06 15:40:51 IST 2017, RpcRetryingCaller{globalStartTime=1486374714593, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: org.apache.hadoop.hbase.MasterNotRunningException: Can't get connection to ZooKeeper: KeeperErrorCode = ConnectionLoss for /hbase-unsecure
        at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:147)
        at org.apache.hadoop.hbase.client.HBaseAdmin.executeCallable(HBaseAdmin.java:3917)
        at org.apache.hadoop.hbase.client.HBaseAdmin.listTableNames(HBaseAdmin.java:413)
        at org.apache.hadoop.hbase.client.HBaseAdmin.listTableNames(HBaseAdmin.java:397)
        at com.bigframe.hbase.api.HDInsightHbase.main(HDInsightHbase.java:43)
Caused by: org.apache.hadoop.hbase.MasterNotRunningException: org.apache.hadoop.hbase.MasterNotRunningException: Can't get connection to ZooKeeper: KeeperErrorCode = ConnectionLoss for /hbase-unsecure
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStub(ConnectionManager.java:1533)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(ConnectionManager.java:1553)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.getKeepAliveMasterService(ConnectionManager.java:1704)
        at org.apache.hadoop.hbase.client.MasterCallable.prepare(MasterCallable.java:38)
        at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:124)
        ... 4 more
Caused by: org.apache.hadoop.hbase.MasterNotRunningException: Can't get connection to ZooKeeper: KeeperErrorCode = ConnectionLoss for /hbase-unsecure
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.checkIfBaseNodeAvailable(ConnectionManager.java:906)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.access$400(ConnectionManager.java:545)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStubNoRetries(ConnectionManager.java:1483)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStub(ConnectionManager.java:1524)
        ... 8 more
Caused by: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase-unsecure
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
        at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1045)
        at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.exists(RecoverableZooKeeper.java:221)
        at org.apache.hadoop.hbase.zookeeper.ZKUtil.checkExists(ZKUtil.java:541)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.checkIfBaseNodeAvailable(ConnectionManager.java:895)
        ... 11 more

MY code snapshot is below

Configuration config = HBaseConfiguration.create();
 config.set("hbase.zookeeper.quorum", "zookeepernode0,zookeepernode1,zookeepernode2");    
 config.set("hbase.zookeeper.property.clientPort", "2181");
 config.set("hbase.cluster.distributed", "true");
 config.set("zookeeper.znode.parent","/hbase-unsecure");
 HBaseAdmin admin = new HBaseAdmin(config);
 TableName[] tm = admin.listTableNames();
 for(int i = 0; i<tm.length;i++){
System.out.println(tm[i].getNameAsString());
  }

Same code is running from inside HDInsight cluster . So I do not have any issue in java code. Please provide suggestion for running this code from outside the cluster. As it is cloud platform, I do not have idea regarding firewall ip/port. This is urgent. Please help.

3 REPLIES 3
Highlighted

Re: How to connect HBase in HDinsight using java api

Mentor
Highlighted

Re: How to connect HBase in HDinsight using java api

Rising Star

@Artem Ervits

Yes. I am not able to connect HBase in HDInsight. I have the internal ip address fro zookepeer but do not have public ip for that. So How can I raise the firewall request.

Highlighted

Re: How to connect HBase in HDinsight using java api

Mentor

Your HDInsight subscription should come with support contact, open a ticket with them.