Search in sources :

Example 1 with Provides

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;
}
Also used : InternalUrlModule(org.jclouds.openstack.v2_0.config.InternalUrlModule) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) ContextBuilder(org.jclouds.ContextBuilder) CloudFilesApi(org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi) Module(com.fasterxml.jackson.databind.Module) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) InternalUrlModule(org.jclouds.openstack.v2_0.config.InternalUrlModule) DruidModule(io.druid.initialization.DruidModule) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 2 with Provides

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;
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) Lifecycle(io.druid.java.util.common.lifecycle.Lifecycle) DefaultACLProvider(org.apache.curator.framework.imps.DefaultACLProvider) IOException(java.io.IOException) BoundedExponentialBackoffRetry(org.apache.curator.retry.BoundedExponentialBackoffRetry) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 3 with Provides

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);
}
Also used : ExecutorServiceMonitor(io.druid.query.ExecutorServiceMonitor) Monitor(com.metamx.metrics.Monitor) JvmCpuMonitor(com.metamx.metrics.JvmCpuMonitor) JvmMonitor(com.metamx.metrics.JvmMonitor) SysMonitor(com.metamx.metrics.SysMonitor) MonitorScheduler(com.metamx.metrics.MonitorScheduler) ManageLifecycle(io.druid.guice.ManageLifecycle) Provides(com.google.inject.Provides)

Example 4 with Provides

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;
}
Also used : Server(org.eclipse.jetty.server.Server) RemoteChatHandler(io.druid.guice.annotations.RemoteChatHandler) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 5 with Provides

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;
}
Also used : JacksonSmileProvider(com.fasterxml.jackson.jaxrs.smile.JacksonSmileProvider) LazySingleton(io.druid.guice.LazySingleton) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)111 AbstractModule (com.google.inject.AbstractModule)26 Singleton (com.google.inject.Singleton)23 Singleton (javax.inject.Singleton)23 Injector (com.google.inject.Injector)22 LazySingleton (io.druid.guice.LazySingleton)12 Named (javax.inject.Named)10 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Named (com.google.inject.name.Named)8 File (java.io.File)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Inject (javax.inject.Inject)6 Properties (java.util.Properties)5 Test (org.junit.Test)5 Key (com.google.inject.Key)4 ExecutorService (java.util.concurrent.ExecutorService)4 ConfigModule (co.cask.cdap.common.guice.ConfigModule)3 DB (com.codecademy.eventhub.base.DB)3 Binder (com.google.inject.Binder)3