Search in sources :

Example 1 with JsonConfigurator

use of io.druid.guice.JsonConfigurator in project druid by druid-io.

the class LookupListeningAnnouncerConfigTest method testSimpleInjection.

@Test
public void testSimpleInjection() {
    final String lookupTier = "some_tier";
    final JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
    properties.put(propertyBase + ".lookupTier", lookupTier);
    final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(propertyBase, LookupListeningAnnouncerConfig.class);
    configProvider.inject(properties, configurator);
    final LookupListeningAnnouncerConfig config = configProvider.get().get();
    Assert.assertEquals(lookupTier, config.getLookupTier());
}
Also used : JsonConfigurator(io.druid.guice.JsonConfigurator) Test(org.junit.Test)

Example 2 with JsonConfigurator

use of io.druid.guice.JsonConfigurator in project druid by druid-io.

the class LookupListeningAnnouncerConfigTest method testFailsInjection.

@Test(expected = IllegalArgumentException.class)
public void testFailsInjection() {
    final String lookupTier = "some_tier";
    final JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
    properties.put(propertyBase + ".lookupTier", lookupTier);
    properties.put(propertyBase + ".lookupTierIsDatasource", "true");
    final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(propertyBase, LookupListeningAnnouncerConfig.class);
    configProvider.inject(properties, configurator);
    final LookupListeningAnnouncerConfig config = configProvider.get().get();
    Assert.assertEquals(lookupTier, config.getLookupTier());
}
Also used : JsonConfigurator(io.druid.guice.JsonConfigurator) Test(org.junit.Test)

Example 3 with JsonConfigurator

use of io.druid.guice.JsonConfigurator in project druid by druid-io.

the class LookupListeningAnnouncerConfigTest method testDatasourceInjection.

@Test
public void testDatasourceInjection() {
    final JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
    properties.put(propertyBase + ".lookupTierIsDatasource", "true");
    final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(propertyBase, LookupListeningAnnouncerConfig.class);
    configProvider.inject(properties, configurator);
    final LookupListeningAnnouncerConfig config = configProvider.get().get();
    Assert.assertEquals("some_datasource", config.getLookupTier());
}
Also used : JsonConfigurator(io.druid.guice.JsonConfigurator) Test(org.junit.Test)

Example 4 with JsonConfigurator

use of io.druid.guice.JsonConfigurator in project druid by druid-io.

the class IndexerZkConfigTest method testExactConfig.

@Test
public void testExactConfig() {
    final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.<Module>of(simpleZkConfigModule));
    propertyValues.setProperty(zkServiceConfigString + ".base", "/druid/metrics");
    JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
    JsonConfigProvider<ZkPathsConfig> zkPathsConfig = JsonConfigProvider.of(zkServiceConfigString, ZkPathsConfig.class);
    zkPathsConfig.inject(propertyValues, configurator);
    ZkPathsConfig zkPathsConfig1 = zkPathsConfig.get().get();
    IndexerZkConfig indexerZkConfig = new IndexerZkConfig(zkPathsConfig1, null, null, null, null, null);
    Assert.assertEquals("/druid/metrics/indexer", indexerZkConfig.getBase());
    Assert.assertEquals("/druid/metrics/indexer/announcements", indexerZkConfig.getAnnouncementsPath());
}
Also used : Injector(com.google.inject.Injector) JsonConfigurator(io.druid.guice.JsonConfigurator) Test(org.junit.Test)

Example 5 with JsonConfigurator

use of io.druid.guice.JsonConfigurator in project druid by druid-io.

the class IndexerZkConfigTest method testNullConfig.

@Test
public void testNullConfig() {
    propertyValues.clear();
    final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.<Module>of(simpleZkConfigModule));
    JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
    JsonConfigProvider<ZkPathsConfig> zkPathsConfig = JsonConfigProvider.of(zkServiceConfigString, ZkPathsConfig.class);
    zkPathsConfig.inject(propertyValues, configurator);
    JsonConfigProvider<IndexerZkConfig> indexerZkConfig = JsonConfigProvider.of(indexerPropertyString, IndexerZkConfig.class);
    indexerZkConfig.inject(propertyValues, configurator);
    Assert.assertEquals("/druid/indexer/leaderLatchPath", indexerZkConfig.get().get().getLeaderLatchPath());
}
Also used : Injector(com.google.inject.Injector) JsonConfigurator(io.druid.guice.JsonConfigurator) Test(org.junit.Test)

Aggregations

JsonConfigurator (io.druid.guice.JsonConfigurator)13 Test (org.junit.Test)13 Injector (com.google.inject.Injector)7 ImmutableList (com.google.common.collect.ImmutableList)3 Lists (com.google.common.collect.Lists)3 Ints (com.google.common.primitives.Ints)3 Inject (com.google.inject.Inject)3 Module (com.google.inject.Module)3 Names (com.google.inject.name.Names)3 GuiceInjectors (io.druid.guice.GuiceInjectors)3 JsonConfigProvider (io.druid.guice.JsonConfigProvider)3 ManageLifecycle (io.druid.guice.ManageLifecycle)3 Initialization (io.druid.initialization.Initialization)3 Lifecycle (io.druid.java.util.common.lifecycle.Lifecycle)3 Field (java.lang.reflect.Field)3 Method (java.lang.reflect.Method)3 Map (java.util.Map)3 Properties (java.util.Properties)3 Random (java.util.Random)3 UUID (java.util.UUID)3