use of org.apache.druid.guice.LifecycleModule in project druid by druid-io.
the class MetricsModuleTest method createInjector.
private static Injector createInjector(Properties properties) {
return Guice.createInjector(new JacksonModule(), new LifecycleModule(), binder -> {
binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
binder.bindScope(LazySingleton.class, Scopes.SINGLETON);
binder.bind(ServiceEmitter.class).toInstance(new NoopServiceEmitter());
binder.bind(Properties.class).toInstance(properties);
}, new MetricsModule());
}
use of org.apache.druid.guice.LifecycleModule in project druid by druid-io.
the class Initialization method makeInjectorWithModules.
public static Injector makeInjectorWithModules(final Set<NodeRole> nodeRoles, final Injector baseInjector, final Iterable<? extends Module> modules) {
final ModuleList defaultModules = new ModuleList(baseInjector, nodeRoles);
defaultModules.addModules(// New modules should be added after Log4jShutterDownerModule
new Log4jShutterDownerModule(), new DruidAuthModule(), new LifecycleModule(), TLSCertificateCheckerModule.class, EmitterModule.class, HttpClientModule.global(), HttpClientModule.escalatedGlobal(), new HttpClientModule("druid.broker.http", Client.class), new HttpClientModule("druid.broker.http", EscalatedClient.class), new CuratorModule(), new AnnouncerModule(), new MetricsModule(), new SegmentWriteOutMediumModule(), new ServerModule(), new DruidProcessingConfigModule(), new StorageNodeModule(), new JettyServerModule(), new ExpressionModule(), new DiscoveryModule(), new ServerViewModule(), new MetadataConfigModule(), new DerbyMetadataStorageDruidModule(), new JacksonConfigManagerModule(), new IndexingServiceDiscoveryModule(), new CoordinatorDiscoveryModule(), new LocalDataStorageDruidModule(), new FirehoseModule(), new JavaScriptModule(), new AuthenticatorModule(), new AuthenticatorMapperModule(), new EscalatorModule(), new AuthorizerModule(), new AuthorizerMapperModule(), new StartupLoggingModule(), new ExternalStorageAccessSecurityModule());
ModuleList actualModules = new ModuleList(baseInjector, nodeRoles);
actualModules.addModule(DruidSecondaryModule.class);
for (Object module : modules) {
actualModules.addModule(module);
}
Module intermediateModules = Modules.override(defaultModules.getModules()).with(actualModules.getModules());
ModuleList extensionModules = new ModuleList(baseInjector, nodeRoles);
final ExtensionsConfig config = baseInjector.getInstance(ExtensionsConfig.class);
for (DruidModule module : Initialization.getFromExtensions(config, DruidModule.class)) {
extensionModules.addModule(module);
}
return Guice.createInjector(Modules.override(intermediateModules).with(extensionModules.getModules()));
}
use of org.apache.druid.guice.LifecycleModule in project druid by druid-io.
the class MySQLMetadataStorageModuleTest method createInjector.
private Injector createInjector() {
MySQLMetadataStorageModule module = new MySQLMetadataStorageModule();
Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(new MetadataConfigModule(), new LifecycleModule(), module, new Module() {
@Override
public void configure(Binder binder) {
module.createBindingChoices(binder, "mysql");
}
@Provides
public ServiceEmitter getEmitter() {
return new ServiceEmitter("test", "localhost", new NoopEmitter());
}
}));
ObjectMapper mapper = injector.getInstance(Key.get(ObjectMapper.class, Json.class));
mapper.registerModules(module.getJacksonModules());
return injector;
}
use of org.apache.druid.guice.LifecycleModule in project druid by druid-io.
the class ComposingEmitterModuleTest method testGetEmitterViaRealGuice.
@Test
public void testGetEmitterViaRealGuice() {
Injector injector = Guice.createInjector(new DruidGuiceExtensions(), new LifecycleModule(), new Module() {
@Override
public void configure(Binder binder) {
Properties props = new Properties();
props.put("druid.emitter.composing.emitters", "[\"" + testEmitterType + "\"]");
binder.bind(Properties.class).toInstance(props);
binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
binder.bind(Emitter.class).annotatedWith(Names.named(testEmitterType)).toInstance(emitter);
}
}, new ComposingEmitterModule());
injector.getInstance(Key.get(Emitter.class, Names.named("composing"))).start();
EasyMock.verify(emitter);
}
use of org.apache.druid.guice.LifecycleModule in project druid by druid-io.
the class SqlModuleTest method makeInjectorWithProperties.
private Injector makeInjectorWithProperties(final Properties props) {
return Guice.createInjector(ImmutableList.of(new DruidGuiceExtensions(), new LifecycleModule(), new ServerModule(), new JacksonModule(), (Module) binder -> {
binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
binder.bind(JsonConfigurator.class).in(LazySingleton.class);
binder.bind(Properties.class).toInstance(props);
binder.bind(ExprMacroTable.class).toInstance(ExprMacroTable.nil());
binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER);
binder.bind(Escalator.class).toInstance(new NoopEscalator());
binder.bind(ServiceEmitter.class).toInstance(serviceEmitter);
binder.bind(RequestLogger.class).toInstance(new NoopRequestLogger());
binder.bind(new TypeLiteral<Supplier<DefaultQueryConfig>>() {
}).toInstance(Suppliers.ofInstance(new DefaultQueryConfig(null)));
binder.bind(FilteredServerInventoryView.class).toInstance(inventoryView);
binder.bind(TimelineServerView.class).toInstance(timelineServerView);
binder.bind(DruidLeaderClient.class).annotatedWith(Coordinator.class).toInstance(druidLeaderClient);
binder.bind(DruidLeaderClient.class).annotatedWith(IndexingService.class).toInstance(druidLeaderClient);
binder.bind(DruidNodeDiscoveryProvider.class).toInstance(druidNodeDiscoveryProvider);
binder.bind(GenericQueryMetricsFactory.class).toInstance(genericQueryMetricsFactory);
binder.bind(QuerySegmentWalker.class).toInstance(querySegmentWalker);
binder.bind(QueryToolChestWarehouse.class).toInstance(queryToolChestWarehouse);
binder.bind(LookupExtractorFactoryContainerProvider.class).toInstance(lookupExtractorFactoryContainerProvider);
binder.bind(JoinableFactory.class).toInstance(joinableFactory);
binder.bind(SegmentLoader.class).toInstance(segmentLoader);
binder.bind(QuerySchedulerProvider.class).in(LazySingleton.class);
binder.bind(QueryScheduler.class).toProvider(QuerySchedulerProvider.class).in(LazySingleton.class);
}, new SqlModule(props), new TestViewManagerModule()));
}
Aggregations