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());
}
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));
}
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());
}
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;
}
Aggregations