use of com.google.inject.Provides in project druid by druid-io.
the class CloudFilesStorageDruidModule method getCloudFilesApi.
@Provides
@LazySingleton
public CloudFilesApi getCloudFilesApi(final CloudFilesAccountConfig config) {
log.info("Building Cloud Files Api...");
Iterable<com.google.inject.Module> modules = null;
if (config.getUseServiceNet()) {
log.info("Configuring Cloud Files Api to use the internal service network...");
modules = ImmutableSet.<com.google.inject.Module>of(new SLF4JLoggingModule(), new InternalUrlModule());
} else {
log.info("Configuring Cloud Files Api to use the public network...");
modules = ImmutableSet.<com.google.inject.Module>of(new SLF4JLoggingModule());
}
ProviderRegistry.registerProvider(CloudFilesUSProviderMetadata.builder().build());
ProviderRegistry.registerProvider(CloudFilesUKProviderMetadata.builder().build());
ContextBuilder cb = ContextBuilder.newBuilder(config.getProvider()).credentials(config.getUserName(), config.getApiKey()).modules(modules);
CloudFilesApi cfa = cb.buildApi(CloudFilesApi.class);
log.info("Cloud Files Api built.");
return cfa;
}
use of com.google.inject.Provides in project druid by druid-io.
the class CuratorModule method makeCurator.
@Provides
@LazySingleton
public CuratorFramework makeCurator(CuratorConfig config, EnsembleProvider ensembleProvider, Lifecycle lifecycle) throws IOException {
final CuratorFramework framework = CuratorFrameworkFactory.builder().ensembleProvider(ensembleProvider).sessionTimeoutMs(config.getZkSessionTimeoutMs()).retryPolicy(new BoundedExponentialBackoffRetry(BASE_SLEEP_TIME_MS, MAX_SLEEP_TIME_MS, MAX_RETRIES)).compressionProvider(new PotentiallyGzippedCompressionProvider(config.getEnableCompression())).aclProvider(config.getEnableAcl() ? new SecuredACLProvider() : new DefaultACLProvider()).build();
lifecycle.addHandler(new Lifecycle.Handler() {
@Override
public void start() throws Exception {
log.info("Starting Curator");
framework.start();
}
@Override
public void stop() {
log.info("Stopping Curator");
framework.close();
}
});
return framework;
}
use of com.google.inject.Provides in project druid by druid-io.
the class MetricsModule method getMonitorScheduler.
@Provides
@ManageLifecycle
public MonitorScheduler getMonitorScheduler(Supplier<DruidMonitorSchedulerConfig> config, MonitorsConfig monitorsConfig, Set<Class<? extends Monitor>> monitorSet, ServiceEmitter emitter, Injector injector) {
List<Monitor> monitors = Lists.newArrayList();
for (Class<? extends Monitor> monitorClass : Iterables.concat(monitorsConfig.getMonitors(), monitorSet)) {
final Monitor monitor = injector.getInstance(monitorClass);
log.info("Adding monitor[%s]", monitor);
monitors.add(monitor);
}
return new MonitorScheduler(config.get(), Execs.scheduledSingleThreaded("MonitorScheduler-%s"), emitter, monitors);
}
use of com.google.inject.Provides in project druid by druid-io.
the class ChatHandlerServerModule method getServer.
@Provides
@LazySingleton
@RemoteChatHandler
public Server getServer(Injector injector, Lifecycle lifecycle, @RemoteChatHandler DruidNode node, @RemoteChatHandler ServerConfig config) {
final Server server = JettyServerModule.makeJettyServer(node, config);
JettyServerModule.initializeServer(injector, lifecycle, server);
return server;
}
use of com.google.inject.Provides in project druid by druid-io.
the class JettyServerModule method getJacksonSmileProvider.
@Provides
@Singleton
public JacksonSmileProvider getJacksonSmileProvider(@Smile ObjectMapper objectMapper) {
final JacksonSmileProvider provider = new JacksonSmileProvider();
provider.setMapper(objectMapper);
return provider;
}
Aggregations