use of org.apache.druid.guice.JsonConfigProvider in project druid by druid-io.
the class RemoteTaskRunnerConfigTest method testMaxZnodeBytesLowerThanExpected.
@Test
public void testMaxZnodeBytesLowerThanExpected() {
final Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(binder -> IndexingServiceModuleHelper.configureTaskRunnerConfigs(binder)));
this.expectedException.expect(ProvisionException.class);
this.expectedException.expectMessage("maxZnodeBytes must be in the range of [10KiB, 2GiB)");
Properties props = new Properties();
props.put(IndexingServiceModuleHelper.INDEXER_RUNNER_PROPERTY_PREFIX + ".maxZnodeBytes", "9KiB");
JsonConfigProvider<RemoteTaskRunnerConfig> configProvider = JsonConfigProvider.of(IndexingServiceModuleHelper.INDEXER_RUNNER_PROPERTY_PREFIX, RemoteTaskRunnerConfig.class);
configProvider.inject(props, injector.getBinding(JsonConfigurator.class).getProvider().get());
configProvider.get().get();
}
use of org.apache.druid.guice.JsonConfigProvider in project druid by druid-io.
the class RemoteTaskRunnerConfigTest method testMaxZnodeBytesGreaterThanExpected.
@Test
public void testMaxZnodeBytesGreaterThanExpected() {
final Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(binder -> IndexingServiceModuleHelper.configureTaskRunnerConfigs(binder)));
this.expectedException.expect(ProvisionException.class);
this.expectedException.expectMessage("maxZnodeBytes must be in the range of [10KiB, 2GiB)");
Properties props = new Properties();
props.put(IndexingServiceModuleHelper.INDEXER_RUNNER_PROPERTY_PREFIX + ".maxZnodeBytes", "2GiB");
JsonConfigProvider<RemoteTaskRunnerConfig> configProvider = JsonConfigProvider.of(IndexingServiceModuleHelper.INDEXER_RUNNER_PROPERTY_PREFIX, RemoteTaskRunnerConfig.class);
configProvider.inject(props, injector.getBinding(JsonConfigurator.class).getProvider().get());
configProvider.get().get();
}
use of org.apache.druid.guice.JsonConfigProvider in project druid by druid-io.
the class CaffeineCacheProviderWithConfig method testFromProperties.
@Test
public void testFromProperties() {
final String keyPrefix = "cache.config.prefix";
final Properties properties = new Properties();
properties.put(keyPrefix + ".expireAfter", "10");
properties.put(keyPrefix + ".sizeInBytes", "100");
properties.put(keyPrefix + ".cacheExecutorFactory", "single_thread");
final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(binder -> {
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/test");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
JsonConfigProvider.bind(binder, keyPrefix, CaffeineCacheConfig.class);
}));
final JsonConfigurator configurator = injector.getInstance(JsonConfigurator.class);
final JsonConfigProvider<CaffeineCacheConfig> caffeineCacheConfigJsonConfigProvider = JsonConfigProvider.of(keyPrefix, CaffeineCacheConfig.class);
caffeineCacheConfigJsonConfigProvider.inject(properties, configurator);
final CaffeineCacheConfig config = caffeineCacheConfigJsonConfigProvider.get().get();
Assert.assertEquals(10, config.getExpireAfter());
Assert.assertEquals(100, config.getSizeInBytes());
Assert.assertNotNull(config.createExecutor());
}
use of org.apache.druid.guice.JsonConfigProvider in project druid by druid-io.
the class CaffeineCacheProviderWithConfig method testDefaultFromProperties.
@Test
public void testDefaultFromProperties() {
final String keyPrefix = "cache.config.prefix";
final Properties properties = new Properties();
final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(binder -> {
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/test");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
JsonConfigProvider.bind(binder, keyPrefix, CaffeineCacheConfig.class);
}));
final JsonConfigurator configurator = injector.getInstance(JsonConfigurator.class);
final JsonConfigProvider<CaffeineCacheConfig> caffeineCacheConfigJsonConfigProvider = JsonConfigProvider.of(keyPrefix, CaffeineCacheConfig.class);
caffeineCacheConfigJsonConfigProvider.inject(properties, configurator);
final CaffeineCacheConfig config = caffeineCacheConfigJsonConfigProvider.get().get();
Assert.assertEquals(-1, config.getExpireAfter());
Assert.assertEquals(-1L, config.getSizeInBytes());
Assert.assertEquals(ForkJoinPool.commonPool(), config.createExecutor());
}
use of org.apache.druid.guice.JsonConfigProvider in project druid by druid-io.
the class CaffeineCacheProviderWithConfig method testMixedCaseFromProperties.
@Test
public void testMixedCaseFromProperties() {
final String keyPrefix = "cache.config.prefix";
final Properties properties = new Properties();
properties.put(keyPrefix + ".expireAfter", "10");
properties.put(keyPrefix + ".sizeInBytes", "100");
properties.put(keyPrefix + ".cacheExecutorFactory", "CoMmON_FjP");
final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(binder -> {
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/test");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
JsonConfigProvider.bind(binder, keyPrefix, CaffeineCacheConfig.class);
}));
final JsonConfigurator configurator = injector.getInstance(JsonConfigurator.class);
final JsonConfigProvider<CaffeineCacheConfig> caffeineCacheConfigJsonConfigProvider = JsonConfigProvider.of(keyPrefix, CaffeineCacheConfig.class);
caffeineCacheConfigJsonConfigProvider.inject(properties, configurator);
final CaffeineCacheConfig config = caffeineCacheConfigJsonConfigProvider.get().get();
Assert.assertEquals(10, config.getExpireAfter());
Assert.assertEquals(100, config.getSizeInBytes());
Assert.assertEquals(ForkJoinPool.commonPool(), config.createExecutor());
}
Aggregations