Search in sources :

Example 1 with NamespaceExtractionModule

use of org.apache.druid.server.lookup.namespace.NamespaceExtractionModule in project druid by druid-io.

the class TestKafkaExtractionCluster method setUp.

@Before
public void setUp() throws Exception {
    zkServer = new TestingCluster(1);
    zkServer.start();
    closer.register(() -> {
        zkServer.stop();
    });
    kafkaServer = new KafkaServer(getBrokerProperties(), Time.SYSTEM, Some.apply(StringUtils.format("TestingBroker[%d]-", 1)), false);
    kafkaServer.startup();
    closer.register(() -> {
        kafkaServer.shutdown();
        kafkaServer.awaitShutdown();
    });
    log.info("---------------------------Started Kafka Broker ---------------------------");
    log.info("---------------------------Publish Messages to topic-----------------------");
    publishRecordsToKafka();
    System.setProperty("druid.extensions.searchCurrentClassloader", "false");
    injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bindConstant().annotatedWith(Names.named("serviceName")).to("test");
            binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
            binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
        }
    }, // These injections fail under IntelliJ but are required for maven
    new NamespaceExtractionModule(), new KafkaExtractionNamespaceModule()));
    mapper = injector.getInstance(ObjectMapper.class);
    log.info("--------------------------- placed default item via producer ---------------------------");
    final Map<String, String> consumerProperties = getConsumerProperties();
    final KafkaLookupExtractorFactory kafkaLookupExtractorFactory = new KafkaLookupExtractorFactory(null, TOPIC_NAME, consumerProperties);
    factory = (KafkaLookupExtractorFactory) mapper.readValue(mapper.writeValueAsString(kafkaLookupExtractorFactory), LookupExtractorFactory.class);
    Assert.assertEquals(kafkaLookupExtractorFactory.getKafkaTopic(), factory.getKafkaTopic());
    Assert.assertEquals(kafkaLookupExtractorFactory.getKafkaProperties(), factory.getKafkaProperties());
    factory.start();
    closer.register(() -> factory.close());
    log.info("--------------------------- started rename manager ---------------------------");
}
Also used : KafkaServer(kafka.server.KafkaServer) NamespaceExtractionModule(org.apache.druid.server.lookup.namespace.NamespaceExtractionModule) Binder(com.google.inject.Binder) TestingCluster(org.apache.curator.test.TestingCluster) Module(com.google.inject.Module) NamespaceExtractionModule(org.apache.druid.server.lookup.namespace.NamespaceExtractionModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Binder (com.google.inject.Binder)1 Module (com.google.inject.Module)1 KafkaServer (kafka.server.KafkaServer)1 TestingCluster (org.apache.curator.test.TestingCluster)1 NamespaceExtractionModule (org.apache.druid.server.lookup.namespace.NamespaceExtractionModule)1 Before (org.junit.Before)1