use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.
the class TestRMFailover method testUncaughtExceptionHandlerWithoutHA.
/**
* Throw {@link RuntimeException} inside a thread of
* {@link ResourceManager} with HA disabled and check
* {@link RMCriticalThreadUncaughtExceptionHandler} instance.
*
* Used {@link ExitUtil} class to avoid jvm exit through
* {@code System.exit(-1)}.
*
* @throws InterruptedException if any
*/
@Test
public void testUncaughtExceptionHandlerWithoutHA() throws InterruptedException {
ExitUtil.disableSystemExit();
// Create a MockRM and start it
ResourceManager resourceManager = new MockRM();
((AsyncDispatcher) resourceManager.getRMContext().getDispatcher()).start();
resourceManager.getRMContext().getStateStore().start();
resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey();
final RMCriticalThreadUncaughtExceptionHandler exHandler = new RMCriticalThreadUncaughtExceptionHandler(resourceManager.getRMContext());
final RMCriticalThreadUncaughtExceptionHandler spyRTEHandler = spy(exHandler);
// Create a thread and throw a RTE inside it
final RuntimeException rte = new RuntimeException("TestRuntimeException");
final Thread testThread = new Thread(new Runnable() {
@Override
public void run() {
throw rte;
}
});
testThread.setName("TestThread");
testThread.setUncaughtExceptionHandler(spyRTEHandler);
assertSame(spyRTEHandler, testThread.getUncaughtExceptionHandler());
testThread.start();
testThread.join();
verify(spyRTEHandler).uncaughtException(testThread, rte);
}
Aggregations