org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB Java Examples

The following examples show how to use org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyServer.java    From nnproxy with Apache License 2.0 5 votes vote down vote up
public void start() throws IOException {
    int rpcHandlerCount = conf.getInt(ProxyConfig.PROXY_HANDLER_COUNT, ProxyConfig.PROXY_HANDLER_COUNT_DEFAULT);
    RPC.setProtocolEngine(conf, ClientNamenodeProtocolPB.class,
            ProtobufRpcEngine.class);
    RPC.setProtocolEngine(conf, NamenodeProtocolPB.class,
            ProtobufRpcEngine.class);

    this.protocol = (ClientProtocol) Proxy.newProxyInstance(
            this.getClass().getClassLoader(),
            new Class[]{ClientProtocol.class},
            this.invocationHandler);

    ClientNamenodeProtocolPB proxy = new ClientNamenodeProtocolServerSideTranslatorPB(this.protocol);
    BlockingService clientNNPbService = ClientNamenodeProtocolProtos.ClientNamenodeProtocol.
            newReflectiveBlockingService(proxy);

    int port = conf.getInt(ProxyConfig.RPC_PORT, ProxyConfig.RPC_PORT_DEFAULT);

    this.rpcServer = new RPC.Builder(conf)
            .setProtocol(org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB.class)
            .setInstance(clientNNPbService).setBindAddress("0.0.0.0")
            .setPort(port).setNumHandlers(rpcHandlerCount)
            .setVerbose(false).build();
    this.rpcServer.start();

    InetSocketAddress listenAddr = rpcServer.getListenerAddress();
    rpcAddress = new InetSocketAddress("0.0.0.0", listenAddr.getPort());
}