Search code examples
hbasemapr

Connecting to Hbase Mapr using Java


Hi I am running the hbase VMWare sandbox MapR-Sandbox-For-Hadoop-3.1.0_VM. I have made no changes to the sandbox. I can access the control panel via browser. On another linux VM I have eclipse and the hbase client installed. I have a java program where I want to create a hbase table but I cannot connect. Please help

As you can see below I get an ERROR

ERROR client.HConnectionManager$HConnectionImplementation: Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.

and then

timesorg.apache.hadoop.hbase.MasterNotRunningException: Retried 1 times

(see full stacktraace below).

My application uses

System.setProperty("java.library.path", "/opt/mapr/lib");
conf = HBaseConfiguration.create();  
conf.set("zookeeper.znode.parent", "/maprdemo");
conf.set("hbase.zookeeper.quorum", "16.49.150.79");
conf.set("hbase.zookeeper.property.clientPort", "5181");
conf.set("hbase.client.retries.number", "2");
admin = new HBaseAdmin(conf); 
System.out.println(admin.isMasterRunning());

POM includes

<dependency>
    <groupId>org.apache.hbase</groupId>
    <artifactId>hbase</artifactId>
    <version>0.94.13-mapr-1401-m7-3.1.0</version>
</dependency>

Stacktrace

14/06/09 15:28:11 INFO zookeeper.ClientCnxn: Opening socket connection to server mapr.sandbox.com/16.49.150.79:5181. Will attempt to SASL-authenticate using Login Context section 'Client_simple'
14/06/09 15:28:11 INFO zookeeper.ClientCnxn: Socket connection established to mapr.sandbox.com/16.49.150.79:5181, initiating session
14/06/09 15:28:11 INFO zookeeper.ClientCnxn: Session establishment complete on server mapr.sandbox.com/16.49.150.79:5181, sessionid = 0x146807e8acc0090, negotiated timeout = 40000
14/06/09 15:28:11 ERROR client.HConnectionManager$HConnectionImplementation: Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
14/06/09 15:28:11 INFO client.HConnectionManager$HConnectionImplementation: Closed zookeeper sessionid=0x146807e8acc0090
14/06/09 15:28:11 INFO zookeeper.ZooKeeper: Session: 0x146807e8acc0090 closed
14/06/09 15:28:11 INFO zookeeper.ClientCnxn: EventThread shut down
Retried 1 timesorg.apache.hadoop.hbase.MasterNotRunningException: Retried 1 times
    at org.apache.hadoop.hbase.client.HBaseAdmin.connectWithConfiguration(HBaseAdmin.java:184)
    at org.apache.hadoop.hbase.client.HBaseAdmin$1.connect(HBaseAdmin.java:153)
    at org.apache.hadoop.hbase.client.HBaseAdmin.ensureConnectedToHBase(HBaseAdmin.java:272)
    at org.apache.hadoop.hbase.client.HBaseAdmin.ensureConnectedToHBase(HBaseAdmin.java:247)
    at org.apache.hadoop.hbase.client.HBaseAdmin.isMasterRunning(HBaseAdmin.java:439)
    at com.hp.spark.hbase.test.HBaseTest.testCreateSchema(HBaseTest.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Solution

  • Looks like you are attempting to access M7 mapr native tables ( which is a different implementation of the HBase APIs )

    The zookeeper znodes are irrelevant in M7.So the lines below don't make a difference.

    conf.set("zookeeper.znode.parent", "/maprdemo");
    conf.set("hbase.zookeeper.quorum", "16.49.150.79");
    conf.set("hbase.zookeeper.property.clientPort", "5181");
    

    It also does not require the hbase master and region services to be running. So you won't find a master service running on the sandbox. It's installed on the node though.

    maprcli node services -nodes `cat /opt/mapr/hostname` -hbmaster restart
    

    You can manually start it and re run your application.