use of org.apache.druid.discovery.DruidLeaderClient in project druid by druid-io.
the class OverlordProxyServletTest method testRewriteURI.
@Test
public void testRewriteURI() {
DruidLeaderClient druidLeaderClient = EasyMock.createMock(DruidLeaderClient.class);
EasyMock.expect(druidLeaderClient.findCurrentLeader()).andReturn("https://overlord:port");
HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
EasyMock.expect(request.getQueryString()).andReturn("param1=test¶m2=test2").anyTimes();
// %3A is a colon; test to make sure urlencoded paths work right.
EasyMock.expect(request.getRequestURI()).andReturn("/druid/over%3Alord/worker").anyTimes();
EasyMock.replay(druidLeaderClient, request);
URI uri = URI.create(new OverlordProxyServlet(druidLeaderClient, null, null).rewriteTarget(request));
Assert.assertEquals("https://overlord:port/druid/over%3Alord/worker?param1=test¶m2=test2", uri.toString());
}
use of org.apache.druid.discovery.DruidLeaderClient in project druid by druid-io.
the class LookupReferencesManagerTest method setUp.
@Before
public void setUp() throws IOException {
EmittingLogger.registerEmitter(new NoopServiceEmitter());
druidLeaderClient = EasyMock.createMock(DruidLeaderClient.class);
config = EasyMock.createMock(LookupListeningAnnouncerConfig.class);
lookupExtractorFactory = new MapLookupExtractorFactory(ImmutableMap.of("key", "value"), true);
container = new LookupExtractorFactoryContainer("v0", lookupExtractorFactory);
mapper.registerSubtypes(MapLookupExtractorFactory.class);
String temporaryPath = temporaryFolder.newFolder().getAbsolutePath();
lookupReferencesManager = new LookupReferencesManager(new LookupConfig(temporaryFolder.newFolder().getAbsolutePath()), mapper, druidLeaderClient, config, true);
}
use of org.apache.druid.discovery.DruidLeaderClient in project druid by druid-io.
the class HttpIndexingServiceClientTest method setup.
@Before
public void setup() {
jsonMapper = new DefaultObjectMapper();
druidLeaderClient = EasyMock.createMock(DruidLeaderClient.class);
mockMapper = EasyMock.createMock(ObjectMapper.class);
httpIndexingServiceClient = new HttpIndexingServiceClient(jsonMapper, druidLeaderClient);
}
use of org.apache.druid.discovery.DruidLeaderClient in project druid by druid-io.
the class CoordinatorRuleManagerTest method mockClient.
private DruidLeaderClient mockClient() {
final Map<String, List<Rule>> rules = ImmutableMap.of(DATASOURCE1, ImmutableList.of(new ForeverLoadRule(null)), DATASOURCE2, ImmutableList.of(new ForeverLoadRule(null), new IntervalDropRule(Intervals.of("2020-01-01/2020-01-02"))), "datasource3", ImmutableList.of(new PeriodLoadRule(new Period("P1M"), true, null), new ForeverDropRule()), TieredBrokerConfig.DEFAULT_RULE_NAME, ImmutableList.of(new ForeverLoadRule(ImmutableMap.of("__default", 2))));
final StringFullResponseHolder holder = EasyMock.niceMock(StringFullResponseHolder.class);
EasyMock.expect(holder.getStatus()).andReturn(HttpResponseStatus.OK);
try {
EasyMock.expect(holder.getContent()).andReturn(objectMapper.writeValueAsString(rules));
final DruidLeaderClient client = EasyMock.niceMock(DruidLeaderClient.class);
EasyMock.expect(client.go(EasyMock.anyObject())).andReturn(holder);
EasyMock.replay(holder, client);
return client;
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}
use of org.apache.druid.discovery.DruidLeaderClient in project druid by druid-io.
the class CalciteTests method createMockSystemSchema.
public static SystemSchema createMockSystemSchema(final DruidSchema druidSchema, final SpecificSegmentsQuerySegmentWalker walker, final PlannerConfig plannerConfig, final AuthorizerMapper authorizerMapper) {
final DruidNode coordinatorNode = new DruidNode("test-coordinator", "dummy", false, 8081, null, true, false);
FakeDruidNodeDiscoveryProvider provider = new FakeDruidNodeDiscoveryProvider(ImmutableMap.of(NodeRole.COORDINATOR, new FakeDruidNodeDiscovery(ImmutableMap.of(NodeRole.COORDINATOR, coordinatorNode))));
final DruidNode overlordNode = new DruidNode("test-overlord", "dummy", false, 8090, null, true, false);
FakeDruidNodeDiscoveryProvider overlordProvider = new FakeDruidNodeDiscoveryProvider(ImmutableMap.of(NodeRole.OVERLORD, new FakeDruidNodeDiscovery(ImmutableMap.of(NodeRole.OVERLORD, coordinatorNode))));
final DruidLeaderClient druidLeaderClient = new DruidLeaderClient(new FakeHttpClient(), provider, NodeRole.COORDINATOR, "/simple/leader") {
@Override
public String findCurrentLeader() {
return coordinatorNode.getHostAndPortToUse();
}
};
final DruidLeaderClient overlordLeaderClient = new DruidLeaderClient(new FakeHttpClient(), overlordProvider, NodeRole.OVERLORD, "/simple/leader") {
@Override
public String findCurrentLeader() {
return overlordNode.getHostAndPortToUse();
}
};
return new SystemSchema(druidSchema, new MetadataSegmentView(druidLeaderClient, getJsonMapper(), new BrokerSegmentWatcherConfig(), plannerConfig), new TestServerInventoryView(walker.getSegments()), new FakeServerInventoryView(), authorizerMapper, druidLeaderClient, overlordLeaderClient, provider, getJsonMapper());
}
Aggregations