Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hbase API through sock proxy

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.

like image 387
Rishi Kesh Dwivedi Avatar asked Oct 04 '22 00:10

Rishi Kesh Dwivedi


1 Answers

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).

like image 77
voiddrum Avatar answered Oct 07 '22 18:10

voiddrum