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());
}
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);
}
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;
}
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);
}
Aggregations