hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1294729 - in /hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src: main/java/org/apache/hadoop/tools/util/RetriableCommand.java test/java/org/apache/hadoop/tools/mapred/TestCopyMapper.java
Date Tue, 28 Feb 2012 16:51:56 GMT
Author: atm
Date: Tue Feb 28 16:51:55 2012
New Revision: 1294729

URL: http://svn.apache.org/viewvc?rev=1294729&view=rev
Log:
HADOOP-8116. RetriableCommand is using RetryPolicy incorrectly after HADOOP-7896. Contributed
by Aaron T. Myers.

Modified:
    hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/RetriableCommand.java
    hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/mapred/TestCopyMapper.java

Modified: hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/RetriableCommand.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/RetriableCommand.java?rev=1294729&r1=1294728&r2=1294729&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/RetriableCommand.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/RetriableCommand.java
Tue Feb 28 16:51:55 2012
@@ -22,7 +22,9 @@ package org.apache.hadoop.tools.util;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 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.util.ThreadUtil;
 
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
@@ -80,7 +82,7 @@ public abstract class RetriableCommand {
   public Object execute(Object... arguments) throws Exception {
     Exception latestException;
     int counter = 0;
-    do {
+    while (true) {
       try {
         return doExecute(arguments);
       } catch(Exception exception) {
@@ -88,7 +90,13 @@ public abstract class RetriableCommand {
         latestException = exception;
       }
       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,
                           latestException);

Modified: hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/mapred/TestCopyMapper.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/mapred/TestCopyMapper.java?rev=1294729&r1=1294728&r2=1294729&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/mapred/TestCopyMapper.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/mapred/TestCopyMapper.java
Tue Feb 28 16:51:55 2012
@@ -545,7 +545,12 @@ public class TestCopyMapper {
             Assert.fail("Didn't expect the file to be copied");
           } catch (AccessControlException ignore) {
           } 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);
             }
           }



Mime
View raw message