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);
}
}
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;
}
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;
}
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);
}
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());
}
Aggregations