Search in sources :

Example 31 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project storm by apache.

the class KinesisSpoutTopology method main.

public static void main(String[] args) throws InvalidTopologyException, AuthorizationException, AlreadyAliveException {
    String topologyName = args[0];
    RecordToTupleMapper recordToTupleMapper = new TestRecordToTupleMapper();
    KinesisConnectionInfo kinesisConnectionInfo = new KinesisConnectionInfo(new CredentialsProviderChain(), new ClientConfiguration(), Regions.US_WEST_2, 1000);
    ZkInfo zkInfo = new ZkInfo("localhost:2181", "/kinesisOffsets", 20000, 15000, 10000L, 3, 2000);
    KinesisConfig kinesisConfig = new KinesisConfig(args[1], ShardIteratorType.TRIM_HORIZON, recordToTupleMapper, new Date(), new ExponentialBackoffRetrier(), zkInfo, kinesisConnectionInfo, 10000L);
    KinesisSpout kinesisSpout = new KinesisSpout(kinesisConfig);
    TopologyBuilder topologyBuilder = new TopologyBuilder();
    topologyBuilder.setSpout("spout", kinesisSpout, 3);
    topologyBuilder.setBolt("bolt", new KinesisBoltTest(), 1).shuffleGrouping("spout");
    Config topologyConfig = new Config();
    topologyConfig.setDebug(true);
    topologyConfig.setNumWorkers(3);
    StormSubmitter.submitTopology(topologyName, topologyConfig, topologyBuilder.createTopology());
}
Also used : RecordToTupleMapper(org.apache.storm.kinesis.spout.RecordToTupleMapper) KinesisConfig(org.apache.storm.kinesis.spout.KinesisConfig) ZkInfo(org.apache.storm.kinesis.spout.ZkInfo) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) KinesisConfig(org.apache.storm.kinesis.spout.KinesisConfig) Config(org.apache.storm.Config) KinesisSpout(org.apache.storm.kinesis.spout.KinesisSpout) Date(java.util.Date) CredentialsProviderChain(org.apache.storm.kinesis.spout.CredentialsProviderChain) KinesisConnectionInfo(org.apache.storm.kinesis.spout.KinesisConnectionInfo) ExponentialBackoffRetrier(org.apache.storm.kinesis.spout.ExponentialBackoffRetrier) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 32 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project gradle by gradle.

the class S3Client method createConnectionProperties.

private ClientConfiguration createConnectionProperties() {
    ClientConfiguration clientConfiguration = new ClientConfiguration();
    Optional<HttpProxySettings.HttpProxy> proxyOptional = s3ConnectionProperties.getProxy();
    if (proxyOptional.isPresent()) {
        HttpProxySettings.HttpProxy proxy = s3ConnectionProperties.getProxy().get();
        clientConfiguration.setProxyHost(proxy.host);
        clientConfiguration.setProxyPort(proxy.port);
        PasswordCredentials credentials = proxy.credentials;
        if (credentials != null) {
            clientConfiguration.setProxyUsername(credentials.getUsername());
            clientConfiguration.setProxyPassword(credentials.getPassword());
        }
    }
    Optional<Integer> maxErrorRetryCount = s3ConnectionProperties.getMaxErrorRetryCount();
    if (maxErrorRetryCount.isPresent()) {
        clientConfiguration.setMaxErrorRetry(maxErrorRetryCount.get());
    }
    return clientConfiguration;
}
Also used : PasswordCredentials(org.gradle.api.artifacts.repositories.PasswordCredentials) HttpProxySettings(org.gradle.internal.resource.transport.http.HttpProxySettings) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 33 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project presto by prestodb.

the class TestPrestoS3FileSystem method testUserAgentPrefix.

@Test
public void testUserAgentPrefix() throws Exception {
    String userAgentPrefix = "agent_prefix";
    Configuration config = new Configuration();
    config.set(S3_USER_AGENT_PREFIX, userAgentPrefix);
    try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
        fs.initialize(new URI("s3n://test-bucket/"), config);
        ClientConfiguration clientConfig = getFieldValue(fs.getS3Client(), AmazonWebServiceClient.class, "clientConfiguration", ClientConfiguration.class);
        assertEquals(clientConfig.getUserAgentSuffix(), S3_USER_AGENT_SUFFIX);
        assertEquals(clientConfig.getUserAgentPrefix(), userAgentPrefix);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ClientConfiguration(com.amazonaws.ClientConfiguration) URI(java.net.URI) ClientConfiguration(com.amazonaws.ClientConfiguration) Test(org.testng.annotations.Test)

Example 34 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project heron by twitter.

the class S3Uploader method initialize.

@Override
public void initialize(Config config) {
    bucket = S3Context.bucket(config);
    String accessKey = S3Context.accessKey(config);
    String accessSecret = S3Context.secretKey(config);
    String awsProfile = S3Context.awsProfile(config);
    String proxy = S3Context.proxyUri(config);
    String endpoint = S3Context.uri(config);
    String customRegion = S3Context.region(config);
    AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
    if (Strings.isNullOrEmpty(bucket)) {
        throw new RuntimeException("Missing heron.uploader.s3.bucket config value");
    }
    // by not specifying a CredentialsProvider.
    if (!Strings.isNullOrEmpty(accessKey) || !Strings.isNullOrEmpty(accessSecret)) {
        if (!Strings.isNullOrEmpty(awsProfile)) {
            throw new RuntimeException("Please provide access_key/secret_key " + "or aws_profile, not both.");
        }
        if (Strings.isNullOrEmpty(accessKey)) {
            throw new RuntimeException("Missing heron.uploader.s3.access_key config value");
        }
        if (Strings.isNullOrEmpty(accessSecret)) {
            throw new RuntimeException("Missing heron.uploader.s3.secret_key config value");
        }
        builder.setCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, accessSecret)));
    } else if (!Strings.isNullOrEmpty(awsProfile)) {
        builder.setCredentials(new ProfileCredentialsProvider(awsProfile));
    }
    if (!Strings.isNullOrEmpty(proxy)) {
        URI proxyUri;
        try {
            proxyUri = new URI(proxy);
        } catch (URISyntaxException e) {
            throw new RuntimeException("Invalid heron.uploader.s3.proxy_uri config value: " + proxy, e);
        }
        ClientConfiguration clientCfg = new ClientConfiguration();
        clientCfg.withProtocol(Protocol.HTTPS).withProxyHost(proxyUri.getHost()).withProxyPort(proxyUri.getPort());
        if (!Strings.isNullOrEmpty(proxyUri.getUserInfo())) {
            String[] info = proxyUri.getUserInfo().split(":", 2);
            clientCfg.setProxyUsername(info[0]);
            if (info.length > 1) {
                clientCfg.setProxyPassword(info[1]);
            }
        }
        builder.setClientConfiguration(clientCfg);
    }
    s3Client = builder.withRegion(customRegion).withPathStyleAccessEnabled(true).withChunkedEncodingDisabled(true).withPayloadSigningEnabled(true).build();
    if (!Strings.isNullOrEmpty(endpoint)) {
        s3Client.setEndpoint(endpoint);
    }
    final String topologyName = Context.topologyName(config);
    final String topologyPackageLocation = Context.topologyPackageFile(config);
    pathPrefix = S3Context.pathPrefix(config);
    packageFileHandler = new File(topologyPackageLocation);
    // The path the packaged topology will be uploaded to
    remoteFilePath = generateS3Path(pathPrefix, topologyName, packageFileHandler.getName());
    // Generate the location of the backup file incase we need to revert the deploy
    previousVersionFilePath = generateS3Path(pathPrefix, topologyName, "previous_" + packageFileHandler.getName());
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) AmazonS3ClientBuilder(com.amazonaws.services.s3.AmazonS3ClientBuilder) ProfileCredentialsProvider(com.amazonaws.auth.profile.ProfileCredentialsProvider) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) File(java.io.File) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 35 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project SimianArmy by Netflix.

the class TestBasicContext method testIsNotUsingProxyByDefault.

@Test
public void testIsNotUsingProxyByDefault() {
    BasicSimianArmyContext ctx = new BasicSimianArmyContext();
    ClientConfiguration awsClientConfig = ctx.getAwsClientConfig();
    Assert.assertNull(awsClientConfig.getProxyHost());
    Assert.assertEquals(awsClientConfig.getProxyPort(), -1);
    Assert.assertNull(awsClientConfig.getProxyUsername());
    Assert.assertNull(awsClientConfig.getProxyPassword());
}
Also used : ClientConfiguration(com.amazonaws.ClientConfiguration) Test(org.testng.annotations.Test)

Aggregations

ClientConfiguration (com.amazonaws.ClientConfiguration)44 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)18 AWSCredentials (com.amazonaws.auth.AWSCredentials)12 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)6 AmazonClientException (com.amazonaws.AmazonClientException)3 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)3 AmazonDynamoDBClient (com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient)3 File (java.io.File)3 Configuration (org.apache.hadoop.conf.Configuration)3 Test (org.testng.annotations.Test)3 AmazonServiceException (com.amazonaws.AmazonServiceException)2 Protocol (com.amazonaws.Protocol)2 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)2 InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)2 AwsClientBuilder (com.amazonaws.client.builder.AwsClientBuilder)2 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)2 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)2 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 S3ClientOptions (com.amazonaws.services.s3.S3ClientOptions)2 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)2