Search in sources :

Example 11 with QueryableDruidServer

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

the class CachingClusteredClientCacheKeyManagerTest method makeServerSelector.

/**
 * using partitionNumber, its possible to create segments with different ids
 */
private SegmentServerSelector makeServerSelector(boolean isHistorical, int partitionNumber) {
    ServerSelector serverSelector = mock(ServerSelector.class);
    QueryableDruidServer queryableDruidServer = mock(QueryableDruidServer.class);
    DruidServer server = mock(DruidServer.class);
    SegmentId segmentId = SegmentId.dummy("data-source", partitionNumber);
    DataSegment segment = new DataSegment(segmentId, null, null, null, new NumberedShardSpec(partitionNumber, 10), null, 0, 0);
    expect(server.isSegmentReplicationTarget()).andReturn(isHistorical).anyTimes();
    expect(serverSelector.pick(query)).andReturn(queryableDruidServer).anyTimes();
    expect(queryableDruidServer.getServer()).andReturn(server).anyTimes();
    expect(serverSelector.getSegment()).andReturn(segment).anyTimes();
    replay(serverSelector, queryableDruidServer, server);
    return new SegmentServerSelector(serverSelector, segmentId.toDescriptor());
}
Also used : ServerSelector(org.apache.druid.client.selector.ServerSelector) SegmentId(org.apache.druid.timeline.SegmentId) QueryableDruidServer(org.apache.druid.client.selector.QueryableDruidServer) DataSegment(org.apache.druid.timeline.DataSegment) NumberedShardSpec(org.apache.druid.timeline.partition.NumberedShardSpec) QueryableDruidServer(org.apache.druid.client.selector.QueryableDruidServer)

Example 12 with QueryableDruidServer

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

the class SimpleServerView method unannounceSegmentFromServer.

public void unannounceSegmentFromServer(DruidServer server, DataSegment segment) {
    final QueryableDruidServer queryableDruidServer = servers.get(server);
    if (queryableDruidServer == null) {
        throw new ISE("Unknown server [%s]", server);
    }
    final ServerSelector selector = selectors.get(segment.getId().toString());
    if (selector == null) {
        throw new ISE("Unknown segment [%s]", segment.getId());
    }
    if (!selector.removeServer(queryableDruidServer)) {
        throw new ISE("Failed to remove segment[%s] from server[%s]", segment.getId(), server);
    }
    final VersionedIntervalTimeline<String, ServerSelector> timeline = timelines.get(segment.getDataSource());
    if (timeline == null) {
        throw new ISE("Unknown datasource [%s]", segment.getDataSource());
    }
    timeline.remove(segment.getInterval(), segment.getVersion(), segment.getShardSpec().createChunk(selector));
}
Also used : ServerSelector(org.apache.druid.client.selector.ServerSelector) ISE(org.apache.druid.java.util.common.ISE) QueryableDruidServer(org.apache.druid.client.selector.QueryableDruidServer)

Example 13 with QueryableDruidServer

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

the class DirectDruidClientTest method setup.

@Before
public void setup() {
    httpClient = EasyMock.createMock(HttpClient.class);
    serverSelector = new ServerSelector(dataSegment, new HighestPriorityTierSelectorStrategy(new ConnectionCountServerSelectorStrategy()));
    client = new DirectDruidClient(new ReflectionQueryToolChestWarehouse(), QueryRunnerTestHelper.NOOP_QUERYWATCHER, new DefaultObjectMapper(), httpClient, "http", hostName, new NoopServiceEmitter());
    queryableDruidServer = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 0), client);
    serverSelector.addServerAndUpdateSegment(queryableDruidServer, serverSelector.getSegment());
}
Also used : ServerSelector(org.apache.druid.client.selector.ServerSelector) HttpClient(org.apache.druid.java.util.http.client.HttpClient) HighestPriorityTierSelectorStrategy(org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy) ConnectionCountServerSelectorStrategy(org.apache.druid.client.selector.ConnectionCountServerSelectorStrategy) QueryableDruidServer(org.apache.druid.client.selector.QueryableDruidServer) NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) ReflectionQueryToolChestWarehouse(org.apache.druid.query.ReflectionQueryToolChestWarehouse) QueryableDruidServer(org.apache.druid.client.selector.QueryableDruidServer) Before(org.junit.Before)

Example 14 with QueryableDruidServer

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

the class CachingClusteredClientTest method makeMockHashBasedSelector.

private ServerSelector makeMockHashBasedSelector(DruidServer server, List<String> partitionDimensions, @Nullable HashPartitionFunction partitionFunction, int partitionNum, int partitions) {
    final DataSegment segment = new DataSegment(SegmentId.dummy(DATA_SOURCE), null, null, null, new HashBasedNumberedShardSpec(partitionNum, partitions, partitionNum, partitions, partitionDimensions, partitionFunction, ServerTestHelper.MAPPER), null, 9, 0L);
    ServerSelector selector = new ServerSelector(segment, new HighestPriorityTierSelectorStrategy(new RandomServerSelectorStrategy()));
    selector.addServerAndUpdateSegment(new QueryableDruidServer(server, null), segment);
    return selector;
}
Also used : HashBasedNumberedShardSpec(org.apache.druid.timeline.partition.HashBasedNumberedShardSpec) 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) QueryableDruidServer(org.apache.druid.client.selector.QueryableDruidServer)

Aggregations

QueryableDruidServer (org.apache.druid.client.selector.QueryableDruidServer)14 ServerSelector (org.apache.druid.client.selector.ServerSelector)12 HighestPriorityTierSelectorStrategy (org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy)8 DataSegment (org.apache.druid.timeline.DataSegment)8 RandomServerSelectorStrategy (org.apache.druid.client.selector.RandomServerSelectorStrategy)7 Test (org.junit.Test)5 ResponseContext (org.apache.druid.query.context.ResponseContext)4 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)4 Interval (org.joda.time.Interval)4 TimeBoundaryQuery (org.apache.druid.query.timeboundary.TimeBoundaryQuery)3 NoopServiceEmitter (org.apache.druid.server.metrics.NoopServiceEmitter)3 SegmentId (org.apache.druid.timeline.SegmentId)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 MapCache (org.apache.druid.client.cache.MapCache)2 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)2 Sequence (org.apache.druid.java.util.common.guava.Sequence)2 Iterators (com.google.common.collect.Iterators)1 Ordering (com.google.common.collect.Ordering)1