hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From whe...@apache.org
Subject svn commit: r1574717 - in /hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common: ./ src/main/java/org/apache/hadoop/io/retry/ src/test/java/org/apache/hadoop/io/retry/
Date Wed, 05 Mar 2014 23:12:22 GMT
Author: wheat9
Date: Wed Mar  5 23:12:22 2014
New Revision: 1574717

URL: http://svn.apache.org/r1574717
Log:
Merge r1574716 from trunk.

Modified:
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/DefaultFailoverProxyProvider.java
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/FailoverProxyProvider.java
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1574717&r1=1574716&r2=1574717&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Wed Mar
 5 23:12:22 2014
@@ -64,6 +64,9 @@ Release 2.4.0 - UNRELEASED
     HADOOP-10211. Enable RPC protocol to negotiate SASL-QOP values between
     clients and servers. (Benoy Antony via Arpit Agarwal)
 
+    HADOOP-10386. Log proxy hostname in various exceptions being thrown in a HA
+    setup. (wheat9)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/DefaultFailoverProxyProvider.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/DefaultFailoverProxyProvider.java?rev=1574717&r1=1574716&r2=1574717&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/DefaultFailoverProxyProvider.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/DefaultFailoverProxyProvider.java
Wed Mar  5 23:12:22 2014
@@ -43,8 +43,8 @@ public class DefaultFailoverProxyProvide
   }
 
   @Override
-  public T getProxy() {
-    return proxy;
+  public ProxyInfo<T> getProxy() {
+    return new ProxyInfo<T>(proxy, null);
   }
 
   @Override

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/FailoverProxyProvider.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/FailoverProxyProvider.java?rev=1574717&r1=1574716&r2=1574717&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/FailoverProxyProvider.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/FailoverProxyProvider.java
Wed Mar  5 23:12:22 2014
@@ -30,6 +30,18 @@ import org.apache.hadoop.classification.
  */
 @InterfaceStability.Evolving
 public interface FailoverProxyProvider<T> extends Closeable {
+  public static final class ProxyInfo<T> {
+    public final T proxy;
+    /*
+     * The information (e.g., the IP address) of the current proxy object. It
+     * provides information for debugging purposes.
+     */
+    public final String proxyInfo;
+    public ProxyInfo(T proxy, String proxyInfo) {
+      this.proxy = proxy;
+      this.proxyInfo = proxyInfo;
+    }
+  }
 
   /**
    * Get the proxy object which should be used until the next failover event
@@ -37,14 +49,14 @@ public interface FailoverProxyProvider<T
    * 
    * @return the proxy object to invoke methods upon
    */
-  public T getProxy();
+  public ProxyInfo<T> getProxy();
 
   /**
    * Called whenever the associated {@link RetryPolicy} determines that an error
    * warrants failing over.
    * 
-   * @param currentProxy the proxy object which was being used before this
-   *        failover event
+   * @param currentProxy
+   *          the proxy object which was being used before this failover event
    */
   public void performFailover(T currentProxy);
 

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java?rev=1574717&r1=1574716&r2=1574717&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
Wed Mar  5 23:12:22 2014
@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.io.retry.FailoverProxyProvider.ProxyInfo;
 import org.apache.hadoop.io.retry.RetryPolicy.RetryAction;
 import org.apache.hadoop.ipc.Client;
 import org.apache.hadoop.ipc.Client.ConnectionId;
@@ -57,7 +58,7 @@ public class RetryInvocationHandler<T> i
   
   private final RetryPolicy defaultPolicy;
   private final Map<String,RetryPolicy> methodNameToPolicyMap;
-  private T currentProxy;
+  private ProxyInfo<T> currentProxy;
 
   protected RetryInvocationHandler(FailoverProxyProvider<T> proxyProvider,
       RetryPolicy retryPolicy) {
@@ -83,7 +84,7 @@ public class RetryInvocationHandler<T> i
     
     // The number of times this method invocation has been failed over.
     int invocationFailoverCount = 0;
-    final boolean isRpc = isRpcInvocation(currentProxy);
+    final boolean isRpc = isRpcInvocation(currentProxy.proxy);
     final int callId = isRpc? Client.nextCallId(): RpcConstants.INVALID_CALL_ID;
     int retries = 0;
     while (true) {
@@ -115,9 +116,9 @@ public class RetryInvocationHandler<T> i
             invocationFailoverCount, isIdempotentOrAtMostOnce);
         if (action.action == RetryAction.RetryDecision.FAIL) {
           if (action.reason != null) {
-            LOG.warn("Exception while invoking " + 
-                currentProxy.getClass() + "." + method.getName() +
-                ". Not retrying because " + action.reason, e);
+            LOG.warn("Exception while invoking " + currentProxy.proxy.getClass()
+                + "." + method.getName() + " over " + currentProxy.proxyInfo
+                + ". Not retrying because " + action.reason, e);
           }
           throw e;
         } else { // retry or failover
@@ -130,7 +131,9 @@ public class RetryInvocationHandler<T> i
           if (action.action == RetryAction.RetryDecision.FAILOVER_AND_RETRY &&
               worthLogging) {
             String msg = "Exception while invoking " + method.getName()
-              + " of class " + currentProxy.getClass().getSimpleName();
+                + " of class " + currentProxy.proxy.getClass().getSimpleName()
+                + " over " + currentProxy.proxyInfo;
+
             if (invocationFailoverCount > 0) {
               msg += " after " + invocationFailoverCount + " fail over attempts"; 
             }
@@ -141,8 +144,9 @@ public class RetryInvocationHandler<T> i
           } else {
             if(LOG.isDebugEnabled()) {
               LOG.debug("Exception while invoking " + method.getName()
-                  + " of class " + currentProxy.getClass().getSimpleName() +
-                  ". Retrying " + formatSleepMessage(action.delayMillis), e);
+                  + " of class " + currentProxy.proxy.getClass().getSimpleName()
+                  + " over " + currentProxy.proxyInfo + ". Retrying "
+                  + formatSleepMessage(action.delayMillis), e);
             }
           }
           
@@ -155,7 +159,7 @@ public class RetryInvocationHandler<T> i
             // single actual fail over.
             synchronized (proxyProvider) {
               if (invocationAttemptFailoverCount == proxyProviderFailoverCount) {
-                proxyProvider.performFailover(currentProxy);
+                proxyProvider.performFailover(currentProxy.proxy);
                 proxyProviderFailoverCount++;
                 currentProxy = proxyProvider.getProxy();
               } else {
@@ -183,7 +187,7 @@ public class RetryInvocationHandler<T> i
       if (!method.isAccessible()) {
         method.setAccessible(true);
       }
-      return method.invoke(currentProxy, args);
+      return method.invoke(currentProxy.proxy, args);
     } catch (InvocationTargetException e) {
       throw e.getCause();
     }
@@ -208,7 +212,7 @@ public class RetryInvocationHandler<T> i
 
   @Override //RpcInvocationHandler
   public ConnectionId getConnectionId() {
-    return RPC.getConnectionIdForProxy(currentProxy);
+    return RPC.getConnectionIdForProxy(currentProxy.proxy);
   }
 
 }

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java?rev=1574717&r1=1574716&r2=1574717&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java
Wed Mar  5 23:12:22 2014
@@ -48,8 +48,8 @@ public class TestFailoverProxy {
     }
     
     @Override
-    public T getProxy() {
-      return currentlyActive;
+    public ProxyInfo<T> getProxy() {
+      return new ProxyInfo<T>(currentlyActive, currentlyActive.toString());
     }
 
     @Override

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java?rev=1574717&r1=1574716&r2=1574717&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java
Wed Mar  5 23:12:22 2014
@@ -22,7 +22,7 @@ import java.io.IOException;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.ipc.StandbyException;
 
-public class UnreliableImplementation implements UnreliableInterface {
+class UnreliableImplementation implements UnreliableInterface {
 
   private int failsOnceInvocationCount,
     failsOnceWithValueInvocationCount,
@@ -154,6 +154,11 @@ public class UnreliableImplementation im
     }
   }
 
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "[" + identifier + "]";
+  }
+
   private static void throwAppropriateException(TypeOfExceptionToFailWith eType,
       String message) throws UnreliableException, StandbyException, IOException {
     switch (eType) {



Mime
View raw message