dannycranmer commented on a change in pull request #18553:
URL: https://github.com/apache/flink/pull/18553#discussion_r800826722



##########
File path: 
flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/util/RetryableExceptionClassifier.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.connector.base.sink.util;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.util.ExceptionUtils;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+/** Util class acting as a classifier for exception to suppress. */
+@Internal
+public class RetryableExceptionClassifier {
+    private final Function<Throwable, Exception> throwableMapper;
+    private final Predicate<Throwable> validator;
+    private RetryableExceptionClassifier chainedClassifier;
+
+    public RetryableExceptionClassifier(
+            Predicate<Throwable> validator, Function<Throwable, Exception> 
throwableMapper) {
+        this.throwableMapper = throwableMapper;
+        this.validator = validator;
+        this.chainedClassifier = null;
+    }
+
+    public boolean shouldSuppress(Throwable err, Consumer<Exception> 
throwableConsumer) {
+        if (validator.test(err)) {
+            throwableConsumer.accept(throwableMapper.apply(err));
+            return false;
+        }
+
+        if (chainedClassifier != null) {
+            return chainedClassifier.shouldSuppress(err, throwableConsumer);
+        } else {
+            return true;
+        }
+    }
+
+    @Override
+    public RetryableExceptionClassifier clone() {
+        return new RetryableExceptionClassifier(validator, throwableMapper);
+    }
+
+    public static RetryableExceptionClassifier withRootCauseOfType(
+            Class<? extends Throwable> type, Function<Throwable, Exception> 
mapper) {
+        return new RetryableExceptionClassifier(
+                err -> ExceptionUtils.findThrowable(err, type).isPresent(), 
mapper);
+    }
+
+    public static RetryableExceptionClassifier withRootCauseWithMessage(

Review comment:
       I cannot see any usages of this, am I missing something or can we remove 
it?

##########
File path: 
flink-connectors/flink-connector-aws-kinesis-data-streams/src/main/java/org/apache/flink/connector/kinesis/sink/KinesisDataStreamsSinkWriter.java
##########
@@ -56,6 +62,61 @@
 class KinesisDataStreamsSinkWriter<InputT> extends AsyncSinkWriter<InputT, 
PutRecordsRequestEntry> {
     private static final Logger LOG = 
LoggerFactory.getLogger(KinesisDataStreamsSinkWriter.class);
 
+    private static final RetryValidationStrategy INVALID_CREDENTIALS_STRATEGY =
+            new RetryValidationStrategy(
+                    err -> ExceptionUtils.findThrowable(err, 
StsException.class).isPresent(),
+                    err ->
+                            new KinesisDataStreamsException(
+                                    "Encountered non-recoverable exception 
relating to the provided credentials.",
+                                    err));
+    private static final RetryValidationStrategy RESOURCE_NOT_FOUND_STRATEGY =
+            new RetryValidationStrategy(
+                    err ->
+                            ExceptionUtils.findThrowable(err, 
ResourceNotFoundException.class)
+                                    .isPresent(),
+                    err ->
+                            new KinesisDataStreamsException(
+                                    "Encountered non-recoverable exception 
relating to not being able to find the specified resources",
+                                    err));
+    private static final RetryValidationStrategy 
SDK_CLIENT_MISCONFIGURED_STRATEGY =
+            new RetryValidationStrategy(
+                    err -> ExceptionUtils.findThrowable(err, 
SdkClientException.class).isPresent(),
+                    err ->
+                            new KinesisDataStreamsException(
+                                    "Encountered non-recoverable exception 
relating to mis-configured client",
+                                    err));
+    private static final RetryValidationStrategy 
MISSING_ACCESS_KEY_ID_STRATEGY =
+            new RetryValidationStrategy(
+                    err ->
+                            ExceptionUtils.findThrowableWithMessage(
+                                                    err, "Access key ID cannot 
be blank.")
+                                            .isPresent()
+                                    || ExceptionUtils.findThrowableWithMessage(
+                                                    err,
+                                                    "Either the environment 
variable AWS_WEB_IDENTITY_TOKEN_FILE or the javaproperty 
aws.webIdentityTokenFile must be set.")
+                                            .isPresent(),

Review comment:
       Bump




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to