Search in sources :

Example 1 with MonitorScheduler

use of org.apache.druid.java.util.metrics.MonitorScheduler in project druid by druid-io.

the class ShuffleModuleTest method testGetShuffleMetricsWhenShuffleMonitorExists.

@Test
public void testGetShuffleMetricsWhenShuffleMonitorExists() {
    final ShuffleMonitor shuffleMonitor = new ShuffleMonitor();
    final MonitorScheduler monitorScheduler = Mockito.mock(MonitorScheduler.class);
    Mockito.when(monitorScheduler.findMonitor(ShuffleMonitor.class)).thenReturn(Optional.of(shuffleMonitor));
    final Injector injector = createInjector(monitorScheduler);
    final Optional<ShuffleMetrics> optional = injector.getInstance(Key.get(new TypeLiteral<Optional<ShuffleMetrics>>() {
    }));
    Assert.assertTrue(optional.isPresent());
}
Also used : TypeLiteral(com.google.inject.TypeLiteral) MonitorScheduler(org.apache.druid.java.util.metrics.MonitorScheduler) Injector(com.google.inject.Injector) Test(org.junit.Test)

Example 2 with MonitorScheduler

use of org.apache.druid.java.util.metrics.MonitorScheduler in project druid by druid-io.

the class ShuffleModuleTest method testGetShuffleMetricsWithNoShuffleMonitor.

@Test
public void testGetShuffleMetricsWithNoShuffleMonitor() {
    final MonitorScheduler monitorScheduler = Mockito.mock(MonitorScheduler.class);
    Mockito.when(monitorScheduler.findMonitor(ArgumentMatchers.eq(ShuffleMonitor.class))).thenReturn(Optional.empty());
    final Injector injector = createInjector(monitorScheduler);
    final Optional<ShuffleMetrics> optional = injector.getInstance(Key.get(new TypeLiteral<Optional<ShuffleMetrics>>() {
    }));
    Assert.assertFalse(optional.isPresent());
}
Also used : TypeLiteral(com.google.inject.TypeLiteral) MonitorScheduler(org.apache.druid.java.util.metrics.MonitorScheduler) Injector(com.google.inject.Injector) Test(org.junit.Test)

Example 3 with MonitorScheduler

use of org.apache.druid.java.util.metrics.MonitorScheduler in project druid by druid-io.

the class TaskLifecycleTest method setUp.

@Before
public void setUp() throws Exception {
    // mock things
    queryRunnerFactoryConglomerate = EasyMock.createStrictMock(QueryRunnerFactoryConglomerate.class);
    monitorScheduler = EasyMock.createStrictMock(MonitorScheduler.class);
    // initialize variables
    announcedSinks = 0;
    pushedSegments = 0;
    indexSpec = new IndexSpec();
    emitter = newMockEmitter();
    EmittingLogger.registerEmitter(emitter);
    mapper = TEST_UTILS.getTestObjectMapper();
    handOffCallbacks = new ConcurrentHashMap<>();
    // Set up things, the order does matter as if it is messed up then the setUp
    // should fail because of the Precondition checks in the respective setUp methods
    // For creating a customized TaskQueue see testRealtimeIndexTaskFailure test
    taskStorage = setUpTaskStorage();
    handoffNotifierFactory = setUpSegmentHandOffNotifierFactory();
    dataSegmentPusher = setUpDataSegmentPusher();
    mdc = setUpMetadataStorageCoordinator();
    tb = setUpTaskToolboxFactory(dataSegmentPusher, handoffNotifierFactory, mdc);
    taskRunner = setUpThreadPoolTaskRunner(tb);
    taskQueue = setUpTaskQueue(taskStorage, taskRunner);
}
Also used : QueryRunnerFactoryConglomerate(org.apache.druid.query.QueryRunnerFactoryConglomerate) IndexSpec(org.apache.druid.segment.IndexSpec) MonitorScheduler(org.apache.druid.java.util.metrics.MonitorScheduler) Before(org.junit.Before)

Example 4 with MonitorScheduler

use of org.apache.druid.java.util.metrics.MonitorScheduler in project druid by druid-io.

the class MetricsModuleTest method testGetBasicMonitorSchedulerViaConfig.

@Test
public void testGetBasicMonitorSchedulerViaConfig() {
    final Properties properties = new Properties();
    properties.setProperty(StringUtils.format("%s.schedulerClassName", MetricsModule.MONITORING_PROPERTY_PREFIX), BasicMonitorScheduler.class.getName());
    final MonitorScheduler monitorScheduler = createInjector(properties).getInstance(MonitorScheduler.class);
    Assert.assertSame(BasicMonitorScheduler.class, monitorScheduler.getClass());
}
Also used : BasicMonitorScheduler(org.apache.druid.java.util.metrics.BasicMonitorScheduler) BasicMonitorScheduler(org.apache.druid.java.util.metrics.BasicMonitorScheduler) ClockDriftSafeMonitorScheduler(org.apache.druid.java.util.metrics.ClockDriftSafeMonitorScheduler) MonitorScheduler(org.apache.druid.java.util.metrics.MonitorScheduler) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with MonitorScheduler

use of org.apache.druid.java.util.metrics.MonitorScheduler in project druid by druid-io.

the class MetricsModuleTest method testGetClockDriftSafeMonitorSchedulerViaConfig.

@Test
public void testGetClockDriftSafeMonitorSchedulerViaConfig() {
    final Properties properties = new Properties();
    properties.setProperty(StringUtils.format("%s.schedulerClassName", MetricsModule.MONITORING_PROPERTY_PREFIX), ClockDriftSafeMonitorScheduler.class.getName());
    final MonitorScheduler monitorScheduler = createInjector(properties).getInstance(MonitorScheduler.class);
    Assert.assertSame(ClockDriftSafeMonitorScheduler.class, monitorScheduler.getClass());
}
Also used : BasicMonitorScheduler(org.apache.druid.java.util.metrics.BasicMonitorScheduler) ClockDriftSafeMonitorScheduler(org.apache.druid.java.util.metrics.ClockDriftSafeMonitorScheduler) MonitorScheduler(org.apache.druid.java.util.metrics.MonitorScheduler) ClockDriftSafeMonitorScheduler(org.apache.druid.java.util.metrics.ClockDriftSafeMonitorScheduler) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

MonitorScheduler (org.apache.druid.java.util.metrics.MonitorScheduler)6 Test (org.junit.Test)5 Properties (java.util.Properties)3 BasicMonitorScheduler (org.apache.druid.java.util.metrics.BasicMonitorScheduler)3 ClockDriftSafeMonitorScheduler (org.apache.druid.java.util.metrics.ClockDriftSafeMonitorScheduler)3 Injector (com.google.inject.Injector)2 TypeLiteral (com.google.inject.TypeLiteral)2 QueryRunnerFactoryConglomerate (org.apache.druid.query.QueryRunnerFactoryConglomerate)1 IndexSpec (org.apache.druid.segment.IndexSpec)1 Before (org.junit.Before)1