Search in sources :

Example 16 with ServiceEmitter

use of org.apache.druid.java.util.emitter.service.ServiceEmitter in project druid by druid-io.

the class TaskLockboxTest method setup.

@Before
public void setup() {
    objectMapper = TestHelper.makeJsonMapper();
    objectMapper.registerSubtypes(NumberedShardSpec.class, HashBasedNumberedShardSpec.class);
    final TestDerbyConnector derbyConnector = derby.getConnector();
    derbyConnector.createTaskTables();
    derbyConnector.createPendingSegmentsTable();
    derbyConnector.createSegmentTable();
    final MetadataStorageTablesConfig tablesConfig = derby.metadataTablesConfigSupplier().get();
    taskStorage = new MetadataTaskStorage(derbyConnector, new TaskStorageConfig(null), new DerbyMetadataStorageActionHandlerFactory(derbyConnector, tablesConfig, objectMapper));
    ServiceEmitter emitter = EasyMock.createMock(ServiceEmitter.class);
    EmittingLogger.registerEmitter(emitter);
    EasyMock.replay(emitter);
    metadataStorageCoordinator = new IndexerSQLMetadataStorageCoordinator(objectMapper, tablesConfig, derbyConnector);
    lockbox = new TaskLockbox(taskStorage, metadataStorageCoordinator);
}
Also used : ServiceEmitter(org.apache.druid.java.util.emitter.service.ServiceEmitter) IndexerSQLMetadataStorageCoordinator(org.apache.druid.metadata.IndexerSQLMetadataStorageCoordinator) DerbyMetadataStorageActionHandlerFactory(org.apache.druid.metadata.DerbyMetadataStorageActionHandlerFactory) MetadataStorageTablesConfig(org.apache.druid.metadata.MetadataStorageTablesConfig) TaskStorageConfig(org.apache.druid.indexing.common.config.TaskStorageConfig) TestDerbyConnector(org.apache.druid.metadata.TestDerbyConnector) Before(org.junit.Before)

Example 17 with ServiceEmitter

use of org.apache.druid.java.util.emitter.service.ServiceEmitter in project druid by druid-io.

the class JvmMonitorTest method testGcCounts.

@Test(timeout = 60_000L)
public void testGcCounts() throws InterruptedException {
    GcTrackingEmitter emitter = new GcTrackingEmitter();
    final ServiceEmitter serviceEmitter = new ServiceEmitter("test", "localhost", emitter);
    serviceEmitter.start();
    final JvmMonitor jvmMonitor = new JvmMonitor();
    // skip tests if gc counters fail to initialize with this JDK
    Assume.assumeNotNull(jvmMonitor.gcCounters);
    while (true) {
        // generate some garbage to see gc counters incremented
        @SuppressWarnings("unused") byte[] b = new byte[1024 * 1024 * 50];
        emitter.reset();
        jvmMonitor.doMonitor(serviceEmitter);
        if (emitter.gcSeen()) {
            return;
        }
        Thread.sleep(10);
    }
}
Also used : ServiceEmitter(org.apache.druid.java.util.emitter.service.ServiceEmitter) Test(org.junit.Test)

Example 18 with ServiceEmitter

use of org.apache.druid.java.util.emitter.service.ServiceEmitter in project druid by druid-io.

the class MovingAverageQueryTest method testQuery.

/**
 * Validate that the specified query behaves correctly.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testQuery() throws IOException {
    Query<?> query = jsonMapper.readValue(getQueryString(), Query.class);
    Assert.assertThat(query, IsInstanceOf.instanceOf(getExpectedQueryType()));
    List<MapBasedRow> expectedResults = jsonMapper.readValue(getExpectedResultString(), getExpectedResultType());
    Assert.assertNotNull(expectedResults);
    Assert.assertThat(expectedResults, IsInstanceOf.instanceOf(List.class));
    CachingClusteredClient baseClient = new CachingClusteredClient(warehouse, new TimelineServerView() {

        @Override
        public Optional<? extends TimelineLookup<String, ServerSelector>> getTimeline(DataSourceAnalysis analysis) {
            return Optional.empty();
        }

        @Override
        public List<ImmutableDruidServer> getDruidServers() {
            return null;
        }

        @Override
        public <T> QueryRunner<T> getQueryRunner(DruidServer server) {
            return null;
        }

        @Override
        public void registerTimelineCallback(Executor exec, TimelineCallback callback) {
        }

        @Override
        public void registerSegmentCallback(Executor exec, SegmentCallback callback) {
        }

        @Override
        public void registerServerRemovedCallback(Executor exec, ServerRemovedCallback callback) {
        }
    }, MapCache.create(100000), jsonMapper, new ForegroundCachePopulator(jsonMapper, new CachePopulatorStats(), -1), new CacheConfig(), new DruidHttpClientConfig() {

        @Override
        public long getMaxQueuedBytes() {
            return 0L;
        }
    }, new DruidProcessingConfig() {

        @Override
        public String getFormatString() {
            return null;
        }
    }, ForkJoinPool.commonPool(), QueryStackTests.DEFAULT_NOOP_SCHEDULER, new MapJoinableFactory(ImmutableSet.of(), ImmutableMap.of()), new NoopServiceEmitter());
    ClientQuerySegmentWalker walker = new ClientQuerySegmentWalker(new ServiceEmitter("", "", null) {

        @Override
        public void emit(Event event) {
        }
    }, baseClient, null, /* local client; unused in this test, so pass in null */
    warehouse, new MapJoinableFactory(ImmutableSet.of(), ImmutableMap.of()), retryConfig, jsonMapper, serverConfig, null, new CacheConfig());
    defineMocks();
    QueryPlus queryPlus = QueryPlus.wrap(query);
    final Sequence<?> res = query.getRunner(walker).run(queryPlus);
    List actualResults = new ArrayList();
    actualResults = (List<MapBasedRow>) res.accumulate(actualResults, Accumulators.list());
    expectedResults = consistentTypeCasting(expectedResults);
    actualResults = consistentTypeCasting(actualResults);
    Assert.assertEquals(expectedResults, actualResults);
}
Also used : ServiceEmitter(org.apache.druid.java.util.emitter.service.ServiceEmitter) NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) ArrayList(java.util.ArrayList) DataSourceAnalysis(org.apache.druid.query.planning.DataSourceAnalysis) DruidHttpClientConfig(org.apache.druid.guice.http.DruidHttpClientConfig) MapBasedRow(org.apache.druid.data.input.MapBasedRow) Executor(java.util.concurrent.Executor) CachePopulatorStats(org.apache.druid.client.cache.CachePopulatorStats) List(java.util.List) ArrayList(java.util.ArrayList) TimelineServerView(org.apache.druid.client.TimelineServerView) CacheConfig(org.apache.druid.client.cache.CacheConfig) MapJoinableFactory(org.apache.druid.segment.join.MapJoinableFactory) QueryPlus(org.apache.druid.query.QueryPlus) CachingClusteredClient(org.apache.druid.client.CachingClusteredClient) Optional(java.util.Optional) DruidServer(org.apache.druid.client.DruidServer) ImmutableDruidServer(org.apache.druid.client.ImmutableDruidServer) NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) QueryRunner(org.apache.druid.query.QueryRunner) ClientQuerySegmentWalker(org.apache.druid.server.ClientQuerySegmentWalker) Event(org.apache.druid.java.util.emitter.core.Event) ForegroundCachePopulator(org.apache.druid.client.cache.ForegroundCachePopulator) DruidProcessingConfig(org.apache.druid.query.DruidProcessingConfig) TimelineLookup(org.apache.druid.timeline.TimelineLookup) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 19 with ServiceEmitter

use of org.apache.druid.java.util.emitter.service.ServiceEmitter in project druid by druid-io.

the class MySQLMetadataStorageModuleTest method createInjector.

private Injector createInjector() {
    MySQLMetadataStorageModule module = new MySQLMetadataStorageModule();
    Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(new MetadataConfigModule(), new LifecycleModule(), module, new Module() {

        @Override
        public void configure(Binder binder) {
            module.createBindingChoices(binder, "mysql");
        }

        @Provides
        public ServiceEmitter getEmitter() {
            return new ServiceEmitter("test", "localhost", new NoopEmitter());
        }
    }));
    ObjectMapper mapper = injector.getInstance(Key.get(ObjectMapper.class, Json.class));
    mapper.registerModules(module.getJacksonModules());
    return injector;
}
Also used : ServiceEmitter(org.apache.druid.java.util.emitter.service.ServiceEmitter) Binder(com.google.inject.Binder) MetadataConfigModule(org.apache.druid.guice.MetadataConfigModule) Injector(com.google.inject.Injector) Json(org.apache.druid.guice.annotations.Json) Module(com.google.inject.Module) LifecycleModule(org.apache.druid.guice.LifecycleModule) MetadataConfigModule(org.apache.druid.guice.MetadataConfigModule) NoopEmitter(org.apache.druid.java.util.emitter.core.NoopEmitter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LifecycleModule(org.apache.druid.guice.LifecycleModule)

Example 20 with ServiceEmitter

use of org.apache.druid.java.util.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 : NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) ServiceEmitter(org.apache.druid.java.util.emitter.service.ServiceEmitter) Test(org.junit.Test)

Aggregations

ServiceEmitter (org.apache.druid.java.util.emitter.service.ServiceEmitter)45 Test (org.junit.Test)24 Before (org.junit.Before)9 Event (org.apache.druid.java.util.emitter.core.Event)8 CachingEmitter (org.apache.druid.query.CachingEmitter)8 DefaultQueryMetricsTest (org.apache.druid.query.DefaultQueryMetricsTest)8 ArrayList (java.util.ArrayList)7 NoopServiceEmitter (org.apache.druid.server.metrics.NoopServiceEmitter)7 Map (java.util.Map)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 List (java.util.List)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 ServiceMetricEvent (org.apache.druid.java.util.emitter.service.ServiceMetricEvent)5 DruidNode (org.apache.druid.server.DruidNode)5 DataSegment (org.apache.druid.timeline.DataSegment)5 Interval (org.joda.time.Interval)5 ImmutableSet (com.google.common.collect.ImmutableSet)4