Search in sources :

Example 6 with RandomServerSelectorStrategy

use of org.apache.druid.client.selector.RandomServerSelectorStrategy in project druid by druid-io.

the class DatasourceOptimizerTest method setupViews.

private void setupViews() throws Exception {
    baseView = new BatchServerInventoryView(zkPathsConfig, curator, jsonMapper, Predicates.alwaysTrue(), "test") {

        @Override
        public void registerSegmentCallback(Executor exec, final SegmentCallback callback) {
            super.registerSegmentCallback(exec, new SegmentCallback() {

                @Override
                public CallbackAction segmentAdded(DruidServerMetadata server, DataSegment segment) {
                    return callback.segmentAdded(server, segment);
                }

                @Override
                public CallbackAction segmentRemoved(DruidServerMetadata server, DataSegment segment) {
                    return callback.segmentRemoved(server, segment);
                }

                @Override
                public CallbackAction segmentViewInitialized() {
                    return callback.segmentViewInitialized();
                }
            });
        }
    };
    brokerServerView = new BrokerServerView(EasyMock.createMock(QueryToolChestWarehouse.class), EasyMock.createMock(QueryWatcher.class), getSmileMapper(), EasyMock.createMock(HttpClient.class), baseView, new HighestPriorityTierSelectorStrategy(new RandomServerSelectorStrategy()), new NoopServiceEmitter(), new BrokerSegmentWatcherConfig());
    baseView.start();
}
Also used : BatchServerInventoryView(org.apache.druid.client.BatchServerInventoryView) Executor(java.util.concurrent.Executor) HighestPriorityTierSelectorStrategy(org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy) BrokerServerView(org.apache.druid.client.BrokerServerView) NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) DruidServerMetadata(org.apache.druid.server.coordination.DruidServerMetadata) DataSegment(org.apache.druid.timeline.DataSegment) BrokerSegmentWatcherConfig(org.apache.druid.client.BrokerSegmentWatcherConfig) RandomServerSelectorStrategy(org.apache.druid.client.selector.RandomServerSelectorStrategy)

Example 7 with RandomServerSelectorStrategy

use of org.apache.druid.client.selector.RandomServerSelectorStrategy in project druid by druid-io.

the class CachingClusteredClientTest method makeMockSingleDimensionSelector.

private ServerSelector makeMockSingleDimensionSelector(DruidServer server, String dimension, String start, String end, int partitionNum) {
    final DataSegment segment = new DataSegment(SegmentId.dummy(DATA_SOURCE), null, null, null, new SingleDimensionShardSpec(dimension, start, end, partitionNum, SingleDimensionShardSpec.UNKNOWN_NUM_CORE_PARTITIONS), null, 9, 0L);
    ServerSelector selector = new ServerSelector(segment, new HighestPriorityTierSelectorStrategy(new RandomServerSelectorStrategy()));
    selector.addServerAndUpdateSegment(new QueryableDruidServer(server, null), segment);
    return selector;
}
Also used : ServerSelector(org.apache.druid.client.selector.ServerSelector) HighestPriorityTierSelectorStrategy(org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy) DataSegment(org.apache.druid.timeline.DataSegment) SingleDimensionShardSpec(org.apache.druid.timeline.partition.SingleDimensionShardSpec) RandomServerSelectorStrategy(org.apache.druid.client.selector.RandomServerSelectorStrategy) QueryableDruidServer(org.apache.druid.client.selector.QueryableDruidServer)

Example 8 with RandomServerSelectorStrategy

use of org.apache.druid.client.selector.RandomServerSelectorStrategy in project druid by druid-io.

the class BrokerServerViewTest method setupViews.

private void setupViews(Set<String> watchedTiers, Set<String> ignoredTiers, boolean watchRealtimeTasks) throws Exception {
    baseView = new BatchServerInventoryView(zkPathsConfig, curator, jsonMapper, Predicates.alwaysTrue(), "test") {

        @Override
        public void registerSegmentCallback(Executor exec, final SegmentCallback callback) {
            super.registerSegmentCallback(exec, new SegmentCallback() {

                @Override
                public CallbackAction segmentAdded(DruidServerMetadata server, DataSegment segment) {
                    CallbackAction res = callback.segmentAdded(server, segment);
                    segmentAddedLatch.countDown();
                    return res;
                }

                @Override
                public CallbackAction segmentRemoved(DruidServerMetadata server, DataSegment segment) {
                    CallbackAction res = callback.segmentRemoved(server, segment);
                    segmentRemovedLatch.countDown();
                    return res;
                }

                @Override
                public CallbackAction segmentViewInitialized() {
                    CallbackAction res = callback.segmentViewInitialized();
                    segmentViewInitLatch.countDown();
                    return res;
                }
            });
        }
    };
    brokerServerView = new BrokerServerView(EasyMock.createMock(QueryToolChestWarehouse.class), EasyMock.createMock(QueryWatcher.class), getSmileMapper(), EasyMock.createMock(HttpClient.class), baseView, new HighestPriorityTierSelectorStrategy(new RandomServerSelectorStrategy()), new NoopServiceEmitter(), new BrokerSegmentWatcherConfig() {

        @Override
        public Set<String> getWatchedTiers() {
            return watchedTiers;
        }

        @Override
        public boolean isWatchRealtimeTasks() {
            return watchRealtimeTasks;
        }

        @Override
        public Set<String> getIgnoredTiers() {
            return ignoredTiers;
        }
    });
    baseView.start();
}
Also used : NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) DruidServerMetadata(org.apache.druid.server.coordination.DruidServerMetadata) DataSegment(org.apache.druid.timeline.DataSegment) Executor(java.util.concurrent.Executor) HighestPriorityTierSelectorStrategy(org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy) RandomServerSelectorStrategy(org.apache.druid.client.selector.RandomServerSelectorStrategy)

Example 9 with RandomServerSelectorStrategy

use of org.apache.druid.client.selector.RandomServerSelectorStrategy in project druid by druid-io.

the class ClientInfoResourceTest method addSegmentWithShardSpec.

private void addSegmentWithShardSpec(VersionedIntervalTimeline<String, ServerSelector> timeline, DruidServer server, String interval, List<String> dims, List<String> metrics, String version, ShardSpec shardSpec) {
    DataSegment segment = DataSegment.builder().dataSource(dataSource).interval(Intervals.of(interval)).version(version).dimensions(dims).metrics(metrics).shardSpec(shardSpec).size(1).build();
    server.addDataSegment(segment);
    ServerSelector ss = new ServerSelector(segment, new HighestPriorityTierSelectorStrategy(new RandomServerSelectorStrategy()));
    timeline.add(Intervals.of(interval), version, shardSpec.createChunk(ss));
}
Also used : ServerSelector(org.apache.druid.client.selector.ServerSelector) HighestPriorityTierSelectorStrategy(org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy) DataSegment(org.apache.druid.timeline.DataSegment) RandomServerSelectorStrategy(org.apache.druid.client.selector.RandomServerSelectorStrategy)

Example 10 with RandomServerSelectorStrategy

use of org.apache.druid.client.selector.RandomServerSelectorStrategy in project druid by druid-io.

the class ClientInfoResourceTest method addSegment.

private void addSegment(VersionedIntervalTimeline<String, ServerSelector> timeline, DruidServer server, String interval, List<String> dims, List<String> metrics, String version) {
    DataSegment segment = DataSegment.builder().dataSource(dataSource).interval(Intervals.of(interval)).version(version).dimensions(dims).metrics(metrics).size(1).build();
    server.addDataSegment(segment);
    ServerSelector ss = new ServerSelector(segment, new HighestPriorityTierSelectorStrategy(new RandomServerSelectorStrategy()));
    timeline.add(Intervals.of(interval), version, new SingleElementPartitionChunk<ServerSelector>(ss));
}
Also used : ServerSelector(org.apache.druid.client.selector.ServerSelector) HighestPriorityTierSelectorStrategy(org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy) DataSegment(org.apache.druid.timeline.DataSegment) RandomServerSelectorStrategy(org.apache.druid.client.selector.RandomServerSelectorStrategy)

Aggregations

HighestPriorityTierSelectorStrategy (org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy)11 RandomServerSelectorStrategy (org.apache.druid.client.selector.RandomServerSelectorStrategy)11 DataSegment (org.apache.druid.timeline.DataSegment)11 ServerSelector (org.apache.druid.client.selector.ServerSelector)9 QueryableDruidServer (org.apache.druid.client.selector.QueryableDruidServer)7 ResponseContext (org.apache.druid.query.context.ResponseContext)4 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)4 Interval (org.joda.time.Interval)4 Test (org.junit.Test)4 NoopServiceEmitter (org.apache.druid.server.metrics.NoopServiceEmitter)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Executor (java.util.concurrent.Executor)2 MapCache (org.apache.druid.client.cache.MapCache)2 TimeBoundaryQuery (org.apache.druid.query.timeboundary.TimeBoundaryQuery)2 Iterators (com.google.common.collect.Iterators)1 Ordering (com.google.common.collect.Ordering)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1