HADOOP-8116. RetriableCommand is using RetryPolicy incorrectly after HADOOP-7896. Contributed by Aaron T. Myers.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1294729 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Aaron Myers 2012-02-28 16:51:55 +00:00
parent 586bd479cb
commit dcd2056e46
3 changed files with 18 additions and 3 deletions

View File

@ -49,3 +49,5 @@ core-default.xml file. (Uma Maheswara Rao G via atm)
HADOOP-8041. Log a warning when a failover is first attempted (todd) HADOOP-8041. Log a warning when a failover is first attempted (todd)
HADOOP-8068. void methods can swallow exceptions when going through failover path (todd) HADOOP-8068. void methods can swallow exceptions when going through failover path (todd)
HADOOP-8116. RetriableCommand is using RetryPolicy incorrectly after HADOOP-7896. (atm)

View File

@ -22,7 +22,9 @@
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.io.retry.RetryPolicy; import org.apache.hadoop.io.retry.RetryPolicy;
import org.apache.hadoop.io.retry.RetryPolicy.RetryAction;
import org.apache.hadoop.io.retry.RetryPolicies; import org.apache.hadoop.io.retry.RetryPolicies;
import org.apache.hadoop.util.ThreadUtil;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -80,7 +82,7 @@ public RetriableCommand(String description, RetryPolicy retryPolicy) {
public Object execute(Object... arguments) throws Exception { public Object execute(Object... arguments) throws Exception {
Exception latestException; Exception latestException;
int counter = 0; int counter = 0;
do { while (true) {
try { try {
return doExecute(arguments); return doExecute(arguments);
} catch(Exception exception) { } catch(Exception exception) {
@ -88,7 +90,13 @@ public Object execute(Object... arguments) throws Exception {
latestException = exception; latestException = exception;
} }
counter++; counter++;
} while (retryPolicy.shouldRetry(latestException, counter, 0, true).equals(RetryPolicy.RetryAction.RETRY)); RetryAction action = retryPolicy.shouldRetry(latestException, counter, 0, true);
if (action.action == RetryPolicy.RetryAction.RetryDecision.RETRY) {
ThreadUtil.sleepAtLeastIgnoreInterrupts(action.delayMillis);
} else {
break;
}
}
throw new IOException("Couldn't run retriable-command: " + description, throw new IOException("Couldn't run retriable-command: " + description,
latestException); latestException);

View File

@ -545,7 +545,12 @@ public Integer run() {
Assert.fail("Didn't expect the file to be copied"); Assert.fail("Didn't expect the file to be copied");
} catch (AccessControlException ignore) { } catch (AccessControlException ignore) {
} catch (Exception e) { } catch (Exception e) {
if (e.getCause() == null || !(e.getCause() instanceof AccessControlException)) { // We want to make sure the underlying cause of the exception is
// due to permissions error. The exception we're interested in is
// wrapped twice - once in RetriableCommand and again in CopyMapper
// itself.
if (e.getCause() == null || e.getCause().getCause() == null ||
!(e.getCause().getCause() instanceof AccessControlException)) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }