You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/12/14 13:31:32 UTC

[GitHub] [flink-connector-aws] darenwkt opened a new pull request, #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

darenwkt opened a new pull request, #39:
URL: https://github.com/apache/flink-connector-aws/pull/39

   Implemented synchronous KinesisClient as described in https://issues.apache.org/jira/browse/FLINK-30418.


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054892121


##########
flink-connector-kinesis/pom.xml:
##########
@@ -256,6 +256,11 @@ under the License.
             <artifactId>netty-nio-client</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>software.amazon.awssdk</groupId>
+            <artifactId>apache-client</artifactId>
+        </dependency>
+

Review Comment:
   Got it, removing this and keep it in aws-base



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#issuecomment-1355508314

   > @darenwkt did you verify this works using EFO? There are no e2e tests for EFO since Kinesalite does not support it
   
   Yes, I verified by running EFOConsumer examples from https://github.com/aws-samples/amazon-kinesis-data-analytics-examples/blob/master/EfoConsumer/pom.xml against my local Flink 1.16.0 cluster.


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1072004206


##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +160,64 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @param clientBuilder httpClientBuilder to build the underlying HTTP client
+     * @param awsUserAgentPrefixFormat user agent prefix for Flink
+     * @param awsClientUserAgentPrefix user agent prefix for kinesis client
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(

Review Comment:
   I think refactoring it to AWSGeneralUtil will be messy as some Client Creation logic will have to be refactored to AWSGeneralUtil. Can I suggest renaming `AWSAsyncSinkUtil` to `AWSClientUtil` instead? This will be more tidy as all the utils to create client are in this class.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1058982468


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -218,7 +219,7 @@ private void waitForConsumerToDeregister(
             @Nullable final DescribeStreamConsumerResponse describeStreamConsumerResponse,
             final String streamConsumerArn,
             final int initialAttempt)
-            throws InterruptedException, ExecutionException {
+            throws Exception {

Review Comment:
   Same reply as above: https://github.com/apache/flink-connector-aws/pull/39/files/de6c5579a3b1d4b59938a7b6c3fcdc56d4ef88d4#r1058982327



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] dannycranmer commented on pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#issuecomment-1354416039

   @darenwkt did you verify this works using EFO? There are no e2e tests for EFO since Kinesalite does not support it


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054459944


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -77,8 +79,8 @@ public StreamConsumerRegistrar(
      * @throws InterruptedException
      */
     public String registerStreamConsumer(final String stream, final String streamConsumerName)
-            throws ExecutionException, InterruptedException {
-        LOG.debug("Registering stream consumer - {}::{}", stream, streamConsumerName);
+            throws Exception {

Review Comment:
   The main reason of the change is that we are using SyncClient for registerStreamConsumer, so it is not a FutureTask and it won't throw ExecutionException. However, I agree that InterruptedException should be readded as it might be thrown during registrationBackoff



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054443739


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxySyncV2.java:
##########
@@ -114,6 +104,7 @@ public DescribeStreamConsumerResponse describeStreamConsumer(
                         .streamARN(streamArn)
                         .consumerName(consumerName)
                         .build();
+        LOG.warn("describeStreamConsumer with arn: {}, consumerName: {}", streamArn, consumerName);

Review Comment:
   Yes, my apology for missing this in post-cleanup, doing a round of check again to remove them



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054442840


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxySyncV2.java:
##########
@@ -148,11 +139,10 @@ public RegisterStreamConsumerResponse registerStreamConsumer(
                         .consumerName(consumerName)
                         .build();
 
+        LOG.warn("registerStreamConsumer with arn: {}, consumerName: {}", streamArn, consumerName);

Review Comment:
   Done, fixed this



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054485689


##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +163,47 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(
+                    final Properties configProps,
+                    final SdkHttpClient httpClient,
+                    final T clientBuilder,
+                    final String awsUserAgentPrefixFormat,
+                    final String awsClientUserAgentPrefix) {
+        SdkClientConfiguration clientConfiguration = SdkClientConfiguration.builder().build();
+
+        String flinkUserAgentPrefix =
+                Optional.ofNullable(configProps.getProperty(awsClientUserAgentPrefix))
+                        .orElse(
+                                formatFlinkUserAgentPrefix(
+                                        awsUserAgentPrefixFormat + V2_USER_AGENT_SUFFIX));
+
+        final ClientOverrideConfiguration overrideConfiguration =
+                createClientOverrideConfiguration(
+                        clientConfiguration,
+                        ClientOverrideConfiguration.builder(),
+                        flinkUserAgentPrefix);
+
+        if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) {
+            final URI endpointOverride =
+                    URI.create(configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT));
+            clientBuilder.endpointOverride(endpointOverride);
+        }
+

Review Comment:
   Done refactored



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054458256


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -243,28 +244,28 @@ private void waitForConsumerToDeregister(
     }
 
     private Optional<DescribeStreamConsumerResponse> describeStreamConsumer(
-            final String streamArn, final String streamConsumerName)
-            throws InterruptedException, ExecutionException {
+            final String streamArn, final String streamConsumerName) throws Exception {
         return describeStreamConsumer(
                 () ->
                         kinesisProxyV2Interface.describeStreamConsumer(
                                 streamArn, streamConsumerName));
     }
 
     private Optional<DescribeStreamConsumerResponse> describeStreamConsumer(
-            final String streamConsumerArn) throws InterruptedException, ExecutionException {
+            final String streamConsumerArn) throws Exception {
         return describeStreamConsumer(
                 () -> kinesisProxyV2Interface.describeStreamConsumer(streamConsumerArn));
     }
 
     private Optional<DescribeStreamConsumerResponse> describeStreamConsumer(
-            final ResponseSupplier<DescribeStreamConsumerResponse> responseSupplier)
-            throws InterruptedException, ExecutionException {
+            final Callable<DescribeStreamConsumerResponse> responseSupplier) throws Exception {
         DescribeStreamConsumerResponse response;
 
         try {
-            response = responseSupplier.get();
-        } catch (ExecutionException ex) {
+            response = responseSupplier.call();
+        } catch (Exception ex) {
+            LOG.warn("describeStreamConsumer caught ExecutionException: {}", ex);

Review Comment:
   Thanks for highlighting this, I will add the InterruptedException back in as it might be thrown by registrationBackoff



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054892467


##########
flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyAsyncV2Test.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.flink.streaming.connectors.kinesis.proxy;
+
+import org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherConfiguration;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import software.amazon.awssdk.http.SdkHttpClient;
+import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
+import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
+import software.amazon.awssdk.services.kinesis.KinesisClient;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardResponseHandler;
+
+import java.util.Properties;
+
+import static java.util.Collections.emptyList;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DEREGISTER_STREAM_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DEREGISTER_STREAM_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DEREGISTER_STREAM_BACKOFF_MAX;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DESCRIBE_STREAM_CONSUMER_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DESCRIBE_STREAM_CONSUMER_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DESCRIBE_STREAM_CONSUMER_BACKOFF_MAX;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.EFO_CONSUMER_NAME;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.RECORD_PUBLISHER_TYPE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.REGISTER_STREAM_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.REGISTER_STREAM_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.REGISTER_STREAM_BACKOFF_MAX;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.RecordPublisherType.EFO;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.STREAM_DESCRIBE_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.STREAM_DESCRIBE_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.STREAM_DESCRIBE_BACKOFF_MAX;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.STREAM_DESCRIBE_RETRIES;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_BACKOFF_MAX;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;

Review Comment:
   Have refactored this away from mockito



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054441165


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -77,8 +79,8 @@ public StreamConsumerRegistrar(
      * @throws InterruptedException
      */
     public String registerStreamConsumer(final String stream, final String streamConsumerName)
-            throws ExecutionException, InterruptedException {
-        LOG.debug("Registering stream consumer - {}::{}", stream, streamConsumerName);
+            throws Exception {
+        LOG.warn("Registering stream consumer - {}::{}", stream, streamConsumerName);

Review Comment:
   Done, fixed this



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -90,7 +92,7 @@ public String registerStreamConsumer(final String stream, final String streamCon
                 kinesisProxyV2Interface.describeStreamSummary(stream);
         String streamArn = describeStreamSummaryResponse.streamDescriptionSummary().streamARN();
 
-        LOG.debug("Found stream ARN - {}", streamArn);
+        LOG.warn("Found stream ARN - {}", streamArn);

Review Comment:
   Done, fixed this



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#issuecomment-1385232794

   @dannycranmer, @vahmed-hamdy I have addressed the comments and retested locally against a local Flink 1.16 cluster and Kinesis EFO Stream. Appreciate if you could review again, thank you


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1072012340


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyAsyncV2Interface.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.flink.streaming.connectors.kinesis.proxy;
+
+import org.apache.flink.annotation.Internal;
+
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardResponseHandler;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Interface for a Kinesis proxy using AWS SDK v2.x operating on multiple Kinesis streams within the
+ * same AWS service region.
+ */
+@Internal
+public interface KinesisProxyAsyncV2Interface {
+
+    CompletableFuture<Void> subscribeToShard(
+            SubscribeToShardRequest request, SubscribeToShardResponseHandler responseHandler);
+
+    /** Destroy any open resources used by the factory. */
+    default void close() {

Review Comment:
   Got it, I have removed default and moved this to KinesisProxyAsyncV2InterfaceAdapter and KinesisProxySyncV2InterfaceAdapter to implement



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] dannycranmer commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054235701


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -77,8 +79,8 @@ public StreamConsumerRegistrar(
      * @throws InterruptedException
      */
     public String registerStreamConsumer(final String stream, final String streamConsumerName)
-            throws ExecutionException, InterruptedException {
-        LOG.debug("Registering stream consumer - {}::{}", stream, streamConsumerName);
+            throws Exception {

Review Comment:
   Why did you make this change? This will possible change the error handling behaviour 



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -90,7 +92,7 @@ public String registerStreamConsumer(final String stream, final String streamCon
                 kinesisProxyV2Interface.describeStreamSummary(stream);
         String streamArn = describeStreamSummaryResponse.streamDescriptionSummary().streamARN();
 
-        LOG.debug("Found stream ARN - {}", streamArn);
+        LOG.warn("Found stream ARN - {}", streamArn);

Review Comment:
   Why is this a warning?



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -77,8 +79,8 @@ public StreamConsumerRegistrar(
      * @throws InterruptedException
      */
     public String registerStreamConsumer(final String stream, final String streamConsumerName)
-            throws ExecutionException, InterruptedException {
-        LOG.debug("Registering stream consumer - {}::{}", stream, streamConsumerName);
+            throws Exception {
+        LOG.warn("Registering stream consumer - {}::{}", stream, streamConsumerName);

Review Comment:
   Why is this a warning?



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -243,28 +244,28 @@ private void waitForConsumerToDeregister(
     }
 
     private Optional<DescribeStreamConsumerResponse> describeStreamConsumer(
-            final String streamArn, final String streamConsumerName)
-            throws InterruptedException, ExecutionException {
+            final String streamArn, final String streamConsumerName) throws Exception {
         return describeStreamConsumer(
                 () ->
                         kinesisProxyV2Interface.describeStreamConsumer(
                                 streamArn, streamConsumerName));
     }
 
     private Optional<DescribeStreamConsumerResponse> describeStreamConsumer(
-            final String streamConsumerArn) throws InterruptedException, ExecutionException {
+            final String streamConsumerArn) throws Exception {
         return describeStreamConsumer(
                 () -> kinesisProxyV2Interface.describeStreamConsumer(streamConsumerArn));
     }
 
     private Optional<DescribeStreamConsumerResponse> describeStreamConsumer(
-            final ResponseSupplier<DescribeStreamConsumerResponse> responseSupplier)
-            throws InterruptedException, ExecutionException {
+            final Callable<DescribeStreamConsumerResponse> responseSupplier) throws Exception {
         DescribeStreamConsumerResponse response;
 
         try {
-            response = responseSupplier.get();
-        } catch (ExecutionException ex) {
+            response = responseSupplier.call();
+        } catch (Exception ex) {
+            LOG.warn("describeStreamConsumer caught ExecutionException: {}", ex);

Review Comment:
   `caught ExecutionException` not necessarily now you are catching `Exception`. This change is slightly worrying, what happens now if an `InterruptedException` is thrown?



##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +163,47 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties

Review Comment:
   This javadoc is missing a comment. 



##########
flink-connector-kinesis/pom.xml:
##########
@@ -256,6 +256,11 @@ under the License.
             <artifactId>netty-nio-client</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>software.amazon.awssdk</groupId>
+            <artifactId>apache-client</artifactId>
+        </dependency>
+

Review Comment:
   Why is this needed explicitly in here and `aws-base`?



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxySyncV2.java:
##########
@@ -114,6 +104,7 @@ public DescribeStreamConsumerResponse describeStreamConsumer(
                         .streamARN(streamArn)
                         .consumerName(consumerName)
                         .build();
+        LOG.warn("describeStreamConsumer with arn: {}, consumerName: {}", streamArn, consumerName);

Review Comment:
   Why is this a warning? (did you leave dev debug logs in?)



##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +163,47 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(
+                    final Properties configProps,
+                    final SdkHttpClient httpClient,
+                    final T clientBuilder,
+                    final String awsUserAgentPrefixFormat,
+                    final String awsClientUserAgentPrefix) {
+        SdkClientConfiguration clientConfiguration = SdkClientConfiguration.builder().build();
+
+        String flinkUserAgentPrefix =
+                Optional.ofNullable(configProps.getProperty(awsClientUserAgentPrefix))
+                        .orElse(
+                                formatFlinkUserAgentPrefix(
+                                        awsUserAgentPrefixFormat + V2_USER_AGENT_SUFFIX));
+
+        final ClientOverrideConfiguration overrideConfiguration =
+                createClientOverrideConfiguration(
+                        clientConfiguration,
+                        ClientOverrideConfiguration.builder(),
+                        flinkUserAgentPrefix);
+
+        if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) {
+            final URI endpointOverride =
+                    URI.create(configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT));
+            clientBuilder.endpointOverride(endpointOverride);
+        }
+

Review Comment:
   This code is duplicated in this file, can you extract to a method please



##########
flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyAsyncV2Test.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.flink.streaming.connectors.kinesis.proxy;
+
+import org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherConfiguration;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import software.amazon.awssdk.http.SdkHttpClient;
+import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
+import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
+import software.amazon.awssdk.services.kinesis.KinesisClient;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardResponseHandler;
+
+import java.util.Properties;
+
+import static java.util.Collections.emptyList;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DEREGISTER_STREAM_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DEREGISTER_STREAM_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DEREGISTER_STREAM_BACKOFF_MAX;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DESCRIBE_STREAM_CONSUMER_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DESCRIBE_STREAM_CONSUMER_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.DESCRIBE_STREAM_CONSUMER_BACKOFF_MAX;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.EFO_CONSUMER_NAME;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.RECORD_PUBLISHER_TYPE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.REGISTER_STREAM_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.REGISTER_STREAM_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.REGISTER_STREAM_BACKOFF_MAX;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.RecordPublisherType.EFO;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.STREAM_DESCRIBE_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.STREAM_DESCRIBE_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.STREAM_DESCRIBE_BACKOFF_MAX;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.STREAM_DESCRIBE_RETRIES;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_BACKOFF_BASE;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_BACKOFF_EXPONENTIAL_CONSTANT;
+import static org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_BACKOFF_MAX;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;

Review Comment:
   Mockito is [banned from use](https://flink.apache.org/contributing/code-style-and-quality-common.html#avoid-mockito---use-reusable-test-implementations) in Flink. I know we do already use it in places but we should not use for new tests. Can we refactor to reusable test implementations?



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxySyncV2.java:
##########
@@ -148,11 +139,10 @@ public RegisterStreamConsumerResponse registerStreamConsumer(
                         .consumerName(consumerName)
                         .build();
 
+        LOG.warn("registerStreamConsumer with arn: {}, consumerName: {}", streamArn, consumerName);

Review Comment:
   Why is this a warning?



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1054467238


##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +163,47 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties

Review Comment:
   Done added



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] dannycranmer commented on pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#issuecomment-1385040323

   @darenwkt please repush with correct component tag in commit message, ie `[FLINK-XXXX][Connectors/Kinesis] ...`


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1072004660


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyAsyncV2.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.flink.streaming.connectors.kinesis.proxy;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherConfiguration;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
+import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardResponseHandler;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Kinesis proxy implementation using AWS SDK v2.x - a utility class that is used as a proxy to make
+ * calls to AWS Kinesis for several EFO (Enhanced Fan Out) functions, such as de-/registering stream
+ * consumers, subscribing to a shard and receiving records from a shard.
+ */
+@Internal
+public class KinesisProxyAsyncV2 implements KinesisProxyAsyncV2Interface {
+
+    private static final Logger LOG = LoggerFactory.getLogger(KinesisProxyAsyncV2.class);

Review Comment:
   Have removed, thank you



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1051107364


##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSGeneralUtil.java:
##########
@@ -301,6 +303,58 @@ public static SdkAsyncHttpClient createAsyncHttpClient(
         return httpClientBuilder.buildWithDefaults(config.merge(HTTP_CLIENT_DEFAULTS));
     }
 
+    public static SdkHttpClient createSyncHttpClient(final Properties configProperties) {
+        return createSyncHttpClient(configProperties, ApacheHttpClient.builder());
+    }
+
+    public static SdkHttpClient createSyncHttpClient(
+            final Properties configProperties, final ApacheHttpClient.Builder httpClientBuilder) {
+
+        final AttributeMap.Builder clientConfiguration =
+                AttributeMap.builder().put(SdkHttpConfigurationOption.TCP_KEEPALIVE, true);
+
+        Optional.ofNullable(
+                        configProperties.getProperty(
+                                AWSConfigConstants.HTTP_CLIENT_MAX_CONCURRENCY))
+                .map(Integer::parseInt)
+                .ifPresent(
+                        integer ->
+                                clientConfiguration.put(
+                                        SdkHttpConfigurationOption.MAX_CONNECTIONS, integer));
+
+        Optional.ofNullable(
+                        configProperties.getProperty(
+                                AWSConfigConstants.HTTP_CLIENT_READ_TIMEOUT_MILLIS))
+                .map(Integer::parseInt)
+                .map(Duration::ofMillis)
+                .ifPresent(
+                        timeout ->
+                                clientConfiguration.put(
+                                        SdkHttpConfigurationOption.READ_TIMEOUT, timeout));
+
+        Optional.ofNullable(configProperties.getProperty(AWSConfigConstants.TRUST_ALL_CERTIFICATES))
+                .map(Boolean::parseBoolean)
+                .ifPresent(
+                        bool ->
+                                clientConfiguration.put(
+                                        SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, bool));
+
+        Optional.ofNullable(configProperties.getProperty(AWSConfigConstants.HTTP_PROTOCOL_VERSION))
+                .map(Protocol::valueOf)
+                .ifPresent(
+                        protocol ->
+                                clientConfiguration.put(
+                                        SdkHttpConfigurationOption.PROTOCOL, protocol));
+

Review Comment:
   Done, extracted to common method



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1051106792


##########
flink-connector-aws-base/pom.xml:
##########
@@ -52,6 +52,11 @@ under the License.
             <artifactId>netty-nio-client</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>software.amazon.awssdk</groupId>
+            <artifactId>apache-client</artifactId>
+        </dependency>

Review Comment:
   Verified that apache-client is in the installed JAR.
   
   <img width="461" alt="Screenshot 2022-12-16 at 19 51 45" src="https://user-images.githubusercontent.com/108749182/208178095-b0490c6f-67c7-4b59-90e2-811415ad2004.png">
   
   
   Verified that NOTICE files are updated.
   
   ```
   
   - software.amazon.awssdk:apache-client:2.17.247
   - software.amazon.awssdk:netty-nio-client:2.17.247
   ```
   
   



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1051108678


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyV2Factory.java:
##########
@@ -55,25 +58,39 @@ public static KinesisProxyV2Interface createKinesisProxyV2(final Properties conf
         final AttributeMap.Builder clientConfiguration = AttributeMap.builder();
         populateDefaultValues(clientConfiguration);
 
-        final SdkAsyncHttpClient httpClient =
+        final SdkHttpClient httpClient =
+                AWSGeneralUtil.createSyncHttpClient(
+                        convertedProperties.merge(clientConfiguration.build()),
+                        ApacheHttpClient.builder());
+
+        final SdkAsyncHttpClient asyncHttpClient =
                 AWSGeneralUtil.createAsyncHttpClient(
                         convertedProperties.merge(clientConfiguration.build()),
                         NettyNioAsyncHttpClient.builder());
+
         final FanOutRecordPublisherConfiguration configuration =
                 new FanOutRecordPublisherConfiguration(configProps, emptyList());
 
-        Properties asyncClientProperties =
-                KinesisConfigUtil.getV2ConsumerAsyncClientProperties(configProps);
+        Properties clientProperties = KinesisConfigUtil.getV2ConsumerClientProperties(configProps);
 
-        final KinesisAsyncClient client =
+        final KinesisAsyncClient asyncClient =
                 AWSAsyncSinkUtil.createAwsAsyncClient(
-                        asyncClientProperties,
-                        httpClient,
+                        clientProperties,
+                        asyncHttpClient,
                         KinesisAsyncClient.builder(),
                         KinesisStreamsConfigConstants.BASE_KINESIS_USER_AGENT_PREFIX_FORMAT,
                         KinesisStreamsConfigConstants.KINESIS_CLIENT_USER_AGENT_PREFIX);
 
-        return new KinesisProxyV2(client, httpClient, configuration, BACKOFF);
+        final KinesisClient client =
+                AWSAsyncSinkUtil.createAwsSyncClient(
+                        clientProperties,
+                        httpClient,
+                        KinesisClient.builder(),
+                        KinesisStreamsConfigConstants.BASE_KINESIS_USER_AGENT_PREFIX_FORMAT,
+                        KinesisStreamsConfigConstants.KINESIS_CLIENT_USER_AGENT_PREFIX);
+
+        return new KinesisProxyV2(
+                asyncClient, client, asyncHttpClient, httpClient, configuration, BACKOFF);

Review Comment:
   Thank you for clarifying, I have split `KinesisProxyV2` to `KinesisProxySyncV2` and `KinesisProxyAsyncV2`. 
   
   For StreamRegistrar related operations (i.e registerStreamConsumer), only `KinesisProxySyncV2` will be created. 
   For EFO related operations (i.e subsribeToShard), only `KinesisProxyAsyncV2` will be created.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1051107066


##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +163,86 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(
+                    final Properties configProps,
+                    final SdkHttpClient httpClient,
+                    final T clientBuilder,
+                    final String awsUserAgentPrefixFormat,
+                    final String awsClientUserAgentPrefix) {
+        SdkClientConfiguration clientConfiguration = SdkClientConfiguration.builder().build();
+        return createAwsSyncClient(
+                configProps,
+                clientConfiguration,
+                httpClient,
+                clientBuilder,
+                awsUserAgentPrefixFormat,
+                awsClientUserAgentPrefix);
+    }
+
+    /**
+     * @param configProps configuration properties
+     * @param clientConfiguration the AWS SDK v2 config to instantiate the client
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(

Review Comment:
   Done, have cleaned the rest



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] dannycranmer commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1050513372


##########
flink-connector-aws-base/pom.xml:
##########
@@ -52,6 +52,11 @@ under the License.
             <artifactId>netty-nio-client</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>software.amazon.awssdk</groupId>
+            <artifactId>apache-client</artifactId>
+        </dependency>

Review Comment:
   We will need to ensure this is shaded correctly and NOTICE files are updated 



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyV2Factory.java:
##########
@@ -55,25 +58,39 @@ public static KinesisProxyV2Interface createKinesisProxyV2(final Properties conf
         final AttributeMap.Builder clientConfiguration = AttributeMap.builder();
         populateDefaultValues(clientConfiguration);
 
-        final SdkAsyncHttpClient httpClient =
+        final SdkHttpClient httpClient =
+                AWSGeneralUtil.createSyncHttpClient(
+                        convertedProperties.merge(clientConfiguration.build()),
+                        ApacheHttpClient.builder());
+
+        final SdkAsyncHttpClient asyncHttpClient =
                 AWSGeneralUtil.createAsyncHttpClient(
                         convertedProperties.merge(clientConfiguration.build()),
                         NettyNioAsyncHttpClient.builder());
+
         final FanOutRecordPublisherConfiguration configuration =
                 new FanOutRecordPublisherConfiguration(configProps, emptyList());
 
-        Properties asyncClientProperties =
-                KinesisConfigUtil.getV2ConsumerAsyncClientProperties(configProps);
+        Properties clientProperties = KinesisConfigUtil.getV2ConsumerClientProperties(configProps);
 
-        final KinesisAsyncClient client =
+        final KinesisAsyncClient asyncClient =
                 AWSAsyncSinkUtil.createAwsAsyncClient(
-                        asyncClientProperties,
-                        httpClient,
+                        clientProperties,
+                        asyncHttpClient,
                         KinesisAsyncClient.builder(),
                         KinesisStreamsConfigConstants.BASE_KINESIS_USER_AGENT_PREFIX_FORMAT,
                         KinesisStreamsConfigConstants.KINESIS_CLIENT_USER_AGENT_PREFIX);
 
-        return new KinesisProxyV2(client, httpClient, configuration, BACKOFF);
+        final KinesisClient client =
+                AWSAsyncSinkUtil.createAwsSyncClient(
+                        clientProperties,
+                        httpClient,
+                        KinesisClient.builder(),
+                        KinesisStreamsConfigConstants.BASE_KINESIS_USER_AGENT_PREFIX_FORMAT,
+                        KinesisStreamsConfigConstants.KINESIS_CLIENT_USER_AGENT_PREFIX);
+
+        return new KinesisProxyV2(
+                asyncClient, client, asyncHttpClient, httpClient, configuration, BACKOFF);

Review Comment:
   As we discussed, we should split `KinesisProxyV2` so we do not need to create both client. In the case of registerStreamConsumer it will not use the async client and it is expensive to create a thread pool, then trash it. We should only create the async client when we actually need to use it



##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +163,86 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(
+                    final Properties configProps,
+                    final SdkHttpClient httpClient,
+                    final T clientBuilder,
+                    final String awsUserAgentPrefixFormat,
+                    final String awsClientUserAgentPrefix) {
+        SdkClientConfiguration clientConfiguration = SdkClientConfiguration.builder().build();
+        return createAwsSyncClient(
+                configProps,
+                clientConfiguration,
+                httpClient,
+                clientBuilder,
+                awsUserAgentPrefixFormat,
+                awsClientUserAgentPrefix);
+    }
+
+    /**
+     * @param configProps configuration properties
+     * @param clientConfiguration the AWS SDK v2 config to instantiate the client
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(

Review Comment:
   Why do we need so many overloaded versions of this? Looks like only 1 is used



##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSGeneralUtil.java:
##########
@@ -301,6 +303,58 @@ public static SdkAsyncHttpClient createAsyncHttpClient(
         return httpClientBuilder.buildWithDefaults(config.merge(HTTP_CLIENT_DEFAULTS));
     }
 
+    public static SdkHttpClient createSyncHttpClient(final Properties configProperties) {
+        return createSyncHttpClient(configProperties, ApacheHttpClient.builder());
+    }
+
+    public static SdkHttpClient createSyncHttpClient(
+            final Properties configProperties, final ApacheHttpClient.Builder httpClientBuilder) {
+
+        final AttributeMap.Builder clientConfiguration =
+                AttributeMap.builder().put(SdkHttpConfigurationOption.TCP_KEEPALIVE, true);
+
+        Optional.ofNullable(
+                        configProperties.getProperty(
+                                AWSConfigConstants.HTTP_CLIENT_MAX_CONCURRENCY))
+                .map(Integer::parseInt)
+                .ifPresent(
+                        integer ->
+                                clientConfiguration.put(
+                                        SdkHttpConfigurationOption.MAX_CONNECTIONS, integer));
+
+        Optional.ofNullable(
+                        configProperties.getProperty(
+                                AWSConfigConstants.HTTP_CLIENT_READ_TIMEOUT_MILLIS))
+                .map(Integer::parseInt)
+                .map(Duration::ofMillis)
+                .ifPresent(
+                        timeout ->
+                                clientConfiguration.put(
+                                        SdkHttpConfigurationOption.READ_TIMEOUT, timeout));
+
+        Optional.ofNullable(configProperties.getProperty(AWSConfigConstants.TRUST_ALL_CERTIFICATES))
+                .map(Boolean::parseBoolean)
+                .ifPresent(
+                        bool ->
+                                clientConfiguration.put(
+                                        SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, bool));
+
+        Optional.ofNullable(configProperties.getProperty(AWSConfigConstants.HTTP_PROTOCOL_VERSION))
+                .map(Protocol::valueOf)
+                .ifPresent(
+                        protocol ->
+                                clientConfiguration.put(
+                                        SdkHttpConfigurationOption.PROTOCOL, protocol));
+

Review Comment:
   Seems like this is duplicated for Async/Sync. Can we extract to a common method?



##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +163,86 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(
+                    final Properties configProps,
+                    final SdkHttpClient httpClient,
+                    final T clientBuilder,
+                    final String awsUserAgentPrefixFormat,
+                    final String awsClientUserAgentPrefix) {
+        SdkClientConfiguration clientConfiguration = SdkClientConfiguration.builder().build();
+        return createAwsSyncClient(
+                configProps,
+                clientConfiguration,
+                httpClient,
+                clientBuilder,
+                awsUserAgentPrefixFormat,
+                awsClientUserAgentPrefix);
+    }
+
+    /**
+     * @param configProps configuration properties
+     * @param clientConfiguration the AWS SDK v2 config to instantiate the client
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(
+                    final Properties configProps,
+                    final SdkClientConfiguration clientConfiguration,
+                    final SdkHttpClient httpClient,
+                    final T clientBuilder,
+                    final String awsUserAgentPrefixFormat,
+                    final String awsClientUserAgentPrefix) {
+        String flinkUserAgentPrefix =
+                Optional.ofNullable(configProps.getProperty(awsClientUserAgentPrefix))
+                        .orElse(
+                                formatFlinkUserAgentPrefix(
+                                        awsUserAgentPrefixFormat + V2_USER_AGENT_SUFFIX));
+
+        final ClientOverrideConfiguration overrideConfiguration =
+                createClientOverrideConfiguration(
+                        clientConfiguration,
+                        ClientOverrideConfiguration.builder(),
+                        flinkUserAgentPrefix);
+
+        return createAwsSyncClient(configProps, clientBuilder, httpClient, overrideConfiguration);
+    }
+
+    @VisibleForTesting

Review Comment:
   Where is this tested such that it requires this scope?



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] vahmed-hamdy commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
vahmed-hamdy commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1055833568


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -218,7 +219,7 @@ private void waitForConsumerToDeregister(
             @Nullable final DescribeStreamConsumerResponse describeStreamConsumerResponse,
             final String streamConsumerArn,
             final int initialAttempt)
-            throws InterruptedException, ExecutionException {
+            throws Exception {

Review Comment:
   Same goes here



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -77,8 +79,8 @@ public StreamConsumerRegistrar(
      * @throws InterruptedException
      */
     public String registerStreamConsumer(final String stream, final String streamConsumerName)
-            throws ExecutionException, InterruptedException {
-        LOG.debug("Registering stream consumer - {}::{}", stream, streamConsumerName);
+            throws Exception {

Review Comment:
   I agree with @dannycranmer , we would better not generalize the Exception.



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyAsyncV2Interface.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.flink.streaming.connectors.kinesis.proxy;
+
+import org.apache.flink.annotation.Internal;
+
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardResponseHandler;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Interface for a Kinesis proxy using AWS SDK v2.x operating on multiple Kinesis streams within the
+ * same AWS service region.
+ */
+@Internal
+public interface KinesisProxyAsyncV2Interface {
+
+    CompletableFuture<Void> subscribeToShard(
+            SubscribeToShardRequest request, SubscribeToShardResponseHandler responseHandler);
+
+    /** Destroy any open resources used by the factory. */
+    default void close() {

Review Comment:
   Why do we provide a default no-op method?



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] dannycranmer commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1071935816


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyAsyncV2.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.flink.streaming.connectors.kinesis.proxy;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherConfiguration;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
+import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardResponseHandler;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Kinesis proxy implementation using AWS SDK v2.x - a utility class that is used as a proxy to make
+ * calls to AWS Kinesis for several EFO (Enhanced Fan Out) functions, such as de-/registering stream
+ * consumers, subscribing to a shard and receiving records from a shard.
+ */
+@Internal
+public class KinesisProxyAsyncV2 implements KinesisProxyAsyncV2Interface {
+
+    private static final Logger LOG = LoggerFactory.getLogger(KinesisProxyAsyncV2.class);

Review Comment:
   This is unused



##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +160,64 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @param clientBuilder httpClientBuilder to build the underlying HTTP client
+     * @param awsUserAgentPrefixFormat user agent prefix for Flink
+     * @param awsClientUserAgentPrefix user agent prefix for kinesis client
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(

Review Comment:
   It seems odd to put `createAwsSyncClient` in `AWSAsyncSinkUtil`. Should this be in `AWSGeneralUtil` instead? I assume the AsyncSink does not use the Sync client?



##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +163,47 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties

Review Comment:
   It is still missing a comment. The first line of javadoc is the comment



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -77,8 +79,8 @@ public StreamConsumerRegistrar(
      * @throws InterruptedException
      */
     public String registerStreamConsumer(final String stream, final String streamConsumerName)
-            throws ExecutionException, InterruptedException {
-        LOG.debug("Registering stream consumer - {}::{}", stream, streamConsumerName);
+            throws Exception {

Review Comment:
   My concerns is the Exception is a wider catch bucket than before. However given `ExecutionException, InterruptedException` would have caught the majority and the parent wraps in a `FlinkKinesisStreamConsumerRegistrarException`, it looks ok



##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyAsyncV2Interface.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.flink.streaming.connectors.kinesis.proxy;
+
+import org.apache.flink.annotation.Internal;
+
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardResponseHandler;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Interface for a Kinesis proxy using AWS SDK v2.x operating on multiple Kinesis streams within the
+ * same AWS service region.
+ */
+@Internal
+public interface KinesisProxyAsyncV2Interface {
+
+    CompletableFuture<Void> subscribeToShard(
+            SubscribeToShardRequest request, SubscribeToShardResponseHandler responseHandler);
+
+    /** Destroy any open resources used by the factory. */
+    default void close() {

Review Comment:
   Seems like a shortcut for testing. I would rather move it to `KinesisProxyAsyncV2InterfaceAdapter` to force developers to think about `close()` in src. We missed this before and it caused issues!



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1051107189


##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSAsyncSinkUtil.java:
##########
@@ -161,4 +163,86 @@ S createAwsAsyncClient(
                 .region(getRegion(configProps))
                 .build();
     }
+
+    /**
+     * @param configProps configuration properties
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(
+                    final Properties configProps,
+                    final SdkHttpClient httpClient,
+                    final T clientBuilder,
+                    final String awsUserAgentPrefixFormat,
+                    final String awsClientUserAgentPrefix) {
+        SdkClientConfiguration clientConfiguration = SdkClientConfiguration.builder().build();
+        return createAwsSyncClient(
+                configProps,
+                clientConfiguration,
+                httpClient,
+                clientBuilder,
+                awsUserAgentPrefixFormat,
+                awsClientUserAgentPrefix);
+    }
+
+    /**
+     * @param configProps configuration properties
+     * @param clientConfiguration the AWS SDK v2 config to instantiate the client
+     * @param httpClient the underlying HTTP client used to talk to AWS
+     * @return a new AWS Sync Client
+     */
+    public static <
+                    S extends SdkClient,
+                    T extends
+                            AwsSyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>>
+            S createAwsSyncClient(
+                    final Properties configProps,
+                    final SdkClientConfiguration clientConfiguration,
+                    final SdkHttpClient httpClient,
+                    final T clientBuilder,
+                    final String awsUserAgentPrefixFormat,
+                    final String awsClientUserAgentPrefix) {
+        String flinkUserAgentPrefix =
+                Optional.ofNullable(configProps.getProperty(awsClientUserAgentPrefix))
+                        .orElse(
+                                formatFlinkUserAgentPrefix(
+                                        awsUserAgentPrefixFormat + V2_USER_AGENT_SUFFIX));
+
+        final ClientOverrideConfiguration overrideConfiguration =
+                createClientOverrideConfiguration(
+                        clientConfiguration,
+                        ClientOverrideConfiguration.builder(),
+                        flinkUserAgentPrefix);
+
+        return createAwsSyncClient(configProps, clientBuilder, httpClient, overrideConfiguration);
+    }
+
+    @VisibleForTesting

Review Comment:
   Done, have clean this up



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1058985956


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxyAsyncV2Interface.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.flink.streaming.connectors.kinesis.proxy;
+
+import org.apache.flink.annotation.Internal;
+
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest;
+import software.amazon.awssdk.services.kinesis.model.SubscribeToShardResponseHandler;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Interface for a Kinesis proxy using AWS SDK v2.x operating on multiple Kinesis streams within the
+ * same AWS service region.
+ */
+@Internal
+public interface KinesisProxyAsyncV2Interface {
+
+    CompletableFuture<Void> subscribeToShard(
+            SubscribeToShardRequest request, SubscribeToShardResponseHandler responseHandler);
+
+    /** Destroy any open resources used by the factory. */
+    default void close() {

Review Comment:
   In the implementation (i.e KinesisProxyAsyncV2.java), close() is overriden and used to close any open HttpClient gracefully. 
   
   I think it's ok to put as default for cases that do not require closing any resources. But do let me know if you think I should remove the default so that any implementation have to explicitly implement it.
   



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] darenwkt commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
darenwkt commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1058982327


##########
flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/StreamConsumerRegistrar.java:
##########
@@ -77,8 +79,8 @@ public StreamConsumerRegistrar(
      * @throws InterruptedException
      */
     public String registerStreamConsumer(final String stream, final String streamConsumerName)
-            throws ExecutionException, InterruptedException {
-        LOG.debug("Registering stream consumer - {}::{}", stream, streamConsumerName);
+            throws Exception {

Review Comment:
   I think we can generalise it here because previously ExecutionException, InterruptedException were thrown from a CompletableFuture get method. However, we are no longer using Future here as registerStreamConsumer is called synchronously now (via Callable call method) instead of async. Unlike CompletableFuture, Callable call method throws Exception instead of Execution + InterruptedException.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] dannycranmer commented on a diff in pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39#discussion_r1072116820


##########
flink-connector-aws-base/pom.xml:
##########
@@ -52,6 +52,11 @@ under the License.
             <artifactId>netty-nio-client</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>software.amazon.awssdk</groupId>
+            <artifactId>apache-client</artifactId>
+        </dependency>

Review Comment:
   Yes, I already see it. For all connectors, thanks



##########
flink-connector-aws-base/pom.xml:
##########
@@ -52,6 +52,11 @@ under the License.
             <artifactId>netty-nio-client</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>software.amazon.awssdk</groupId>
+            <artifactId>apache-client</artifactId>
+        </dependency>

Review Comment:
   NOTICE files do not update automatically, so either:
   - It is already included and this is not necessary, or
   - The NOTICE files need updating
   
   Since flink-connector-aws-base is common to all connectors we will need to update all the NOTICE files I believe. 



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-connector-aws] dannycranmer merged pull request #39: [FLINK-30418] Implement synchronous KinesisClient in EFO

Posted by GitBox <gi...@apache.org>.
dannycranmer merged PR #39:
URL: https://github.com/apache/flink-connector-aws/pull/39


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org