geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [03/16] incubator-geode git commit: GEODE-968 Fixed typo in api name and added unit test.
Date Fri, 19 Feb 2016 01:05:46 GMT
GEODE-968 Fixed typo in api name and added unit test.


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

Branch: refs/heads/feature/GEODE-831
Commit: b9fe0919b2f117151845730e157bf38d50a2181c
Parents: fd31ea5
Author: Hitesh Khamesra <hkhamesra@pivotal.io>
Authored: Wed Feb 17 16:00:24 2016 -0800
Committer: Hitesh Khamesra <hkhamesra@pivotal.io>
Committed: Wed Feb 17 16:00:24 2016 -0800

----------------------------------------------------------------------
 .../gemfire/distributed/internal/DMStats.java   |  3 +-
 .../distributed/internal/DistributionStats.java | 16 ++--
 .../internal/LonerDistributionManager.java      |  4 +-
 .../gms/messenger/JGroupsMessenger.java         |  2 +-
 .../messenger/JGroupsMessengerJUnitTest.java    | 86 ++++++++++++--------
 5 files changed, 66 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/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 c241bc7..6091b83 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
@@ -172,7 +172,8 @@ public interface DMStats {
 
   public void incMessageChannelTime(long val);
 
-  public void incUDPDispachRequestTime(long val);
+  public void incUDPDispatchRequestTime(long val);
+  public long getUDPDispatchRequestTime();
   
   public long getReplyMessageTime();
   public void incReplyMessageTime(long val);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/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 634929e..6750a54 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
@@ -61,7 +61,7 @@ public class DistributionStats implements DMStats {
   private final static int processedMessagesTimeId;
   private final static int messageProcessingScheduleTimeId;
   private final static int messageChannelTimeId;
-  private final static int udpDispachRequestTimeId;
+  private final static int udpDispatchRequestTimeId;
   private final static int replyMessageTimeId;
   private final static int distributeMessageTimeId;
   private final static int nodesId;
@@ -273,7 +273,7 @@ public class DistributionStats implements DMStats {
     final String functionExecutionThreadsDesc = "The number of threads currently processing
function execution messages.";
     final String waitingThreadsDesc = "The number of threads currently processing messages
that had to wait for a resource.";
     final String messageChannelTimeDesc = "The total amount of time received messages spent
in the distribution channel";
-    final String udpDispachRequestTimeDesc = "The total amount of time spent deserializing
and dispatching UDP messages in the message-reader thread.";
+    final String udpDispatchRequestTimeDesc = "The total amount of time spent deserializing
and dispatching UDP messages in the message-reader thread.";
     final String replyMessageTimeDesc = "The amount of time spent processing reply messages.
This includes both processedMessagesTime and messageProcessingScheduleTime.";
     final String distributeMessageTimeDesc = "The amount of time it takes to prepare a message
and send it on the network.  This includes sentMessagesTime.";
     final String nodesDesc = "The current number of nodes in this distributed system.";
@@ -411,7 +411,7 @@ public class DistributionStats implements DMStats {
         f.createIntGauge("functionExecutionThreads", functionExecutionThreadsDesc, "threads"),
         f.createIntGauge("waitingThreads", waitingThreadsDesc, "threads"),
         f.createLongCounter("messageChannelTime", messageChannelTimeDesc, "nanoseconds",
false),
-        f.createLongCounter("udpDispachRequestTime", udpDispachRequestTimeDesc, "nanoseconds",
false),
+        f.createLongCounter("udpDispatchRequestTime", udpDispatchRequestTimeDesc, "nanoseconds",
false),
         f.createLongCounter("replyMessageTime", replyMessageTimeDesc, "nanoseconds", false),
         f.createLongCounter("distributeMessageTime", distributeMessageTimeDesc, "nanoseconds",
false),
         f.createIntGauge("nodes", nodesDesc, "nodes"),
@@ -575,7 +575,7 @@ public class DistributionStats implements DMStats {
     messageProcessingScheduleTimeId =
       type.nameToId("messageProcessingScheduleTime");
     messageChannelTimeId = type.nameToId("messageChannelTime");
-    udpDispachRequestTimeId = type.nameToId("udpDispachRequestTime");
+    udpDispatchRequestTimeId = type.nameToId("udpDispatchRequestTime");
     replyMessageTimeId = type.nameToId("replyMessageTime");
     distributeMessageTimeId = type.nameToId("distributeMessageTime");
     nodesId = type.nameToId("nodes");
@@ -1083,12 +1083,16 @@ public class DistributionStats implements DMStats {
     }
   }
   
-  public void incUDPDispachRequestTime(long delta) {
+  public void incUDPDispatchRequestTime(long delta) {
     if (enableClockStats) {
-      this.stats.incLong(udpDispachRequestTimeId, delta);
+      this.stats.incLong(udpDispatchRequestTimeId, delta);
     }
   }
 
+  public long getUDPDispatchRequestTime() {
+    return this.stats.getLong(udpDispatchRequestTimeId);
+  }
+  
   public long getReplyMessageTime() {
     return this.stats.getLong(replyMessageTimeId);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/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 50c07de..c958028 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
@@ -363,7 +363,9 @@ public class LonerDistributionManager implements DM {
     @Override
     public void incMessageChannelTime(long val) {}
     @Override
-    public void incUDPDispachRequestTime(long val) {};
+    public void incUDPDispatchRequestTime(long val) {};
+    @Override
+    public long getUDPDispatchRequestTime() {return 0;};
     @Override
     public long getReplyMessageTime() {return 0;}
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index b9fcc38..f3ba7a2 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -1082,7 +1082,7 @@ public class JGroupsMessenger implements Messenger {
         }
       }finally {
         long delta = DistributionStats.getStatTime() - startTime ;
-        JGroupsMessenger.this.services.getStatistics().incUDPDispachRequestTime(delta);
+        JGroupsMessenger.this.services.getStatistics().incUDPDispatchRequestTime(delta);
       }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
index f30efc8..3dcf035 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
@@ -49,11 +49,14 @@ import org.junit.experimental.categories.Category;
 import com.gemstone.gemfire.ForcedDisconnectException;
 import com.gemstone.gemfire.GemFireIOException;
 import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
+import com.gemstone.gemfire.distributed.internal.DM;
 import com.gemstone.gemfire.distributed.internal.DMStats;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
 import com.gemstone.gemfire.distributed.internal.DistributionManager;
 import com.gemstone.gemfire.distributed.internal.DistributionMessage;
+import com.gemstone.gemfire.distributed.internal.DistributionStats;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.distributed.internal.SerialAckedMessage;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.distributed.internal.membership.NetView;
@@ -78,6 +81,8 @@ import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
 import com.gemstone.gemfire.internal.cache.DistributedCacheOperation;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 
+import junit.framework.Assert;
+
 @Category(IntegrationTest.class)
 public class JGroupsMessengerJUnitTest {
   private Services services;
@@ -87,7 +92,7 @@ public class JGroupsMessengerJUnitTest {
   private Stopper stopper;
   private HealthMonitor healthMonitor;
   private InterceptUDP interceptor;
-
+  private long statsId = 123;
 
   /**
    * Create stub and mock objects
@@ -127,7 +132,9 @@ public class JGroupsMessengerJUnitTest {
     when(services.getHealthMonitor()).thenReturn(healthMonitor);
     when(services.getManager()).thenReturn(manager);
     when(services.getJoinLeave()).thenReturn(joinLeave);
-    when(services.getStatistics()).thenReturn(mock(DMStats.class));
+    DM dm = mock(DM.class);
+    InternalDistributedSystem system = InternalDistributedSystem.newInstanceForTesting(dm,
nonDefault);
+    when(services.getStatistics()).thenReturn(new DistributionStats(system, statsId));
     
     messenger = new JGroupsMessenger();
     messenger.init(services);
@@ -747,40 +754,47 @@ public class JGroupsMessengerJUnitTest {
   
   @Test
   public void testReceiver() throws Exception {
-    initMocks(false);
-    JGroupsReceiver receiver = (JGroupsReceiver)messenger.myChannel.getReceiver();
-    
-    // a zero-length message is ignored
-    Message msg = new Message(new JGAddress(messenger.getMemberID()));
-    Object result = messenger.readJGMessage(msg);
-    assertNull(result);
-    
-    // for code coverage we need to pump this message through the receiver
-    receiver.receive(msg);
-    
-    // for more code coverage we need to actually set a buffer in the message
-    msg.setBuffer(new byte[0]);
-    result = messenger.readJGMessage(msg);
-    assertNull(result);
-    receiver.receive(msg);
-    
-    // now create a view and a real distribution-message
-    InternalDistributedMember myAddress = messenger.getMemberID();
-    InternalDistributedMember other = createAddress(8888);
-    NetView v = new NetView(myAddress);
-    v.add(other);
-    when(joinLeave.getView()).thenReturn(v);
-    messenger.installView(v);
-
-    List<InternalDistributedMember> recipients = v.getMembers();
-    SerialAckedMessage dmsg = new SerialAckedMessage();
-    dmsg.setRecipients(recipients);
-
-    // a message is ignored during manager shutdown
-    msg = messenger.createJGMessage(dmsg, new JGAddress(other), Version.CURRENT_ORDINAL);
-    when(manager.shutdownInProgress()).thenReturn(Boolean.TRUE);
-    receiver.receive(msg);
-    verify(manager, never()).processMessage(isA(DistributionMessage.class));
+    try {
+      DistributionStats.enableClockStats = true;
+      initMocks(false);
+      JGroupsReceiver receiver = (JGroupsReceiver)messenger.myChannel.getReceiver();
+      
+      // a zero-length message is ignored
+      Message msg = new Message(new JGAddress(messenger.getMemberID()));
+      Object result = messenger.readJGMessage(msg);
+      assertNull(result);
+      
+      // for code coverage we need to pump this message through the receiver
+      receiver.receive(msg);
+      
+      // for more code coverage we need to actually set a buffer in the message
+      msg.setBuffer(new byte[0]);
+      result = messenger.readJGMessage(msg);
+      assertNull(result);
+      receiver.receive(msg);
+      
+      // now create a view and a real distribution-message
+      InternalDistributedMember myAddress = messenger.getMemberID();
+      InternalDistributedMember other = createAddress(8888);
+      NetView v = new NetView(myAddress);
+      v.add(other);
+      when(joinLeave.getView()).thenReturn(v);
+      messenger.installView(v);
+  
+      List<InternalDistributedMember> recipients = v.getMembers();
+      SerialAckedMessage dmsg = new SerialAckedMessage();
+      dmsg.setRecipients(recipients);
+  
+      // a message is ignored during manager shutdown
+      msg = messenger.createJGMessage(dmsg, new JGAddress(other), Version.CURRENT_ORDINAL);
+      when(manager.shutdownInProgress()).thenReturn(Boolean.TRUE);
+      receiver.receive(msg);
+      verify(manager, never()).processMessage(isA(DistributionMessage.class));
+      
+      assertTrue("There should be UDPDispatchRequestTime stats", services.getStatistics().getUDPDispatchRequestTime()
> 0);
+    }finally {
+      DistributionStats.enableClockStats = false;
+    }
   }
   
   @Test


Mime
View raw message