Search in sources :

Example 6 with DruidNode

use of io.druid.server.DruidNode in project druid by druid-io.

the class DruidAvaticaHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    Calcites.setSystemProperties();
    walker = CalciteTests.createMockWalker(temporaryFolder.newFolder());
    final PlannerConfig plannerConfig = new PlannerConfig();
    final SchemaPlus rootSchema = Calcites.createRootSchema(CalciteTests.createMockSchema(walker, plannerConfig));
    final DruidOperatorTable operatorTable = CalciteTests.createOperatorTable();
    final DruidAvaticaHandler handler = new DruidAvaticaHandler(new DruidMeta(new PlannerFactory(rootSchema, walker, operatorTable, plannerConfig), AVATICA_CONFIG), new DruidNode("dummy", "dummy", 1), new AvaticaMonitor());
    final int port = new Random().nextInt(9999) + 10000;
    server = new Server(new InetSocketAddress("127.0.0.1", port));
    server.setHandler(handler);
    server.start();
    final String url = String.format("jdbc:avatica:remote:url=http://127.0.0.1:%d%s", port, DruidAvaticaHandler.AVATICA_PATH);
    client = DriverManager.getConnection(url);
    final Properties propertiesLosAngeles = new Properties();
    propertiesLosAngeles.setProperty("sqlTimeZone", "America/Los_Angeles");
    clientLosAngeles = DriverManager.getConnection(url, propertiesLosAngeles);
}
Also used : Server(org.eclipse.jetty.server.Server) InetSocketAddress(java.net.InetSocketAddress) SchemaPlus(org.apache.calcite.schema.SchemaPlus) Properties(java.util.Properties) DruidOperatorTable(io.druid.sql.calcite.planner.DruidOperatorTable) Random(java.util.Random) PlannerConfig(io.druid.sql.calcite.planner.PlannerConfig) PlannerFactory(io.druid.sql.calcite.planner.PlannerFactory) DruidNode(io.druid.server.DruidNode) Before(org.junit.Before)

Example 7 with DruidNode

use of io.druid.server.DruidNode in project druid by druid-io.

the class NamespaceLookupExtractorFactoryTest method testSimpleIntrospectionHandler.

@Test
public void testSimpleIntrospectionHandler() throws Exception {
    final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(new Module() {

        @Override
        public void configure(Binder binder) {
            JsonConfigProvider.bindInstance(binder, Key.get(DruidNode.class, Self.class), new DruidNode("test-inject", null, null));
        }
    }));
    final ObjectMapper mapper = injector.getInstance(Key.get(ObjectMapper.class, Json.class));
    mapper.registerSubtypes(NamespaceLookupExtractorFactory.class);
    final String str = "{ \"type\": \"cachedNamespace\", \"extractionNamespace\": { \"type\": \"staticMap\", \"map\": {\"foo\":\"bar\"} }, \"firstCacheTimeout\":10000 }";
    final LookupExtractorFactory lookupExtractorFactory = mapper.readValue(str, LookupExtractorFactory.class);
    Assert.assertTrue(lookupExtractorFactory.start());
    try {
        final LookupIntrospectHandler handler = lookupExtractorFactory.getIntrospectHandler();
        Assert.assertNotNull(handler);
        final Class<? extends LookupIntrospectHandler> clazz = handler.getClass();
        Assert.assertNotNull(clazz.getMethod("getVersion").invoke(handler));
        Assert.assertEquals(ImmutableSet.of("foo"), ((Response) clazz.getMethod("getKeys").invoke(handler)).getEntity());
        Assert.assertEquals(ImmutableSet.of("bar"), ((Response) clazz.getMethod("getValues").invoke(handler)).getEntity());
        Assert.assertEquals(ImmutableMap.builder().put("foo", "bar").build(), ((Response) clazz.getMethod("getMap").invoke(handler)).getEntity());
    } finally {
        Assert.assertTrue(lookupExtractorFactory.close());
    }
}
Also used : Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) DruidNode(io.druid.server.DruidNode) Self(io.druid.guice.annotations.Self) Json(io.druid.guice.annotations.Json) Module(com.google.inject.Module) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with DruidNode

use of io.druid.server.DruidNode in project druid by druid-io.

the class OffHeapNamespaceExtractionCacheManagerTest method testInjection.

@Test
public void testInjection() {
    final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(new Module() {

        @Override
        public void configure(Binder binder) {
            JsonConfigProvider.bindInstance(binder, Key.get(DruidNode.class, Self.class), new DruidNode("test-inject", null, null));
        }
    }));
    final Properties properties = injector.getInstance(Properties.class);
    properties.clear();
    properties.put(NamespaceExtractionModule.TYPE_PREFIX, "offHeap");
    final NamespaceExtractionCacheManager manager = injector.getInstance(NamespaceExtractionCacheManager.class);
    Assert.assertEquals(OffHeapNamespaceExtractionCacheManager.class, manager.getClass());
}
Also used : Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) DruidNode(io.druid.server.DruidNode) Self(io.druid.guice.annotations.Self) Module(com.google.inject.Module) NamespaceExtractionModule(io.druid.server.lookup.namespace.NamespaceExtractionModule) Properties(java.util.Properties) Test(org.junit.Test)

Example 9 with DruidNode

use of io.druid.server.DruidNode in project druid by druid-io.

the class OnHeapNamespaceExtractionCacheManagerTest method testInjection.

@Test
public void testInjection() {
    final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(new Module() {

        @Override
        public void configure(Binder binder) {
            JsonConfigProvider.bindInstance(binder, Key.get(DruidNode.class, Self.class), new DruidNode("test-inject", null, null));
        }
    }));
    final Properties properties = injector.getInstance(Properties.class);
    properties.clear();
    properties.put(NamespaceExtractionModule.TYPE_PREFIX, "onHeap");
    final NamespaceExtractionCacheManager manager = injector.getInstance(NamespaceExtractionCacheManager.class);
    Assert.assertEquals(OnHeapNamespaceExtractionCacheManager.class, manager.getClass());
}
Also used : Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) DruidNode(io.druid.server.DruidNode) Self(io.druid.guice.annotations.Self) Module(com.google.inject.Module) NamespaceExtractionModule(io.druid.server.lookup.namespace.NamespaceExtractionModule) Properties(java.util.Properties) Test(org.junit.Test)

Example 10 with DruidNode

use of io.druid.server.DruidNode in project druid by druid-io.

the class TaskLifecycleTest method setUpThreadPoolTaskRunner.

private TaskRunner setUpThreadPoolTaskRunner(TaskToolboxFactory tb) {
    Preconditions.checkNotNull(taskConfig);
    Preconditions.checkNotNull(emitter);
    return new ThreadPoolTaskRunner(tb, taskConfig, emitter, new DruidNode("dummy", "dummy", 10000));
}
Also used : DruidNode(io.druid.server.DruidNode)

Aggregations

DruidNode (io.druid.server.DruidNode)19 Self (io.druid.guice.annotations.Self)13 Binder (com.google.inject.Binder)12 Injector (com.google.inject.Injector)11 Module (com.google.inject.Module)11 Test (org.junit.Test)10 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)4 Before (org.junit.Before)4 Properties (java.util.Properties)3 ServiceEmitter (com.metamx.emitter.service.ServiceEmitter)2 NoopServiceAnnouncer (io.druid.curator.discovery.NoopServiceAnnouncer)2 LifecycleModule (io.druid.guice.LifecycleModule)2 Json (io.druid.guice.annotations.Json)2 ZkPathsConfig (io.druid.server.initialization.ZkPathsConfig)2 NamespaceExtractionModule (io.druid.server.lookup.namespace.NamespaceExtractionModule)2 NoopServiceEmitter (io.druid.server.metrics.NoopServiceEmitter)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Server (org.eclipse.jetty.server.Server)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1