Search in sources :

Example 21 with DataSourcesSnapshot

use of org.apache.druid.client.DataSourcesSnapshot in project druid by apache.

the class LogUsedSegments method run.

@Override
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) {
    log.debug("Starting coordination. Getting used segments.");
    // Log info about all used segments only if debug logging is enabled
    if (log.isDebugEnabled()) {
        DataSourcesSnapshot dataSourcesSnapshot = params.getDataSourcesSnapshot();
        log.debug("Used Segments");
        for (DataSegment dataSegment : dataSourcesSnapshot.iterateAllUsedSegmentsInSnapshot()) {
            log.debug("  %s", dataSegment);
        }
    }
    log.info("Found [%,d] used segments.", params.getUsedSegments().size());
    return params;
}
Also used : DataSourcesSnapshot(org.apache.druid.client.DataSourcesSnapshot) DataSegment(org.apache.druid.timeline.DataSegment)

Example 22 with DataSourcesSnapshot

use of org.apache.druid.client.DataSourcesSnapshot in project druid by apache.

the class DataSourcesSnapshotBenchmark method setUp.

@Setup
public void setUp() {
    long start = System.currentTimeMillis();
    Map<String, ImmutableDruidDataSource> dataSources = new HashMap<>();
    for (int i = 0; i < numDataSources; i++) {
        String dataSource = StringUtils.format("ds-%d", i);
        List<DataSegment> segments = new ArrayList<>();
        for (int j = 0; j < numSegmentPerDataSource; j++) {
            segments.add(new DataSegment(dataSource, TEST_SEGMENT_INTERVAL, String.valueOf(j), Collections.emptyMap(), Collections.emptyList(), Collections.emptyList(), NoneShardSpec.instance(), 0, 10L));
        }
        dataSources.put(dataSource, new ImmutableDruidDataSource(dataSource, Collections.emptyMap(), segments));
    }
    snapshot = new DataSourcesSnapshot(dataSources);
    System.out.println("Setup Time " + (System.currentTimeMillis() - start) + " ms");
}
Also used : ImmutableDruidDataSource(org.apache.druid.client.ImmutableDruidDataSource) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DataSegment(org.apache.druid.timeline.DataSegment) DataSourcesSnapshot(org.apache.druid.client.DataSourcesSnapshot) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

DataSourcesSnapshot (org.apache.druid.client.DataSourcesSnapshot)22 ImmutableDruidDataSource (org.apache.druid.client.ImmutableDruidDataSource)14 DataSegment (org.apache.druid.timeline.DataSegment)12 Test (org.junit.Test)8 CountDownLatch (java.util.concurrent.CountDownLatch)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 JacksonConfigManager (org.apache.druid.common.config.JacksonConfigManager)6 NoopServiceAnnouncer (org.apache.druid.curator.discovery.NoopServiceAnnouncer)6 SegmentsMetadataManager (org.apache.druid.metadata.SegmentsMetadataManager)6 DruidNode (org.apache.druid.server.DruidNode)6 CoordinatorCustomDutyGroups (org.apache.druid.server.coordinator.duty.CoordinatorCustomDutyGroups)6 ZkPathsConfig (org.apache.druid.server.initialization.ZkPathsConfig)6 HashSet (java.util.HashSet)4 Nullable (javax.annotation.Nullable)4 PathChildrenCache (org.apache.curator.framework.recipes.cache.PathChildrenCache)4 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)4 MetadataRuleManager (org.apache.druid.metadata.MetadataRuleManager)4 Duration (org.joda.time.Duration)4 Before (org.junit.Before)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2