-
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
Changes from 32 commits
e70429c
2ddd8c9
cc2deb2
eece65f
40adc3e
77c9d21
b5d176b
c980762
34fe029
7acee90
b7d7121
1c3f2ee
9201ab7
77eb790
32e69cb
7f77ead
90fce12
06af705
62179bc
270545d
de424e3
94810b8
dad7b61
ac5593e
77aaa01
c49ab44
e1d38a0
e37d2e2
8c4ac80
9799dba
75594b9
e3ba294
836a352
a2a9a62
e312898
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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; | ||
| } | ||
| } | ||
| 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"; | ||
| } |
| 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 | ||
| public 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 | ||
| public String getAbbreviation(final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return statusCode + ""; | ||
| } | ||
| } |
| 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 | ||
| public Boolean canCapture(final Exception ex, | ||
| final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return checkExceptionMessage(ex, CONNECTION_RESET_MESSAGE); | ||
| } | ||
|
|
||
| @Override | ||
| public String getAbbreviation(final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return CONNECTION_RESET_ABBREVIATION; | ||
| } | ||
| } |
| 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 | ||
| public String getAbbreviation(final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return CONNECTION_TIMEOUT_ABBREVIATION; | ||
| } | ||
|
|
||
| @Override | ||
| public Boolean canCapture(final Exception ex, | ||
| final Integer statusCode, | ||
| final String serverErrorMessage) { | ||
| return checkExceptionMessage(ex, CONNECTION_TIMEOUT_JDK_MESSAGE); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.