Search in sources :

Example 1 with DruidLeaderClient

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&param2=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&param2=test2", uri.toString());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) DruidLeaderClient(org.apache.druid.discovery.DruidLeaderClient) URI(java.net.URI) Test(org.junit.Test)

Example 2 with DruidLeaderClient

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);
}
Also used : NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) DruidLeaderClient(org.apache.druid.discovery.DruidLeaderClient) Before(org.junit.Before)

Example 3 with DruidLeaderClient

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);
}
Also used : DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) DruidLeaderClient(org.apache.druid.discovery.DruidLeaderClient) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Before(org.junit.Before)

Example 4 with 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);
    }
}
Also used : Period(org.joda.time.Period) IntervalDropRule(org.apache.druid.server.coordinator.rules.IntervalDropRule) DruidLeaderClient(org.apache.druid.discovery.DruidLeaderClient) IOException(java.io.IOException) StringFullResponseHolder(org.apache.druid.java.util.http.client.response.StringFullResponseHolder) ForeverDropRule(org.apache.druid.server.coordinator.rules.ForeverDropRule) ForeverLoadRule(org.apache.druid.server.coordinator.rules.ForeverLoadRule) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) PeriodLoadRule(org.apache.druid.server.coordinator.rules.PeriodLoadRule)

Example 5 with DruidLeaderClient

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());
}
Also used : SystemSchema(org.apache.druid.sql.calcite.schema.SystemSchema) NamedSystemSchema(org.apache.druid.sql.calcite.schema.NamedSystemSchema) DiscoveryDruidNode(org.apache.druid.discovery.DiscoveryDruidNode) DruidNode(org.apache.druid.server.DruidNode) DruidLeaderClient(org.apache.druid.discovery.DruidLeaderClient) BrokerSegmentWatcherConfig(org.apache.druid.client.BrokerSegmentWatcherConfig) MetadataSegmentView(org.apache.druid.sql.calcite.schema.MetadataSegmentView)

Aggregations

DruidLeaderClient (org.apache.druid.discovery.DruidLeaderClient)5 Before (org.junit.Before)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 BrokerSegmentWatcherConfig (org.apache.druid.client.BrokerSegmentWatcherConfig)1 DiscoveryDruidNode (org.apache.druid.discovery.DiscoveryDruidNode)1 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)1 StringFullResponseHolder (org.apache.druid.java.util.http.client.response.StringFullResponseHolder)1 DruidNode (org.apache.druid.server.DruidNode)1 ForeverDropRule (org.apache.druid.server.coordinator.rules.ForeverDropRule)1 ForeverLoadRule (org.apache.druid.server.coordinator.rules.ForeverLoadRule)1 IntervalDropRule (org.apache.druid.server.coordinator.rules.IntervalDropRule)1 PeriodLoadRule (org.apache.druid.server.coordinator.rules.PeriodLoadRule)1 NoopServiceEmitter (org.apache.druid.server.metrics.NoopServiceEmitter)1 MetadataSegmentView (org.apache.druid.sql.calcite.schema.MetadataSegmentView)1