anmolanmol1234 commented on code in PR #5299:
URL: https://github.com/apache/hadoop/pull/5299#discussion_r1069480910
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/RetryReason.java:
##########
@@ -0,0 +1,128 @@
+package org.apache.hadoop.fs.azurebfs.services;
+
+import java.io.IOException;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.List;
+
+public enum RetryReason {
+ CONNECTION_TIMEOUT(((exceptionCaptured, statusCode) -> {
+ return exceptionCaptured != null && "connect timed out".equalsIgnoreCase(
+ exceptionCaptured.getMessage());
+ }), 2, "CT"),
+ READ_TIMEOUT(((exceptionCaptured, statusCode) -> {
+ return exceptionCaptured != null && "Read timed out".equalsIgnoreCase(
+ exceptionCaptured.getMessage());
+ }), 2, "RT"),
+ UNKNOWN_HOST("UH"),
+ CONNECTION_RESET(((exceptionCaptured, statusCode) -> {
+ return exceptionCaptured != null && exceptionCaptured.getMessage() != null
+ && exceptionCaptured.getMessage().contains("Connection reset");
+ }), 2, "CR"),
+ STATUS_5XX(((exceptionCaptured, statusCode) -> {
+ return statusCode / 100 == 5;
+ }), 0, ((ex, statusCode, serverErrorMessage) -> {
+ if (statusCode == 503) {
+ //ref:
https://github.com/apache/hadoop/pull/4564/files#diff-75a2f54df6618d4015c63812e6a9916ddfb475d246850edfd2a6f57e36805e79
+ serverErrorMessage = serverErrorMessage.split(System.lineSeparator(),
+ 2)[0];
+ if ("Ingress is over the account limit.".equalsIgnoreCase(
+ serverErrorMessage)) {
+ return "ING";
+ }
+ if ("Egress is over the account limit.".equalsIgnoreCase(
+ serverErrorMessage)) {
+ return "EGR";
+ }
+ if ("Operations per second is over the account limit.".equalsIgnoreCase(
+ serverErrorMessage)) {
+ return "OPR";
+ }
+ return "503";
+ }
+ return statusCode + "";
+ })),
+ STATUS_4XX(((exceptionCaptured, statusCode) -> {
+ return statusCode / 100 == 4;
+ }), 0, ((ex, statusCode, serverErrorMessage) -> {
+ return statusCode + "";
+ })),
+ UNKNOWN_SOCKET_EXCEPTION(((exceptionCaptured, statusCode) -> {
+ return exceptionCaptured instanceof SocketException;
+ }), 1, "SE"),
+ UNKNOWN_IO_EXCEPTION(((exceptionCaptured, statusCode) -> {
+ return exceptionCaptured instanceof IOException;
+ }), 0, "IOE");
+
+ private RetryReasonCaptureMechanism mechanism = null;
Review Comment:
We can avoid the use of these interfaces by directly using a single
constructor. This complicates the logic.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]