Search in sources :

Example 16 with Event

use of org.apache.druid.java.util.emitter.core.Event in project druid by druid-io.

the class SeekableStreamSupervisorStateTest method testEmitNoticesQueueSize.

@Test
public void testEmitNoticesQueueSize() throws Exception {
    expectEmitterSupervisor(false);
    CountDownLatch latch = new CountDownLatch(1);
    TestEmittingTestSeekableStreamSupervisor supervisor = new TestEmittingTestSeekableStreamSupervisor(latch, null, null);
    supervisor.start();
    Assert.assertTrue(supervisor.stateManager.isHealthy());
    Assert.assertEquals(BasicState.PENDING, supervisor.stateManager.getSupervisorState());
    Assert.assertEquals(BasicState.PENDING, supervisor.stateManager.getSupervisorState().getBasicState());
    Assert.assertTrue(supervisor.stateManager.getExceptionEvents().isEmpty());
    Assert.assertFalse(supervisor.stateManager.isAtLeastOneSuccessfulRun());
    latch.await();
    List<Event> events = emitter.getEvents();
    List<String> whitelist = Collections.singletonList("ingest/notices/queueSize");
    events = filterMetrics(events, whitelist);
    Assert.assertEquals(1, events.size());
    Assert.assertEquals("ingest/notices/queueSize", events.get(0).toMap().get("metric"));
    Assert.assertEquals(0, events.get(0).toMap().get("value"));
    Assert.assertEquals("testDS", events.get(0).toMap().get("dataSource"));
    verifyAll();
}
Also used : Event(org.apache.druid.java.util.emitter.core.Event) SeekableStreamExceptionEvent(org.apache.druid.indexing.seekablestream.supervisor.SeekableStreamSupervisorStateManager.SeekableStreamExceptionEvent) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 17 with Event

use of org.apache.druid.java.util.emitter.core.Event in project druid by druid-io.

the class SeekableStreamSupervisorStateTest method testEmitNoLagWhenSuspended.

@Test
public void testEmitNoLagWhenSuspended() throws Exception {
    expectEmitterSupervisor(true);
    CountDownLatch latch = new CountDownLatch(2);
    TestEmittingTestSeekableStreamSupervisor supervisor = new TestEmittingTestSeekableStreamSupervisor(latch, ImmutableMap.of("1", 100L, "2", 250L, "3", 500L), ImmutableMap.of("1", 10000L, "2", 15000L, "3", 20000L));
    supervisor.start();
    supervisor.runInternal();
    Assert.assertTrue(supervisor.stateManager.isHealthy());
    Assert.assertEquals(BasicState.SUSPENDED, supervisor.stateManager.getSupervisorState());
    Assert.assertEquals(BasicState.SUSPENDED, supervisor.stateManager.getSupervisorState().getBasicState());
    Assert.assertTrue(supervisor.stateManager.getExceptionEvents().isEmpty());
    latch.await();
    List<Event> events = emitter.getEvents();
    List<String> whitelist = Arrays.asList("ingest/test/lag", "ingest/test/maxLag", "ingest/test/avgLag", "ingest/test/lag/time", "ingest/test/maxLag/time", "ingest/test/avgLag/time");
    events = filterMetrics(events, whitelist);
    Assert.assertEquals(0, events.size());
    verifyAll();
}
Also used : Event(org.apache.druid.java.util.emitter.core.Event) SeekableStreamExceptionEvent(org.apache.druid.indexing.seekablestream.supervisor.SeekableStreamSupervisorStateManager.SeekableStreamExceptionEvent) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 18 with Event

use of org.apache.druid.java.util.emitter.core.Event in project druid by druid-io.

the class SeekableStreamSupervisorStateTest method testEmitNoticesTime.

@Test
public void testEmitNoticesTime() throws Exception {
    expectEmitterSupervisor(false);
    CountDownLatch latch = new CountDownLatch(2);
    TestEmittingTestSeekableStreamSupervisor supervisor = new TestEmittingTestSeekableStreamSupervisor(latch, null, null);
    supervisor.start();
    supervisor.emitNoticesTime();
    Assert.assertTrue(supervisor.stateManager.isHealthy());
    Assert.assertEquals(BasicState.PENDING, supervisor.stateManager.getSupervisorState());
    Assert.assertEquals(BasicState.PENDING, supervisor.stateManager.getSupervisorState().getBasicState());
    Assert.assertTrue(supervisor.stateManager.getExceptionEvents().isEmpty());
    Assert.assertFalse(supervisor.stateManager.isAtLeastOneSuccessfulRun());
    latch.await();
    List<Event> events = emitter.getEvents();
    List<String> whitelist = Collections.singletonList("ingest/notices/time");
    events = filterMetrics(events, whitelist);
    Assert.assertEquals(1, events.size());
    Assert.assertEquals("ingest/notices/time", events.get(0).toMap().get("metric"));
    Assert.assertEquals(500L, events.get(0).toMap().get("value"));
    Assert.assertEquals("testDS", events.get(0).toMap().get("dataSource"));
    Assert.assertEquals("dummyNoticeType", events.get(0).toMap().get("noticeType"));
    verifyAll();
}
Also used : Event(org.apache.druid.java.util.emitter.core.Event) SeekableStreamExceptionEvent(org.apache.druid.indexing.seekablestream.supervisor.SeekableStreamSupervisorStateManager.SeekableStreamExceptionEvent) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 19 with Event

use of org.apache.druid.java.util.emitter.core.Event in project druid by druid-io.

the class MetricsEmittingQueryProcessingPoolTest method testPrioritizedExecutorDelegate.

@Test
public void testPrioritizedExecutorDelegate() {
    PrioritizedExecutorService service = Mockito.mock(PrioritizedExecutorService.class);
    Mockito.when(service.getQueueSize()).thenReturn(10);
    ExecutorServiceMonitor monitor = new ExecutorServiceMonitor();
    List<Event> events = new ArrayList<>();
    MetricsEmittingQueryProcessingPool processingPool = new MetricsEmittingQueryProcessingPool(service, monitor);
    Assert.assertSame(service, processingPool.delegate());
    ServiceEmitter serviceEmitter = new ServiceEmitter("service", "host", Mockito.mock(Emitter.class)) {

        @Override
        public void emit(Event event) {
            events.add(event);
        }
    };
    monitor.doMonitor(serviceEmitter);
    Assert.assertEquals(1, events.size());
    Assert.assertEquals(((ServiceMetricEvent) (events.get(0))).getMetric(), "segment/scan/pending");
    Assert.assertEquals(((ServiceMetricEvent) (events.get(0))).getValue(), 10);
}
Also used : ServiceEmitter(org.apache.druid.java.util.emitter.service.ServiceEmitter) Emitter(org.apache.druid.java.util.emitter.core.Emitter) ServiceEmitter(org.apache.druid.java.util.emitter.service.ServiceEmitter) ArrayList(java.util.ArrayList) ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) Event(org.apache.druid.java.util.emitter.core.Event) Test(org.junit.Test)

Example 20 with Event

use of org.apache.druid.java.util.emitter.core.Event in project druid by druid-io.

the class LookupCoordinatorManagerTest method setUpStatic.

@BeforeClass
public static void setUpStatic() {
    LoggingEmitter loggingEmitter = EasyMock.createNiceMock(LoggingEmitter.class);
    EasyMock.replay(loggingEmitter);
    SERVICE_EMITTER = new ServiceEmitter("", "", loggingEmitter) {

        @Override
        public void emit(Event event) {
            EVENT_EMITS.incrementAndGet();
            super.emit(event);
        }
    };
    EmittingLogger.registerEmitter(SERVICE_EMITTER);
}
Also used : ServiceEmitter(org.apache.druid.java.util.emitter.service.ServiceEmitter) Event(org.apache.druid.java.util.emitter.core.Event) LoggingEmitter(org.apache.druid.java.util.emitter.core.LoggingEmitter) BeforeClass(org.junit.BeforeClass)

Aggregations

Event (org.apache.druid.java.util.emitter.core.Event)22 Test (org.junit.Test)19 CountDownLatch (java.util.concurrent.CountDownLatch)12 ServiceEmitter (org.apache.druid.java.util.emitter.service.ServiceEmitter)10 ArrayList (java.util.ArrayList)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 Arrays (java.util.Arrays)6 Collections (java.util.Collections)6 HashSet (java.util.HashSet)6 List (java.util.List)6 Map (java.util.Map)6 TimeUnit (java.util.concurrent.TimeUnit)6 Pair (org.apache.druid.java.util.common.Pair)6 TypeReference (com.fasterxml.jackson.core.type.TypeReference)5 Preconditions (com.google.common.base.Preconditions)5 ImmutableList (com.google.common.collect.ImmutableList)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 Sets (com.google.common.collect.Sets)5 Files (com.google.common.io.Files)5 BufferedWriter (java.io.BufferedWriter)5