use of com.linkedin.kafka.cruisecontrol.common.KafkaCruiseControlThreadFactory in project cruise-control by linkedin.
the class AnomalyDetectorTest method testShutdown.
@Test
public void testShutdown() throws InterruptedException {
AnomalyNotifier mockAnomalyNotifier = EasyMock.createNiceMock(AnomalyNotifier.class);
BrokerFailureDetector mockBrokerFailureDetector = EasyMock.createNiceMock(BrokerFailureDetector.class);
GoalViolationDetector mockGoalViolationDetector = EasyMock.createNiceMock(GoalViolationDetector.class);
KafkaCruiseControl mockKafkaCruiseControl = EasyMock.createNiceMock(KafkaCruiseControl.class);
ScheduledExecutorService detectorScheduler = Executors.newScheduledThreadPool(2, new KafkaCruiseControlThreadFactory("AnomalyDetector", false, null));
AnomalyDetector anomalyDetector = new AnomalyDetector(new LinkedBlockingDeque<>(), 3000L, mockKafkaCruiseControl, mockAnomalyNotifier, mockGoalViolationDetector, mockBrokerFailureDetector, detectorScheduler, EasyMock.mock(LoadMonitor.class));
anomalyDetector.shutdown();
Thread t = new Thread(anomalyDetector::shutdown);
t.start();
t.join(30000L);
assertTrue(detectorScheduler.isTerminated());
}
Aggregations