Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1801 [created] 9b6c10bc2


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b6c10bc/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 a7c7b48..3f960c7 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
@@ -162,13 +162,7 @@ public class SingleHopStatsDUnitTest extends 
JUnit4CacheTestCase {
     CacheServerTestUtil.disableShufflingOfEndpoints();
     Pool p;
     try {
-      p = PoolManager.createFactory().addServer("localhost", port0)
-          .addServer("localhost", port1).addServer("localhost", port2)
-          .setRetryAttempts(5)
-          .setMinConnections(1)
-          .setMaxConnections(-1)
-          .setSubscriptionEnabled(false)
-          .create(Region_Name);
+      p = 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();
     }
@@ -195,58 +189,40 @@ public class SingleHopStatsDUnitTest extends 
JUnit4CacheTestCase {
         attr.setDataPolicy(DataPolicy.REPLICATE);
         region = cache.createRegion(Region_Name, attr.create());
         assertNotNull(region);
-        LogWriterUtils.getLogWriter().info(
-            "Distributed Region " + Region_Name + " created Successfully :"
-                + region.toString());
+        LogWriterUtils.getLogWriter().info("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());
         assertNotNull(region);
-        LogWriterUtils.getLogWriter().info(
-            "Partitioned Region " + Region_Name + " created Successfully :"
-                + region.toString());
+        LogWriterUtils.getLogWriter().info("Partitioned Region " + Region_Name 
+ " created Successfully :" + region.toString());
       }
     } else {
       PartitionAttributesFactory paf = new PartitionAttributesFactory();
-      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(
-          totalNoofBuckets).setPartitionResolver(
-          new CustomerIDPartitionResolver("CustomerIDPartitio"
-              + "nResolver"));
+      
paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoofBuckets).setPartitionResolver(new
 CustomerIDPartitionResolver("CustomerIDPartitio" + "nResolver"));
       AttributesFactory attr = new AttributesFactory();
       attr.setPartitionAttributes(paf.create());
       Region customerRegion = cache.createRegion(CUSTOMER_REGION_NAME, 
attr.create());
       assertNotNull(customerRegion);
-      LogWriterUtils.getLogWriter().info(
-          "Partitioned Region CUSTOMER created Successfully :"
-              + customerRegion.toString());
+      LogWriterUtils.getLogWriter().info("Partitioned Region CUSTOMER created 
Successfully :" + customerRegion.toString());
 
       paf = new PartitionAttributesFactory();
-      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(
-          
totalNoofBuckets).setColocatedWith(CUSTOMER_REGION_NAME).setPartitionResolver(
-          new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
+      
paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoofBuckets).setColocatedWith(CUSTOMER_REGION_NAME).setPartitionResolver(new
 CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
       attr = new AttributesFactory();
       attr.setPartitionAttributes(paf.create());
       Region orderRegion = cache.createRegion(ORDER_REGION_NAME, 
attr.create());
       assertNotNull(orderRegion);
-      LogWriterUtils.getLogWriter().info(
-          "Partitioned Region ORDER created Successfully :"
-              + orderRegion.toString());
+      LogWriterUtils.getLogWriter().info("Partitioned Region ORDER created 
Successfully :" + orderRegion.toString());
 
       paf = new PartitionAttributesFactory();
-      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(
-          
totalNoofBuckets).setColocatedWith(ORDER_REGION_NAME).setPartitionResolver(
-          new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
+      
paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNoofBuckets).setColocatedWith(ORDER_REGION_NAME).setPartitionResolver(new
 CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
       attr = new AttributesFactory();
       attr.setPartitionAttributes(paf.create());
       Region shipmentRegion = cache.createRegion(SHIPMENT_REGION_NAME, 
attr.create());
       assertNotNull(shipmentRegion);
-      LogWriterUtils.getLogWriter().info(
-          "Partitioned Region SHIPMENT created Successfully :"
-              + shipmentRegion.toString());
+      LogWriterUtils.getLogWriter().info("Partitioned Region SHIPMENT created 
Successfully :" + shipmentRegion.toString());
     }
     return server.getPort();
   }
@@ -260,35 +236,28 @@ public class SingleHopStatsDUnitTest extends 
JUnit4CacheTestCase {
       RegionAttributes attrs = factory.create();
       region = cache.createRegion(Region_Name, attrs);
       assertNotNull(region);
-      LogWriterUtils.getLogWriter().info(
-          "Region " + Region_Name + " created Successfully :" + 
region.toString());
+      LogWriterUtils.getLogWriter().info("Region " + Region_Name + " created 
Successfully :" + region.toString());
     } else {
       AttributesFactory factory = new AttributesFactory();
       factory.setPoolName(poolName);
       RegionAttributes attrs = factory.create();
       Region customerRegion = cache.createRegion(CUSTOMER_REGION_NAME, attrs);
       assertNotNull(customerRegion);
-      LogWriterUtils.getLogWriter().info(
-          "Partitioned Region CUSTOMER created Successfully :"
-              + customerRegion.toString());
+      LogWriterUtils.getLogWriter().info("Partitioned Region CUSTOMER created 
Successfully :" + customerRegion.toString());
 
       factory = new AttributesFactory();
       factory.setPoolName(poolName);
       attrs = factory.create();
       Region orderRegion = cache.createRegion(ORDER_REGION_NAME, attrs);
       assertNotNull(orderRegion);
-      LogWriterUtils.getLogWriter().info(
-          "Partitioned Region ORDER created Successfully :"
-              + orderRegion.toString());
+      LogWriterUtils.getLogWriter().info("Partitioned Region ORDER created 
Successfully :" + orderRegion.toString());
 
       factory = new AttributesFactory();
       factory.setPoolName(poolName);
       attrs = factory.create();
       Region shipmentRegion = cache.createRegion("SHIPMENT", attrs);
       assertNotNull(shipmentRegion);
-      LogWriterUtils.getLogWriter().info(
-          "Partitioned Region SHIPMENT created Successfully :"
-              + shipmentRegion.toString());
+      LogWriterUtils.getLogWriter().info("Partitioned Region SHIPMENT created 
Successfully :" + shipmentRegion.toString());
     }
   }
 
@@ -304,23 +273,17 @@ public class SingleHopStatsDUnitTest extends 
JUnit4CacheTestCase {
         for (int i = 0; i < 113; i++) {
           region.create(new Integer(i), "create" + i);
         }
-        ClientMetadataService cms = ((GemFireCacheImpl) cache)
-            .getClientMetadataService();
-        final Map<String, ClientPartitionAdvisor> regionMetaData = cms
-            .getClientPRMetadata_TEST_ONLY();
+        ClientMetadataService cms = ((GemFireCacheImpl) 
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);
         }
-        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;
-        });
+        Awaitility.await().timeout(120, TimeUnit.SECONDS).pollDelay(100, 
TimeUnit.MILLISECONDS).pollInterval(500, TimeUnit.MILLISECONDS).until(() -> 
regionMetaData.size() == 1);
 
         assertTrue(regionMetaData.containsKey(region.getFullPath()));
         regionMetaData.get(region.getFullPath());
@@ -328,17 +291,15 @@ public class SingleHopStatsDUnitTest extends 
JUnit4CacheTestCase {
         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);
         }
-        ClientMetadataService cms = ((GemFireCacheImpl) cache)
-            .getClientMetadataService();
-        Map<String, ClientPartitionAdvisor> regionMetaData = cms
-            .getClientPRMetadata_TEST_ONLY();
+        ClientMetadataService cms = ((GemFireCacheImpl) 
cache).getClientMetadataService();
+        Map<String, ClientPartitionAdvisor> regionMetaData = 
cms.getClientPRMetadata_TEST_ONLY();
         assertEquals(1, regionMetaData.size());
         assertTrue(regionMetaData.containsKey(region.getFullPath()));
 
@@ -376,9 +337,9 @@ public class SingleHopStatsDUnitTest extends 
JUnit4CacheTestCase {
         }
       }
     }
+
     ClientMetadataService cms = cache.getClientMetadataService();
-    Map<String, ClientPartitionAdvisor> regionMetaData = cms
-        .getClientPRMetadata_TEST_ONLY();
+    Map<String, ClientPartitionAdvisor> regionMetaData = 
cms.getClientPRMetadata_TEST_ONLY();
     assertEquals(3, regionMetaData.size());
     assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
     regionMetaData.get(customerRegion.getFullPath());
@@ -407,31 +368,15 @@ public class SingleHopStatsDUnitTest extends 
JUnit4CacheTestCase {
     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());
+      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 <= 20; i++) {
         CustId custid = new CustId(i);
@@ -447,10 +392,8 @@ public class SingleHopStatsDUnitTest extends 
JUnit4CacheTestCase {
           }
         }
       }
-      ClientMetadataService cms = ((GemFireCacheImpl) cache)
-          .getClientMetadataService();
-      Map<String, ClientPartitionAdvisor> regionMetaData = cms
-          .getClientPRMetadata_TEST_ONLY();
+      ClientMetadataService cms = ((GemFireCacheImpl) 
cache).getClientMetadataService();
+      Map<String, ClientPartitionAdvisor> regionMetaData = 
cms.getClientPRMetadata_TEST_ONLY();
       assertEquals(3, regionMetaData.size());
       assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
       regionMetaData.get(customerRegion.getFullPath());
@@ -475,10 +418,8 @@ public class SingleHopStatsDUnitTest extends 
JUnit4CacheTestCase {
         for (int i = 0; i < 226; i++) {
           region.put(new Integer(i), "Update" + i);
         }
-        ClientMetadataService cms = ((GemFireCacheImpl) cache)
-            .getClientMetadataService();
-        Map<String, ClientPartitionAdvisor> regionMetaData = cms
-            .getClientPRMetadata_TEST_ONLY();
+        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());

Reply via email to