Search in sources :

Example 1 with JsonConfigurator

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

the class FilteredRequestLoggerTest method testInvalidDelegateType.

@Test
public void testInvalidDelegateType() {
    final Properties properties = new Properties();
    properties.setProperty("log.type", "filtered");
    properties.setProperty("log.queryTimeThresholdMs", "100");
    properties.setProperty("log.delegate.type", "nope");
    final JsonConfigurator configurator = new JsonConfigurator(mapper, Validation.buildDefaultValidatorFactory().getValidator());
    expectedException.expect(ProvisionException.class);
    expectedException.expectMessage("Could not resolve type id 'nope'");
    configurator.configurate(properties, "log", RequestLoggerProvider.class);
}
Also used : JsonConfigurator(org.apache.druid.guice.JsonConfigurator) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with JsonConfigurator

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

the class FilteredRequestLoggerTest method testConfiguration.

@Test
public void testConfiguration() {
    final Properties properties = new Properties();
    properties.setProperty("log.type", "filtered");
    properties.setProperty("log.queryTimeThresholdMs", "100");
    properties.setProperty("log.delegate.type", "slf4j");
    properties.setProperty("log.delegate.setMDC", "true");
    properties.setProperty("log.delegate.setContextMDC", "true");
    final JsonConfigurator configurator = new JsonConfigurator(mapper, Validation.buildDefaultValidatorFactory().getValidator());
    final FilteredRequestLoggerProvider provider = (FilteredRequestLoggerProvider) configurator.configurate(properties, "log", RequestLoggerProvider.class);
    final FilteredRequestLoggerProvider.FilteredRequestLogger logger = ((FilteredRequestLoggerProvider.FilteredRequestLogger) provider.get());
    final LoggingRequestLogger delegate = (LoggingRequestLogger) logger.getDelegate();
    Assert.assertEquals(100, logger.getQueryTimeThresholdMs());
    Assert.assertTrue(delegate.isSetContextMDC());
    Assert.assertTrue(delegate.isSetMDC());
}
Also used : JsonConfigurator(org.apache.druid.guice.JsonConfigurator) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with JsonConfigurator

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

the class FilteredRequestLoggerTest method testNoDelegate.

@Test
public void testNoDelegate() {
    final Properties properties = new Properties();
    properties.setProperty("log.type", "filtered");
    properties.setProperty("log.queryTimeThresholdMs", "100");
    final JsonConfigurator configurator = new JsonConfigurator(mapper, Validation.buildDefaultValidatorFactory().getValidator());
    expectedException.expect(ProvisionException.class);
    expectedException.expectMessage("log.delegate - may not be null");
    configurator.configurate(properties, "log", RequestLoggerProvider.class);
}
Also used : JsonConfigurator(org.apache.druid.guice.JsonConfigurator) Properties(java.util.Properties) Test(org.junit.Test)

Example 4 with JsonConfigurator

use of org.apache.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(PROPERTY_BASE + ".lookupTierIsDatasource", "true");
    final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(PROPERTY_BASE, LookupListeningAnnouncerConfig.class);
    configProvider.inject(properties, configurator);
    final LookupListeningAnnouncerConfig config = configProvider.get().get();
    Assert.assertEquals("some_datasource", config.getLookupTier());
}
Also used : JsonConfigurator(org.apache.druid.guice.JsonConfigurator) Test(org.junit.Test)

Example 5 with JsonConfigurator

use of org.apache.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(PROPERTY_BASE + ".lookupTier", lookupTier);
    properties.put(PROPERTY_BASE + ".lookupTierIsDatasource", "true");
    final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(PROPERTY_BASE, LookupListeningAnnouncerConfig.class);
    configProvider.inject(properties, configurator);
    final LookupListeningAnnouncerConfig config = configProvider.get().get();
    Assert.assertEquals(lookupTier, config.getLookupTier());
}
Also used : JsonConfigurator(org.apache.druid.guice.JsonConfigurator) Test(org.junit.Test)

Aggregations

JsonConfigurator (org.apache.druid.guice.JsonConfigurator)19 Test (org.junit.Test)19 Properties (java.util.Properties)9 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 Names (com.google.inject.name.Names)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 Map (java.util.Map)3 Random (java.util.Random)3 UUID (java.util.UUID)3 ForkJoinPool (java.util.concurrent.ForkJoinPool)3 GuiceInjectors (org.apache.druid.guice.GuiceInjectors)3 JsonConfigProvider (org.apache.druid.guice.JsonConfigProvider)3 ManageLifecycle (org.apache.druid.guice.ManageLifecycle)3 Initialization (org.apache.druid.initialization.Initialization)3 StringUtils (org.apache.druid.java.util.common.StringUtils)3