Search in sources :

Example 76 with Singleton

use of com.google.inject.Singleton in project Singularity by HubSpot.

the class SingularityExecutorModule method provideDownloadFetcher.

@Provides
@Singleton
public LocalDownloadServiceFetcher provideDownloadFetcher(SingularityS3Configuration s3Configuration, SingularityExecutorConfiguration executorConfiguration, ObjectMapper objectMapper) {
    if (s3Configuration.getLocalDownloadSocket().isPresent()) {
        HttpClient httpClient = new HttpClient(new HttpClientTransportOverUnixSockets(s3Configuration.getLocalDownloadSocket().get()), null);
        return new UnixLocalDownloadServiceFetcher(httpClient, objectMapper, executorConfiguration, s3Configuration);
    } else {
        AsyncHttpClientConfig.Builder configBldr = new AsyncHttpClientConfig.Builder();
        configBldr.setRequestTimeout((int) executorConfiguration.getLocalDownloadServiceTimeoutMillis());
        configBldr.setPooledConnectionIdleTimeout((int) executorConfiguration.getLocalDownloadServiceTimeoutMillis());
        configBldr.addRequestFilter(new ThrottleRequestFilter(executorConfiguration.getLocalDownloadServiceMaxConnections()));
        return new HttpLocalDownloadServiceFetcher(new AsyncHttpClient(configBldr.build()), objectMapper, executorConfiguration, s3Configuration);
    }
}
Also used : ThrottleRequestFilter(com.ning.http.client.extra.ThrottleRequestFilter) HttpLocalDownloadServiceFetcher(com.hubspot.singularity.executor.task.HttpLocalDownloadServiceFetcher) UnixLocalDownloadServiceFetcher(com.hubspot.singularity.executor.task.UnixLocalDownloadServiceFetcher) HttpClient(org.eclipse.jetty.client.HttpClient) AsyncHttpClient(com.ning.http.client.AsyncHttpClient) Builder(com.spotify.docker.client.DefaultDockerClient.Builder) AsyncHttpClientConfig(com.ning.http.client.AsyncHttpClientConfig) HttpClientTransportOverUnixSockets(org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets) AsyncHttpClient(com.ning.http.client.AsyncHttpClient) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 77 with Singleton

use of com.google.inject.Singleton in project Singularity by HubSpot.

the class SingularityExecutorModule method providesHandlebars.

@Provides
@Singleton
public Handlebars providesHandlebars() {
    // handlebars emits DEBUG logs before logger is properly configured
    SingularityRunnerBaseLogging.quietEagerLogging();
    final Handlebars handlebars = new Handlebars();
    handlebars.registerHelper(BashEscapedHelper.NAME, new BashEscapedHelper());
    handlebars.registerHelper(ShellQuoteHelper.NAME, new ShellQuoteHelper());
    handlebars.registerHelper(IfPresentHelper.NAME, new IfPresentHelper());
    handlebars.registerHelper(IfHasNewLinesOrBackticksHelper.NAME, new IfHasNewLinesOrBackticksHelper());
    handlebars.registerHelper(EscapeNewLinesAndQuotesHelper.NAME, new EscapeNewLinesAndQuotesHelper());
    return handlebars;
}
Also used : IfPresentHelper(com.hubspot.singularity.executor.handlebars.IfPresentHelper) Handlebars(com.github.jknack.handlebars.Handlebars) EscapeNewLinesAndQuotesHelper(com.hubspot.singularity.executor.handlebars.EscapeNewLinesAndQuotesHelper) ShellQuoteHelper(com.hubspot.singularity.executor.handlebars.ShellQuoteHelper) IfHasNewLinesOrBackticksHelper(com.hubspot.singularity.executor.handlebars.IfHasNewLinesOrBackticksHelper) BashEscapedHelper(com.hubspot.singularity.executor.handlebars.BashEscapedHelper) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 78 with Singleton

use of com.google.inject.Singleton in project activityinfo by bedatadriven.

the class TemplateModule method provideConfiguration.

@Provides
@Singleton
public Configuration provideConfiguration(Provider<Domain> domainProvider) throws TemplateModelException {
    Configuration config = new Configuration();
    config.setClassForTemplateLoading(TemplateModule.class, "/template");
    config.setDefaultEncoding("UTF-8");
    config.setSharedVariable("domain", new InjectedTemplateModel<Domain>(domainProvider));
    return config;
}
Also used : Configuration(freemarker.template.Configuration) Domain(org.activityinfo.server.database.hibernate.entity.Domain) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 79 with Singleton

use of com.google.inject.Singleton in project activityinfo by bedatadriven.

the class BlobServiceModule method provideBlobService.

@Provides
@Singleton
public BlobService provideBlobService(DeploymentConfiguration config) {
    String defaultRoot = System.getProperty("user.home") + File.separator + "activityinfo.blob";
    File blobRoot = new File(config.getProperty(BLOB_ROOT_KEY, defaultRoot));
    if (blobRoot.exists() && !blobRoot.isDirectory()) {
        throw new RuntimeException("blob.root must be a directory");
    }
    return new FsBlobService(blobRoot);
}
Also used : File(java.io.File) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 80 with Singleton

use of com.google.inject.Singleton in project data-transfer-project by google.

the class WorkerModule method getImporter.

@Provides
@Singleton
Importer getImporter(ImmutableList<TransferExtension> transferExtensions) {
    TransferExtension extension = findTransferExtension(transferExtensions, JobMetadata.getImportService());
    DelegatingExtensionContext serviceSpecificContext = new DelegatingExtensionContext(context);
    serviceSpecificContext.registerOverrideService(MetricRecorder.class, new ServiceAwareMetricRecorder(extension.getServiceId(), context.getService(DtpInternalMetricRecorder.class)));
    serviceSpecificContext.registerOverrideService(TransferServiceConfig.class, getTransferServiceConfig(extension));
    extension.initialize(serviceSpecificContext);
    return extension.getImporter(JobMetadata.getDataType());
}
Also used : TransferExtension(org.datatransferproject.spi.transfer.extension.TransferExtension) ServiceAwareMetricRecorder(org.datatransferproject.launcher.metrics.ServiceAwareMetricRecorder) DelegatingExtensionContext(org.datatransferproject.api.launcher.DelegatingExtensionContext) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Singleton (com.google.inject.Singleton)81 Provides (com.google.inject.Provides)78 AbstractModule (com.google.inject.AbstractModule)8 Injector (com.google.inject.Injector)8 Named (com.google.inject.name.Named)7 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)7 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)7 Model (org.ovirt.engine.ui.uicommonweb.models.Model)7 File (java.io.File)5 IOException (java.io.IOException)5 SearchableDetailTabModelProvider (org.ovirt.engine.ui.common.uicommon.model.SearchableDetailTabModelProvider)5 PermissionListModel (org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel)5 DataSourceFactory (io.dropwizard.db.DataSourceFactory)4 ManagedDataSource (io.dropwizard.db.ManagedDataSource)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 InetSocketAddress (java.net.InetSocketAddress)3 SocketAddress (java.net.SocketAddress)3 Properties (java.util.Properties)3 Test (org.junit.Test)3 ConfigModule (co.cask.cdap.common.guice.ConfigModule)2