Search in sources :

Example 11 with BlockingService

use of com.google.protobuf.BlockingService in project hive by apache.

the class LlapPluginServerImpl method serviceStart.

@Override
public void serviceStart() {
    final Configuration conf = getConfig();
    final BlockingService daemonImpl = LlapPluginProtocolProtos.LlapPluginProtocol.newReflectiveBlockingService(this);
    server = LlapUtil.startProtocolServer(0, numHandlers, bindAddress, conf, daemonImpl, LlapPluginProtocolPB.class, secretManager, new LlapPluginPolicyProvider(), ConfVars.LLAP_PLUGIN_ACL, ConfVars.LLAP_PLUGIN_ACL_DENY);
    LOG.info("Starting the plugin endpoint on port " + bindAddress.get().getPort());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) BlockingService(com.google.protobuf.BlockingService) LlapPluginProtocolPB(org.apache.hadoop.hive.llap.protocol.LlapPluginProtocolPB)

Example 12 with BlockingService

use of com.google.protobuf.BlockingService in project hadoop by apache.

the class TestRMAuditLogger method testRMAuditLoggerWithIP.

/**
   * Test {@link RMAuditLogger} with IP set.
   */
@Test
public void testRMAuditLoggerWithIP() throws Exception {
    Configuration conf = new Configuration();
    RPC.setProtocolEngine(conf, TestRpcService.class, ProtobufRpcEngine.class);
    // Create server side implementation
    MyTestRPCServer serverImpl = new MyTestRPCServer();
    BlockingService service = TestRpcServiceProtos.TestProtobufRpcProto.newReflectiveBlockingService(serverImpl);
    // start the IPC server
    Server server = new RPC.Builder(conf).setProtocol(TestRpcService.class).setInstance(service).setBindAddress("0.0.0.0").setPort(0).setNumHandlers(5).setVerbose(true).build();
    server.start();
    InetSocketAddress addr = NetUtils.getConnectAddress(server);
    // Make a client connection and test the audit log
    TestRpcService proxy = RPC.getProxy(TestRpcService.class, TestProtocol.versionID, addr, conf);
    // Start the testcase
    TestProtos.EmptyRequestProto pingRequest = TestProtos.EmptyRequestProto.newBuilder().build();
    proxy.ping(null, pingRequest);
    server.stop();
    RPC.stopProxy(proxy);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.ipc.Server) RPC(org.apache.hadoop.ipc.RPC) InetSocketAddress(java.net.InetSocketAddress) BlockingService(com.google.protobuf.BlockingService) TestProtos(org.apache.hadoop.ipc.protobuf.TestProtos) TestRpcService(org.apache.hadoop.ipc.TestRpcBase.TestRpcService) Test(org.junit.Test)

Example 13 with BlockingService

use of com.google.protobuf.BlockingService in project hadoop by apache.

the class TestRpcBase method newServerBuilder.

protected static RPC.Builder newServerBuilder(Configuration serverConf) throws IOException {
    // Create server side implementation
    PBServerImpl serverImpl = new PBServerImpl();
    BlockingService service = TestRpcServiceProtos.TestProtobufRpcProto.newReflectiveBlockingService(serverImpl);
    // Get RPC server for server side implementation
    RPC.Builder builder = new RPC.Builder(serverConf).setProtocol(TestRpcService.class).setInstance(service).setBindAddress(ADDRESS).setPort(PORT);
    return builder;
}
Also used : BlockingService(com.google.protobuf.BlockingService)

Example 14 with BlockingService

use of com.google.protobuf.BlockingService in project hadoop by apache.

the class TestProtoBufRpcServerHandoff method test.

@Test(timeout = 20000)
public void test() throws Exception {
    Configuration conf = new Configuration();
    TestProtoBufRpcServerHandoffServer serverImpl = new TestProtoBufRpcServerHandoffServer();
    BlockingService blockingService = TestProtobufRpcHandoffProto.newReflectiveBlockingService(serverImpl);
    RPC.setProtocolEngine(conf, TestProtoBufRpcServerHandoffProtocol.class, ProtobufRpcEngine.class);
    RPC.Server server = new RPC.Builder(conf).setProtocol(TestProtoBufRpcServerHandoffProtocol.class).setInstance(blockingService).setVerbose(true).setNumHandlers(// Num Handlers explicitly set to 1 for test.
    1).build();
    server.start();
    InetSocketAddress address = server.getListenerAddress();
    long serverStartTime = System.currentTimeMillis();
    LOG.info("Server started at: " + address + " at time: " + serverStartTime);
    final TestProtoBufRpcServerHandoffProtocol client = RPC.getProxy(TestProtoBufRpcServerHandoffProtocol.class, 1, address, conf);
    ExecutorService executorService = Executors.newFixedThreadPool(2);
    CompletionService<ClientInvocationCallable> completionService = new ExecutorCompletionService<ClientInvocationCallable>(executorService);
    completionService.submit(new ClientInvocationCallable(client, 5000l));
    completionService.submit(new ClientInvocationCallable(client, 5000l));
    long submitTime = System.currentTimeMillis();
    Future<ClientInvocationCallable> future1 = completionService.take();
    Future<ClientInvocationCallable> future2 = completionService.take();
    ClientInvocationCallable callable1 = future1.get();
    ClientInvocationCallable callable2 = future2.get();
    LOG.info(callable1);
    LOG.info(callable2);
    // Ensure the 5 second sleep responses are within a reasonable time of each
    // other.
    Assert.assertTrue(Math.abs(callable1.endTime - callable2.endTime) < 2000l);
    Assert.assertTrue(System.currentTimeMillis() - submitTime < 7000l);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) InetSocketAddress(java.net.InetSocketAddress) ExecutorCompletionService(java.util.concurrent.ExecutorCompletionService) BlockingService(com.google.protobuf.BlockingService) ExecutorService(java.util.concurrent.ExecutorService) Test(org.junit.Test)

Aggregations

BlockingService (com.google.protobuf.BlockingService)14 Configuration (org.apache.hadoop.conf.Configuration)9 RPC (org.apache.hadoop.ipc.RPC)5 InetSocketAddress (java.net.InetSocketAddress)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 Server (org.apache.hadoop.ipc.Server)3 HAServiceProtocolServerSideTranslatorPB (org.apache.hadoop.ha.protocolPB.HAServiceProtocolServerSideTranslatorPB)2 TestRpcService (org.apache.hadoop.ipc.TestRpcBase.TestRpcService)2 TestProtos (org.apache.hadoop.ipc.protobuf.TestProtos)2 ByteString (com.google.protobuf.ByteString)1 RpcController (com.google.protobuf.RpcController)1 ServiceException (com.google.protobuf.ServiceException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 ExecutorCompletionService (java.util.concurrent.ExecutorCompletionService)1 ExecutorService (java.util.concurrent.ExecutorService)1 OptionBuilder (org.apache.commons.cli.OptionBuilder)1 HDFSPolicyProvider (org.apache.hadoop.hdfs.HDFSPolicyProvider)1 GetReplicaVisibleLengthRequestProto (org.apache.hadoop.hdfs.protocol.proto.ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto)1