You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bo...@apache.org on 2016/12/06 18:51:30 UTC

geode git commit: GEODE-2174: Added message for clients who unregister abnormally

Repository: geode
Updated Branches:
  refs/heads/develop 18d3e17b6 -> f403ae7cf


GEODE-2174: Added message for clients who unregister abnormally


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

Branch: refs/heads/develop
Commit: f403ae7cf3ef2ef3babccc561765bed824d6306a
Parents: 18d3e17
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Mon Nov 28 18:17:32 2016 -0800
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Tue Dec 6 10:42:48 2016 -0800

----------------------------------------------------------------------
 .../cache/tier/sockets/BaseCommand.java         |  5 ++++
 .../cache/tier/sockets/BaseCommandQuery.java    |  1 +
 .../cache/tier/sockets/CacheClientProxy.java    |  8 +++---
 .../cache/tier/sockets/ClientHealthMonitor.java | 27 +++++++++++++-------
 .../cache/tier/sockets/ServerConnection.java    | 11 +++++++-
 .../tier/sockets/command/DestroyRegion.java     |  2 ++
 .../sockets/command/GatewayReceiverCommand.java |  2 ++
 .../geode/internal/i18n/LocalizedStrings.java   |  3 +++
 8 files changed, 45 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f403ae7c/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java
index c51868a..5379605 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java
@@ -305,6 +305,7 @@ public abstract class BaseCommand implements Command {
       }
     }
     servConn.setFlagProcessMessagesAsFalse();
+    servConn.setClientDisconnectedException(eof);
   }
 
   private static void handleInterruptedIOException(Message msg, ServerConnection servConn,
@@ -317,6 +318,7 @@ public abstract class BaseCommand implements Command {
       }
     }
     servConn.setFlagProcessMessagesAsFalse();
+    servConn.setClientDisconnectedException(e);
   }
 
   private static void handleIOException(Message msg, ServerConnection servConn, Exception e) {
@@ -339,6 +341,7 @@ public abstract class BaseCommand implements Command {
       }
     }
     servConn.setFlagProcessMessagesAsFalse();
+    servConn.setClientDisconnectedException(e);
   }
 
   private static void handleShutdownException(Message msg, ServerConnection servConn, Exception e) {
@@ -359,6 +362,7 @@ public abstract class BaseCommand implements Command {
       }
     }
     servConn.setFlagProcessMessagesAsFalse();
+    servConn.setClientDisconnectedException(e);
   }
 
   // Handle GemfireSecurityExceptions separately since the connection should not
@@ -499,6 +503,7 @@ public abstract class BaseCommand implements Command {
       }
     } finally {
       servConn.setFlagProcessMessagesAsFalse();
+      servConn.setClientDisconnectedException(th);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f403ae7c/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommandQuery.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommandQuery.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommandQuery.java
index 24711e4..5f7a8ef 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommandQuery.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommandQuery.java
@@ -271,6 +271,7 @@ public abstract class BaseCommandQuery extends BaseCommand {
             servConn.getName(), MessageType.getString(msg.getMessageType()), servConn.getProxyID());
       }
       servConn.setFlagProcessMessagesAsFalse();
+      servConn.setClientDisconnectedException(se);
       return false;
     } catch (Exception e) {
       // If an interrupted exception is thrown , rethrow it

http://git-wip-us.apache.org/repos/asf/geode/blob/f403ae7c/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
index 5ec34fc..6e31fe5 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
@@ -2585,7 +2585,7 @@ public class CacheClientProxy implements ClientSession {
               // See isAlive().
               // getProxy().close(false);
 
-              pauseOrUnregisterProxy();
+              pauseOrUnregisterProxy(e);
             } // _isStopped
           } // synchronized
           exceptionOccured = true;
@@ -2700,7 +2700,7 @@ public class CacheClientProxy implements ClientSession {
 
     }
 
-    private void pauseOrUnregisterProxy() {
+    private void pauseOrUnregisterProxy(Throwable t) {
       if (getProxy().isDurable()) {
         try {
           getProxy().pauseDispatching();
@@ -2727,7 +2727,7 @@ public class CacheClientProxy implements ClientSession {
       // been caught and here, so the _proxy will be null.
       if (chm != null) {
         ClientProxyMembershipID proxyID = getProxy().proxyID;
-        chm.removeAllConnectionsAndUnregisterClient(proxyID);
+        chm.removeAllConnectionsAndUnregisterClient(proxyID, t);
         if (!getProxy().isDurable()) {
           getProxy().getCacheClientNotifier().unregisterClient(proxyID, false);
         }
@@ -2917,7 +2917,7 @@ public class CacheClientProxy implements ClientSession {
                 LocalizedMessage.create(
                     LocalizedStrings.CacheClientProxy_0__AN_UNEXPECTED_EXCEPTION_OCCURRED, this),
                 e);
-            pauseOrUnregisterProxy();
+            pauseOrUnregisterProxy(e);
           }
         }
       } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/geode/blob/f403ae7c/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java
index 2202124..e21a834 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java
@@ -202,7 +202,8 @@ public class ClientHealthMonitor {
    * 
    * @param proxyID The id of the client to be unregistered
    */
-  private void unregisterClient(ClientProxyMembershipID proxyID) {
+  private void unregisterClient(ClientProxyMembershipID proxyID, boolean clientDisconnectedCleanly,
+      Throwable clientDisconnectException) {
     boolean unregisterClient = false;
     synchronized (_clientHeartbeatsLock) {
       Map oldClientHeartbeats = this._clientHeartbeats;
@@ -215,10 +216,17 @@ public class ClientHealthMonitor {
     }
 
     if (unregisterClient) {
-      if (logger.isDebugEnabled()) {
-        logger.debug(LocalizedMessage.create(
-            LocalizedStrings.ClientHealthMonitor_CLIENTHEALTHMONITOR_UNREGISTERING_CLIENT_WITH_MEMBER_ID_0,
-            new Object[] {proxyID}));
+      if (clientDisconnectedCleanly) {
+        if (logger.isDebugEnabled()) {
+          logger.debug(LocalizedMessage.create(
+              LocalizedStrings.ClientHealthMonitor_CLIENTHEALTHMONITOR_UNREGISTERING_CLIENT_WITH_MEMBER_ID_0,
+              new Object[] {proxyID}));
+        }
+      } else {
+        logger.warn(LocalizedMessage.create(
+            LocalizedStrings.ClientHealthMonitor_CLIENTHEALTHMONITOR_UNREGISTERING_CLIENT_WITH_MEMBER_ID_0_DUE_TO_1,
+            new Object[] {proxyID, clientDisconnectException == null ? "Unknown reason"
+                : clientDisconnectException.getLocalizedMessage()}));
       }
       if (this.stats != null) {
         this.stats.incClientUnRegisterRequests();
@@ -236,8 +244,8 @@ public class ClientHealthMonitor {
    * @param clientDisconnectedCleanly Whether the client disconnected cleanly or crashed
    */
   public void unregisterClient(ClientProxyMembershipID proxyID, AcceptorImpl acceptor,
-      boolean clientDisconnectedCleanly) {
-    unregisterClient(proxyID);
+      boolean clientDisconnectedCleanly, Throwable clientDisconnectException) {
+    unregisterClient(proxyID, clientDisconnectedCleanly, clientDisconnectException);
     // Unregister any CacheClientProxy instances associated with this member id
     // if this method was invoked from a ServerConnection and the client did
     // not disconnect cleanly.
@@ -302,11 +310,12 @@ public class ClientHealthMonitor {
     }
   }
 
-  public void removeAllConnectionsAndUnregisterClient(ClientProxyMembershipID proxyID) {
+  public void removeAllConnectionsAndUnregisterClient(ClientProxyMembershipID proxyID,
+      Throwable t) {
     // Remove all connections
     cleanupClientThreads(proxyID, false);
 
-    unregisterClient(proxyID);
+    unregisterClient(proxyID, false, t);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/f403ae7c/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
index 7e915f2..59b0fa4 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
@@ -691,6 +691,7 @@ public class ServerConnection implements Runnable {
   private boolean doHandshake = true;
 
   private boolean clientDisconnectedCleanly = false;
+  private Throwable clientDisconnectedException;
   private int failureCount = 0;
   private boolean processMessages = true;
 
@@ -804,6 +805,9 @@ public class ServerConnection implements Runnable {
 
   // package access allowed so AcceptorImpl can call
   void handleTermination() {
+    if (this.crHelper.isShutdown()) {
+      setClientDisconnectCleanly();
+    }
     handleTermination(false);
   }
 
@@ -886,7 +890,7 @@ public class ServerConnection implements Runnable {
         this.acceptor.getClientHealthMonitor().removeConnection(this.proxyId, this);
         if (unregisterClient) {
           this.acceptor.getClientHealthMonitor().unregisterClient(this.proxyId, getAcceptor(),
-              this.clientDisconnectedCleanly);
+              this.clientDisconnectedCleanly, this.clientDisconnectedException);
         }
       }
     }
@@ -1138,6 +1142,7 @@ public class ServerConnection implements Runnable {
       } catch (IOException ex) {
         logger.warn(
             LocalizedMessage.create(LocalizedStrings.ServerConnection_0__UNEXPECTED_EXCEPTION, ex));
+        setClientDisconnectedException(ex);
       } finally {
         getAcceptor().releaseCommBuffer(Message.setTLCommBuffer(null));
         // DistributedSystem.releaseThreadsSockets();
@@ -1853,4 +1858,8 @@ public class ServerConnection implements Runnable {
   public void setClientDisconnectCleanly() {
     this.clientDisconnectedCleanly = true;
   }
+
+  public void setClientDisconnectedException(Throwable e) {
+    this.clientDisconnectedException = e;
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f403ae7c/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegion.java
index e69747b..13fef02 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegion.java
@@ -78,6 +78,7 @@ public class DestroyRegion extends BaseCommand {
         }
 
         servConn.setFlagProcessMessagesAsFalse();
+        servConn.setClientDisconnectedException(se);
         return;
       } catch (Exception e) {
         writeException(msg, e, false, servConn);
@@ -146,6 +147,7 @@ public class DestroyRegion extends BaseCommand {
               servConn.getProxyID());
         }
         servConn.setFlagProcessMessagesAsFalse();
+        servConn.setClientDisconnectedException(e);
       } else {
         writeException(msg, e, false, servConn);
         servConn.setAsTrue(RESPONDED);

http://git-wip-us.apache.org/repos/asf/geode/blob/f403ae7c/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GatewayReceiverCommand.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
index cb5c9dc..54140bd 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
@@ -490,6 +490,7 @@ public class GatewayReceiverCommand extends BaseCommand {
                         servConn.getProxyID());
                   }
                   servConn.setFlagProcessMessagesAsFalse();
+                  servConn.setClientDisconnectedException(e);
                 } else {
                   throw e;
                 }
@@ -683,6 +684,7 @@ public class GatewayReceiverCommand extends BaseCommand {
               servConn.getProxyID());
         }
         servConn.setFlagProcessMessagesAsFalse();
+        servConn.setClientDisconnectedException(e);
         return;
       } catch (Exception e) {
         // If an interrupted exception is thrown , rethrow it

http://git-wip-us.apache.org/repos/asf/geode/blob/f403ae7c/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
index fc59922..10e64cd 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
@@ -399,6 +399,9 @@ public class LocalizedStrings {
   public static final StringId DiskRegion_COMPLEXDISKREGIONGETNEXTDIR_MAX_DIRECTORY_SIZE_WILL_GET_VIOLATED__GOING_AHEAD_WITH_THE_SWITCHING_OF_OPLOG_ANY_WAYS_CURRENTLY_AVAILABLE_SPACE_IN_THE_DIRECTORY_IS__0__THE_CAPACITY_OF_DIRECTORY_IS___1 =
       new StringId(1200,
           "Even though the configured directory size limit has been exceeded a new oplog will be created because compaction is enabled. The configured limit is {1}. The current space used in the directory by this disk store is {0}.");
+  public static final StringId ClientHealthMonitor_CLIENTHEALTHMONITOR_UNREGISTERING_CLIENT_WITH_MEMBER_ID_0_DUE_TO_1 =
+      new StringId(1201,
+          "ClientHealthMonitor: Unregistering client with member id {0} due to: {1}");
 
   public static final StringId AttributesFactory_CLONENOTSUPPORTEDEXCEPTION_THROWN_IN_CLASS_THAT_IMPLEMENTS_CLONEABLE =
       new StringId(1213, "CloneNotSupportedException thrown in class that implements cloneable.");