Search in sources :

Example 1 with AwsOptions

use of org.apache.beam.sdk.io.aws2.options.AwsOptions in project beam by apache.

the class KinesisSource method createClient.

private SimplifiedKinesisClient createClient(PipelineOptions options) {
    AwsOptions awsOptions = options.as(AwsOptions.class);
    KinesisClient kinesis;
    CloudWatchClient cloudWatch;
    if (spec.getAWSClientsProvider() != null) {
        kinesis = spec.getAWSClientsProvider().getKinesisClient();
        cloudWatch = spec.getAWSClientsProvider().getCloudWatchClient();
    } else {
        ClientConfiguration config = spec.getClientConfiguration();
        kinesis = ClientBuilderFactory.buildClient(awsOptions, KinesisClient.builder(), config);
        cloudWatch = ClientBuilderFactory.buildClient(awsOptions, CloudWatchClient.builder(), config);
    }
    return new SimplifiedKinesisClient(kinesis, cloudWatch, spec.getRequestRecordsLimit(), Instant::now);
}
Also used : CloudWatchClient(software.amazon.awssdk.services.cloudwatch.CloudWatchClient) Instant(org.joda.time.Instant) KinesisClient(software.amazon.awssdk.services.kinesis.KinesisClient) AwsOptions(org.apache.beam.sdk.io.aws2.options.AwsOptions) ClientConfiguration(org.apache.beam.sdk.io.aws2.common.ClientConfiguration)

Example 2 with AwsOptions

use of org.apache.beam.sdk.io.aws2.options.AwsOptions in project beam by apache.

the class ClientBuilderFactoryTest method testSyncProxyConfiguration.

@Test
public void testSyncProxyConfiguration() {
    ProxyConfiguration proxy = ProxyConfiguration.builder().endpoint(URI.create("http://localhost:7777")).username("user").password("secret").build();
    builder = mock(AwsSyncBuilder.class);
    when(awsOptions.getProxyConfiguration()).thenReturn(proxy);
    getFactory(awsOptions).create(builder, awsOptions);
    ArgumentCaptor<ApacheHttpClient.Builder> httpClientBuilder = ArgumentCaptor.forClass(ApacheHttpClient.Builder.class);
    verify((AwsSyncBuilder) builder).httpClientBuilder(httpClientBuilder.capture());
    verify(httpClientBuilder.getValue()).proxyConfiguration(proxy);
    verifyNoMoreInteractions(httpClientBuilder.getValue());
}
Also used : ProxyConfiguration(software.amazon.awssdk.http.apache.ProxyConfiguration) SdkSyncClientBuilder(software.amazon.awssdk.core.client.builder.SdkSyncClientBuilder) SdkAsyncClientBuilder(software.amazon.awssdk.core.client.builder.SdkAsyncClientBuilder) DefaultClientBuilder(org.apache.beam.sdk.io.aws2.common.ClientBuilderFactory.DefaultClientBuilder) AwsClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsClientBuilder) ApacheHttpClient(software.amazon.awssdk.http.apache.ApacheHttpClient) Test(org.junit.Test)

Example 3 with AwsOptions

use of org.apache.beam.sdk.io.aws2.options.AwsOptions in project beam by apache.

the class ClientBuilderFactoryTest method testAsyncProxyConfiguration.

@Test
public void testAsyncProxyConfiguration() {
    ProxyConfiguration proxy = ProxyConfiguration.builder().endpoint(URI.create("http://localhost:7777")).username("user").password("secret").build();
    software.amazon.awssdk.http.nio.netty.ProxyConfiguration nettyProxy = software.amazon.awssdk.http.nio.netty.ProxyConfiguration.builder().scheme(proxy.scheme()).host(proxy.host()).port(proxy.port()).username(proxy.username()).password(proxy.password()).nonProxyHosts(proxy.nonProxyHosts()).build();
    builder = mock(AwsAsyncBuilder.class);
    when(awsOptions.getProxyConfiguration()).thenReturn(proxy);
    getFactory(awsOptions).create(builder, awsOptions);
    ArgumentCaptor<NettyNioAsyncHttpClient.Builder> httpClientBuilder = ArgumentCaptor.forClass(NettyNioAsyncHttpClient.Builder.class);
    verify((AwsAsyncBuilder) builder).httpClientBuilder(httpClientBuilder.capture());
    verify(httpClientBuilder.getValue()).proxyConfiguration(nettyProxy);
    verifyNoMoreInteractions(httpClientBuilder.getValue());
}
Also used : ProxyConfiguration(software.amazon.awssdk.http.apache.ProxyConfiguration) SdkSyncClientBuilder(software.amazon.awssdk.core.client.builder.SdkSyncClientBuilder) SdkAsyncClientBuilder(software.amazon.awssdk.core.client.builder.SdkAsyncClientBuilder) DefaultClientBuilder(org.apache.beam.sdk.io.aws2.common.ClientBuilderFactory.DefaultClientBuilder) AwsClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsClientBuilder) NettyNioAsyncHttpClient(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient) Test(org.junit.Test)

Example 4 with AwsOptions

use of org.apache.beam.sdk.io.aws2.options.AwsOptions in project beam by apache.

the class AwsOptionsTest method testSetHttpClientConfiguration.

@Test
public void testSetHttpClientConfiguration() {
    AwsOptions options = create("--httpClientConfiguration={" + "\"connectionAcquisitionTimeout\":100," + "\"connectionMaxIdleTime\":200," + "\"connectionTimeout\":300," + "\"connectionTimeToLive\":400," + "\"socketTimeout\":500," + "\"readTimeout\":600," + "\"writeTimeout\":700," + "\"maxConnections\":10}");
    HttpClientConfiguration expected = HttpClientConfiguration.builder().connectionAcquisitionTimeout(100).connectionMaxIdleTime(200).connectionTimeout(300).connectionTimeToLive(400).socketTimeout(500).readTimeout(600).writeTimeout(700).maxConnections(10).build();
    assertThat(options.getHttpClientConfiguration()).isEqualTo(expected);
    assertThat(serializeDeserialize(options).getHttpClientConfiguration()).isEqualTo(expected);
}
Also used : HttpClientConfiguration(org.apache.beam.sdk.io.aws2.common.HttpClientConfiguration) Test(org.junit.Test)

Example 5 with AwsOptions

use of org.apache.beam.sdk.io.aws2.options.AwsOptions in project beam by apache.

the class SqsUnboundedReader method initClient.

private void initClient() {
    if (sqsClient == null) {
        if (source.getRead().sqsClientProvider() != null) {
            // build client using legacy SqsClientProvider
            sqsClient = source.getRead().sqsClientProvider().getSqsClient();
        } else {
            ClientConfiguration config = source.getRead().clientConfiguration();
            sqsClient = ClientBuilderFactory.buildClient(awsOptions, SqsClient.builder(), config);
        }
    }
}
Also used : ClientConfiguration(org.apache.beam.sdk.io.aws2.common.ClientConfiguration)

Aggregations

Test (org.junit.Test)3 DefaultClientBuilder (org.apache.beam.sdk.io.aws2.common.ClientBuilderFactory.DefaultClientBuilder)2 ClientConfiguration (org.apache.beam.sdk.io.aws2.common.ClientConfiguration)2 AwsClientBuilder (software.amazon.awssdk.awscore.client.builder.AwsClientBuilder)2 SdkAsyncClientBuilder (software.amazon.awssdk.core.client.builder.SdkAsyncClientBuilder)2 SdkSyncClientBuilder (software.amazon.awssdk.core.client.builder.SdkSyncClientBuilder)2 ProxyConfiguration (software.amazon.awssdk.http.apache.ProxyConfiguration)2 HttpClientConfiguration (org.apache.beam.sdk.io.aws2.common.HttpClientConfiguration)1 AwsOptions (org.apache.beam.sdk.io.aws2.options.AwsOptions)1 Instant (org.joda.time.Instant)1 ApacheHttpClient (software.amazon.awssdk.http.apache.ApacheHttpClient)1 NettyNioAsyncHttpClient (software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient)1 CloudWatchClient (software.amazon.awssdk.services.cloudwatch.CloudWatchClient)1 KinesisClient (software.amazon.awssdk.services.kinesis.KinesisClient)1