Search in sources :

Example 1 with ServiceEmitter

use of com.metamx.emitter.service.ServiceEmitter in project druid by druid-io.

the class MockMemcachedClient method testMonitor.

@Test
public void testMonitor() throws Exception {
    final MemcachedCache cache = MemcachedCache.create(memcachedCacheConfig);
    final Emitter emitter = EasyMock.createNiceMock(Emitter.class);
    final Collection<Event> events = new ArrayList<>();
    final ServiceEmitter serviceEmitter = new ServiceEmitter("service", "host", emitter) {

        @Override
        public void emit(Event event) {
            events.add(event);
        }
    };
    while (events.isEmpty()) {
        Thread.sleep(memcachedCacheConfig.getTimeout());
        cache.doMonitor(serviceEmitter);
    }
    Assert.assertFalse(events.isEmpty());
    ObjectMapper mapper = new DefaultObjectMapper();
    for (Event event : events) {
        log.debug("Found event `%s`", mapper.writeValueAsString(event.toMap()));
    }
}
Also used : ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) Emitter(com.metamx.emitter.core.Emitter) ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) ArrayList(java.util.ArrayList) Event(com.metamx.emitter.core.Event) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with ServiceEmitter

use of com.metamx.emitter.service.ServiceEmitter 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);
        }
    };
    com.metamx.emitter.EmittingLogger.registerEmitter(SERVICE_EMITTER);
}
Also used : ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) Event(com.metamx.emitter.core.Event) LoggingEmitter(com.metamx.emitter.core.LoggingEmitter) BeforeClass(org.junit.BeforeClass)

Example 3 with ServiceEmitter

use of com.metamx.emitter.service.ServiceEmitter in project druid by druid-io.

the class KafkaIndexTaskTest method setUp.

@Before
public void setUp() throws Exception {
    emitter = new ServiceEmitter("service", "host", new LoggingEmitter(log, LoggingEmitter.Level.ERROR, new DefaultObjectMapper()));
    emitter.start();
    EmittingLogger.registerEmitter(emitter);
    makeToolboxFactory();
    zkServer = new TestingCluster(1);
    zkServer.start();
    kafkaServer = new TestBroker(zkServer.getConnectString(), tempFolder.newFolder(), 1, ImmutableMap.of("num.partitions", "2"));
    kafkaServer.start();
    taskExec = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool(Execs.makeThreadFactory("kafka-task-test-%d")));
    handoffConditionTimeout = 0;
    reportParseExceptions = false;
    doHandoff = true;
}
Also used : ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) TestingCluster(org.apache.curator.test.TestingCluster) TestBroker(io.druid.indexing.kafka.test.TestBroker) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) LoggingEmitter(com.metamx.emitter.core.LoggingEmitter) Before(org.junit.Before)

Example 4 with ServiceEmitter

use of com.metamx.emitter.service.ServiceEmitter in project druid by druid-io.

the class RemoteTaskRunnerTest method testRunTooMuchZKData.

@Test
public void testRunTooMuchZKData() throws Exception {
    ServiceEmitter emitter = EasyMock.createMock(ServiceEmitter.class);
    EmittingLogger.registerEmitter(emitter);
    EasyMock.replay(emitter);
    doSetup();
    remoteTaskRunner.run(TestTasks.unending(new String(new char[5000])));
    EasyMock.verify(emitter);
}
Also used : ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) Test(org.junit.Test)

Example 5 with ServiceEmitter

use of com.metamx.emitter.service.ServiceEmitter in project druid by druid-io.

the class PendingTaskBasedResourceManagementStrategyTest method testProvisionAlert.

@Test
public void testProvisionAlert() throws Exception {
    ServiceEmitter emitter = EasyMock.createMock(ServiceEmitter.class);
    EmittingLogger.registerEmitter(emitter);
    emitter.emit(EasyMock.<ServiceEventBuilder>anyObject());
    EasyMock.expectLastCall();
    EasyMock.replay(emitter);
    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0).times(1);
    EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(2).times(1);
    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.<String>newArrayList()).times(2);
    EasyMock.expect(autoScaler.terminateWithIds(EasyMock.<List<String>>anyObject())).andReturn(null);
    EasyMock.expect(autoScaler.provision()).andReturn(new AutoScalingData(Lists.<String>newArrayList("fake")));
    EasyMock.replay(autoScaler);
    RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
    EasyMock.expect(runner.getPendingTaskPayloads()).andReturn(Arrays.<Task>asList(NoopTask.create())).times(2);
    EasyMock.expect(runner.getWorkers()).andReturn(Arrays.asList(new TestZkWorker(testTask, "hi", "lo", MIN_VERSION, 1).toImmutable(), // Invalid version node
    new TestZkWorker(testTask, "h1", "n1", INVALID_VERSION).toImmutable(), // Invalid version node
    new TestZkWorker(testTask, "h2", "n1", INVALID_VERSION).toImmutable())).times(2);
    EasyMock.expect(runner.getConfig()).andReturn(new RemoteTaskRunnerConfig());
    EasyMock.replay(runner);
    boolean provisionedSomething = strategy.doProvision(runner);
    Assert.assertTrue(provisionedSomething);
    Assert.assertTrue(strategy.getStats().toList().size() == 1);
    DateTime createdTime = strategy.getStats().toList().get(0).getTimestamp();
    Assert.assertTrue(strategy.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.PROVISION);
    Thread.sleep(2000);
    provisionedSomething = strategy.doProvision(runner);
    Assert.assertFalse(provisionedSomething);
    Assert.assertTrue(strategy.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.PROVISION);
    DateTime anotherCreatedTime = strategy.getStats().toList().get(0).getTimestamp();
    Assert.assertTrue(createdTime.equals(anotherCreatedTime));
    EasyMock.verify(autoScaler);
    EasyMock.verify(emitter);
    EasyMock.verify(runner);
}
Also used : ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) Task(io.druid.indexing.common.task.Task) NoopTask(io.druid.indexing.common.task.NoopTask) RemoteTaskRunner(io.druid.indexing.overlord.RemoteTaskRunner) List(java.util.List) RemoteTaskRunnerConfig(io.druid.indexing.overlord.config.RemoteTaskRunnerConfig) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

ServiceEmitter (com.metamx.emitter.service.ServiceEmitter)13 Test (org.junit.Test)4 ServiceMetricEvent (com.metamx.emitter.service.ServiceMetricEvent)3 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)3 Map (java.util.Map)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Event (com.metamx.emitter.core.Event)2 LoggingEmitter (com.metamx.emitter.core.LoggingEmitter)2 NoopTask (io.druid.indexing.common.task.NoopTask)2 Task (io.druid.indexing.common.task.Task)2 RemoteTaskRunner (io.druid.indexing.overlord.RemoteTaskRunner)2 DruidNode (io.druid.server.DruidNode)2 DataSegment (io.druid.timeline.DataSegment)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 DateTime (org.joda.time.DateTime)2