Repository: kudu
Updated Branches:
  refs/heads/master f907db137 -> b7e2089f8


KUDU-1771. Java client "connection refused" errors logged as
"connection reset"

This commit changes cleanup() to accepts a string input.
It allows a caller to customize its error message based
on the caller site context.

Change-Id: If9eb40f11757ae76bc430b3f513b96592068d6e2
Reviewed-on: http://gerrit.cloudera.org:8080/5680
Tested-by: Kudu Jenkins
Reviewed-by: Jean-Daniel Cryans <jdcry...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/ef710cd0
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/ef710cd0
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/ef710cd0

Branch: refs/heads/master
Commit: ef710cd00c3fa93ab63c175ed32e946ca057702e
Parents: f907db1
Author: Jun He <junhe...@gmail.com>
Authored: Tue Jan 10 23:36:31 2017 -0800
Committer: Jean-Daniel Cryans <jdcry...@apache.org>
Committed: Fri Jan 13 16:32:35 2017 +0000

----------------------------------------------------------------------
 .../java/org/apache/kudu/client/TabletClient.java | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/ef710cd0/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java
----------------------------------------------------------------------
diff --git 
a/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java 
b/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java
index eb6adf0..4550751 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java
@@ -680,7 +680,7 @@ public class TabletClient extends 
ReplayingDecoder<VoidEnum> {
                                   final ChannelStateEvent e) throws Exception {
     chan = null;
     super.channelDisconnected(ctx, e);  // Let the ReplayingDecoder cleanup.
-    cleanup(e.getChannel());
+    cleanup("Connection disconnected");
   }
 
   @Override
@@ -691,7 +691,7 @@ public class TabletClient extends 
ReplayingDecoder<VoidEnum> {
     // super.channelDisconnected().  If we get here without getting a
     // DISCONNECTED event, then we were never connected in the first place so
     // the ReplayingDecoder has nothing to cleanup.
-    cleanup(e.getChannel());
+    cleanup("Connection closed");
   }
 
   /**
@@ -699,8 +699,10 @@ public class TabletClient extends 
ReplayingDecoder<VoidEnum> {
    * <p>
    * All RPCs in flight will fail with a {@link RecoverableException} and
    * all edits buffered will be re-scheduled.
+   *
+   * @param errorMessage string to describe the cause of cleanup
    */
-  private void cleanup(final Channel chan) {
+  private void cleanup(final String errorMessage) {
     final ArrayList<KuduRpc<?>> rpcs;
 
     // The timing of this block is critical. If this TabletClient is 'dead' 
then it means that
@@ -725,8 +727,8 @@ public class TabletClient extends 
ReplayingDecoder<VoidEnum> {
 
       pendingRpcs = null;
     }
-    Status statusNetworkError =
-        Status.NetworkError(getPeerUuidLoggingString() + "Connection reset");
+    Status statusNetworkError = Status.NetworkError(getPeerUuidLoggingString() 
+
+        (errorMessage == null ? "Connection reset" : errorMessage));
     RecoverableException exception = new 
RecoverableException(statusNetworkError);
 
     failOrRetryRpcs(rpcs, exception);
@@ -794,9 +796,9 @@ public class TabletClient extends 
ReplayingDecoder<VoidEnum> {
       gotUncaughtException = true;
     }
     if (c.isOpen()) {
-      Channels.close(c);  // Will trigger channelClosed(), which will cleanup()
-    } else {              // else: presumably a connection timeout.
-      cleanup(c);         // => need to cleanup() from here directly.
+      Channels.close(c);        // Will trigger channelClosed(), which will 
cleanup()
+    } else {                    // else: presumably a connection timeout.
+      cleanup(e.getMessage());  // => need to cleanup() from here directly.
     }
   }
 

Reply via email to