@Override public void start() { delegate.start(); } @Override
private ThreadPoolExecutor disableHandlers(RpcScheduler scheduler) { ThreadPoolExecutor rpcExecutor=null; try { Field ExecutorField = scheduler.getClass().getDeclaredField("executor"); ExecutorField.setAccessible(true); scheduler.start(); rpcExecutor = (ThreadPoolExecutor) ExecutorField.get(scheduler); rpcExecutor.setMaximumPoolSize(1); rpcExecutor.allowCoreThreadTimeOut(true); rpcExecutor.setCorePoolSize(0); rpcExecutor.setKeepAliveTime(1, TimeUnit.MICROSECONDS); // Wait for 2 seconds, so that idle threads will die Thread.sleep(2000); } catch (NoSuchFieldException e) { LOG.error("No such field exception:"+e); } catch (IllegalAccessException e) { LOG.error("Illegal access exception:"+e); } catch (InterruptedException e) { LOG.error("Interrupted exception:"+e); } return rpcExecutor; }
@Override public synchronized void start() { if (started) { return; } authTokenSecretMgr = createSecretManager(); if (authTokenSecretMgr != null) { setSecretManager(authTokenSecretMgr); authTokenSecretMgr.start(); } this.authManager = new ServiceAuthorizationManager(); HBasePolicyProvider.init(conf, authManager); scheduler.start(); started = true; }
/** Starts the service. Must be called before any calls will be handled. */ @Override public synchronized void start() { if (started) return; authTokenSecretMgr = createSecretManager(); if (authTokenSecretMgr != null) { setSecretManager(authTokenSecretMgr); authTokenSecretMgr.start(); } this.authManager = new ServiceAuthorizationManager(); HBasePolicyProvider.init(conf, authManager); responder.start(); listener.start(); scheduler.start(); started = true; }
HConstants.QOS_THRESHOLD); try { scheduler.start();
@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(); }
HConstants.QOS_THRESHOLD); try { scheduler.start();
conf, 1, 1 ,1, qosFunction, HConstants.HIGH_QOS); scheduler.init(CONTEXT); scheduler.start(); for (CallRunner task : tasks) { when(qosFunction.getPriority(any(), any(), any())).thenReturn(qos.get(task));
scheduler.start();
/** * 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 { 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 start() { delegate.start(); indexCallExecutor.start(port); metadataCallExecutor.start(port); }
@Override public void start() { delegate.start(); } @Override
@Override public void start() { delegate.start(); indexCallExecutor.start(port); metadataCallExecutor.start(port); }
@Override public void start() { delegate.start(); indexCallExecutor.start(port); metadataCallExecutor.start(port); }
private ThreadPoolExecutor disableHandlers(RpcScheduler scheduler) { ThreadPoolExecutor rpcExecutor=null; try { Field ExecutorField = scheduler.getClass().getDeclaredField("executor"); ExecutorField.setAccessible(true); scheduler.start(); rpcExecutor = (ThreadPoolExecutor) ExecutorField.get(scheduler); rpcExecutor.setMaximumPoolSize(1); rpcExecutor.allowCoreThreadTimeOut(true); rpcExecutor.setCorePoolSize(0); rpcExecutor.setKeepAliveTime(1, TimeUnit.MICROSECONDS); // Wait for 2 seconds, so that idle threads will die Thread.sleep(2000); } catch (NoSuchFieldException e) { LOG.error("No such field exception:"+e); } catch (IllegalAccessException e) { LOG.error("Illegal access exception:"+e); } catch (InterruptedException e) { LOG.error("Interrupted exception:"+e); } return rpcExecutor; }
/** Starts the service. Must be called before any calls will be handled. */ @Override public synchronized void start() { if (started) return; authTokenSecretMgr = createSecretManager(); if (authTokenSecretMgr != null) { setSecretManager(authTokenSecretMgr); authTokenSecretMgr.start(); } this.authManager = new ServiceAuthorizationManager(); HBasePolicyProvider.init(conf, authManager); responder.start(); listener.start(); scheduler.start(); started = true; }
@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 { 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(); }