geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hiteshkhame...@apache.org
Subject incubator-geode git commit: GEODE-1372 added time stats for udp encryption-de. added test for it
Date Thu, 16 Jun 2016 23:11:54 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1372 8bf10a5e8 -> e96c57528


GEODE-1372 added time stats for udp encryption-de. added test for it


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

Branch: refs/heads/feature/GEODE-1372
Commit: e96c57528aa0775b90a255fdc4c8519104af7154
Parents: 8bf10a5
Author: Hitesh Khamesra <hiteshk25@yahoo.com>
Authored: Thu Jun 16 16:10:55 2016 -0700
Committer: Hitesh Khamesra <hiteshk25@yahoo.com>
Committed: Thu Jun 16 16:10:55 2016 -0700

----------------------------------------------------------------------
 .../gemfire/distributed/internal/DMStats.java   |  7 ++
 .../distributed/internal/DistributionStats.java | 43 ++++++++++-
 .../internal/LonerDistributionManager.java      | 22 ++++++
 .../gms/messenger/JGroupsMessenger.java         | 79 +++++++++++---------
 .../DistributedMulticastRegionDUnitTest.java    | 20 ++++-
 ...MulticastRegionWithUDPSecurityDUnitTest.java | 37 +++++++++
 6 files changed, 168 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e96c5752/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
index 1b36ee1..1a230c7 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
@@ -215,8 +215,15 @@ public interface DMStats {
   public void endDeserialization(long start, int bytes);
   public long startMsgSerialization();
   public void endMsgSerialization(long start);
+  public long startUDPMsgEncryption();
+  public void endUDPMsgEncryption(long start);
+  public long startUDPMsgDecryption();
+  public void endUDPMsgDecryption(long start);
   public long startMsgDeserialization();
   public void endMsgDeserialization(long start);
+  
+  public long getUDPMsgEncryptionTiime();
+  public long getUDPMsgDecryptionTime();
 
   public int getNodes();
   public void setNodes(int val);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e96c5752/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
index c4803ab..46a8020 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
@@ -140,6 +140,9 @@ public class DistributionStats implements DMStats {
 
   private final static int msgSerializationTimeId;
   private final static int msgDeserializationTimeId;
+  
+  private final static int udpMsgEncryptionTimeId;
+  private final static int udpMsgDecryptionTimeId;
 
   private final static int batchSendTimeId;
   private final static int batchCopyTimeId;
@@ -458,6 +461,8 @@ public class DistributionStats implements DMStats {
         f.createLongCounter("pdxDeserializedBytes", "Total number of bytes read by pdx deserialization.",
"bytes"),
         f.createLongCounter("msgSerializationTime", "Total amount of time, in nanoseconds,
spent serializing messages.", "nanoseconds"),
         f.createLongCounter("msgDeserializationTime", "Total amount of time, in nanoseconds,
spent deserializing messages.", "nanoseconds"),
+        f.createLongCounter("udpMsgEncryptionTime", "Total amount of time, in nanoseconds,
spent encrypting udp messages.", "nanoseconds"),
+        f.createLongCounter("udpMsgDecryptionTime", "Total amount of time, in nanoseconds,
spent decrypting udp messages.", "nanoseconds"),
         f.createIntCounter("pdxInstanceDeserializations", "Total number of times getObject
has been called on a PdxInstance.", "ops"),
         f.createLongCounter("pdxInstanceDeserializationTime", "Total amount of time, in nanoseconds,
spent deserializing PdxInstances by calling getObject.", "nanoseconds"),
         f.createIntCounter("pdxInstanceCreations", "Total number of times a deserialization
created a PdxInstance.", "ops"),
@@ -650,6 +655,9 @@ public class DistributionStats implements DMStats {
 
     msgSerializationTimeId = type.nameToId("msgSerializationTime");
     msgDeserializationTimeId = type.nameToId("msgDeserializationTime");
+    
+    udpMsgEncryptionTimeId = type.nameToId("udpMsgEncryptionTime");
+    udpMsgDecryptionTimeId = type.nameToId("udpMsgDecryptionTime");
 
     batchSendTimeId = type.nameToId("batchSendTime");
     batchCopyTimeId = type.nameToId("batchCopyTime");
@@ -1196,6 +1204,17 @@ public class DistributionStats implements DMStats {
   public int getMcastReads() {
     return stats.getInt(mcastReadsId);
   }
+  
+  @Override
+  public long getUDPMsgDecryptionTime() {
+    return stats.getLong(udpMsgDecryptionTimeId);
+  }
+  
+  @Override
+  public long getUDPMsgEncryptionTiime() {
+    return stats.getLong(udpMsgEncryptionTimeId);
+  }
+  
   public void incMcastReadBytes(int amount) {
     stats.incInt(mcastReadsId, 1);
     stats.incLong(mcastReadBytesId, amount);
@@ -1252,12 +1271,34 @@ public class DistributionStats implements DMStats {
       stats.incLong(msgSerializationTimeId, getStatTime()-start);
     }
   }
+
+  public long startUDPMsgEncryption() {
+    return getStatTime();
+  }
+
+  public void endUDPMsgEncryption(long start) {
+    if (enableClockStats) {
+      stats.incLong(udpMsgEncryptionTimeId, getStatTime() - start);
+    }
+  }
+  
   public long startMsgDeserialization() {
     return getStatTime();
   }
+
   public void endMsgDeserialization(long start) {
     if (enableClockStats) {
-      stats.incLong(msgDeserializationTimeId, getStatTime()-start);
+      stats.incLong(msgDeserializationTimeId, getStatTime() - start);
+    }
+  }
+  
+  public long startUDPMsgDecryption() {
+    return getStatTime();
+  }
+
+  public void endUDPMsgDecryption(long start) {
+    if (enableClockStats) {
+      stats.incLong(udpMsgDecryptionTimeId, getStatTime() - start);
     }
   }
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e96c5752/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
index 7f8eed6..c4621ce 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
@@ -624,6 +624,28 @@ public class LonerDistributionManager implements DM {
     public long getUdpFinalCheckResponsesReceived() {return 0;}
     @Override
     public void incUdpFinalCheckResponsesReceived() {}
+    @Override
+    public long startUDPMsgEncryption() {
+      return 0;
+    }
+    @Override
+    public void endUDPMsgEncryption(long start) {
+    }
+    @Override
+    public long startUDPMsgDecryption() {
+      return 0;
+    }
+    @Override
+    public void endUDPMsgDecryption(long start) {
+    }
+    @Override
+    public long getUDPMsgEncryptionTiime() {
+      return 0;
+    }
+    @Override
+    public long getUDPMsgDecryptionTime() {
+      return 0;
+    }
   }
   protected static class DummyExecutor implements ExecutorService {
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e96c5752/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index a16bd11..5c0a327 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -823,43 +823,48 @@ public class JGroupsMessenger implements Messenger {
   }
   
   void writeEncryptedMessage(DistributionMessage gfmsg, short version, HeapDataOutputStream
out) throws Exception {
-    InternalDataSerializer.writeDSFIDHeader(gfmsg.getDSFID(), out);
-    byte[] pk = null;
-    int requestId = 0;
-    InternalDistributedMember pkMbr = null;
-    switch (gfmsg.getDSFID()) {
-    case FIND_COORDINATOR_REQ:
-    case JOIN_REQUEST:
-      //need to append mine PK
-      pk = encrypt.getPublicKey(localAddress);
-      
-      pkMbr = gfmsg.getRecipients()[0];      
-      requestId = getRequestId(gfmsg, true);
-      break;
-    case FIND_COORDINATOR_RESP:
-    case JOIN_RESPONSE:
-      pkMbr = gfmsg.getRecipients()[0];
-      requestId = getRequestId(gfmsg, false);
-    default:
-      break;
-    }
-    logger.debug("writeEncryptedMessage gfmsg.getDSFID() = {}  for {} with requestid  {}",
gfmsg.getDSFID(), pkMbr, requestId);
-    out.writeInt(requestId);
-    if (pk != null) {      
-      InternalDataSerializer.writeByteArray(pk, out);
-    }
+    long start = services.getStatistics().startUDPMsgEncryption();
+    try {
+      InternalDataSerializer.writeDSFIDHeader(gfmsg.getDSFID(), out);
+      byte[] pk = null;
+      int requestId = 0;
+      InternalDistributedMember pkMbr = null;
+      switch (gfmsg.getDSFID()) {
+      case FIND_COORDINATOR_REQ:
+      case JOIN_REQUEST:
+        // need to append mine PK
+        pk = encrypt.getPublicKey(localAddress);
 
-    HeapDataOutputStream out_stream = new HeapDataOutputStream(Version.fromOrdinalOrCurrent(version));
-    byte[] messageBytes = serializeMessage(gfmsg, out_stream);
-    
-    if (pkMbr != null) {
-      // using members private key
-      messageBytes = encrypt.encryptData(messageBytes, pkMbr);
-    } else {
-      // using cluster secret key
-      messageBytes = encrypt.encryptData(messageBytes);
+        pkMbr = gfmsg.getRecipients()[0];
+        requestId = getRequestId(gfmsg, true);
+        break;
+      case FIND_COORDINATOR_RESP:
+      case JOIN_RESPONSE:
+        pkMbr = gfmsg.getRecipients()[0];
+        requestId = getRequestId(gfmsg, false);
+      default:
+        break;
+      }
+      logger.debug("writeEncryptedMessage gfmsg.getDSFID() = {}  for {} with requestid  {}",
gfmsg.getDSFID(), pkMbr, requestId);
+      out.writeInt(requestId);
+      if (pk != null) {
+        InternalDataSerializer.writeByteArray(pk, out);
+      }
+
+      HeapDataOutputStream out_stream = new HeapDataOutputStream(Version.fromOrdinalOrCurrent(version));
+      byte[] messageBytes = serializeMessage(gfmsg, out_stream);
+
+      if (pkMbr != null) {
+        // using members private key
+        messageBytes = encrypt.encryptData(messageBytes, pkMbr);
+      } else {
+        // using cluster secret key
+        messageBytes = encrypt.encryptData(messageBytes);
+      }
+      InternalDataSerializer.writeByteArray(messageBytes, out);
+    } finally {
+      services.getStatistics().endUDPMsgEncryption(start);
     }
-    InternalDataSerializer.writeByteArray(messageBytes, out);
   }
   
   int getRequestId(DistributionMessage gfmsg, boolean add) {
@@ -999,7 +1004,7 @@ public class JGroupsMessenger implements Messenger {
   DistributionMessage readEncryptedMessage(DataInputStream dis, short ordinal, GMSEncrypt
encryptLocal) throws Exception {
     int dfsid = InternalDataSerializer.readDSFIDHeader(dis);
     int requestId = dis.readInt();
-
+    long start = services.getStatistics().startUDPMsgDecryption();
     try {
       // TODO seems like we don't need this, just set bit that PK is appended
 
@@ -1070,6 +1075,8 @@ public class JGroupsMessenger implements Messenger {
       }
     } catch (Exception e) {
       throw new Exception("Message id is " + dfsid, e);
+    } finally {
+      services.getStatistics().endUDPMsgDecryption(start);
     }
 
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e96c5752/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java
index 2926b40..6132276 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java
@@ -33,6 +33,7 @@ import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionAttributes;
 import com.gemstone.gemfire.cache.Scope;
 import com.gemstone.gemfire.distributed.Locator;
+import com.gemstone.gemfire.distributed.internal.DistributionStats;
 import com.gemstone.gemfire.distributed.internal.InternalLocator;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.cache.CachedDeserializableFactory;
@@ -249,19 +250,32 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase
{
     Properties p = new Properties();
     p.put(STATISTIC_SAMPLING_ENABLED, "true");
     p.put(STATISTIC_ARCHIVE_FILE, "multicast");
+    p.put(ENABLE_TIME_STATISTICS, "true");
     p.put(MCAST_PORT, mcastport);
     p.put(MCAST_TTL, mcastttl);
     p.put(LOCATORS, "localhost[" + locatorPort + "]");
     p.put(LOG_LEVEL, "info");
-    p.put(SECURITY_UDP_DHALGO, "AES:128");
+    addDSProps(p);
     return p;
   } 
   
-  private void validateMulticastOpsAfterRegionOps() {
+  protected void addDSProps(Properties p) {
+  }
+  
+  protected void validateMulticastOpsAfterRegionOps() {
     int writes = getGemfireCache().getDistributionManager().getStats().getMcastWrites();
     int reads = getGemfireCache().getDistributionManager().getStats().getMcastReads();
     assertTrue("Should have multicast writes or reads. Writes=  " + writes +  " ,read= "
+ reads, 
         writes > 0 || reads > 0);
+    
+    validateUDPEncryptionStats();
+  }
+  
+  protected void validateUDPEncryptionStats() {
+    long encrptTime = getGemfireCache().getDistributionManager().getStats().getUDPMsgEncryptionTiime();
+    long decryptTime = getGemfireCache().getDistributionManager().getStats().getUDPMsgDecryptionTime();
+    assertTrue("Should have multicast writes or reads. encrptTime=  " + encrptTime +  " ,decryptTime=
" + decryptTime, 
+        encrptTime == 0 && decryptTime == 0);
   }
   
   private void validateMulticastOpsBeforeRegionOps() {
@@ -286,7 +300,7 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase
{
         locatorProps.setProperty(MCAST_PORT, mcastport);
         locatorProps.setProperty(MCAST_TTL, mcastttl);
         locatorProps.setProperty(LOG_LEVEL, "info");
-        locatorProps.setProperty(SECURITY_UDP_DHALGO, "AES:128");
+        addDSProps(locatorProps);
         //locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME,
"true");
         try {
           final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort,
null, null,

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e96c5752/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionWithUDPSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionWithUDPSecurityDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionWithUDPSecurityDUnitTest.java
new file mode 100644
index 0000000..b9fc6fa
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionWithUDPSecurityDUnitTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.cache30;
+
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.SECURITY_UDP_DHALGO;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Properties;
+
+public class DistributedMulticastRegionWithUDPSecurityDUnitTest extends DistributedMulticastRegionDUnitTest
{
+  @Override
+  protected void addDSProps(Properties p) {
+    p.setProperty(SECURITY_UDP_DHALGO, "AES:128");
+  }
+  
+  @Override
+  protected void validateUDPEncryptionStats() {
+    long encrptTime = getGemfireCache().getDistributionManager().getStats().getUDPMsgEncryptionTiime();
+    long decryptTime = getGemfireCache().getDistributionManager().getStats().getUDPMsgDecryptionTime();
+    assertTrue("Should have multicast writes or reads. encrptTime=  " + encrptTime +  " ,decryptTime=
" + decryptTime, 
+        encrptTime > 0 && decryptTime > 0);
+  }
+}


Mime
View raw message