geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [3/8] incubator-geode git commit: GEODE-708: Add stats for Geode membership health monitor
Date Mon, 04 Jan 2016 17:04:39 GMT
GEODE-708: Add stats for Geode membership health monitor


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

Branch: refs/heads/feature/GEODE-715
Commit: 91b438971a33b444c8de826bb18a3fc2cff4f8b4
Parents: 81eafcc
Author: Jianxia Chen <jchen@pivotal.io>
Authored: Tue Dec 29 09:38:43 2015 -0800
Committer: Jianxia Chen <jchen@pivotal.io>
Committed: Tue Dec 29 09:38:43 2015 -0800

----------------------------------------------------------------------
 .../gemfire/distributed/internal/DMStats.java   |  80 +++++++
 .../distributed/internal/DistributionStats.java | 237 +++++++++++++++++++
 .../internal/LonerDistributionManager.java      |  64 +++++
 .../membership/gms/fd/GMSHealthMonitor.java     |  93 +++++---
 .../gms/fd/GMSHealthMonitorJUnitTest.java       |  42 +++-
 5 files changed, 482 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b43897/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
index e79a40b..7bf5b80 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
@@ -536,4 +536,84 @@ public interface DMStats {
 
   public void endPdxInstanceDeserialization(long start);
   public void incPdxInstanceCreations();
+  
+  //Stats for GMSHealthMonitor
+  public long getHeartbeatRequestsSent();
+  
+  public void incHeartbeatRequestsSent();
+  
+  public long getHeartbeatRequestsReceived();
+  
+  public void incHeartbeatRequestsReceived();
+  
+  public long getHeartbeatsSent();
+  
+  public void incHeartbeatsSent();
+
+  public long getHeartbeatsReceived();
+  
+  public void incHeartbeatsReceived();
+  
+
+  public long getSuspectsSent();
+  
+  public void incSuspectsSent();
+
+  public long getSuspectsReceived();
+  
+  public void incSuspectsReceived();
+  
+  
+  public long getFinalCheckRequestsSent();
+  
+  public void incFinalCheckRequestsSent();
+  
+  public long getFinalCheckRequestsReceived();
+  
+  public void incFinalCheckRequestsReceived();
+  
+  public long getFinalCheckResponsesSent();
+  
+  public void incFinalCheckResponsesSent();
+  
+  public long getFinalCheckResponsesReceived();
+  
+  public void incFinalCheckResponsesReceived();
+  
+  
+  public long getTcpFinalCheckRequestsSent();
+  
+  public void incTcpFinalCheckRequestsSent();
+
+  public long getTcpFinalCheckRequestsReceived();
+  
+  public void incTcpFinalCheckRequestsReceived();
+  
+  public long getTcpFinalCheckResponsesSent();
+  
+  public void incTcpFinalCheckResponsesSent();
+
+  public long getTcpFinalCheckResponsesReceived();
+  
+  public void incTcpFinalCheckResponsesReceived();
+
+  
+  public long getUdpFinalCheckRequestsSent();
+  
+  public void incUdpFinalCheckRequestsSent();
+  
+//  UDP final check is implemented using HeartbeatRequestMessage and HeartbeatMessage
+//  So the following code is commented out.
+  
+//  public long getUdpFinalCheckRequestsReceived();
+//  
+//  public void incUdpFinalCheckRequestsReceived();
+//  
+//  public long getUdpFinalCheckResponsesSent();
+//  
+//  public void incUdpFinalCheckResponsesSent();
+
+  public long getUdpFinalCheckResponsesReceived();
+  
+  public void incUdpFinalCheckResponsesReceived();
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b43897/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
index 804b507..92b0fcb 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
@@ -215,6 +215,26 @@ public class DistributionStats implements DMStats {
   private final static int eldersId;
   private final static int initialImageMessagesInFlightId;
   private final static int initialImageRequestsInProgressId;
+  
+  //For GMSHealthMonitor
+  private final static int heartbeatRequestsSentId;  
+  private final static int heartbeatRequestsReceivedId;  
+  private final static int heartbeatsSentId;  
+  private final static int heartbeatsReceivedId;  
+  private final static int suspectsSentId;  
+  private final static int suspectsReceivedId;
+  private final static int finalCheckRequestsSentId;  
+  private final static int finalCheckRequestsReceivedId;  
+  private final static int finalCheckResponsesSentId;  
+  private final static int finalCheckResponsesReceivedId;  
+  private final static int tcpFinalCheckRequestsSentId; 
+  private final static int tcpFinalCheckRequestsReceivedId;  
+  private final static int tcpFinalCheckResponsesSentId;  
+  private final static int tcpFinalCheckResponsesReceivedId;
+  private final static int udpFinalCheckRequestsSentId;
+  private final static int udpFinalCheckRequestsReceivedId;
+  private final static int udpFinalCheckResponsesSentId;
+  private final static int udpFinalCheckResponsesReceivedId;
 
   static {
     String statName = "DistributionStats";
@@ -317,6 +337,33 @@ public class DistributionStats implements DMStats {
     final String initialImageMessagesInFlightDesc = "The number of messages with initial
image data sent from this member that have not yet been acknowledged.";
     final String initialImageRequestsInProgressDesc = "The number of initial images this
member is currently receiving.";
 
+    //For GMSHealthMonitor
+    final String heartbeatRequestsSentDesc = "The number of heartbeat request messages that
this member has sent.";
+    final String heartbeatRequestsReceivedDesc = "The number of heartbeat request messages
that this member has received.";
+    
+    final String heartbeatsSentDesc = "The number of heartbeat messages that this member
has sent.";
+    final String heartbeatsReceivedDesc = "The number of heartbeat messages that this member
has received.";
+    
+    final String suspectsSentDesc = "The number of suspect member messages that this member
has sent.";
+    final String suspectsReceivedDesc = "The number of suspect member messages that this
member has received.";
+    
+    final String finalCheckRequestsSentDesc = "The number of final check requests that this
member has sent.";
+    final String finalCheckRequestsReceivedDesc = "The number of final check requests that
this member has received.";
+    
+    final String finalCheckResponsesSentDesc = "The number of final check responses that
this member has sent.";
+    final String finalCheckResponsesReceivedDesc = "The number of final check responses that
this member has received.";    
+    
+    final String tcpFinalCheckRequestsSentDesc = "The number of TCP final check requests
that this member has sent.";
+    final String tcpFinalCheckRequestsReceivedDesc = "The number of TCP final check requests
that this member has received.";
+    
+    final String tcpFinalCheckResponsesSentDesc = "The number of TCP final check responses
that this member has sent.";
+    final String tcpFinalCheckResponsesReceivedDesc = "The number of TCP final check responses
that this member has received.";
+
+    final String udpFinalCheckRequestsSentDesc = "The number of UDP final checks that this
member has sent.";
+    final String udpFinalCheckRequestsReceivedDesc = "The number of UDP final check requests
that this member has received.";
+    
+    final String udpFinalCheckResponsesSentDesc = "The number of UDP final check responses
that this member has sent.";
+    final String udpFinalCheckResponsesReceivedDesc = "The number of UDP final check responses
that this member has received.";
 
     StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
 
@@ -486,6 +533,26 @@ public class DistributionStats implements DMStats {
         f.createIntGauge("elders", eldersDesc, "elders"),
         f.createIntGauge("initialImageMessagesInFlight", initialImageMessagesInFlightDesc,
"messages"),
         f.createIntGauge("initialImageRequestsInProgress", initialImageRequestsInProgressDesc,
"requests"),
+        
+        //For GMSHealthMonitor
+        f.createLongCounter("heartbeatRequestsSent", heartbeatRequestsSentDesc, "messages"),
+        f.createLongCounter("heartbeatRequestsReceived", heartbeatRequestsReceivedDesc, "messages"),
+        f.createLongCounter("heartbeatsSent", heartbeatsSentDesc, "messages"),
+        f.createLongCounter("heartbeatsReceived", heartbeatsReceivedDesc, "messages"),
+        f.createLongCounter("suspectsSent", suspectsSentDesc, "messages"),
+        f.createLongCounter("suspectsReceived", suspectsReceivedDesc, "messages"),
+        f.createLongCounter("finalCheckRequestsSent", finalCheckRequestsSentDesc, "messages"),
+        f.createLongCounter("finalCheckRequestsReceived", finalCheckRequestsReceivedDesc,
"messages"),
+        f.createLongCounter("finalCheckResponsesSent", finalCheckResponsesSentDesc, "messages"),
+        f.createLongCounter("finalCheckResponsesReceived", finalCheckResponsesReceivedDesc,
"messages"),
+        f.createLongCounter("tcpFinalCheckRequestsSent", tcpFinalCheckRequestsSentDesc, "nanoseconds",
false),
+        f.createLongCounter("tcpFinalCheckRequestsReceived", tcpFinalCheckRequestsReceivedDesc,
"nanoseconds", false),
+        f.createLongCounter("tcpFinalCheckResponsesSent", tcpFinalCheckResponsesSentDesc,
"nanoseconds", false),
+        f.createLongCounter("tcpFinalCheckResponsesReceived", tcpFinalCheckResponsesReceivedDesc,
"nanoseconds", false),
+        f.createLongCounter("udpFinalCheckRequestsSent", udpFinalCheckRequestsSentDesc, "messages"),
+        f.createLongCounter("udpFinalCheckRequestsReceived", udpFinalCheckRequestsReceivedDesc,
"messages"),
+        f.createLongCounter("udpFinalCheckResponsesSent", udpFinalCheckResponsesSentDesc,
"messages"),
+        f.createLongCounter("udpFinalCheckResponsesReceived", udpFinalCheckResponsesReceivedDesc,
"messages"),
       }
     );
 
@@ -654,6 +721,26 @@ public class DistributionStats implements DMStats {
     eldersId = type.nameToId("elders");
     initialImageMessagesInFlightId = type.nameToId("initialImageMessagesInFlight");
     initialImageRequestsInProgressId = type.nameToId("initialImageRequestsInProgress");
+    
+    //For GMSHealthMonitor
+    heartbeatRequestsSentId = type.nameToId("heartbeatRequestsSent");
+    heartbeatRequestsReceivedId = type.nameToId("heartbeatRequestsReceived");
+    heartbeatsSentId = type.nameToId("heartbeatsSent");
+    heartbeatsReceivedId = type.nameToId("heartbeatsReceived");
+    suspectsSentId = type.nameToId("suspectsSent");
+    suspectsReceivedId = type.nameToId("suspectsReceived");
+    finalCheckRequestsSentId = type.nameToId("finalCheckRequestsSent");
+    finalCheckRequestsReceivedId = type.nameToId("finalCheckRequestsReceived");
+    finalCheckResponsesSentId = type.nameToId("finalCheckResponsesSent");
+    finalCheckResponsesReceivedId = type.nameToId("finalCheckResponsesReceived");
+    tcpFinalCheckRequestsSentId = type.nameToId("tcpFinalCheckRequestsSent");
+    tcpFinalCheckRequestsReceivedId = type.nameToId("tcpFinalCheckRequestsReceived");
+    tcpFinalCheckResponsesSentId = type.nameToId("tcpFinalCheckResponsesSent");
+    tcpFinalCheckResponsesReceivedId = type.nameToId("tcpFinalCheckResponsesReceived");
+    udpFinalCheckRequestsSentId = type.nameToId("udpFinalCheckRequestsSent");
+    udpFinalCheckRequestsReceivedId = type.nameToId("udpFinalCheckRequestsReceived");
+    udpFinalCheckResponsesSentId = type.nameToId("udpFinalCheckResponsesSent");
+    udpFinalCheckResponsesReceivedId = type.nameToId("udpFinalCheckResponsesReceived");
   }
 
   /** The Statistics object that we delegate most behavior to */
@@ -1811,4 +1898,154 @@ public class DistributionStats implements DMStats {
   public Statistics getStats(){
     return stats;
   }
+  
+  //For GMSHealthMonitor
+  public long getHeartbeatRequestsSent() {
+    return this.stats.getLong(heartbeatRequestsSentId);
+  }
+  
+  public void incHeartbeatRequestsSent() {
+    this.stats.incLong(heartbeatRequestsSentId, 1L);
+  }
+  
+  public long getHeartbeatRequestsReceived() {
+    return this.stats.getLong(heartbeatRequestsReceivedId);
+  }
+  
+  public void incHeartbeatRequestsReceived() {
+    this.stats.incLong(heartbeatRequestsReceivedId, 1L);
+  }
+  
+  public long getHeartbeatsSent() {
+    return this.stats.getLong(heartbeatsSentId);
+  }
+  
+  public void incHeartbeatsSent() {
+    this.stats.incLong(heartbeatsSentId, 1L);
+  }
+  
+  public long getHeartbeatsReceived() {
+    return this.stats.getLong(heartbeatsReceivedId);
+  }
+  
+  public void incHeartbeatsReceived() {
+    this.stats.incLong(heartbeatsReceivedId, 1L);
+  }
+  
+  public long getSuspectsSent() {
+    return this.stats.getLong(suspectsSentId);
+  }
+  
+  public void incSuspectsSent() {
+    this.stats.incLong(suspectsSentId, 1L);
+  }
+
+  public long getSuspectsReceived() {
+    return this.stats.getLong(suspectsReceivedId);
+  }
+  
+  public void incSuspectsReceived() {
+    this.stats.incLong(suspectsReceivedId, 1L);
+  }
+  
+  public long getFinalCheckRequestsSent() {
+    return this.stats.getLong(finalCheckRequestsSentId);
+  }
+  
+  public void incFinalCheckRequestsSent() {
+    this.stats.incLong(finalCheckRequestsSentId, 1L);
+  }
+  
+  public long getFinalCheckRequestsReceived() {
+    return this.stats.getLong(finalCheckRequestsReceivedId);
+  }
+  
+  public void incFinalCheckRequestsReceived() {
+    this.stats.incLong(finalCheckRequestsReceivedId, 1L);
+  }
+  
+  public long getFinalCheckResponsesSent() {
+    return this.stats.getLong(finalCheckResponsesSentId);
+  }
+  
+  public void incFinalCheckResponsesSent() {
+    this.stats.incLong(finalCheckResponsesSentId, 1L);
+  }
+  
+  public long getFinalCheckResponsesReceived() {
+    return this.stats.getLong(finalCheckResponsesReceivedId);
+  }
+  
+  public void incFinalCheckResponsesReceived() {
+    this.stats.incLong(finalCheckResponsesReceivedId, 1L);
+  }
+  
+///
+  public long getTcpFinalCheckRequestsSent() {
+    return this.stats.getLong(tcpFinalCheckRequestsSentId);
+  }
+  
+  public void incTcpFinalCheckRequestsSent() {
+    this.stats.incLong(tcpFinalCheckRequestsSentId, 1L);
+  }
+  
+  public long getTcpFinalCheckRequestsReceived() {
+    return this.stats.getLong(tcpFinalCheckRequestsReceivedId);
+  }
+  
+  public void incTcpFinalCheckRequestsReceived() {
+    this.stats.incLong(tcpFinalCheckRequestsReceivedId, 1L);
+  }
+  
+  public long getTcpFinalCheckResponsesSent() {
+    return this.stats.getLong(tcpFinalCheckResponsesSentId);
+  }
+  
+  public void incTcpFinalCheckResponsesSent() {
+    this.stats.incLong(tcpFinalCheckResponsesSentId, 1L);
+  }
+  
+  public long getTcpFinalCheckResponsesReceived() {
+    return this.stats.getLong(tcpFinalCheckResponsesReceivedId);
+  }
+  
+  public void incTcpFinalCheckResponsesReceived() {
+    this.stats.incLong(tcpFinalCheckResponsesReceivedId, 1L);
+  }
+ 
+///
+  public long getUdpFinalCheckRequestsSent() {
+    return this.stats.getLong(udpFinalCheckRequestsSentId);
+  }
+  
+  public void incUdpFinalCheckRequestsSent() {
+    this.stats.incLong(udpFinalCheckRequestsSentId, 1L);
+  }
+
+//  UDP final check is implemented using HeartbeatRequestMessage and HeartbeatMessage
+//  So the following code is commented out  
+//  public long getUdpFinalCheckRequestsReceived() {
+//    return this.stats.getLong(udpFinalCheckRequestsReceivedId);
+//  }
+//  
+//  public void incUdpFinalCheckRequestsReceived() {
+//    this.stats.incLong(udpFinalCheckRequestsReceivedId, 1L);
+//  }
+//  
+//  public long getUdpFinalCheckResponsesSent() {
+//    return this.stats.getLong(udpFinalCheckResponsesSentId);
+//  }
+//  
+//  public void incUdpFinalCheckResponsesSent() {
+//    this.stats.incLong(udpFinalCheckResponsesSentId, 1L);
+//  }
+  
+  public long getUdpFinalCheckResponsesReceived() {
+    return this.stats.getLong(udpFinalCheckResponsesReceivedId);
+  }
+  
+  public void incUdpFinalCheckResponsesReceived() {
+    this.stats.incLong(udpFinalCheckResponsesReceivedId, 1L);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b43897/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
index 60158d1..b55fe88 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
@@ -573,6 +573,70 @@ public class LonerDistributionManager implements DM {
     @Override
     public void incThreadOwnedReceivers(long value, int dominoCount) {
     }
+    @Override
+    public long getHeartbeatRequestsSent() {return 0;}
+    @Override
+    public void incHeartbeatRequestsSent() {}
+    @Override
+    public long getHeartbeatRequestsReceived() {return 0;}
+    @Override
+    public void incHeartbeatRequestsReceived() {}
+    @Override
+    public long getHeartbeatsSent() {return 0;}
+    @Override
+    public void incHeartbeatsSent() {}
+    @Override
+    public long getHeartbeatsReceived() {return 0;}
+    @Override
+    public void incHeartbeatsReceived() {}
+    @Override
+    public long getSuspectsSent() {return 0;}
+    @Override
+    public void incSuspectsSent() {}
+    @Override
+    public long getSuspectsReceived() {return 0;}
+    @Override
+    public void incSuspectsReceived() {}
+    @Override
+    public long getFinalCheckRequestsSent() {return 0;}
+    @Override
+    public void incFinalCheckRequestsSent() {}
+    @Override
+    public long getFinalCheckRequestsReceived() {return 0;}
+    @Override
+    public void incFinalCheckRequestsReceived() {}
+    @Override
+    public long getFinalCheckResponsesSent() {return 0;}
+    @Override
+    public void incFinalCheckResponsesSent() {}
+    @Override
+    public long getFinalCheckResponsesReceived() {return 0;}
+    @Override
+    public void incFinalCheckResponsesReceived() {}
+    @Override    
+    public long getTcpFinalCheckRequestsSent() {return 0;}
+    @Override
+    public void incTcpFinalCheckRequestsSent() {}
+    @Override
+    public long getTcpFinalCheckRequestsReceived() {return 0;}
+    @Override
+    public void incTcpFinalCheckRequestsReceived() {}
+    @Override
+    public long getTcpFinalCheckResponsesSent() {return 0;}
+    @Override
+    public void incTcpFinalCheckResponsesSent() {}
+    @Override
+    public long getTcpFinalCheckResponsesReceived() {return 0;}
+    @Override
+    public void incTcpFinalCheckResponsesReceived() {}
+    @Override
+    public long getUdpFinalCheckRequestsSent() {return 0;}
+    @Override
+    public void incUdpFinalCheckRequestsSent() {}
+    @Override
+    public long getUdpFinalCheckResponsesReceived() {return 0;}
+    @Override
+    public void incUdpFinalCheckResponsesReceived() {}
   }
   protected static class DummyExecutor implements ExecutorService {
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b43897/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
index 005b0ed..b6f6c12 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
@@ -32,7 +32,6 @@ import java.net.SocketTimeoutException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -59,6 +58,7 @@ import com.gemstone.gemfire.GemFireConfigException;
 import com.gemstone.gemfire.SystemConnectException;
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
+import com.gemstone.gemfire.distributed.internal.DMStats;
 import com.gemstone.gemfire.distributed.internal.DistributionMessage;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.distributed.internal.membership.NetView;
@@ -139,10 +139,10 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
    */
   final private ConcurrentHashMap<InternalDistributedMember, NetView> suspectedMemberInView
= new ConcurrentHashMap<>();
   
-  /**
-   * Members undergoing final checks
-   */
-  final private List<InternalDistributedMember> membersInFinalCheck = Collections.synchronizedList(new
ArrayList<>(30));
+//  /**
+//   * Members undergoing final checks
+//   */
+//  final private List<InternalDistributedMember> membersInFinalCheck = Collections.synchronizedList(new
ArrayList<>(30));
 
   /**
    * Replies to messages
@@ -175,6 +175,9 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
   static final int ERROR = 0x00;  
   private volatile int socketPort;
   private volatile ServerSocket serverSocket;
+  
+  /** Statistics about health monitor */
+  protected DMStats stats;
 
   /**
    * this class is to avoid garbage
@@ -282,6 +285,8 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
         int  vmViewId = in.readInt();
         long uuidLSBs = in.readLong();
         long uuidMSBs = in.readLong();
+        GMSHealthMonitor.this.stats.incFinalCheckRequestsReceived();
+        GMSHealthMonitor.this.stats.incTcpFinalCheckRequestsReceived();
         boolean debug = logger.isDebugEnabled();
         GMSMember gmbr = (GMSMember) GMSHealthMonitor.this.localAddress.getNetMember();
         UUID myUUID = gmbr.getUUID();
@@ -311,6 +316,8 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
           out.write(OK);
           out.flush();
           socket.shutdownOutput();
+          GMSHealthMonitor.this.stats.incFinalCheckResponsesSent();
+          GMSHealthMonitor.this.stats.incTcpFinalCheckResponsesSent();
           if (debug) {
             logger.debug("GMSHealthMonitor server socket replied OK.");
           }
@@ -320,6 +327,8 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
           out.write(ERROR);
           out.flush();
           socket.shutdownOutput();
+          GMSHealthMonitor.this.stats.incFinalCheckResponsesSent();
+          GMSHealthMonitor.this.stats.incTcpFinalCheckResponsesSent();
           if (debug) {
             logger.debug("GMSHealthMonitor server socket replied ERROR.");
           }
@@ -358,9 +367,9 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
   public void contactedBy(InternalDistributedMember sender) {
     TimeStamp cTS = new TimeStamp(currentTimeStamp);
     cTS = memberTimeStamps.putIfAbsent(sender, cTS);
-    if (cTS != null) {
-      cTS.setTimeStamp(currentTimeStamp);
-    }
+//    if (cTS != null) {
+//      cTS.setTimeStamp(currentTimeStamp);
+//    }
     if (suspectedMemberInView.remove(sender) != null) {
       logger.info("No longer suspecting {}", sender);
     }
@@ -369,10 +378,10 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
 
   private HeartbeatRequestMessage constructHeartbeatRequestMessage(final InternalDistributedMember
mbr) {
     final int reqId = requestId.getAndIncrement();
-    final HeartbeatRequestMessage prm = new HeartbeatRequestMessage(mbr, reqId);
-    prm.setRecipient(mbr);
+    final HeartbeatRequestMessage hrm = new HeartbeatRequestMessage(mbr, reqId);
+    hrm.setRecipient(mbr);
 
-    return prm;
+    return hrm;
   }
 
   private void checkMember(final InternalDistributedMember mbr) {
@@ -424,11 +433,12 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
       return true;
     }
     logger.trace("Checking member {}", member);
-    final HeartbeatRequestMessage prm = constructHeartbeatRequestMessage(member);
+    final HeartbeatRequestMessage hrm = constructHeartbeatRequestMessage(member);
     final Response pingResp = new Response();
-    requestIdVsResponse.put(prm.getRequestId(), pingResp);
+    requestIdVsResponse.put(hrm.getRequestId(), pingResp);
     try {
-      Set<InternalDistributedMember> membersNotReceivedMsg = this.services.getMessenger().send(prm);
+      Set<InternalDistributedMember> membersNotReceivedMsg = this.services.getMessenger().send(hrm);
+      this.stats.incHeartbeatRequestsSent();
       if (membersNotReceivedMsg != null && membersNotReceivedMsg.contains(member))
{
         // member is not part of current view.
         logger.trace("Member {} is not part of current view.", member);
@@ -446,6 +456,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
             return false;
           } else {
             logger.trace("received heartbeat from {}", member);
+            this.stats.incHeartbeatsReceived();
             if (ts != null) {
               ts.setTimeStamp(System.currentTimeMillis());
             }
@@ -456,7 +467,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
     } catch (InterruptedException e) {
       logger.debug("GMSHealthMonitor checking thread interrupted, while waiting for response
from member: {} .", member);
     } finally {
-      requestIdVsResponse.remove(prm.getRequestId());
+      requestIdVsResponse.remove(hrm.getRequestId());
     }
     return false;
   }
@@ -502,8 +513,12 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
         GMSMember gmbr = (GMSMember) suspectMember.getNetMember();
         writeMemberToStream(gmbr, out);
         clientSocket.shutdownOutput();
+        this.stats.incFinalCheckRequestsSent();
+        this.stats.incTcpFinalCheckRequestsSent();
         logger.debug("Connected - reading response from suspect member {}", suspectMember);
         int b = in.read();
+        this.stats.incFinalCheckResponsesReceived();
+        this.stats.incTcpFinalCheckResponsesReceived();
         logger.debug("Received {}", (b == OK ? "OK" : (b == ERROR ? "ERROR" : b)), suspectMember);
         if (b == OK) {
           TimeStamp ts = memberTimeStamps.get(suspectMember);
@@ -535,12 +550,6 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
     out.flush();
   }
   
-  /*
-   * (non-Javadoc)
-   * 
-   * @see com.gemstone.gemfire.distributed.internal.membership.gms.fd.HealthMonitor#suspectMember(com.gemstone.gemfire.distributed.DistributedMember,
-   * java.lang.String)
-   */
   @Override
   public void suspect(InternalDistributedMember mbr, String reason) {
     initiateSuspicion(mbr, reason);
@@ -722,6 +731,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
               return;
             }
             services.getMessenger().sendUnreliably(message);
+            GMSHealthMonitor.this.stats.incHeartbeatsSent();
           } catch (CancelException e) {
             return;
           }
@@ -748,6 +758,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
           message.setRecipient(mbr);
           try {
             services.getMessenger().sendUnreliably(message);
+            GMSHealthMonitor.this.stats.incHeartbeatsSent();
             numSent++;
             if (numSent >= NUM_HEARTBEATS) {
               break;
@@ -843,11 +854,12 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
     isStopping = false;
     services = s;
     memberTimeout = s.getConfig().getMemberTimeout();
+    this.stats = services.getStatistics();
     services.getMessenger().addHandler(HeartbeatRequestMessage.class, this);
     services.getMessenger().addHandler(HeartbeatMessage.class, this);
     services.getMessenger().addHandler(SuspectMembersMessage.class, this);
   }
-
+  
   @Override
   public void started() {
     setLocalAddress( services.getMessenger().getMemberID());
@@ -993,6 +1005,8 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
 
   private void processHeartbeatRequest(HeartbeatRequestMessage m) {
     
+    this.stats.incHeartbeatRequestsReceived();
+    
     if (this.isStopping || this.playingDead) {
       return;
     }
@@ -1001,9 +1015,10 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
     InternalDistributedMember me = localAddress;
 
     if (me.getVmViewId() >= 0  &&  m.getTarget().equals(me)) {
-      HeartbeatMessage prm = new HeartbeatMessage(m.getRequestId());
-      prm.setRecipient(m.getSender());
-      Set<InternalDistributedMember> membersNotReceivedMsg = services.getMessenger().send(prm);
+      HeartbeatMessage hm = new HeartbeatMessage(m.getRequestId());
+      hm.setRecipient(m.getSender());
+      Set<InternalDistributedMember> membersNotReceivedMsg = services.getMessenger().send(hm);
+      this.stats.incHeartbeatsSent();
       if (membersNotReceivedMsg != null && membersNotReceivedMsg.contains(m.getSender()))
{
         logger.debug("Unable to send heartbeat to member: {}", m.getSender());
       }
@@ -1013,6 +1028,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
   }
 
   private void processHeartbeat(HeartbeatMessage m) {
+    this.stats.incHeartbeatsReceived();
     if (m.getRequestId() < 0) {
       // a periodic heartbeat
       contactedBy(m.getSender());
@@ -1037,6 +1053,9 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
    * @param incomingRequest
    */
   private void processSuspectMembersRequest(SuspectMembersMessage incomingRequest) {
+    
+    this.stats.incSuspectsReceived();
+    
     NetView cv = currentView;
 
     if (cv == null) {
@@ -1062,6 +1081,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
           message.setRecipient(sender);
           try {
             services.getMessenger().send(message);
+            this.stats.incHeartbeatsSent();
             it.remove();
           } catch (CancelException e) {
             return;
@@ -1132,13 +1152,13 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
   private void doFinalCheck(final InternalDistributedMember initiator,
       List<SuspectRequest> sMembers, NetView cv, InternalDistributedMember localAddress)
{
 
-    List<InternalDistributedMember> membersChecked = new ArrayList<>(10);
+//    List<InternalDistributedMember> membersChecked = new ArrayList<>(10);
     try {
       for (int i = 0; i < sMembers.size(); i++) {
         final SuspectRequest sr = sMembers.get(i);
         final InternalDistributedMember mbr = sr.getSuspectMember();
 
-        if (!cv.contains(mbr) || membersInFinalCheck.contains(mbr)) {
+        if (!cv.contains(mbr) /*|| membersInFinalCheck.contains(mbr)*/) {
           continue;
         }
 
@@ -1146,7 +1166,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
           continue;// self
         }
         
-        membersChecked.add(mbr);
+//        membersChecked.add(mbr);
 
         // suspectMemberInView is now set by the heartbeat monitoring code
         // to allow us to move on from watching members we've already
@@ -1181,6 +1201,12 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
                   logger.debug("\ncurrent view: {}\nports: {}", view, Arrays.toString(view.getFailureDetectionPorts()));
                 }
                 pinged = GMSHealthMonitor.this.doCheckMember(mbr);
+                GMSHealthMonitor.this.stats.incFinalCheckRequestsSent();
+                GMSHealthMonitor.this.stats.incUdpFinalCheckRequestsSent();
+                if (pinged) {
+                  GMSHealthMonitor.this.stats.incFinalCheckResponsesReceived();
+                  GMSHealthMonitor.this.stats.incUdpFinalCheckResponsesReceived();
+                }
               } else {
                 pinged = GMSHealthMonitor.this.doTCPCheckMember(mbr, port);
               }
@@ -1214,7 +1240,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
         //      }// scheduling for final check and removing it..
       }
     } finally {
-      membersInFinalCheck.removeAll(membersChecked);
+//      membersInFinalCheck.removeAll(membersChecked);
     }
   }
   @Override
@@ -1253,10 +1279,11 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
       recipients = currentView.getMembers();
 //    }
 
-    SuspectMembersMessage rmm = new SuspectMembersMessage(recipients, requests);
+    SuspectMembersMessage smm = new SuspectMembersMessage(recipients, requests);
     Set<InternalDistributedMember> failedRecipients;
     try {
-      failedRecipients = services.getMessenger().send(rmm);
+      failedRecipients = services.getMessenger().send(smm);
+      this.stats.incSuspectsSent();
     } catch (CancelException e) {
       return;
     }
@@ -1299,4 +1326,8 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler
{
     }
     
   }
+  
+  public DMStats getStats() {
+    return this.stats;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b43897/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
index d539374..82ac316 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
@@ -39,6 +39,7 @@ import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Properties;
 
 import org.jgroups.util.UUID;
 import org.junit.After;
@@ -49,8 +50,11 @@ import org.junit.experimental.categories.Category;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
+import com.gemstone.gemfire.distributed.internal.DM;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.DistributionManager;
+import com.gemstone.gemfire.distributed.internal.DistributionStats;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.distributed.internal.membership.NetView;
 import com.gemstone.gemfire.distributed.internal.membership.gms.GMSMember;
@@ -80,6 +84,7 @@ public class GMSHealthMonitorJUnitTest {
   private JoinLeave joinLeave;
   private GMSHealthMonitor gmsHealthMonitor;
   private Manager manager;
+  private long statsId = 123;
   final long memberTimeout = 1000l;
   private int[] portRange= new int[]{0, 65535};
 
@@ -92,7 +97,20 @@ public class GMSHealthMonitorJUnitTest {
     joinLeave = mock(JoinLeave.class);
     manager = mock(Manager.class);
     services = mock(Services.class);
-    Stopper stopper = mock(Stopper.class);
+    Stopper stopper = mock(Stopper.class); 
+    
+    Properties nonDefault = new Properties();
+    nonDefault.put(DistributionConfig.ACK_WAIT_THRESHOLD_NAME, "1");
+    nonDefault.put(DistributionConfig.ACK_SEVERE_ALERT_THRESHOLD_NAME, "10");
+    nonDefault.put(DistributionConfig.DISABLE_TCP_NAME, "true");
+    nonDefault.put(DistributionConfig.MCAST_PORT_NAME, "0");
+    nonDefault.put(DistributionConfig.MCAST_TTL_NAME, "0");
+    nonDefault.put(DistributionConfig.LOG_FILE_NAME, "");
+    nonDefault.put(DistributionConfig.LOG_LEVEL_NAME, "fine");
+    nonDefault.put(DistributionConfig.MEMBER_TIMEOUT_NAME, "2000");
+    nonDefault.put(DistributionConfig.LOCATORS_NAME, "localhost[10344]");
+    DM dm = mock(DM.class);    
+    InternalDistributedSystem system = InternalDistributedSystem.newInstanceForTesting(dm,
nonDefault);
 
     when(mockConfig.getDistributionConfig()).thenReturn(mockDistConfig);
     when(mockConfig.getMemberTimeout()).thenReturn(memberTimeout);
@@ -102,8 +120,8 @@ public class GMSHealthMonitorJUnitTest {
     when(services.getJoinLeave()).thenReturn(joinLeave);
     when(services.getCancelCriterion()).thenReturn(stopper);
     when(services.getManager()).thenReturn(manager);
+    when(services.getStatistics()).thenReturn(new DistributionStats(system, statsId));
     when(stopper.isCancelInProgress()).thenReturn(false);
-    
 
     if (mockMembers == null) {
       mockMembers = new ArrayList<InternalDistributedMember>();
@@ -142,6 +160,8 @@ public class GMSHealthMonitorJUnitTest {
 
     gmsHealthMonitor.processMessage(new HeartbeatRequestMessage(mbr, 1));
     verify(messenger, atLeastOnce()).send(any(HeartbeatMessage.class));
+    Assert.assertEquals(1, gmsHealthMonitor.getStats().getHeartbeatRequestsReceived());
+    Assert.assertEquals(1, gmsHealthMonitor.getStats().getHeartbeatsSent());
   }
 
   /**
@@ -187,7 +207,7 @@ public class GMSHealthMonitorJUnitTest {
     // neighbor should change to 5th
     System.out.println("testHMNextNeighborAfterTimeout ending");
     Assert.assertEquals("expected " + expected + " but found " + neighbor
-        + ".  view="+v, expected, neighbor);
+        + ".  view="+v, expected, neighbor);  
   }
 
   /**
@@ -239,6 +259,8 @@ public class GMSHealthMonitorJUnitTest {
 
     System.out.println("testSuspectMembersCalledThroughMemberCheckThread ending");
     assertTrue(gmsHealthMonitor.isSuspectMember(mockMembers.get(4)));
+    Assert.assertTrue(gmsHealthMonitor.getStats().getHeartbeatRequestsSent() > 0);
+    Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsSent() > 0);
   }
 
   /***
@@ -282,6 +304,8 @@ public class GMSHealthMonitorJUnitTest {
     Thread.sleep(GMSHealthMonitor.MEMBER_SUSPECT_COLLECTION_INTERVAL + 1000);
 
     verify(messenger, atLeastOnce()).send(any(SuspectMembersMessage.class));
+    
+    Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsSent() > 0);
   }
 
   /***
@@ -306,6 +330,8 @@ public class GMSHealthMonitorJUnitTest {
     }
 
     verify(messenger, atLeastOnce()).send(isA(SuspectMembersMessage.class));
+    
+    Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsSent() > 0);
   }
 
   /***
@@ -338,6 +364,7 @@ public class GMSHealthMonitorJUnitTest {
 
     System.out.println("testRemoveMemberCalled ending");
     verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class), any(String.class));
+    Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsReceived() > 0);
   }
 
   /***
@@ -373,6 +400,7 @@ public class GMSHealthMonitorJUnitTest {
 
     System.out.println("testRemoveMemberNotCalledBeforeTimeout ending");
     verify(joinLeave, never()).remove(any(InternalDistributedMember.class), any(String.class));
+    Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsReceived() > 0);
   }
 
   /***
@@ -407,6 +435,7 @@ public class GMSHealthMonitorJUnitTest {
     Thread.sleep(memberTimeout + 200);
 
     verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class), any(String.class));
+    Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsReceived() > 0);
   }
 
   /***
@@ -548,6 +577,9 @@ public class GMSHealthMonitorJUnitTest {
     DataInputStream dis = new DataInputStream(new ByteArrayInputStream(outputStream.toByteArray()));
     int byteReply = dis.read();
     Assert.assertEquals(expectedResult, byteReply);
+    
+    Assert.assertTrue(gmsHealthMonitor.getStats().getFinalCheckResponsesSent() > 0);
+    Assert.assertTrue(gmsHealthMonitor.getStats().getTcpFinalCheckResponsesSent() > 0);
   }
   
   @Test
@@ -610,6 +642,10 @@ public class GMSHealthMonitorJUnitTest {
     when(fakeSocket.isConnected()).thenReturn(true);
     
     Assert.assertEquals(expectedResult, gmsHealthMonitor.doTCPCheckMember(otherMember, fakeSocket));
+    Assert.assertTrue(gmsHealthMonitor.getStats().getFinalCheckRequestsSent() > 0);
+    Assert.assertTrue(gmsHealthMonitor.getStats().getTcpFinalCheckRequestsSent() > 0);
+    Assert.assertTrue(gmsHealthMonitor.getStats().getFinalCheckResponsesReceived() > 0);
+    Assert.assertTrue(gmsHealthMonitor.getStats().getTcpFinalCheckResponsesReceived() >
0);
     
     //we can check to see if the gms member information was written out by the tcp check
     byte[] bytesWritten = outputStream.toByteArray();



Mime
View raw message