5

Is there a way to call HbaseAdmin/Htable through sock proxy? I want to use localhost:1080 socks proxy mapped to one of the boxes in cluster and then talk to Hbase(Zookeeper, Master, RegionServer). Is there a way to do that?

Thanks.

Irfan DANISH
  • 8,349
  • 12
  • 42
  • 67
Rishi Kesh Dwivedi
  • 643
  • 2
  • 7
  • 15

1 Answers1

4

I too had the same requirement and figured out that ZooKeeper client connection is implemented over NIO (org.apache.zookeeper.ClientCnxnSocketNIO). And NIO doesn't support connection over socks

Checkout the method getClientCnxnSocket() on ZooKeeper.java if you have the source.

private static ClientCnxnSocket getClientCnxnSocket() throws IOException {
    String clientCnxnSocketName = System
            .getProperty(ZOOKEEPER_CLIENT_CNXN_SOCKET);
    if (clientCnxnSocketName == null) {
        clientCnxnSocketName = ClientCnxnSocketNIO.class.getName();
    }
    try {
        return (ClientCnxnSocket) Class.forName(clientCnxnSocketName)
                .newInstance();
    } catch (Exception e) {
        IOException ioe = new IOException("Couldn't instantiate "
                + clientCnxnSocketName);
        ioe.initCause(e);
        throw ioe;
    }
}

If you want to make it work over socks you need to provide your own implementation by extending ClientCnxnSocket and specify it using System variable zookeeper.clientCnxnSocket).

voiddrum
  • 93
  • 8
  • The current ZooKeeper implementation is annoying. The ClientCnxnSocket class you need to extend has 'package' scope, so if you want to add your own implementation you'll have to put it in the org.apache.zookeeper package. – THelper Aug 15 '17 at 13:59
  • has there been any movement on this or do we still need to hack it to get zk/hbase connections to work through a socks proxy? – Tucker Dec 01 '17 at 19:57