use of org.apache.druid.guice.JsonConfigurator in project druid by druid-io.
the class ZkPathsConfigTest method testOverrideBaseOnlyConfig.
@Test
public void testOverrideBaseOnlyConfig() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, IOException {
JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
JsonConfigProvider<ZkPathsConfig> zkPathsConfig = JsonConfigProvider.of(CONFIG_PREFIX, ZkPathsConfig.class);
testProperties.clear();
String base = UUID.randomUUID().toString();
testProperties.put(StringUtils.format("%s.base", CONFIG_PREFIX), base);
zkPathsConfig.inject(testProperties, configurator);
propertyValues.clear();
propertyValues.put(StringUtils.format("%s.base", CONFIG_PREFIX), base);
propertyValues.put(StringUtils.format("%s.propertiesPath", CONFIG_PREFIX), ZKPaths.makePath(base, "properties"));
propertyValues.put(StringUtils.format("%s.announcementsPath", CONFIG_PREFIX), ZKPaths.makePath(base, "announcements"));
propertyValues.put(StringUtils.format("%s.servedSegmentsPath", CONFIG_PREFIX), ZKPaths.makePath(base, "servedSegments"));
propertyValues.put(StringUtils.format("%s.liveSegmentsPath", CONFIG_PREFIX), ZKPaths.makePath(base, "segments"));
propertyValues.put(StringUtils.format("%s.coordinatorPath", CONFIG_PREFIX), ZKPaths.makePath(base, "coordinator"));
propertyValues.put(StringUtils.format("%s.loadQueuePath", CONFIG_PREFIX), ZKPaths.makePath(base, "loadQueue"));
propertyValues.put(StringUtils.format("%s.connectorPath", CONFIG_PREFIX), ZKPaths.makePath(base, "connector"));
ZkPathsConfig zkPathsConfigObj = zkPathsConfig.get().get();
validateEntries(zkPathsConfigObj);
Assert.assertEquals(propertyValues.size(), assertions);
ObjectMapper jsonMapper = injector.getProvider(Key.get(ObjectMapper.class, Json.class)).get();
String jsonVersion = jsonMapper.writeValueAsString(zkPathsConfigObj);
ZkPathsConfig zkPathsConfigObjDeSer = jsonMapper.readValue(jsonVersion, ZkPathsConfig.class);
Assert.assertEquals(zkPathsConfigObj, zkPathsConfigObjDeSer);
}
use of org.apache.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.of(SIMPLE_ZK_CONFIG_MODULE));
JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
JsonConfigProvider<ZkPathsConfig> zkPathsConfig = JsonConfigProvider.of(ZK_SERVICE_CONFIG_STRING, ZkPathsConfig.class);
zkPathsConfig.inject(propertyValues, configurator);
JsonConfigProvider<IndexerZkConfig> indexerZkConfig = JsonConfigProvider.of(INDEXER_PROPERTY_STRING, IndexerZkConfig.class);
indexerZkConfig.inject(propertyValues, configurator);
Assert.assertEquals("/druid/indexer/tasks", indexerZkConfig.get().get().getTasksPath());
}
use of org.apache.druid.guice.JsonConfigurator in project druid by druid-io.
the class IndexerZkConfigTest method testSimpleConfig.
@Test
public void testSimpleConfig() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(SIMPLE_ZK_CONFIG_MODULE));
JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
JsonConfigProvider<ZkPathsConfig> zkPathsConfig = JsonConfigProvider.of(ZK_SERVICE_CONFIG_STRING, ZkPathsConfig.class);
zkPathsConfig.inject(propertyValues, configurator);
JsonConfigProvider<IndexerZkConfig> indexerZkConfig = JsonConfigProvider.of(INDEXER_PROPERTY_STRING, IndexerZkConfig.class);
indexerZkConfig.inject(propertyValues, configurator);
IndexerZkConfig zkConfig = indexerZkConfig.get().get();
ZkPathsConfig zkPathsConfig1 = zkPathsConfig.get().get();
validateEntries(zkConfig);
validateEntries(zkPathsConfig1);
Assert.assertEquals(CLOBBERABLE_PROPERTIES.size(), assertions);
}
use of org.apache.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.of(SIMPLE_ZK_CONFIG_MODULE));
propertyValues.setProperty(ZK_SERVICE_CONFIG_STRING + ".base", "/druid/metrics");
JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
JsonConfigProvider<ZkPathsConfig> zkPathsConfig = JsonConfigProvider.of(ZK_SERVICE_CONFIG_STRING, ZkPathsConfig.class);
zkPathsConfig.inject(propertyValues, configurator);
ZkPathsConfig zkPathsConfig1 = zkPathsConfig.get().get();
IndexerZkConfig indexerZkConfig = new IndexerZkConfig(zkPathsConfig1, null, null, null, null);
Assert.assertEquals("/druid/metrics/indexer", indexerZkConfig.getBase());
Assert.assertEquals("/druid/metrics/indexer/announcements", indexerZkConfig.getAnnouncementsPath());
}
use of org.apache.druid.guice.JsonConfigurator in project druid by druid-io.
the class IndexerZkConfigTest method testIndexerBaseOverride.
@Test
public void testIndexerBaseOverride() {
final String overrideValue = "/foo/bar/baz";
final String indexerPropertyKey = INDEXER_PROPERTY_STRING + ".base";
final String priorValue = System.getProperty(indexerPropertyKey);
// Set it here so that the binding picks it up
System.setProperty(indexerPropertyKey, overrideValue);
final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(SIMPLE_ZK_CONFIG_MODULE));
propertyValues.clear();
// Have to set it here as well annoyingly enough
propertyValues.setProperty(indexerPropertyKey, overrideValue);
JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
JsonConfigProvider<IndexerZkConfig> indexerPathsConfig = JsonConfigProvider.of(INDEXER_PROPERTY_STRING, IndexerZkConfig.class);
indexerPathsConfig.inject(propertyValues, configurator);
IndexerZkConfig indexerZkConfig = indexerPathsConfig.get().get();
// Rewind value before we potentially fail
if (priorValue == null) {
System.clearProperty(indexerPropertyKey);
} else {
System.setProperty(indexerPropertyKey, priorValue);
}
Assert.assertEquals(overrideValue, indexerZkConfig.getBase());
Assert.assertEquals(overrideValue + "/announcements", indexerZkConfig.getAnnouncementsPath());
}
Aggregations