-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-18606. Add reason in in x-ms-client-request-id on a retry API call. #5299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
e70429c
retryReason foundations.
saxenapranav 2ddd8c9
send failureReasons for adding in x-ms-client-request-id
saxenapranav cc2deb2
added heuristics in RetryReason
saxenapranav eece65f
fixed test for connect timed out
saxenapranav 40adc3e
testabfsrestOperation: to add 5xx tests
saxenapranav 77c9d21
test added
saxenapranav b5d176b
test: testClientRequestIdForConnectAndReadTimeoutRetry
saxenapranav c980762
small refactors
saxenapranav 34fe029
removed non-required capture interface
saxenapranav 7acee90
ASF license; javadocs on the interface.
saxenapranav b7d7121
minimize TestAbfsRestOperation class with added methods for common te…
saxenapranav 1c3f2ee
added javadocs in RetryReason
saxenapranav 9201ab7
removal of non-required new-lines
saxenapranav 77eb790
small refactors
saxenapranav 32e69cb
checkstyle: magic number
saxenapranav 7f77ead
review refactors
saxenapranav 90fce12
review WIP
saxenapranav 06af705
removing enums and having classes with implementation of RetryReasonA…
saxenapranav 62179bc
method change in RetryReasonAbbreviationCreator
saxenapranav 270545d
asf license
saxenapranav de424e3
javadocs + small refactors
saxenapranav 94810b8
fixed access modifier, only public method in abstract class is captur…
saxenapranav dad7b61
javadoc for RetryReason; package name change
saxenapranav ac5593e
RetryReasonConstants
saxenapranav 77aaa01
asf license in RetryReasonConstants
saxenapranav c49ab44
constants in TestAbfsRestOperationMockFailures
saxenapranav e1d38a0
TestRetryReason
saxenapranav e37d2e2
javadocs wip
saxenapranav 8c4ac80
javadocs on retry-categories
saxenapranav 9799dba
javadoc fix in the RetryReasonCategory
saxenapranav 75594b9
Merge pull request #4 from saxenapranav/retry_reason_review2
saxenapranav e3ba294
checkstyle issue
saxenapranav 836a352
canCapture and getAbbreviation to be package-protected and not public
saxenapranav a2a9a62
review comments
saxenapranav e312898
Merge branch 'trunk' into retry_reason
saxenapranav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/RetryReason.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.hadoop.fs.azurebfs.services; | ||
|
|
||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
|
|
||
| import org.apache.hadoop.fs.azurebfs.services.retryReasonCategories.ClientErrorRetryReason; | ||
| import org.apache.hadoop.fs.azurebfs.services.retryReasonCategories.ConnectionResetRetryReason; | ||
| import org.apache.hadoop.fs.azurebfs.services.retryReasonCategories.ConnectionTimeoutRetryReason; | ||
| import org.apache.hadoop.fs.azurebfs.services.retryReasonCategories.ReadTimeoutRetryReason; | ||
| import org.apache.hadoop.fs.azurebfs.services.retryReasonCategories.RetryReasonCategory; | ||
| import org.apache.hadoop.fs.azurebfs.services.retryReasonCategories.ServerErrorRetryReason; | ||
| import org.apache.hadoop.fs.azurebfs.services.retryReasonCategories.UnknownHostRetryReason; | ||
| import org.apache.hadoop.fs.azurebfs.services.retryReasonCategories.UnknownIOExceptionRetryReason; | ||
| import org.apache.hadoop.fs.azurebfs.services.retryReasonCategories.UnknownSocketExceptionRetryReason; | ||
|
|
||
|
|
||
| /** | ||
| * This utility class exposes methods to convert a server response-error to a | ||
| * category of error. | ||
| */ | ||
| final class RetryReason { | ||
|
|
||
| /** | ||
| * Linked-list of the implementations of RetryReasonCategory. The objects in the | ||
| * list are arranged by the rank of their significance. | ||
| * <ul> | ||
| * <li>ServerError (statusCode==5XX), ClientError (statusCode==4XX) are | ||
| * independent of other retryReason categories.</li> | ||
| * <li>Since {@link java.net.SocketException} is subclass of | ||
| * {@link java.io.IOException}, | ||
| * hence, {@link UnknownIOExceptionRetryReason} is placed before | ||
| * {@link UnknownSocketExceptionRetryReason}</li> | ||
| * <li>Since, connectionTimeout, readTimeout, and connectionReset are | ||
| * {@link java.net.SocketTimeoutException} exceptions with different messages, | ||
| * hence, {@link ConnectionTimeoutRetryReason}, {@link ReadTimeoutRetryReason}, | ||
| * {@link ConnectionResetRetryReason} are above {@link UnknownIOExceptionRetryReason}. | ||
| * There is no order between the three reasons as they are differentiated | ||
| * by exception-message.</li> | ||
| * <li>Since, {@link java.net.UnknownHostException} is subclass of | ||
| * {@link java.io.IOException}, {@link UnknownHostRetryReason} is placed | ||
| * over {@link UnknownIOExceptionRetryReason}</li> | ||
| * </ul> | ||
| */ | ||
| private static List<RetryReasonCategory> rankedReasonCategories | ||
| = new LinkedList<RetryReasonCategory>() {{ | ||
| add(new ServerErrorRetryReason()); | ||
| add(new ClientErrorRetryReason()); | ||
| add(new UnknownIOExceptionRetryReason()); | ||
| add(new UnknownSocketExceptionRetryReason()); | ||
| add(new ConnectionTimeoutRetryReason()); | ||
| add(new ReadTimeoutRetryReason()); | ||
| add(new UnknownHostRetryReason()); | ||
| add(new ConnectionResetRetryReason()); | ||
| }}; | ||
|
|
||
| private RetryReason() { | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Method to get correct abbreviation for a given set of exception, statusCode, | ||
| * storageStatusCode. | ||
| * | ||
| * @param ex exception caught during server communication. | ||
| * @param statusCode statusCode in the server response. | ||
| * @param storageErrorMessage storageErrorMessage in the server response. | ||
| * | ||
| * @return abbreviation for the the given set of exception, statusCode, storageStatusCode. | ||
| */ | ||
| static String getAbbreviation(Exception ex, | ||
| Integer statusCode, | ||
| String storageErrorMessage) { | ||
| String result = null; | ||
| for (RetryReasonCategory retryReasonCategory : rankedReasonCategories) { | ||
| final String abbreviation | ||
| = retryReasonCategory.captureAndGetAbbreviation(ex, | ||
| statusCode, storageErrorMessage); | ||
| if (abbreviation != null) { | ||
| result = abbreviation; | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
...doop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/RetryReasonConstants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.hadoop.fs.azurebfs.services; | ||
|
|
||
| public final class RetryReasonConstants { | ||
|
|
||
| private RetryReasonConstants() { | ||
|
|
||
| } | ||
| public static final String CONNECTION_TIMEOUT_JDK_MESSAGE = "connect timed out"; | ||
| public static final String READ_TIMEOUT_JDK_MESSAGE = "Read timed out"; | ||
| public static final String CONNECTION_RESET_MESSAGE = "Connection reset"; | ||
| public static final String OPERATION_BREACH_MESSAGE = "Operations per second is over the account limit."; | ||
| public static final String CONNECTION_RESET_ABBREVIATION = "CR"; | ||
| public static final String CONNECTION_TIMEOUT_ABBREVIATION = "CT"; | ||
| public static final String READ_TIMEOUT_ABBREVIATION = "RT"; | ||
| public static final String INGRESS_LIMIT_BREACH_ABBREVIATION = "ING"; | ||
| public static final String EGRESS_LIMIT_BREACH_ABBREVIATION = "EGR"; | ||
| public static final String OPERATION_LIMIT_BREACH_ABBREVIATION = "OPR"; | ||
| public static final String UNKNOWN_HOST_EXCEPTION_ABBREVIATION = "UH"; | ||
| public static final String IO_EXCEPTION_ABBREVIATION = "IOE"; | ||
| public static final String SOCKET_EXCEPTION_ABBREVIATION = "SE"; | ||
| } |
43 changes: 43 additions & 0 deletions
43
.../org/apache/hadoop/fs/azurebfs/services/retryReasonCategories/ClientErrorRetryReason.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.hadoop.fs.azurebfs.services.retryReasonCategories; | ||
|
|
||
| import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.HTTP_STATUS_CATEGORY_QUOTIENT; | ||
|
|
||
| /** | ||
| * Category that can capture server-response errors for 4XX status-code. | ||
| */ | ||
| public class ClientErrorRetryReason extends RetryReasonCategory { | ||
|
|
||
| @Override | ||
| Boolean canCapture(final Exception ex, | ||
| final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| if (statusCode == null || statusCode / HTTP_STATUS_CATEGORY_QUOTIENT != 4) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| String getAbbreviation(final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return statusCode + ""; | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
.../apache/hadoop/fs/azurebfs/services/retryReasonCategories/ConnectionResetRetryReason.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.hadoop.fs.azurebfs.services.retryReasonCategories; | ||
|
|
||
| import static org.apache.hadoop.fs.azurebfs.services.RetryReasonConstants.CONNECTION_RESET_ABBREVIATION; | ||
| import static org.apache.hadoop.fs.azurebfs.services.RetryReasonConstants.CONNECTION_RESET_MESSAGE; | ||
|
|
||
| /** | ||
| * Category that can capture server-response errors for connection-reset exception. | ||
| */ | ||
| public class ConnectionResetRetryReason extends | ||
| RetryReasonCategory { | ||
|
|
||
| @Override | ||
| Boolean canCapture(final Exception ex, | ||
| final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return checkExceptionMessage(ex, CONNECTION_RESET_MESSAGE); | ||
| } | ||
|
|
||
| @Override | ||
| String getAbbreviation(final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return CONNECTION_RESET_ABBREVIATION; | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
...pache/hadoop/fs/azurebfs/services/retryReasonCategories/ConnectionTimeoutRetryReason.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.hadoop.fs.azurebfs.services.retryReasonCategories; | ||
|
|
||
|
|
||
| import static org.apache.hadoop.fs.azurebfs.services.RetryReasonConstants.CONNECTION_TIMEOUT_ABBREVIATION; | ||
| import static org.apache.hadoop.fs.azurebfs.services.RetryReasonConstants.CONNECTION_TIMEOUT_JDK_MESSAGE; | ||
|
|
||
| /** | ||
| * Category that can capture server-response errors for connection-timeout. | ||
| */ | ||
| public class ConnectionTimeoutRetryReason extends | ||
| RetryReasonCategory { | ||
|
|
||
| @Override | ||
| String getAbbreviation(final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return CONNECTION_TIMEOUT_ABBREVIATION; | ||
| } | ||
|
|
||
| @Override | ||
| Boolean canCapture(final Exception ex, | ||
| final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return checkExceptionMessage(ex, CONNECTION_TIMEOUT_JDK_MESSAGE); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.