protected void startAllocatorThread() { allocatorThread = new Thread(new AllocatorRunnable()); allocatorThread.setName("RMCommunicator Allocator"); allocatorThread.start(); }
@Test(timeout = 2000) public void testRMContainerAllocatorYarnRuntimeExceptionIsHandled() throws Exception { ClientService mockClientService = mock(ClientService.class); AppContext mockContext = mock(AppContext.class); MockRMCommunicator mockRMCommunicator = new MockRMCommunicator(mockClientService, mockContext); final RMCommunicator communicator = spy(mockRMCommunicator); Clock mockClock = mock(Clock.class); when(mockContext.getClock()).thenReturn(mockClock); doThrow(new YarnRuntimeException("Test")).doNothing() .when(communicator).heartbeat(); when(mockClock.getTime()).thenReturn(1L).thenAnswer(new Answer<Integer>() { @Override public Integer answer(InvocationOnMock invocation) throws Throwable { communicator.stop(); return 2; } }).thenThrow(new AssertionError( "GetClock called second time, when it should not have since the thread " + "should have quit")); AllocatorRunnable testRunnable = communicator.new AllocatorRunnable(); testRunnable.run(); verify(mockClock, times(2)).getTime(); } }
@Test(timeout = 2000) public void testRMContainerAllocatorExceptionIsHandled() throws Exception { ClientService mockClientService = mock(ClientService.class); AppContext mockContext = mock(AppContext.class); MockRMCommunicator mockRMCommunicator = new MockRMCommunicator(mockClientService, mockContext); RMCommunicator communicator = spy(mockRMCommunicator); Clock mockClock = mock(Clock.class); when(mockContext.getClock()).thenReturn(mockClock); doThrow(new RMContainerAllocationException("Test")).doNothing() .when(communicator).heartbeat(); when(mockClock.getTime()).thenReturn(1L).thenThrow(new AssertionError( "GetClock called second time, when it should not have since the " + "thread should have quit")); AllocatorRunnable testRunnable = communicator.new AllocatorRunnable(); testRunnable.run(); }
protected void startAllocatorThread() { allocatorThread = new Thread(new AllocatorRunnable()); allocatorThread.setName("RMCommunicator Allocator"); allocatorThread.start(); }
protected void startAllocatorThread() { allocatorThread = new Thread(new AllocatorRunnable()); allocatorThread.setName("RMCommunicator Allocator"); allocatorThread.start(); }