[ 
https://issues.apache.org/jira/browse/BEAM-8511?focusedWorklogId=338388&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-338388
 ]

ASF GitHub Bot logged work on BEAM-8511:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Nov/19 22:28
            Start Date: 04/Nov/19 22:28
    Worklog Time Spent: 10m 
      Work Description: cmachgodaddy commented on pull request #9899: 
[BEAM-8511] [WIP] KinesisIO enhanced fanout
URL: https://github.com/apache/beam/pull/9899#discussion_r342302772
 
 

 ##########
 File path: 
sdks/java/io/kinesis2/src/main/java/org/apache/beam/sdk/io/kinesis2/BasicKinesisProvider.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.kinesis2;
+
+import static 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument;
+
+import java.net.URI;
+import javax.annotation.Nullable;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import software.amazon.awssdk.services.cloudwatch.CloudWatchClientBuilder;
+import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
+import software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder;
+import software.amazon.awssdk.services.kinesis.KinesisClient;
+import software.amazon.awssdk.services.kinesis.KinesisClientBuilder;
+
+/** Basic implementation of {@link AWSClientsProvider} used by default in 
{@link KinesisIO}. */
+class BasicKinesisProvider implements AWSClientsProvider {
+  private final String accessKey;
+  private final String secretKey;
+  private final String region;
+  @Nullable private final String serviceEndpoint;
+
+  BasicKinesisProvider(
+      String accessKey, String secretKey, Region region, @Nullable String 
serviceEndpoint) {
+    checkArgument(accessKey != null, "accessKey can not be null");
+    checkArgument(secretKey != null, "secretKey can not be null");
+    checkArgument(region != null, "region can not be null");
+    this.accessKey = accessKey;
+    this.secretKey = secretKey;
+    this.region = region.toString();
+    this.serviceEndpoint = serviceEndpoint;
+  }
+
+  private AwsCredentialsProvider getCredentialsProvider() {
+    return 
StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, 
secretKey));
+  }
+
+  @Override
+  public KinesisClient getKinesisClient() {
+    KinesisClientBuilder clientBuilder =
+        KinesisClient.builder()
+            .credentialsProvider(getCredentialsProvider())
+            .region(Region.of(region));
+    if (serviceEndpoint != null) {
+      clientBuilder.endpointOverride(URI.create(serviceEndpoint));
+    }
+    return clientBuilder.build();
+  }
+
+  @Override
+  public KinesisAsyncClient getKinesisAsyncClient() {
+    KinesisAsyncClientBuilder clientBuilder =
+        KinesisAsyncClient.builder()
+            .credentialsProvider(getCredentialsProvider())
+            .region(Region.of(region));
+    if (serviceEndpoint != null) {
+      clientBuilder.endpointOverride(URI.create(serviceEndpoint));
+    }
+    return clientBuilder.build();
+  }
+
+  @Override
+  public CloudWatchClient getCloudWatchClient() {
+    CloudWatchClientBuilder clientBuilder =
+        CloudWatchClient.builder()
+            .credentialsProvider(getCredentialsProvider())
+            .region(Region.of(region));
+    if (serviceEndpoint != null) {
+      clientBuilder.endpointOverride(URI.create(serviceEndpoint));
+    }
+    return clientBuilder.build();
+  }
+}
 
 Review comment:
   .
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 338388)
    Time Spent: 1h 20m  (was: 1h 10m)

> Support for enhanced fan-out in KinesisIO
> -----------------------------------------
>
>                 Key: BEAM-8511
>                 URL: https://issues.apache.org/jira/browse/BEAM-8511
>             Project: Beam
>          Issue Type: New Feature
>          Components: io-java-kinesis
>            Reporter: Jonothan Farr
>            Assignee: Jonothan Farr
>            Priority: Major
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Add support for reading from an enhanced fan-out consumer using KinesisIO.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to