geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject incubator-geode git commit: GEODE-2017: Remove nonPRSingleHop stat from client
Date Wed, 02 Nov 2016 22:38:07 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-2017 [created] 47d295cb2


GEODE-2017: Remove nonPRSingleHop stat from client


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

Branch: refs/heads/feature/GEODE-2017
Commit: 47d295cb2aa7931007188b2c31ee443b46c4c357
Parents: 9bbecb2
Author: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Authored: Thu Nov 3 09:36:31 2016 +1100
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Thu Nov 3 09:36:31 2016 +1100

----------------------------------------------------------------------
 .../client/internal/ClientMetadataService.java  |  84 ++++----
 .../geode/internal/cache/CachePerfStats.java    |  11 --
 .../geode/internal/cache/LocalRegion.java       |   6 -
 .../internal/cache/SingleHopStatsDUnitTest.java | 191 +++++++------------
 4 files changed, 118 insertions(+), 174 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/47d295cb/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientMetadataService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientMetadataService.java
b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientMetadataService.java
index 915e1bf..d4d5ac9 100755
--- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientMetadataService.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientMetadataService.java
@@ -15,15 +15,33 @@
 package org.apache.geode.cache.client.internal;
 
 import org.apache.geode.SystemFailure;
-import org.apache.geode.cache.*;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.EntryOperation;
+import org.apache.geode.cache.FixedPartitionResolver;
+import org.apache.geode.cache.Operation;
+import org.apache.geode.cache.PartitionResolver;
+import org.apache.geode.cache.Region;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.ServerLocation;
-import org.apache.geode.internal.cache.*;
+import org.apache.geode.internal.cache.BucketServerLocation66;
+import org.apache.geode.internal.cache.EntryOperationImpl;
+import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.PartitionedRegionHelper;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.logging.log4j.Logger;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArraySet;
 
@@ -31,10 +49,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
  * Maintains {@link ClientPartitionAdvisor} for Partitioned Regions on servers Client operations
  * will consult this service to identify the server locations on which the data for the client
  * operation is residing
- * 
- * 
  * @since GemFire 6.5
- * 
  */
 public final class ClientMetadataService {
 
@@ -51,7 +66,9 @@ public final class ClientMetadataService {
 
   public static final int INITIAL_VERSION = 0;
 
-  /** random number generator used in pruning */
+  /**
+   * random number generator used in pruning
+   */
   private final Random rand = new Random();
 
   private volatile boolean isMetadataStable = true;
@@ -100,7 +117,7 @@ public final class ClientMetadataService {
   }
 
   public ServerLocation getBucketServerLocation(Region region, Operation operation, Object
key,
-      Object value, Object callbackArg) {
+                                                Object value, Object callbackArg) {
     ClientPartitionAdvisor prAdvisor = this.getClientPartitionAdvisor(region.getFullPath());
     if (prAdvisor == null) {
       return null;
@@ -131,7 +148,7 @@ public final class ClientMetadataService {
       String partition = ((FixedPartitionResolver) resolver).getPartitionName(entryOp,
           prAdvisor.getFixedPartitionNames());
       if (partition == null) {
-        Object[] prms = new Object[] {region.getName(), resolver};
+        Object[] prms = new Object[]{region.getName(), resolver};
         throw new IllegalStateException(
             LocalizedStrings.PartitionedRegionHelper_FOR_REGION_0_PARTITIONRESOLVER_1_RETURNED_PARTITION_NAME_NULL
                 .toLocalizedString(prms));
@@ -149,9 +166,10 @@ public final class ClientMetadataService {
 
     ServerLocation bucketServerLocation = getServerLocation(region, operation, bucketId);
     ServerLocation location = null;
-    if (bucketServerLocation != null)
+    if (bucketServerLocation != null) {
       location =
           new ServerLocation(bucketServerLocation.getHostName(), bucketServerLocation.getPort());
+    }
     return location;
   }
 
@@ -167,18 +185,6 @@ public final class ClientMetadataService {
       return null;
     }
 
-    // if (prAdvisor.getColocatedWith() != null) {
-    // prAdvisor = this.getClientPartitionAdvisor(prAdvisor.getColocatedWith());
-    // if (prAdvisor == null) {
-    // if (this.logger.fineEnabled()) {
-    // this.logger.fine(
-    // "ClientMetadataService#getServerLocation : Region "
-    // + regionFullPath + "prAdvisor does not exist.");
-    // }
-    // return null;
-    // }
-    // }
-
     if (operation.isGet()) {
       return prAdvisor.adviseServerLocation(bucketId);
     } else {
@@ -187,12 +193,15 @@ public final class ClientMetadataService {
   }
 
   public Map<ServerLocation, HashSet> getServerToFilterMap(final Collection routingKeys,
-      final Region region, boolean primaryMembersNeeded) {
+                                                           final Region region,
+                                                           boolean primaryMembersNeeded)
{
     return getServerToFilterMap(routingKeys, region, primaryMembersNeeded, false);
   }
 
   public Map<ServerLocation, HashSet> getServerToFilterMap(final Collection routingKeys,
-      final Region region, boolean primaryMembersNeeded, boolean bucketsAsFilter) {
+                                                           final Region region,
+                                                           boolean primaryMembersNeeded,
+                                                           boolean bucketsAsFilter) {
     final String regionFullPath = region.getFullPath();
     ClientPartitionAdvisor prAdvisor = this.getClientPartitionAdvisor(regionFullPath);
     if (prAdvisor == null || prAdvisor.adviseRandomServerLocation() == null) {
@@ -232,7 +241,7 @@ public final class ClientMetadataService {
   }
 
   public HashMap<ServerLocation, HashSet<Integer>> groupByServerToAllBuckets(Region
region,
-      boolean primaryOnly) {
+                                                                             boolean primaryOnly)
{
     final String regionFullPath = region.getFullPath();
     ClientPartitionAdvisor prAdvisor = this.getClientPartitionAdvisor(regionFullPath);
     if (prAdvisor == null || prAdvisor.adviseRandomServerLocation() == null) {
@@ -284,7 +293,7 @@ public final class ClientMetadataService {
 
 
   private HashMap<ServerLocation, HashSet<Integer>> pruneNodes(ClientPartitionAdvisor
prAdvisor,
-      Set<Integer> buckets) {
+                                                               Set<Integer> buckets)
{
 
     final boolean isDebugEnabled = logger.isDebugEnabled();
     if (isDebugEnabled) {
@@ -388,7 +397,7 @@ public final class ClientMetadataService {
 
 
   private ServerLocation findNextServer(Set<Map.Entry<ServerLocation, HashSet<Integer>>>
entrySet,
-      HashSet<Integer> currentBucketSet) {
+                                        HashSet<Integer> currentBucketSet) {
 
     ServerLocation server = null;
     int max = -1;
@@ -410,14 +419,17 @@ public final class ClientMetadataService {
 
     // return node;
     Random r = new Random();
-    if (nodesOfEqualSize.size() > 0)
+    if (nodesOfEqualSize.size() > 0) {
       return nodesOfEqualSize.get(r.nextInt(nodesOfEqualSize.size()));
+    }
 
     return null;
   }
 
   private HashMap<Integer, HashSet> groupByBucketOnClientSide(Region region,
-      ClientPartitionAdvisor prAdvisor, Collection routingKeys, boolean bucketsAsFilter)
{
+                                                              ClientPartitionAdvisor prAdvisor,
+                                                              Collection routingKeys,
+                                                              boolean bucketsAsFilter) {
 
     HashMap<Integer, HashSet> bucketToKeysMap = new HashMap();
     int totalNumberOfBuckets = prAdvisor.getTotalNumBuckets();
@@ -440,7 +452,7 @@ public final class ClientMetadataService {
   }
 
   private int extractBucketID(Region region, ClientPartitionAdvisor prAdvisor,
-      int totalNumberOfBuckets, Object key) {
+                              int totalNumberOfBuckets, Object key) {
     int bucketId = -1;
     final PartitionResolver resolver = getResolver(region, key, null);
     Object resolveKey;
@@ -466,7 +478,7 @@ public final class ClientMetadataService {
       String partition = ((FixedPartitionResolver) resolver).getPartitionName(entryOp,
           prAdvisor.getFixedPartitionNames());
       if (partition == null) {
-        Object[] prms = new Object[] {region.getName(), resolver};
+        Object[] prms = new Object[]{region.getName(), resolver};
         throw new IllegalStateException(
             LocalizedStrings.PartitionedRegionHelper_FOR_REGION_0_PARTITIONRESOLVER_1_RETURNED_PARTITION_NAME_NULL
                 .toLocalizedString(prms));
@@ -486,13 +498,11 @@ public final class ClientMetadataService {
   }
 
 
-
   public void scheduleGetPRMetaData(final LocalRegion region, final boolean isRecursive)
{
     if (this.nonPRs.contains(region.getFullPath())) {
       return;
     }
     this.setMetadataStable(false);
-    region.getCachePerfStats().incNonSingleHopsCount();
     if (isRecursive) {
       try {
         getClientPRMetadata(region);
@@ -580,7 +590,7 @@ public final class ClientMetadataService {
   }
 
   public void scheduleGetPRMetaData(final LocalRegion region, final boolean isRecursive,
-      byte nwHopType) {
+                                    byte nwHopType) {
     if (this.nonPRs.contains(region.getFullPath())) {
       return;
     }
@@ -600,7 +610,6 @@ public final class ClientMetadataService {
       }
     }
     if (isRecursive) {
-      region.getCachePerfStats().incNonSingleHopsCount();
       try {
         getClientPRMetadata(region);
       } catch (VirtualMachineError e) {
@@ -617,7 +626,6 @@ public final class ClientMetadataService {
         if (regionsBeingRefreshed.contains(region.getFullPath())) {
           return;
         }
-        region.getCachePerfStats().incNonSingleHopsCount();
         regionsBeingRefreshed.add(region.getFullPath());
         refreshTaskCount++;
       }
@@ -666,7 +674,7 @@ public final class ClientMetadataService {
   }
 
   public byte getMetaDataVersion(Region region, Operation operation, Object key, Object value,
-      Object callbackArg) {
+                                 Object callbackArg) {
     ClientPartitionAdvisor prAdvisor = this.getClientPartitionAdvisor(region.getFullPath());
     if (prAdvisor == null) {
       return 0;
@@ -699,7 +707,7 @@ public final class ClientMetadataService {
       String partition = ((FixedPartitionResolver) resolver).getPartitionName(entryOp,
           prAdvisor.getFixedPartitionNames());
       if (partition == null) {
-        Object[] prms = new Object[] {region.getName(), resolver};
+        Object[] prms = new Object[]{region.getName(), resolver};
         throw new IllegalStateException(
             LocalizedStrings.PartitionedRegionHelper_FOR_REGION_0_PARTITIONRESOLVER_1_RETURNED_PARTITION_NAME_NULL
                 .toLocalizedString(prms));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/47d295cb/geode-core/src/main/java/org/apache/geode/internal/cache/CachePerfStats.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/CachePerfStats.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/CachePerfStats.java
index 395e8c7..67e04f1 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/CachePerfStats.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/CachePerfStats.java
@@ -120,8 +120,6 @@ public class CachePerfStats {
   protected static final int indexInitializationCompletedId;
   protected static final int indexInitializationTimeId;
 
-  /** Id of two hops statistic */
-  protected static final int nonSingleHopsCountId;
   /** Id of the meta data refresh statistic */
   protected static final int metaDataRefreshCountId;
 
@@ -597,7 +595,6 @@ public class CachePerfStats {
     evictorQueueSizeId = type.nameToId("evictorQueueSize");
     evictWorkTimeId = type.nameToId("evictWorkTime");
 
-    nonSingleHopsCountId = type.nameToId("nonSingleHopsCount");
     metaDataRefreshCountId = type.nameToId("metaDataRefreshCount");
 
     conflatedEventsId = type.nameToId("conflatedEvents");
@@ -1498,14 +1495,6 @@ public class CachePerfStats {
     };
   }
 
-  public void incNonSingleHopsCount() {
-    this.stats.incLong(nonSingleHopsCountId, 1);
-  }
-
-  public long getNonSingleHopsCount() {
-    return this.stats.getLong(nonSingleHopsCountId);
-  }
-
   public void incMetaDataRefreshCount() {
     this.stats.incLong(metaDataRefreshCountId, 1);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/47d295cb/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index 360c6a9..7ccf3d6 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -11663,12 +11663,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
     }
 
     @Override
-    public void incNonSingleHopsCount() {
-      this.stats.incLong(nonSingleHopsCountId, 1);
-      this.cachePerfStats.incNonSingleHopsCount();
-    }
-
-    @Override
     public void incMetaDataRefreshCount() {
       this.stats.incLong(metaDataRefreshCountId, 1);
       this.cachePerfStats.incMetaDataRefreshCount();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/47d295cb/geode-core/src/test/java/org/apache/geode/internal/cache/SingleHopStatsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/SingleHopStatsDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/SingleHopStatsDUnitTest.java
index 1b6a00c..0d57155 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/SingleHopStatsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/SingleHopStatsDUnitTest.java
@@ -14,18 +14,13 @@
  */
 package org.apache.geode.internal.cache;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import com.jayway.awaitility.Awaitility;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheClosedException;
@@ -52,27 +47,30 @@ import org.apache.geode.test.dunit.LogWriterUtils;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
 
 @Category(DistributedTest.class)
 public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
 
-  private final String Region_Name = "42010";
-  private final String ORDER_REGION_NAME = "ORDER";
-  private final String SHIPMENT_REGION_NAME = "SHIPMENT";
-  private final String CUSTOMER_REGION_NAME = "CUSTOMER";
+  private static final String Region_Name = "42010";
+  private static final String ORDER_REGION_NAME = "ORDER";
+  private static final String SHIPMENT_REGION_NAME = "SHIPMENT";
+  private static final String CUSTOMER_REGION_NAME = "CUSTOMER";
   private VM member0 = null;
   private VM member1 = null;
   private VM member2 = null;
   private VM member3 = null;
 
   private static long metaDataRefreshCount;
-  private static long nonSingleHopsCount;
   private static long metaDataRefreshCount_Customer;
-  private static long nonSingleHopsCount_Customer;
   private static long metaDataRefreshCount_Order;
-  private static long nonSingleHopsCount_Order;
   private static long metaDataRefreshCount_Shipment;
-  private static long nonSingleHopsCount_Shipment;
 
   @Override
   public final void postSetUp() throws Exception {
@@ -86,10 +84,10 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
   @Override
   public final void preTearDownCacheTestCase() throws Exception {
     // close the clients first
-    member0.invoke(() -> closeCacheAndDisconnect());
-    member1.invoke(() -> closeCacheAndDisconnect());
-    member2.invoke(() -> closeCacheAndDisconnect());
-    member3.invoke(() -> closeCacheAndDisconnect());
+    member0.invoke(this::closeCacheAndDisconnect);
+    member1.invoke(this::closeCacheAndDisconnect);
+    member2.invoke(this::closeCacheAndDisconnect);
+    member3.invoke(this::closeCacheAndDisconnect);
     closeCacheAndDisconnect();
   }
 
@@ -118,39 +116,34 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
 
   @Test
   public void testClientStatsPR() {
-    Integer port0 = (Integer) member0.invoke(() -> createServerForStats(0, 113, "No_Colocation"));
-    Integer port1 = (Integer) member1.invoke(() -> createServerForStats(0, 113, "No_Colocation"));
-    Integer port2 = (Integer) member2.invoke(() -> createServerForStats(0, 113, "No_Colocation"));
+    Integer port0 = member0.invoke(() -> createServerForStats(0, 113, false));
+    Integer port1 = member1.invoke(() -> createServerForStats(0, 113, false));
+    Integer port2 = member2.invoke(() -> createServerForStats(0, 113, false));
 
-    member3.invoke("createClient", () -> createClient(port0, port1, port2, "No_Colocation"));
-    System.out.println("createClient");
-    createClient(port0, port1, port2, "No_Colocation");
+    member3.invoke("createClient", () -> createClient(port0, port1, port2, false));
+    createClient(port0, port1, port2, false);
 
-    member3.invoke("createPR", () -> createPR("FirstClient", "No_Colocation"));
-    System.out.println("createPR");
-    createPR("SecondClient", "No_Colocation");
+    member3.invoke("createPR", () -> createPR("FirstClient", false));
+    createPR("SecondClient", false);
 
-    member3.invoke("getPR", () -> getPR("FirstClient", "No_Colocation"));
-    System.out.println("getPR");
-    getPR("SecondClient", "No_Colocation");
+    member3.invoke("getPR", () -> getPR("FirstClient", false));
+    getPR("SecondClient", false);
 
-    member3.invoke("updatePR", () -> updatePR("FirstClient", "No_Colocation"));
+    member3.invoke("updatePR", () -> updatePR("FirstClient", false));
   }
 
   @Test
   public void testClientStatsColocationPR() {
-    Integer port0 = (Integer) member0.invoke(() -> createServerForStats(0, 4, "Colocation"));
-    Integer port1 = (Integer) member1.invoke(() -> createServerForStats(0, 4, "Colocation"));
-    Integer port2 = (Integer) member2.invoke(() -> createServerForStats(0, 4, "Colocation"));
-    member3.invoke(() -> createClient(port0, port1, port2, "Colocation"));
-    createClient(port0, port1, port2, "Colocation");
-
-    member3.invoke(() -> createPR("FirstClient", "Colocation"));
-
-    member3.invoke(() -> getPR("FirstClient", "Colocation"));
+    Integer port0 = member0.invoke(() -> createServerForStats(0, 4, true));
+    Integer port1 = member1.invoke(() -> createServerForStats(0, 4, true));
+    Integer port2 = member2.invoke(() -> createServerForStats(0, 4, true));
+    member3.invoke(() -> createClient(port0, port1, port2, true));
+    createClient(port0, port1, port2, true);
+    member3.invoke(() -> createPR("FirstClient", true));
+    member3.invoke(() -> getPR("FirstClient", true));
   }
 
-  private void createClient(int port0, int port1, int port2, String colocation) {
+  private void createClient(int port0, int port1, int port2, boolean colocated) {
     Properties props = new Properties();
     props.setProperty(MCAST_PORT, "0");
     props.setProperty(LOCATORS, "");
@@ -158,18 +151,18 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
     Cache cache = CacheFactory.create(distributedSystem);
     assertNotNull(cache);
     CacheServerTestUtil.disableShufflingOfEndpoints();
-    Pool p;
+    Pool pool;
     try {
-      p = PoolManager.createFactory().addServer("localhost", port0).addServer("localhost",
port1)
+      pool = PoolManager.createFactory().addServer("localhost", port0).addServer("localhost",
port1)
           .addServer("localhost", port2).setRetryAttempts(5).setMinConnections(1)
           .setMaxConnections(-1).setSubscriptionEnabled(false).create(Region_Name);
     } finally {
       CacheServerTestUtil.enableShufflingOfEndpoints();
     }
-    createRegionInClientCache(p.getName(), colocation, cache);
+    createRegionInClientCache(pool.getName(), colocated, cache);
   }
 
-  private int createServerForStats(int redundantCopies, int totalNoofBuckets, String colocation)
{
+  private int createServerForStats(int redundantCopies, int totalNoOfBuckets, boolean colocated)
{
     Cache cache = getCache();
     CacheServer server = cache.addCacheServer();
     server.setPort(0);
@@ -182,8 +175,8 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
 
     Region region = null;
 
-    if (colocation.equals("No_Colocation")) {
-      if (totalNoofBuckets == 0) { // DR
+    if (!colocated) {
+      if (totalNoOfBuckets == 0) { // DR
         AttributesFactory attr = new AttributesFactory();
         attr.setScope(Scope.DISTRIBUTED_ACK);
         attr.setDataPolicy(DataPolicy.REPLICATE);
@@ -193,7 +186,7 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
             "Distributed Region " + Region_Name + " created Successfully :" + region.toString());
       } else {
         PartitionAttributesFactory paf = new PartitionAttributesFactory();
-        paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoofBuckets);
+        paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoOfBuckets);
         AttributesFactory attr = new AttributesFactory();
         attr.setPartitionAttributes(paf.create());
         region = cache.createRegion(Region_Name, attr.create());
@@ -203,7 +196,7 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
       }
     } else {
       PartitionAttributesFactory paf = new PartitionAttributesFactory();
-      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoofBuckets)
+      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoOfBuckets)
           .setPartitionResolver(
               new CustomerIDPartitionResolver("CustomerIDPartitio" + "nResolver"));
       AttributesFactory attr = new AttributesFactory();
@@ -214,7 +207,7 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
           .info("Partitioned Region CUSTOMER created Successfully :" + customerRegion.toString());
 
       paf = new PartitionAttributesFactory();
-      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoofBuckets)
+      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoOfBuckets)
           .setColocatedWith(CUSTOMER_REGION_NAME)
           .setPartitionResolver(new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
       attr = new AttributesFactory();
@@ -225,7 +218,7 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
           .info("Partitioned Region ORDER created Successfully :" + orderRegion.toString());
 
       paf = new PartitionAttributesFactory();
-      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoofBuckets)
+      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoOfBuckets)
           .setColocatedWith(ORDER_REGION_NAME)
           .setPartitionResolver(new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
       attr = new AttributesFactory();
@@ -238,9 +231,9 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
     return server.getPort();
   }
 
-  private void createRegionInClientCache(String poolName, String colocation, Cache cache)
{
-    Region region = null;
-    if (colocation.equals("No_Colocation")) {
+  private void createRegionInClientCache(String poolName, boolean colocated, Cache cache)
{
+    Region region;
+    if (!colocated) {
       AttributesFactory factory = new AttributesFactory();
       factory.setPoolName(poolName);
       factory.setDataPolicy(DataPolicy.EMPTY);
@@ -276,58 +269,51 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
     }
   }
 
-  private void createPR(String fromClient, String colocation) {
+  private void createPR(String fromClient, boolean colocated) {
     GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
     Region region = cache.getRegion(Region_Name);
 
-
-    if (colocation.equals("No_Colocation")) {
+    if (!colocated) {
       if (fromClient.equals("FirstClient")) {
 
         System.out.println("first pass...");
         for (int i = 0; i < 113; i++) {
-          region.create(new Integer(i), "create" + i);
+          region.create(i, "create" + i);
         }
-        ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
+        ClientMetadataService cms = cache.getClientMetadataService();
         final Map<String, ClientPartitionAdvisor> regionMetaData =
             cms.getClientPRMetadata_TEST_ONLY();
         assertEquals(0, regionMetaData.size());
 
         System.out.println("second pass...");
         for (int i = 113; i < 226; i++) {
-          region.create(new Integer(i), "create" + i);
+          region.create(i, "create" + i);
         }
         cms = ((GemFireCacheImpl) cache).getClientMetadataService();
         // since PR metadata is fetched in a background executor thread
         // we need to wait for it to arrive for a bit
         Awaitility.await().timeout(120, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS)
-            .pollInterval(500, TimeUnit.MILLISECONDS).until(() -> {
-              return regionMetaData.size() == 1;
-            });
+            .pollInterval(500, TimeUnit.MILLISECONDS).until(() -> regionMetaData.size()
== 1);
 
         assertTrue(regionMetaData.containsKey(region.getFullPath()));
         regionMetaData.get(region.getFullPath());
         metaDataRefreshCount = ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount();
-        nonSingleHopsCount = ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount();
         assertTrue(metaDataRefreshCount != 0); // hops are not predictable
-        assertTrue(nonSingleHopsCount != 0);
 
         System.out.println("metadata refresh count after second pass is " + metaDataRefreshCount);
       } else {
         System.out.println("creating keys in second client");
         for (int i = 0; i < 226; i++) {
-          region.create(new Integer(i), "create" + i);
+          region.create(i, "create" + i);
         }
-        ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
+        ClientMetadataService cms = cache.getClientMetadataService();
         Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
         assertEquals(1, regionMetaData.size());
         assertTrue(regionMetaData.containsKey(region.getFullPath()));
 
         regionMetaData.get(region.getFullPath());
         metaDataRefreshCount = ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount();
-        nonSingleHopsCount = ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount();
         assertTrue(metaDataRefreshCount != 0); // hops are not predictable
-        assertTrue(nonSingleHopsCount != 0);
         System.out.println("metadata refresh count in second client is " + metaDataRefreshCount);
       }
     } else {
@@ -364,60 +350,35 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
     regionMetaData.get(customerRegion.getFullPath());
     metaDataRefreshCount_Customer =
         ((LocalRegion) customerRegion).getCachePerfStats().getMetaDataRefreshCount();
-    nonSingleHopsCount_Customer =
-        ((LocalRegion) customerRegion).getCachePerfStats().getNonSingleHopsCount();
     assertTrue(metaDataRefreshCount_Customer != 0); // hops are not predictable
-    assertTrue(nonSingleHopsCount_Customer != 0);
 
     regionMetaData.get(orderRegion.getFullPath());
     metaDataRefreshCount_Order =
         ((LocalRegion) orderRegion).getCachePerfStats().getMetaDataRefreshCount();
-    nonSingleHopsCount_Order =
-        ((LocalRegion) orderRegion).getCachePerfStats().getNonSingleHopsCount();
     assertTrue(metaDataRefreshCount_Order == 0);
-    assertTrue(nonSingleHopsCount_Order != 0);
 
     regionMetaData.get(shipmentRegion.getFullPath());
     metaDataRefreshCount_Shipment =
         ((LocalRegion) shipmentRegion).getCachePerfStats().getMetaDataRefreshCount();
-    nonSingleHopsCount_Shipment =
-        ((LocalRegion) shipmentRegion).getCachePerfStats().getNonSingleHopsCount();
     assertTrue(metaDataRefreshCount_Shipment == 0);
-    assertTrue(nonSingleHopsCount_Shipment != 0);
   }
 
-  private void getPR(String FromClient, String colocation) {
+  private void getPR(String FromClient, boolean colocated) {
     Cache cache = CacheFactory.getAnyInstance();
     Region region = cache.getRegion(Region_Name);
     Region customerRegion = cache.getRegion(CUSTOMER_REGION_NAME);
     Region orderRegion = cache.getRegion(ORDER_REGION_NAME);
     Region shipmentRegion = cache.getRegion("SHIPMENT");
-    if (colocation.equals("No_Colocation")) {
-      if (FromClient.equals("FirstClient")) {
-        for (int i = 0; i < 226; i++) {
-          region.get(new Integer(i));
-        }
-        ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
-        Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
-        assertEquals(1, regionMetaData.size());
-        regionMetaData.get(region.getFullPath());
-        assertEquals(metaDataRefreshCount,
-            ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount());
-        assertEquals(nonSingleHopsCount,
-            ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount());
-      } else {
-        for (int i = 0; i < 226; i++) {
-          region.get(new Integer(i));
-        }
-        ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
-        Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
-        assertEquals(1, regionMetaData.size());
-        regionMetaData.get(region.getFullPath());
-        assertEquals(metaDataRefreshCount,
-            ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount());
-        assertEquals(nonSingleHopsCount,
-            ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount());
+    if (!colocated) {
+      for (int i = 0; i < 226; i++) {
+        region.get(i);
       }
+      ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
+      Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
+      assertEquals(1, regionMetaData.size());
+      regionMetaData.get(region.getFullPath());
+      assertEquals(metaDataRefreshCount,
+          ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount());
     } else {
       for (int i = 0; i <= 20; i++) {
         CustId custid = new CustId(i);
@@ -440,30 +401,24 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
       regionMetaData.get(customerRegion.getFullPath());
       assertEquals(metaDataRefreshCount_Customer,
           ((LocalRegion) customerRegion).getCachePerfStats().getMetaDataRefreshCount());
-      assertEquals(nonSingleHopsCount_Customer,
-          ((LocalRegion) customerRegion).getCachePerfStats().getNonSingleHopsCount());
 
       regionMetaData.get(orderRegion.getFullPath());
       assertEquals(metaDataRefreshCount_Order,
           ((LocalRegion) orderRegion).getCachePerfStats().getMetaDataRefreshCount());
-      assertEquals(nonSingleHopsCount_Order,
-          ((LocalRegion) orderRegion).getCachePerfStats().getNonSingleHopsCount());
 
       regionMetaData.get(shipmentRegion.getFullPath());
       assertEquals(metaDataRefreshCount_Shipment,
           ((LocalRegion) shipmentRegion).getCachePerfStats().getMetaDataRefreshCount());
-      assertEquals(nonSingleHopsCount_Shipment,
-          ((LocalRegion) shipmentRegion).getCachePerfStats().getNonSingleHopsCount());
     }
   }
 
-  private void updatePR(String FromClient, String colocation) {
+  private void updatePR(String FromClient, boolean colocated) {
     Cache cache = CacheFactory.getAnyInstance();
     Region region = cache.getRegion(Region_Name);
-    if (colocation.equals("No_Colocation")) {
+    if (!colocated) {
       if (FromClient.equals("FirstClient")) {
         for (int i = 0; i < 226; i++) {
-          region.put(new Integer(i), "Update" + i);
+          region.put(i, "Update" + i);
         }
         ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
         Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
@@ -471,8 +426,6 @@ public class SingleHopStatsDUnitTest extends JUnit4CacheTestCase {
         regionMetaData.get(region.getFullPath());
         assertEquals(metaDataRefreshCount,
             ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount());
-        assertEquals(nonSingleHopsCount,
-            ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount());
       }
     }
   }


Mime
View raw message