How about checking the connection this way:
import java.net.InetSocketAddress; import org.apache.hadoop.hbase.ipc.HBaseRPC; import org.apache.hadoop.hbase.ipc.HMasterInterface; import org.apache.hadoop.hbase.ipc.RpcEngine; ... public static boolean isRunning() { boolean result = false; Configuration conf = HBaseConfiguration.create(); conf.clear(); conf.set("hbase.zookeeper.quorum", "myhost"); conf.set("hbase.zookeeper.property.clientPort", "2181"); conf.set("hbase.master", "myhost:60000"); RpcEngine rpcEngine = null; try { InetSocketAddress isa = new InetSocketAddress("myhost", 60000); rpcEngine = HBaseRPC.getProtocolEngine(conf); HMasterInterface master = rpcEngine.getProxy(HMasterInterface.class, HMasterInterface.VERSION, isa, conf, 1000); result = master.isMasterRunning(); } catch (Exception e) {
Note. I assumed here version> = 0.94.5
source share