Search in sources :

Example 1 with KafkaCruiseControlThreadFactory

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());
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AnomalyNotifier(com.linkedin.kafka.cruisecontrol.detector.notifier.AnomalyNotifier) KafkaCruiseControl(com.linkedin.kafka.cruisecontrol.KafkaCruiseControl) KafkaCruiseControlThreadFactory(com.linkedin.kafka.cruisecontrol.common.KafkaCruiseControlThreadFactory) LoadMonitor(com.linkedin.kafka.cruisecontrol.monitor.LoadMonitor) Test(org.junit.Test)

Aggregations

KafkaCruiseControl (com.linkedin.kafka.cruisecontrol.KafkaCruiseControl)1 KafkaCruiseControlThreadFactory (com.linkedin.kafka.cruisecontrol.common.KafkaCruiseControlThreadFactory)1 AnomalyNotifier (com.linkedin.kafka.cruisecontrol.detector.notifier.AnomalyNotifier)1 LoadMonitor (com.linkedin.kafka.cruisecontrol.monitor.LoadMonitor)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Test (org.junit.Test)1