@Override public void run() { callRunner.run(); }
@Override public void run() { task.setStatus(RpcServer.getStatus()); task.run(); queueSize.decrementAndGet(); } });
private CallRunner createMockTask() { ServerCall call = mock(ServerCall.class); CallRunner task = mock(CallRunner.class); when(task.getRpcCall()).thenReturn(call); doAnswer(new Answer<Void>() { @Override public Void answer (InvocationOnMock invocation) throws Throwable { callExecutionCount.incrementAndGet(); Thread.sleep(1000); return null; } }).when(task).run(); return task; }
try { this.activeHandlerCount.incrementAndGet(); cr.run(); } catch (Throwable e) { if (e instanceof Error) {
private void doAnswerTaskExecution(final CallRunner callTask, final ArrayList<Integer> results, final int value, final int sleepInterval) { callTask.setStatus(new MonitoredRPCHandlerImpl()); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { synchronized (results) { results.add(value); } Threads.sleepWithoutInterrupt(sleepInterval); return null; } }).when(callTask).run(); }
private CallRunner createMockTask(AtomicInteger callExecutionCount, boolean isRegionServerReportTask) { CallRunner task = mock(CallRunner.class); ServerCall call = mock(ServerCall.class); when(task.getRpcCall()).thenReturn(call); when(call.getHeader()).thenReturn(RPCProtos.RequestHeader.newBuilder() .setMethodName(isRegionServerReportTask ? REGION_SERVER_REPORT : OTHER).build()); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { callExecutionCount.incrementAndGet(); Thread.sleep(1000); return null; } }).when(task).run(); return task; }
/** * Does nothing but exercise a {@link CallRunner} outside of {@link RpcServer} context. */ @Test public void testSimpleCall() { RpcServerInterface mockRpcServer = Mockito.mock(RpcServerInterface.class); Mockito.when(mockRpcServer.isStarted()).thenReturn(true); ServerCall mockCall = Mockito.mock(ServerCall.class); CallRunner cr = new CallRunner(mockRpcServer, mockCall); cr.setStatus(new MonitoredRPCHandlerImpl()); cr.run(); } }
@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(); }
@Override public void run() { task.setStatus(RpcServer.getStatus()); task.run(); queueSize.decrementAndGet(); } });
private CallRunner createMockTask() { ServerCall call = mock(ServerCall.class); CallRunner task = mock(CallRunner.class); when(task.getRpcCall()).thenReturn(call); doAnswer(new Answer<Void>() { @Override public Void answer (InvocationOnMock invocation) throws Throwable { callExecutionCount.incrementAndGet(); Thread.sleep(1000); return null; } }).when(task).run(); return task; }
private void doAnswerTaskExecution(final CallRunner callTask, final ArrayList<Integer> results, final int value, final int sleepInterval) { callTask.setStatus(new MonitoredRPCHandlerImpl()); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { synchronized (results) { results.add(value); } Threads.sleepWithoutInterrupt(sleepInterval); return null; } }).when(callTask).run(); }
private CallRunner createMockTask(AtomicInteger callExecutionCount, boolean isRegionServerReportTask) { CallRunner task = mock(CallRunner.class); ServerCall call = mock(ServerCall.class); when(task.getRpcCall()).thenReturn(call); when(call.getHeader()).thenReturn(RPCProtos.RequestHeader.newBuilder() .setMethodName(isRegionServerReportTask ? REGION_SERVER_REPORT : OTHER).build()); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { callExecutionCount.incrementAndGet(); Thread.sleep(1000); return null; } }).when(task).run(); return task; }
/** * Does nothing but exercise a {@link CallRunner} outside of {@link RpcServer} context. */ @Test public void testSimpleCall() { RpcServerInterface mockRpcServer = Mockito.mock(RpcServerInterface.class); Mockito.when(mockRpcServer.isStarted()).thenReturn(true); ServerCall mockCall = Mockito.mock(ServerCall.class); CallRunner cr = new CallRunner(mockRpcServer, mockCall); cr.setStatus(new MonitoredRPCHandlerImpl()); cr.run(); } }
try { activeHandlerCount.incrementAndGet(); task.run(); } catch (Throwable e) { if (e instanceof Error) {
@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(); }