Search in sources :

Example 1 with Event

use of com.metamx.emitter.core.Event 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 Event

use of com.metamx.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);
        }
    };
    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)

Aggregations

Event (com.metamx.emitter.core.Event)2 ServiceEmitter (com.metamx.emitter.service.ServiceEmitter)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Emitter (com.metamx.emitter.core.Emitter)1 LoggingEmitter (com.metamx.emitter.core.LoggingEmitter)1 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)1 ArrayList (java.util.ArrayList)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1