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