@Override public void stop() { delegate.stop(); } @Override
/** Stops the service. No new calls will be handled after this is called. */ @Override public synchronized void stop() { LOG.info("Stopping server on " + port); running = false; if (authTokenSecretMgr != null) { authTokenSecretMgr.stop(); authTokenSecretMgr = null; } listener.interrupt(); listener.doStop(); responder.interrupt(); scheduler.stop(); notifyAll(); }
@Override public synchronized void stop() { if (!running) { return; } LOG.info("Stopping server on " + this.serverChannel.localAddress()); if (authTokenSecretMgr != null) { authTokenSecretMgr.stop(); authTokenSecretMgr = null; } allChannels.close().awaitUninterruptibly(); serverChannel.close(); scheduler.stop(); closed.countDown(); running = false; }
scheduler.stop();
@Test public void testBasic() throws IOException, InterruptedException { PriorityFunction qosFunction = mock(PriorityFunction.class); RpcScheduler scheduler = new SimpleRpcScheduler( conf, 10, 0, 0, qosFunction, 0); scheduler.init(CONTEXT); scheduler.start(); CallRunner task = createMockTask(); task.setStatus(new MonitoredRPCHandlerImpl()); scheduler.dispatch(task); verify(task, timeout(10000)).run(); scheduler.stop(); }
scheduler.stop();
verify(task, timeout(10000)).run(); scheduler.stop();
scheduler.stop();
/** * Tests that the rpc scheduler is called when requests arrive. */ @Test public void testRpcScheduler() throws IOException, ServiceException, InterruptedException { RpcScheduler scheduler = spy(new FifoRpcScheduler(CONF, 1)); RpcServer rpcServer = createRpcServer(null, "testRpcServer", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface( SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, scheduler); verify(scheduler).init((RpcScheduler.Context) anyObject()); try (AbstractRpcClient<?> client = createRpcClient(CONF)) { rpcServer.start(); verify(scheduler).start(); BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress()); EchoRequestProto param = EchoRequestProto.newBuilder().setMessage("hello").build(); for (int i = 0; i < 10; i++) { stub.echo(null, param); } verify(scheduler, times(10)).dispatch((CallRunner) anyObject()); } finally { rpcServer.stop(); verify(scheduler).stop(); } }
@Test public void testCallQueueInfo() throws IOException, InterruptedException { ThreadPoolExecutor rpcExecutor; RpcScheduler scheduler = new FifoRpcScheduler( conf, 1); scheduler.init(CONTEXT); // Set number of handlers to a minimum value disableHandlers(scheduler); int totalCallMethods = 30; int unableToDispatch = 0; for (int i = totalCallMethods; i>0; i--) { CallRunner task = createMockTask(); task.setStatus(new MonitoredRPCHandlerImpl()); if(!scheduler.dispatch(task)) { unableToDispatch++; } Thread.sleep(10); } CallQueueInfo callQueueInfo = scheduler.getCallQueueInfo(); int executionCount = callExecutionCount.get(); int callQueueSize = 0; for (String callQueueName:callQueueInfo.getCallQueueNames()) { for (String calledMethod: callQueueInfo.getCalledMethodNames(callQueueName)) { callQueueSize += callQueueInfo.getCallMethodCount(callQueueName, calledMethod); } } assertEquals(totalCallMethods - unableToDispatch, callQueueSize + executionCount); scheduler.stop(); }
@Test public void testCallQueueInfo() throws IOException, InterruptedException { PriorityFunction qosFunction = mock(PriorityFunction.class); RpcScheduler scheduler = new SimpleRpcScheduler( conf, 0, 0, 0, qosFunction, 0); scheduler.init(CONTEXT); // Set the handlers to zero. So that number of requests in call Queue can be tested scheduler = disableHandlers(scheduler); scheduler.start(); int totalCallMethods = 10; for (int i = totalCallMethods; i>0; i--) { CallRunner task = createMockTask(); task.setStatus(new MonitoredRPCHandlerImpl()); scheduler.dispatch(task); } CallQueueInfo callQueueInfo = scheduler.getCallQueueInfo(); for (String callQueueName:callQueueInfo.getCallQueueNames()) { for (String calledMethod: callQueueInfo.getCalledMethodNames(callQueueName)) { assertEquals(totalCallMethods, callQueueInfo.getCallMethodCount(callQueueName, calledMethod)); } } scheduler.stop(); }
@Override public void stop() { delegate.stop(); indexCallExecutor.stop(); metadataCallExecutor.stop(); }
@Override public void stop() { delegate.stop(); } @Override
@Override public void stop() { delegate.stop(); indexCallExecutor.stop(); metadataCallExecutor.stop(); }
@Override public void stop() { delegate.stop(); indexCallExecutor.stop(); metadataCallExecutor.stop(); }
/** Stops the service. No new calls will be handled after this is called. */ @Override public synchronized void stop() { LOG.info("Stopping server on " + port); running = false; if (authTokenSecretMgr != null) { authTokenSecretMgr.stop(); authTokenSecretMgr = null; } listener.interrupt(); listener.doStop(); responder.interrupt(); scheduler.stop(); notifyAll(); }
@Test public void testBasic() throws IOException, InterruptedException { PriorityFunction qosFunction = mock(PriorityFunction.class); RpcScheduler scheduler = new SimpleRpcScheduler( conf, 10, 0, 0, qosFunction, 0); scheduler.init(CONTEXT); scheduler.start(); CallRunner task = createMockTask(); task.setStatus(new MonitoredRPCHandlerImpl()); scheduler.dispatch(task); verify(task, timeout(10000)).run(); scheduler.stop(); }
/** * Tests that the rpc scheduler is called when requests arrive. */ @Test public void testRpcScheduler() throws IOException, ServiceException, InterruptedException { RpcScheduler scheduler = spy(new FifoRpcScheduler(CONF, 1)); RpcServer rpcServer = createRpcServer(null, "testRpcServer", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface( SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, scheduler); verify(scheduler).init((RpcScheduler.Context) anyObject()); try (AbstractRpcClient<?> client = createRpcClient(CONF)) { rpcServer.start(); verify(scheduler).start(); BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress()); EchoRequestProto param = EchoRequestProto.newBuilder().setMessage("hello").build(); for (int i = 0; i < 10; i++) { stub.echo(null, param); } verify(scheduler, times(10)).dispatch((CallRunner) anyObject()); } finally { rpcServer.stop(); verify(scheduler).stop(); } }
@Test public void testCallQueueInfo() throws IOException, InterruptedException { ThreadPoolExecutor rpcExecutor; RpcScheduler scheduler = new FifoRpcScheduler( conf, 1); scheduler.init(CONTEXT); // Set number of handlers to a minimum value disableHandlers(scheduler); int totalCallMethods = 30; int unableToDispatch = 0; for (int i = totalCallMethods; i>0; i--) { CallRunner task = createMockTask(); task.setStatus(new MonitoredRPCHandlerImpl()); if(!scheduler.dispatch(task)) { unableToDispatch++; } Thread.sleep(10); } CallQueueInfo callQueueInfo = scheduler.getCallQueueInfo(); int executionCount = callExecutionCount.get(); int callQueueSize = 0; for (String callQueueName:callQueueInfo.getCallQueueNames()) { for (String calledMethod: callQueueInfo.getCalledMethodNames(callQueueName)) { callQueueSize += callQueueInfo.getCallMethodCount(callQueueName, calledMethod); } } assertEquals(totalCallMethods - unableToDispatch, callQueueSize + executionCount); scheduler.stop(); }
@Test public void testCallQueueInfo() throws IOException, InterruptedException { PriorityFunction qosFunction = mock(PriorityFunction.class); RpcScheduler scheduler = new SimpleRpcScheduler( conf, 0, 0, 0, qosFunction, 0); scheduler.init(CONTEXT); // Set the handlers to zero. So that number of requests in call Queue can be tested scheduler = disableHandlers(scheduler); scheduler.start(); int totalCallMethods = 10; for (int i = totalCallMethods; i>0; i--) { CallRunner task = createMockTask(); task.setStatus(new MonitoredRPCHandlerImpl()); scheduler.dispatch(task); } CallQueueInfo callQueueInfo = scheduler.getCallQueueInfo(); for (String callQueueName:callQueueInfo.getCallQueueNames()) { for (String calledMethod: callQueueInfo.getCalledMethodNames(callQueueName)) { assertEquals(totalCallMethods, callQueueInfo.getCallMethodCount(callQueueName, calledMethod)); } } scheduler.stop(); }