Search in sources :

Example 1 with SingularityS3Services

use of com.hubspot.singularity.helpers.SingularityS3Services in project Singularity by HubSpot.

the class SingularityMainModule method provideS3Services.

@Provides
@Singleton
public SingularityS3Services provideS3Services(Optional<S3Configuration> config) {
    if (!config.isPresent()) {
        return new SingularityS3Services();
    }
    final ImmutableList.Builder<SingularityS3Service> s3ServiceBuilder = ImmutableList.builder();
    for (Map.Entry<String, S3GroupConfiguration> entry : config.get().getGroupOverrides().entrySet()) {
        s3ServiceBuilder.add(new SingularityS3Service(entry.getKey(), entry.getValue().getS3Bucket(), new AmazonS3Client(new BasicAWSCredentials(entry.getValue().getS3AccessKey(), entry.getValue().getS3SecretKey()))));
    }
    for (Map.Entry<String, S3GroupConfiguration> entry : config.get().getGroupS3SearchConfigs().entrySet()) {
        s3ServiceBuilder.add(new SingularityS3Service(entry.getKey(), entry.getValue().getS3Bucket(), new AmazonS3Client(new BasicAWSCredentials(entry.getValue().getS3AccessKey(), entry.getValue().getS3SecretKey()))));
    }
    SingularityS3Service defaultService = new SingularityS3Service(SingularityS3FormatHelper.DEFAULT_GROUP_NAME, config.get().getS3Bucket(), new AmazonS3Client(new BasicAWSCredentials(config.get().getS3AccessKey(), config.get().getS3SecretKey())));
    return new SingularityS3Services(s3ServiceBuilder.build(), defaultService);
}
Also used : S3GroupConfiguration(com.hubspot.singularity.config.S3GroupConfiguration) SingularityS3Service(com.hubspot.singularity.helpers.SingularityS3Service) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) ImmutableList(com.google.common.collect.ImmutableList) SingularityS3Services(com.hubspot.singularity.helpers.SingularityS3Services) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 ImmutableList (com.google.common.collect.ImmutableList)1 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 S3GroupConfiguration (com.hubspot.singularity.config.S3GroupConfiguration)1 SingularityS3Service (com.hubspot.singularity.helpers.SingularityS3Service)1 SingularityS3Services (com.hubspot.singularity.helpers.SingularityS3Services)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1