forked from apache/hadoop
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#64 from saxenapranav/ABFS_3.3.2_dev_retry_r…
…eason Retry-reason in x-ms-client-request-id
- Loading branch information
Showing
20 changed files
with
1,227 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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.