use of com.sequenceiq.cloudbreak.logger.concurrent.MDCCleanerThreadPoolExecutor in project cloudbreak by hortonworks.
the class ContextClosedEventHandlerTest method testHandleContextClosedEventShouldStopExecutor.
@Test
public void testHandleContextClosedEventShouldStopExecutor() {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
applicationContext.getEnvironment().setActiveProfiles(TEST_PROFILE);
applicationContext.register(EventBusConfig.class, ContextClosedEventHandler.class, FlowRegister.class, TestMetricService.class);
applicationContext.refresh();
MDCCleanerThreadPoolExecutor eventBusThreadPoolExecutor = applicationContext.getBean("eventBusThreadPoolExecutor", MDCCleanerThreadPoolExecutor.class);
Assertions.assertFalse(eventBusThreadPoolExecutor.isShutdown());
EventBus eventBus = applicationContext.getBean(EventBus.class);
Assertions.assertTrue(eventBus.getDispatcher().alive());
applicationContext.close();
Assertions.assertTrue(eventBusThreadPoolExecutor.isShutdown());
Assertions.assertFalse(eventBus.getDispatcher().alive());
}
use of com.sequenceiq.cloudbreak.logger.concurrent.MDCCleanerThreadPoolExecutor in project cloudbreak by hortonworks.
the class EventBusConfig method reactor.
@Bean
public EventBus reactor(MDCCleanerThreadPoolExecutor threadPoolExecutor, Environment env) {
ThreadPoolExecutorDispatcher dispatcher = new ThreadPoolExecutorDispatcher(eventBusThreadPoolBacklogSize, eventBusThreadPoolCoreSize, threadPoolExecutor);
EventBus eventBus = new EventBusSpec().env(env).dispatcher(dispatcher).traceEventPath().dispatchErrorHandler(throwable -> {
handleFlowFail(throwable, dispatcher);
LOGGER.error("Exception happened in dispatcher", throwable);
}).uncaughtErrorHandler(throwable -> {
handleFlowFail(throwable, dispatcher);
LOGGER.error("Uncaught exception happened", throwable);
}).consumerNotFoundHandler(new ConsumerNotFoundHandler()).get();
return new ConsumerCheckerEventBus(eventBus);
}
Aggregations