You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2016/03/21 22:33:05 UTC

[1/3] incubator-geode git commit: GEODE-980: Convert all SerializableCallables to lambda expressions

Repository: incubator-geode
Updated Branches:
  refs/heads/develop 60266fd56 -> bde4dd7c9


GEODE-980: Convert all SerializableCallables to lambda expressions


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

Branch: refs/heads/develop
Commit: 7e8da3454337c3201852fa7f00a3b999278f0d7d
Parents: 60266fd
Author: Jens Deppe <jd...@pivotal.io>
Authored: Mon Mar 14 15:09:12 2016 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Mon Mar 21 14:32:41 2016 -0700

----------------------------------------------------------------------
 ...eateAlterDestroyRegionCommandsDUnitTest.java | 813 ++++++++-----------
 1 file changed, 354 insertions(+), 459 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e8da345/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
index 9f6b141..7319934 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
@@ -44,7 +44,6 @@ import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.Wait;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
@@ -92,11 +91,8 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     VM vm = Host.getHost(0).getVM(1);
 
     // Create a cache in vm 1
-    vm.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        assertNotNull(getCache());
-      }
+    vm.invoke(() -> {
+      assertNotNull(getCache());
     });
 
     // Run create region command with compression
@@ -109,13 +105,10 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Make sure our region exists with compression enabled
-    vm.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        Region region = getCache().getRegion("compressedRegion");
-        assertNotNull(region);
-        assertTrue(SnappyCompressor.getDefaultInstance().equals(region.getAttributes().getCompressor()));
-      }
+    vm.invoke(() -> {
+      Region region = getCache().getRegion("compressedRegion");
+      assertNotNull(region);
+      assertTrue(SnappyCompressor.getDefaultInstance().equals(region.getAttributes().getCompressor()));
     });
 
     // cleanup
@@ -134,11 +127,8 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     VM vm = Host.getHost(0).getVM(1);
 
     // Create a cache in vm 1
-    vm.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
+    vm.invoke(() -> {
         assertNotNull(getCache());
-      }
     });
 
     // Create a region with an unrecognized compressor
@@ -150,12 +140,9 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.ERROR, cmdResult.getStatus());
 
     // Assert that our region was not created
-    vm.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        Region region = getCache().getRegion("compressedRegion");
-        assertNull(region);
-      }
+    vm.invoke(() -> {
+      Region region = getCache().getRegion("compressedRegion");
+      assertNull(region);
     });
   }
 
@@ -169,11 +156,8 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     VM vm = Host.getHost(0).getVM(1);
 
     // Create a cache in vm 1
-    vm.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
+    vm.invoke(() -> {
         assertNotNull(getCache());
-      }
     });
 
     // Create a region with no compression
@@ -184,13 +168,10 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Assert that our newly created region has no compression
-    vm.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        Region region = getCache().getRegion("testRegion");
-        assertNotNull(region);
-        assertNull(region.getAttributes().getCompressor());
-      }
+    vm.invoke(() -> {
+      Region region = getCache().getRegion("testRegion");
+      assertNotNull(region);
+      assertNull(region.getAttributes().getCompressor());
     });
 
     // Cleanup
@@ -204,50 +185,44 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     createDefaultSetup(null);
 
     for (int i = 1; i <= 2; i++) {
-      Host.getHost(0).getVM(i).invoke(new SerializableRunnable() {
-        @Override
-        public void run() {
-          final Cache cache = getCache();
+      Host.getHost(0).getVM(i).invoke(() -> {
+        final Cache cache = getCache();
 
-          RegionFactory<Object, Object> factory = cache.createRegionFactory(RegionShortcut.PARTITION);
-          factory.create("Customer");
+        RegionFactory<Object, Object> factory = cache.createRegionFactory(RegionShortcut.PARTITION);
+        factory.create("Customer");
 
-          PartitionAttributesFactory paFactory = new PartitionAttributesFactory();
-          paFactory.setColocatedWith("Customer");
-          factory.setPartitionAttributes(paFactory.create());
-          factory.create("Order");
-        }
+        PartitionAttributesFactory paFactory = new PartitionAttributesFactory();
+        paFactory.setColocatedWith("Customer");
+        factory.setPartitionAttributes(paFactory.create());
+        factory.create("Order");
       });
     }
 
     // Make sure that the region has been registered with the Manager MXBean
-    Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            try {
-              MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-              String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN,
-                  new Object[]{"/Customer", "*"});
-              ObjectName queryExpON = new ObjectName(queryExp);
-              return !(mbeanServer.queryNames(null, queryExpON).isEmpty());
-            } catch (MalformedObjectNameException mone) {
-              LogWriterUtils.getLogWriter().error(mone);
-              fail(mone.getMessage());
-              return false;
-            }
+    Host.getHost(0).getVM(0).invoke(() -> {
+      WaitCriterion wc = new WaitCriterion() {
+        @Override
+        public boolean done() {
+          try {
+            MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
+            String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN,
+                new Object[]{"/Customer", "*"});
+            ObjectName queryExpON = new ObjectName(queryExp);
+            return !(mbeanServer.queryNames(null, queryExpON).isEmpty());
+          } catch (MalformedObjectNameException mone) {
+            LogWriterUtils.getLogWriter().error(mone);
+            fail(mone.getMessage());
+            return false;
           }
+        }
 
-          @Override
-          public String description() {
-            return "Waiting for the region to be registed with the MXBean";
-          }
-        };
+        @Override
+        public String description() {
+          return "Waiting for the region to be registed with the MXBean";
+        }
+      };
 
-        Wait.waitForCriterion(wc, 5000, 500, true);
-      }
+      Wait.waitForCriterion(wc, 5000, 500, true);
     });
 
     // Test failure when region not found
@@ -325,63 +300,54 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
     assertTrue(commandResultToString(cmdResult).contains("No Regions Found"));
 
-    Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        Cache cache = getCache();
-        cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
-      }
+    Host.getHost(0).getVM(0).invoke(() -> {
+      Cache cache = getCache();
+      cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
     });
 
     this.alterVm1 = Host.getHost(0).getVM(1);
     this.alterVm1Name = "VM" + this.alterVm1.getPid();
-    this.alterVm1.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.NAME_NAME, alterVm1Name);
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, "Group1");
-        getSystem(localProps);
-        Cache cache = getCache();
-
-        // Setup queues and gateway senders to be used by all tests
-        cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
-        AsyncEventListener listener = new AsyncEventListener() {
-          @Override
-          public void close() {
-            // Nothing to do
-          }
+    this.alterVm1.invoke(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(DistributionConfig.NAME_NAME, alterVm1Name);
+      localProps.setProperty(DistributionConfig.GROUPS_NAME, "Group1");
+      getSystem(localProps);
+      Cache cache = getCache();
+
+      // Setup queues and gateway senders to be used by all tests
+      cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
+      AsyncEventListener listener = new AsyncEventListener() {
+        @Override
+        public void close() {
+          // Nothing to do
+        }
 
-          @Override
-          public boolean processEvents(List<AsyncEvent> events) {
-            return true;
-          }
-        };
-        cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId1, listener);
-        cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId2, listener);
-        cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId3, listener);
-
-        GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
-        gatewaySenderFactory.setManualStart(true);
-        gatewaySenderFactory.create(alterGatewaySenderId1, 2);
-        gatewaySenderFactory.create(alterGatewaySenderId2, 3);
-        gatewaySenderFactory.create(alterGatewaySenderId3, 4);
-      }
+        @Override
+        public boolean processEvents(List<AsyncEvent> events) {
+          return true;
+        }
+      };
+      cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId1, listener);
+      cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId2, listener);
+      cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId3, listener);
+
+      GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
+      gatewaySenderFactory.setManualStart(true);
+      gatewaySenderFactory.create(alterGatewaySenderId1, 2);
+      gatewaySenderFactory.create(alterGatewaySenderId2, 3);
+      gatewaySenderFactory.create(alterGatewaySenderId3, 4);
     });
 
     this.alterVm2 = Host.getHost(0).getVM(2);
     this.alterVm2Name = "VM" + this.alterVm2.getPid();
-    this.alterVm2.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.NAME_NAME, alterVm2Name);
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, "Group1,Group2");
-        getSystem(localProps);
-        Cache cache = getCache();
-
-        cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
-      }
+    this.alterVm2.invoke(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(DistributionConfig.NAME_NAME, alterVm2Name);
+      localProps.setProperty(DistributionConfig.GROUPS_NAME, "Group1,Group2");
+      getSystem(localProps);
+      Cache cache = getCache();
+
+      cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
     });
 
     deployJarFilesForRegionAlter();
@@ -391,11 +357,8 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     regionAlterSetDefaultsTest();
     regionAlterManipulatePlugInsTest();
 
-    this.alterVm1.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        getCache().getRegion(alterRegionName).destroyRegion();
-      }
+    this.alterVm1.invoke(() -> {
+      getCache().getRegion(alterRegionName).destroyRegion();
     });
   }
 
@@ -414,20 +377,14 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertTrue(
         stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
 
-    this.alterVm1.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
-      }
+    this.alterVm1.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
     });
 
-    this.alterVm2.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
-      }
+    this.alterVm2.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
     });
 
     commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
@@ -444,20 +401,14 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertTrue(
         stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
 
-    this.alterVm1.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
-      }
+    this.alterVm1.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
     });
 
-    this.alterVm2.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(6963, attributes.getEvictionAttributes().getMaximum());
-      }
+    this.alterVm2.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(6963, attributes.getEvictionAttributes().getMaximum());
     });
   }
 
@@ -491,28 +442,25 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertTrue(
         stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
 
-    this.alterVm1.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(35464, attributes.getEvictionAttributes().getMaximum());
-        assertEquals(3453, attributes.getEntryIdleTimeout().getTimeout());
-        assertTrue(attributes.getEntryIdleTimeout().getAction().isDestroy());
-        assertEquals(7563, attributes.getEntryTimeToLive().getTimeout());
-        assertTrue(attributes.getEntryTimeToLive().getAction().isDestroy());
-        assertEquals(6234, attributes.getRegionIdleTimeout().getTimeout());
-        assertTrue(attributes.getRegionIdleTimeout().getAction().isDestroy());
-        assertEquals(4562, attributes.getRegionTimeToLive().getTimeout());
-        assertTrue(attributes.getRegionTimeToLive().getAction().isDestroy());
-        assertEquals(1, attributes.getAsyncEventQueueIds().size());
-        assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId1));
-        assertEquals(1, attributes.getGatewaySenderIds().size());
-        assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId1));
-        assertEquals(1, attributes.getCacheListeners().length);
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerA", attributes.getCacheListeners()[0].getClass().getName());
-        assertEquals("com.cadrdunit.RegionAlterCacheWriter", attributes.getCacheWriter().getClass().getName());
-        assertEquals("com.cadrdunit.RegionAlterCacheLoader", attributes.getCacheLoader().getClass().getName());
-      }
+    this.alterVm1.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(35464, attributes.getEvictionAttributes().getMaximum());
+      assertEquals(3453, attributes.getEntryIdleTimeout().getTimeout());
+      assertTrue(attributes.getEntryIdleTimeout().getAction().isDestroy());
+      assertEquals(7563, attributes.getEntryTimeToLive().getTimeout());
+      assertTrue(attributes.getEntryTimeToLive().getAction().isDestroy());
+      assertEquals(6234, attributes.getRegionIdleTimeout().getTimeout());
+      assertTrue(attributes.getRegionIdleTimeout().getAction().isDestroy());
+      assertEquals(4562, attributes.getRegionTimeToLive().getTimeout());
+      assertTrue(attributes.getRegionTimeToLive().getAction().isDestroy());
+      assertEquals(1, attributes.getAsyncEventQueueIds().size());
+      assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId1));
+      assertEquals(1, attributes.getGatewaySenderIds().size());
+      assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId1));
+      assertEquals(1, attributes.getCacheListeners().length);
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerA", attributes.getCacheListeners()[0].getClass().getName());
+      assertEquals("com.cadrdunit.RegionAlterCacheWriter", attributes.getCacheWriter().getClass().getName());
+      assertEquals("com.cadrdunit.RegionAlterCacheLoader", attributes.getCacheLoader().getClass().getName());
     });
   }
 
@@ -532,28 +480,25 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertTrue(
         stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
 
-    this.alterVm2.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(35464, attributes.getEvictionAttributes().getMaximum());
-        assertEquals(3453, attributes.getEntryIdleTimeout().getTimeout());
-        assertTrue(attributes.getEntryIdleTimeout().getAction().isDestroy());
-        assertEquals(7563, attributes.getEntryTimeToLive().getTimeout());
-        assertTrue(attributes.getEntryTimeToLive().getAction().isDestroy());
-        assertEquals(6234, attributes.getRegionIdleTimeout().getTimeout());
-        assertTrue(attributes.getRegionIdleTimeout().getAction().isDestroy());
-        assertEquals(4562, attributes.getRegionTimeToLive().getTimeout());
-        assertTrue(attributes.getRegionTimeToLive().getAction().isDestroy());
-        assertEquals(1, attributes.getAsyncEventQueueIds().size());
-        assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId1));
-        assertEquals(1, attributes.getGatewaySenderIds().size());
-        assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId1));
-        assertEquals(1, attributes.getCacheListeners().length);
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerA", attributes.getCacheListeners()[0].getClass().getName());
-        assertEquals("com.cadrdunit.RegionAlterCacheWriter", attributes.getCacheWriter().getClass().getName());
-        assertEquals("com.cadrdunit.RegionAlterCacheLoader", attributes.getCacheLoader().getClass().getName());
-      }
+    this.alterVm2.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(35464, attributes.getEvictionAttributes().getMaximum());
+      assertEquals(3453, attributes.getEntryIdleTimeout().getTimeout());
+      assertTrue(attributes.getEntryIdleTimeout().getAction().isDestroy());
+      assertEquals(7563, attributes.getEntryTimeToLive().getTimeout());
+      assertTrue(attributes.getEntryTimeToLive().getAction().isDestroy());
+      assertEquals(6234, attributes.getRegionIdleTimeout().getTimeout());
+      assertTrue(attributes.getRegionIdleTimeout().getAction().isDestroy());
+      assertEquals(4562, attributes.getRegionTimeToLive().getTimeout());
+      assertTrue(attributes.getRegionTimeToLive().getAction().isDestroy());
+      assertEquals(1, attributes.getAsyncEventQueueIds().size());
+      assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId1));
+      assertEquals(1, attributes.getGatewaySenderIds().size());
+      assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId1));
+      assertEquals(1, attributes.getCacheListeners().length);
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerA", attributes.getCacheListeners()[0].getClass().getName());
+      assertEquals("com.cadrdunit.RegionAlterCacheWriter", attributes.getCacheWriter().getClass().getName());
+      assertEquals("com.cadrdunit.RegionAlterCacheLoader", attributes.getCacheLoader().getClass().getName());
     });
   }
 
@@ -583,23 +528,20 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertTrue(
         stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
 
-    this.alterVm1.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(0, attributes.getEvictionAttributes().getMaximum());
-        assertEquals(0, attributes.getEntryIdleTimeout().getTimeout());
-        assertTrue(attributes.getEntryIdleTimeout().getAction().isDestroy());
-        assertEquals(7563, attributes.getEntryTimeToLive().getTimeout());
-        assertTrue(attributes.getEntryTimeToLive().getAction().isInvalidate());
-        assertEquals(0, attributes.getRegionIdleTimeout().getTimeout());
-        assertTrue(attributes.getRegionIdleTimeout().getAction().isInvalidate());
-        assertEquals(4562, attributes.getRegionTimeToLive().getTimeout());
-        assertTrue(attributes.getRegionTimeToLive().getAction().isDestroy());
-        assertEquals(0, attributes.getAsyncEventQueueIds().size());
-        assertEquals(0, attributes.getGatewaySenderIds().size());
-        assertEquals(0, attributes.getCacheListeners().length);
-      }
+    this.alterVm1.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(0, attributes.getEvictionAttributes().getMaximum());
+      assertEquals(0, attributes.getEntryIdleTimeout().getTimeout());
+      assertTrue(attributes.getEntryIdleTimeout().getAction().isDestroy());
+      assertEquals(7563, attributes.getEntryTimeToLive().getTimeout());
+      assertTrue(attributes.getEntryTimeToLive().getAction().isInvalidate());
+      assertEquals(0, attributes.getRegionIdleTimeout().getTimeout());
+      assertTrue(attributes.getRegionIdleTimeout().getAction().isInvalidate());
+      assertEquals(4562, attributes.getRegionTimeToLive().getTimeout());
+      assertTrue(attributes.getRegionTimeToLive().getAction().isDestroy());
+      assertEquals(0, attributes.getAsyncEventQueueIds().size());
+      assertEquals(0, attributes.getGatewaySenderIds().size());
+      assertEquals(0, attributes.getCacheListeners().length);
     });
   }
 
@@ -629,23 +571,20 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertTrue(
         stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
 
-    this.alterVm1.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(3, attributes.getAsyncEventQueueIds().size());
-        assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId1));
-        assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId2));
-        assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId3));
-        assertEquals(3, attributes.getGatewaySenderIds().size());
-        assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId1));
-        assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId2));
-        assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId3));
-        assertEquals(3, attributes.getCacheListeners().length);
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerA", attributes.getCacheListeners()[0].getClass().getName());
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerB", attributes.getCacheListeners()[1].getClass().getName());
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerC", attributes.getCacheListeners()[2].getClass().getName());
-      }
+    this.alterVm1.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(3, attributes.getAsyncEventQueueIds().size());
+      assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId1));
+      assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId2));
+      assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId3));
+      assertEquals(3, attributes.getGatewaySenderIds().size());
+      assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId1));
+      assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId2));
+      assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId3));
+      assertEquals(3, attributes.getCacheListeners().length);
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerA", attributes.getCacheListeners()[0].getClass().getName());
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerB", attributes.getCacheListeners()[1].getClass().getName());
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerC", attributes.getCacheListeners()[2].getClass().getName());
     });
 
     // Now take 1 entry out of each of the sets
@@ -668,22 +607,19 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertTrue(
         stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
 
-    this.alterVm2.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(2, attributes.getAsyncEventQueueIds().size());
-        Iterator iterator = attributes.getAsyncEventQueueIds().iterator();
-        assertEquals(alterAsyncEventQueueId1, iterator.next());
-        assertEquals(alterAsyncEventQueueId2, iterator.next());
-        assertEquals(2, attributes.getGatewaySenderIds().size());
-        iterator = attributes.getGatewaySenderIds().iterator();
-        assertEquals(alterGatewaySenderId1, iterator.next());
-        assertEquals(alterGatewaySenderId3, iterator.next());
-        assertEquals(2, attributes.getCacheListeners().length);
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerB", attributes.getCacheListeners()[0].getClass().getName());
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerC", attributes.getCacheListeners()[1].getClass().getName());
-      }
+    this.alterVm2.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(2, attributes.getAsyncEventQueueIds().size());
+      Iterator iterator = attributes.getAsyncEventQueueIds().iterator();
+      assertEquals(alterAsyncEventQueueId1, iterator.next());
+      assertEquals(alterAsyncEventQueueId2, iterator.next());
+      assertEquals(2, attributes.getGatewaySenderIds().size());
+      iterator = attributes.getGatewaySenderIds().iterator();
+      assertEquals(alterGatewaySenderId1, iterator.next());
+      assertEquals(alterGatewaySenderId3, iterator.next());
+      assertEquals(2, attributes.getCacheListeners().length);
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerB", attributes.getCacheListeners()[0].getClass().getName());
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerC", attributes.getCacheListeners()[1].getClass().getName());
     });
 
     // Add 1 back to each of the sets
@@ -709,23 +645,20 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertTrue(
         stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
 
-    this.alterVm1.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-        assertEquals(3, attributes.getAsyncEventQueueIds().size());
-        assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId1));
-        assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId2));
-        assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId3));
-        assertEquals(3, attributes.getGatewaySenderIds().size());
-        assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId1));
-        assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId3));
-        assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId2));
-        assertEquals(3, attributes.getCacheListeners().length);
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerB", attributes.getCacheListeners()[0].getClass().getName());
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerC", attributes.getCacheListeners()[1].getClass().getName());
-        assertEquals("com.cadrdunit.RegionAlterCacheListenerA", attributes.getCacheListeners()[2].getClass().getName());
-      }
+    this.alterVm1.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(3, attributes.getAsyncEventQueueIds().size());
+      assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId1));
+      assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId2));
+      assertTrue(attributes.getAsyncEventQueueIds().contains(alterAsyncEventQueueId3));
+      assertEquals(3, attributes.getGatewaySenderIds().size());
+      assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId1));
+      assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId3));
+      assertTrue(attributes.getGatewaySenderIds().contains(alterGatewaySenderId2));
+      assertEquals(3, attributes.getCacheListeners().length);
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerB", attributes.getCacheListeners()[0].getClass().getName());
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerC", attributes.getCacheListeners()[1].getClass().getName());
+      assertEquals("com.cadrdunit.RegionAlterCacheListenerA", attributes.getCacheListeners()[2].getClass().getName());
     });
   }
 
@@ -740,35 +673,31 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
 
     // Start the Locator and wait for shared configuration to be available
     final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-
-        final File locatorLogFile = new File("locator-" + locatorPort + ".log");
-        final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, "Locator");
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "fine");
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-        try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, locatorLogFile, null,
-              locatorProps);
-
-          WaitCriterion wc = new WaitCriterion() {
-            @Override
-            public boolean done() {
-              return locator.isSharedConfigurationRunning();
-            }
-
-            @Override
-            public String description() {
-              return "Waiting for shared configuration to be started";
-            }
-          };
-          Wait.waitForCriterion(wc, 5000, 500, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
-        }
+    Host.getHost(0).getVM(3).invoke(() -> {
+      final File locatorLogFile = new File("locator-" + locatorPort + ".log");
+      final Properties locatorProps = new Properties();
+      locatorProps.setProperty(DistributionConfig.NAME_NAME, "Locator");
+      locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+      locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "fine");
+      locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+      try {
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, locatorLogFile, null,
+            locatorProps);
+
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        Wait.waitForCriterion(wc, 5000, 500, true);
+      } catch (IOException ioex) {
+        fail("Unable to create a locator with a shared configuration");
       }
     });
 
@@ -780,16 +709,13 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
 
     // Create a cache in VM 1
     VM vm = Host.getHost(0).getVM(1);
-    vm.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
-        getSystem(localProps);
-        assertNotNull(getCache());
-      }
+    vm.invoke(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+      localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
+      localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
+      getSystem(localProps);
+      assertNotNull(getCache());
     });
 
     // Test creating the region
@@ -802,69 +728,60 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Make sure that the region has been registered with the Manager MXBean
-    Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            try {
-              MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-              String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN,
-                  new Object[]{"/" + regionName, "*"});
-              ObjectName queryExpON = new ObjectName(queryExp);
-              return !(mbeanServer.queryNames(null, queryExpON).isEmpty());
-            } catch (MalformedObjectNameException mone) {
-              LogWriterUtils.getLogWriter().error(mone);
-              fail(mone.getMessage());
-              return false;
-            }
+    Host.getHost(0).getVM(0).invoke(() -> {
+      WaitCriterion wc = new WaitCriterion() {
+        @Override
+        public boolean done() {
+          try {
+            MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
+            String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN,
+                new Object[]{"/" + regionName, "*"});
+            ObjectName queryExpON = new ObjectName(queryExp);
+            return !(mbeanServer.queryNames(null, queryExpON).isEmpty());
+          } catch (MalformedObjectNameException mone) {
+            LogWriterUtils.getLogWriter().error(mone);
+            fail(mone.getMessage());
+            return false;
           }
+        }
 
-          @Override
-          public String description() {
-            return "Waiting for the region to be registed with the MXBean";
-          }
-        };
+        @Override
+        public String description() {
+          return "Waiting for the region to be registed with the MXBean";
+        }
+      };
 
-        Wait.waitForCriterion(wc, 5000, 500, true);
-      }
+      Wait.waitForCriterion(wc, 5000, 500, true);
     });
 
     // Make sure the region exists in the shared config
-    Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
-        try {
-          assertTrue(sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains(regionName));
-        } catch (Exception e) {
-          Assert.fail("Error in cluster configuration service", e);
-        }
+    Host.getHost(0).getVM(3).invoke(() -> {
+      SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
+      try {
+        assertTrue(sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains(regionName));
+      } catch (Exception e) {
+        Assert.fail("Error in cluster configuration service", e);
       }
     });
 
     //Restart the data vm to make sure the changes are in place
     vm = Host.getHost(0).getVM(1);
-    vm.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        Cache cache = getCache();
-        assertNotNull(cache);
-        cache.close();
-        assertTrue(cache.isClosed());
-
-        Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
-        localProps.setProperty(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "true");
-        getSystem(localProps);
-        cache = getCache();
-        assertNotNull(cache);
-        Region region = cache.getRegion(regionName);
-        assertNotNull(region);
-      }
+    vm.invoke(() -> {
+      Cache cache = getCache();
+      assertNotNull(cache);
+      cache.close();
+      assertTrue(cache.isClosed());
+
+      Properties localProps = new Properties();
+      localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+      localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
+      localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
+      localProps.setProperty(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "true");
+      getSystem(localProps);
+      cache = getCache();
+      assertNotNull(cache);
+      Region region = cache.getRegion(regionName);
+      assertNotNull(region);
     });
 
 
@@ -878,15 +795,12 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Make sure the region was altered in the shared config
-    Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
-        try {
-          assertTrue(sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains("45635"));
-        } catch (Exception e) {
-          fail("Error in cluster configuration service");
-        }
+    Host.getHost(0).getVM(3).invoke(() -> {
+      SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
+      try {
+        assertTrue(sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains("45635"));
+      } catch (Exception e) {
+        fail("Error in cluster configuration service");
       }
     });
 
@@ -926,35 +840,31 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
 
     // Start the Locator and wait for shared configuration to be available
     final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-
-        final File locatorLogFile = new File("locator-" + locatorPort + ".log");
-        final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, "Locator");
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "fine");
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-        try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, locatorLogFile, null,
-              locatorProps);
-
-          WaitCriterion wc = new WaitCriterion() {
-            @Override
-            public boolean done() {
-              return locator.isSharedConfigurationRunning();
-            }
-
-            @Override
-            public String description() {
-              return "Waiting for shared configuration to be started";
-            }
-          };
-          Wait.waitForCriterion(wc, 5000, 500, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
-        }
+    Host.getHost(0).getVM(3).invoke(() -> {
+      final File locatorLogFile = new File("locator-" + locatorPort + ".log");
+      final Properties locatorProps = new Properties();
+      locatorProps.setProperty(DistributionConfig.NAME_NAME, "Locator");
+      locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+      locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "fine");
+      locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+      try {
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, locatorLogFile, null,
+            locatorProps);
+
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        Wait.waitForCriterion(wc, 5000, 500, true);
+      } catch (IOException ioex) {
+        fail("Unable to create a locator with a shared configuration");
       }
     });
 
@@ -966,16 +876,13 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
 
     // Create a cache in VM 1
     VM vm = Host.getHost(0).getVM(1);
-    vm.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
-        getSystem(localProps);
-        assertNotNull(getCache());
-      }
+    vm.invoke(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+      localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
+      localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
+      getSystem(localProps);
+      assertNotNull(getCache());
     });
 
     // Test creating the region
@@ -988,45 +895,39 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Make sure that the region has been registered with the Manager MXBean
-    Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            try {
-              MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-              String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN,
-                  new Object[]{"/" + regionName, "*"});
-              ObjectName queryExpON = new ObjectName(queryExp);
-              return !(mbeanServer.queryNames(null, queryExpON).isEmpty());
-            } catch (MalformedObjectNameException mone) {
-              LogWriterUtils.getLogWriter().error(mone);
-              fail(mone.getMessage());
-              return false;
-            }
+    Host.getHost(0).getVM(0).invoke(() -> {
+      WaitCriterion wc = new WaitCriterion() {
+        @Override
+        public boolean done() {
+          try {
+            MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
+            String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN,
+                new Object[]{"/" + regionName, "*"});
+            ObjectName queryExpON = new ObjectName(queryExp);
+            return !(mbeanServer.queryNames(null, queryExpON).isEmpty());
+          } catch (MalformedObjectNameException mone) {
+            LogWriterUtils.getLogWriter().error(mone);
+            fail(mone.getMessage());
+            return false;
           }
+        }
 
-          @Override
-          public String description() {
-            return "Waiting for the region to be registed with the MXBean";
-          }
-        };
+        @Override
+        public String description() {
+          return "Waiting for the region to be registed with the MXBean";
+        }
+      };
 
-        Wait.waitForCriterion(wc, 5000, 500, true);
-      }
+      Wait.waitForCriterion(wc, 5000, 500, true);
     });
 
     // Make sure the region exists in the shared config
-    Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
-        try {
-          assertTrue(sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains(regionName));
-        } catch (Exception e) {
-          fail("Error occurred in cluster configuration service");
-        }
+    Host.getHost(0).getVM(3).invoke(() -> {
+      SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
+      try {
+        assertTrue(sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains(regionName));
+      } catch (Exception e) {
+        fail("Error occurred in cluster configuration service");
       }
     });
 
@@ -1038,42 +939,36 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Make sure the region was removed from the shared config
-    Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
-        try {
-          assertFalse(sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains(regionName));
-        } catch (Exception e) {
-          fail("Error occurred in cluster configuration service");
-        }
+    Host.getHost(0).getVM(3).invoke(() -> {
+      SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
+      try {
+        assertFalse(sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains(regionName));
+      } catch (Exception e) {
+        fail("Error occurred in cluster configuration service");
       }
     });
 
 
     //Restart the data vm to make sure the region is not existing any more
     vm = Host.getHost(0).getVM(1);
-    vm.invoke(new SerializableCallable() {
-      @Override
-      public Object call() {
-        Cache cache = getCache();
-        assertNotNull(cache);
-        cache.close();
-        assertTrue(cache.isClosed());
-
-        Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
-        localProps.setProperty(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "true");
-        getSystem(localProps);
-        cache = getCache();
-        assertNotNull(cache);
-        Region region = cache.getRegion(regionName);
-        assertNull(region);
-
-        return null;
-      }
+    vm.invoke(() -> {
+      Cache cache = getCache();
+      assertNotNull(cache);
+      cache.close();
+      assertTrue(cache.isClosed());
+
+      Properties localProps = new Properties();
+      localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+      localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
+      localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
+      localProps.setProperty(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "true");
+      getSystem(localProps);
+      cache = getCache();
+      assertNotNull(cache);
+      Region region = cache.getRegion(regionName);
+      assertNull(region);
+
+      return null;
     });
   }
 


[3/3] incubator-geode git commit: GEODE-980: The member's local hostname is just an IP address

Posted by je...@apache.org.
GEODE-980: The member's local hostname is just an IP address

- Trouble on Mac OS is that the hostname is not tied to a particular
  address like other *nix systems. A typical *nix system might have the
  hostname defined in /etc/hosts or resolvable via DNS. The hostname/IP
  mapping remains fixed and consistent. Under Mac OS (and at least under
  Java) the InetAddress.getLocalHost call is not deterministic and may
  associate the local hostname with any of the hosts' currently assigned
  IP addresses. There is no mapping done through /etc/hosts. This also
  means that given a localhost InetAddress, a reverse DNS lookup of the
  address will fail.
- By using only the IP address for the local hostname, the member ID
  remains consistent.


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

Branch: refs/heads/develop
Commit: bde4dd7c9c3b135a5c89501c8c8f1e75a6082d09
Parents: ae7d4da
Author: Jens Deppe <jd...@pivotal.io>
Authored: Thu Mar 17 07:31:40 2016 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Mon Mar 21 14:32:42 2016 -0700

----------------------------------------------------------------------
 .../src/main/java/com/gemstone/gemfire/internal/SocketCreator.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bde4dd7c/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
index 458f41a..2130a26 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
@@ -176,7 +176,7 @@ public class SocketCreator {
   static {
     InetAddress lh = null;
     try {
-      lh = InetAddress.getLocalHost();
+      lh = InetAddress.getByAddress(InetAddress.getLocalHost().getAddress());
       if (lh.isLoopbackAddress()) {
         InetAddress ipv4Fallback = null;
         InetAddress ipv6Fallback = null;


[2/3] incubator-geode git commit: GEODE-980: Refactor destroyRegion command

Posted by je...@apache.org.
GEODE-980: Refactor destroyRegion command

- Remove a bunch of logic separating local regions vs. other types. For
  distributed regions we just need to find one member ('cos the destroy
  region call gets distributed) and for local regions we choose each
  member hosting the named region Then do a function call against all
  these members.


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

Branch: refs/heads/develop
Commit: ae7d4da9c992db0810a9c37baa5d5a63db1ff75e
Parents: 7e8da34
Author: Jens Deppe <jd...@pivotal.io>
Authored: Thu Mar 17 07:24:48 2016 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Mon Mar 21 14:32:42 2016 -0700

----------------------------------------------------------------------
 .../CreateAlterDestroyRegionCommands.java       | 236 ++++++++-----------
 ...eateAlterDestroyRegionCommandsDUnitTest.java | 221 +++++++++--------
 2 files changed, 213 insertions(+), 244 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ae7d4da9/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
index bf1fdf0..29de9ee 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
@@ -16,28 +16,6 @@
  */
 package com.gemstone.gemfire.management.internal.cli.commands;
 
-import java.lang.reflect.Array;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.regex.Pattern;
-
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
 import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.CacheFactory;
@@ -54,7 +32,6 @@ import com.gemstone.gemfire.distributed.internal.DistributionManager;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.internal.ClassPathLoader;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.cache.xmlcache.CacheXml;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.lang.StringUtils;
 import com.gemstone.gemfire.management.DistributedRegionMXBean;
@@ -83,6 +60,25 @@ import com.gemstone.gemfire.management.internal.cli.result.TabularResultData;
 import com.gemstone.gemfire.management.internal.cli.util.RegionPath;
 import com.gemstone.gemfire.management.internal.configuration.SharedConfigurationWriter;
 import com.gemstone.gemfire.management.internal.configuration.domain.XmlEntity;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.regex.Pattern;
 
 /**
  * 
@@ -1001,118 +997,75 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
           mandatory = true,
           help = CliStrings.DESTROY_REGION__REGION__HELP)
       String regionPath) {
+
+    if (regionPath == null) {
+      return ResultBuilder.createInfoResult(CliStrings.DESTROY_REGION__MSG__SPECIFY_REGIONPATH_TO_DESTROY);
+    }
+
+    if (regionPath.trim().isEmpty() || regionPath.equals(Region.SEPARATOR)) {
+      return ResultBuilder.createInfoResult(
+          CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGIONPATH_0_NOT_VALID, new Object[]{regionPath}));
+    }
+
     Result result = null;
     XmlEntity xmlEntity = null;
     try {
-      if (regionPath != null) {
-        if (regionPath.trim().isEmpty()) { // unlikely through gfsh
-          result = ResultBuilder.createInfoResult(CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGIONPATH_0_NOT_VALID,
-              new Object[] { regionPath }));
-        } else if (regionPath.equals(Region.SEPARATOR)) {
-          result = ResultBuilder.createUserErrorResult(CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGIONPATH_0_NOT_VALID,
-              new Object[] { regionPath }));
-        } else {
-          boolean isRegionDestroyed = false;
-          String message = "";
-          Cache cache = CacheFactory.getAnyInstance();
-          ManagementService managementService = ManagementService.getExistingManagementService(cache);
-          String regionPathToUse = regionPath;
-          String regionName = regionPath.startsWith(Region.SEPARATOR) ? regionPath.substring(1) : regionPath;
-          
-          if (!regionPathToUse.startsWith(Region.SEPARATOR)) {
-            regionPathToUse = Region.SEPARATOR + regionPathToUse;
-          }
-          Set<DistributedMember>[] regionMembersList = findMembersForRegion(cache, managementService, regionPathToUse);
-          if (regionMembersList != null) {
-            Set<DistributedMember> regionMembers      = regionMembersList[0];
-            Set<DistributedMember> localRegionMembers = regionMembersList[1];
-            
-            if (regionMembers != null && !regionMembers.isEmpty()) { // Distributed Region with this region path exists
-              Region<?, ?> regionInThisCache = cache.getRegion(regionPath);
-              if (regionInThisCache != null) {// exists in local cache?
-                regionInThisCache.destroyRegion(); // this is for a Distributed Region & destroy event will be propagated
-                message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED, new Object[] { regionPath, /*subRegionMessage*/"" });
-                xmlEntity = new XmlEntity(CacheXml.REGION, "name", regionName);
-                isRegionDestroyed = true;
-              } else {
-                CliFunctionResult destroyRegionResult = null;
-                Iterator<DistributedMember> it = regionMembers.iterator();
-                DistributedMember firstMember = it.next(); // regionMembers is not empty
-
-                ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(RegionDestroyFunction.INSTANCE, regionPath, firstMember);
-                List<CliFunctionResult> destroyRegionResults = (List<CliFunctionResult>) resultCollector.getResult();
-
-                destroyRegionResult = destroyRegionResults.get(0);
-
-                if (destroyRegionResult.isSuccessful()) {
-                  message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED, new Object[] { regionPath, /*subRegionMessage*/"" });
-                  xmlEntity = destroyRegionResult.getXmlEntity();
-                  isRegionDestroyed = true;
-                } else if (destroyRegionResult.getThrowable() != null) {
-                  Throwable t = destroyRegionResult.getThrowable();
-                  LogWrapper.getInstance().info(t.getMessage(), t);
-                  message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__ERROR_OCCURRED_WHILE_DESTROYING_0_REASON_1,
-                      new Object[] { regionPath, t.getMessage() });
-                  isRegionDestroyed = false;
-                } else {
-                  message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__UNKNOWN_RESULT_WHILE_DESTROYING_REGION_0_REASON_1,
-                      new Object[] { regionPath, destroyRegionResult.getMessage() });
-                  isRegionDestroyed = false;
-                }
-              }
-            }
+      String message = "";
+      Cache cache = CacheFactory.getAnyInstance();
+      ManagementService managementService = ManagementService.getExistingManagementService(cache);
+      String regionPathToUse = regionPath;
 
-            if (localRegionMembers != null && !localRegionMembers.isEmpty()) { // Local Regions with this region path also exist
-              Region<?, ?> regionInThisCache = cache.getRegion(regionPath);
-              if (regionInThisCache != null) {// exists in local cache?
-                regionInThisCache.destroyRegion();
-                message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED, new Object[] { regionPath, /*subRegionMessage*/"" });
-                xmlEntity = new XmlEntity(CacheXml.REGION, "name", regionName);
-                isRegionDestroyed = true;
-              }
-              DistributedMember distributedMember = cache.getDistributedSystem().getDistributedMember();
-              localRegionMembers.remove(distributedMember); //remove this member from the found members
-              
-              CliFunctionResult destroyRegionResult = null;
-
-              ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(RegionDestroyFunction.INSTANCE, regionPath, localRegionMembers);
-              List<CliFunctionResult> resultsList = (List<CliFunctionResult>) resultCollector.getResult();
-              for (int i = 0; i < resultsList.size(); i++) {
-                destroyRegionResult = resultsList.get(i) ;
-                if (destroyRegionResult.isSuccessful()) {
-                  message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED, new Object[] { regionPath, /*subRegionMessage*/"" });
-                  xmlEntity = destroyRegionResult.getXmlEntity();
-                  isRegionDestroyed = true;
-                } else if (destroyRegionResult.getThrowable() != null) {
-                  Throwable t = destroyRegionResult.getThrowable();
-                  LogWrapper.getInstance().info(t.getMessage(), t);
-                  message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__ERROR_OCCURRED_WHILE_DESTROYING_0_REASON_1,
-                      new Object[] { regionPath, t.getMessage() });
-                  isRegionDestroyed = false;
-                } else {
-                  message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__UNKNOWN_RESULT_WHILE_DESTROYING_REGION_0_REASON_1,
-                      new Object[] { regionPath, destroyRegionResult.getMessage() });
-                  isRegionDestroyed = false;
-                }
-              }
-            }
-          } else {
-            message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__COULDNOT_FIND_REGIONPATH_0_IN_GEMFIRE, new Object[] { regionPath, "jmx-manager-update-rate milliseconds" });
-            isRegionDestroyed = false;
-          }
-          if (isRegionDestroyed) {
-            result = ResultBuilder.createInfoResult(message);
-          } else {
-            result = ResultBuilder.createUserErrorResult(message);
-          }
+      if (!regionPathToUse.startsWith(Region.SEPARATOR)) {
+        regionPathToUse = Region.SEPARATOR + regionPathToUse;
+      }
+
+      Set<DistributedMember> regionMembersList = findMembersForRegion(cache, managementService, regionPathToUse);
+
+      if (regionMembersList.size() == 0) {
+        return ResultBuilder.createUserErrorResult(
+            CliStrings.format(CliStrings.DESTROY_REGION__MSG__COULDNOT_FIND_REGIONPATH_0_IN_GEMFIRE,
+                new Object[]{regionPath, "jmx-manager-update-rate milliseconds"}));
+      }
+
+      CliFunctionResult destroyRegionResult = null;
+
+      ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(RegionDestroyFunction.INSTANCE, regionPath,
+          regionMembersList);
+      List<CliFunctionResult> resultsList = (List<CliFunctionResult>) resultCollector.getResult();
+      message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED,
+          new Object[]{regionPath, /*subRegionMessage*/""});
+
+      // Only if there is an error is this set to false
+      boolean isRegionDestroyed = true;
+      for (int i = 0; i < resultsList.size(); i++) {
+        destroyRegionResult = resultsList.get(i);
+        if (destroyRegionResult.isSuccessful()) {
+          xmlEntity = destroyRegionResult.getXmlEntity();
+        } else if (destroyRegionResult.getThrowable() != null) {
+          Throwable t = destroyRegionResult.getThrowable();
+          LogWrapper.getInstance().info(t.getMessage(), t);
+          message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__ERROR_OCCURRED_WHILE_DESTROYING_0_REASON_1,
+              new Object[]{regionPath, t.getMessage()});
+          isRegionDestroyed = false;
+        } else {
+          message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__UNKNOWN_RESULT_WHILE_DESTROYING_REGION_0_REASON_1,
+              new Object[]{regionPath, destroyRegionResult.getMessage()});
+          isRegionDestroyed = false;
         }
+      }
+      if (isRegionDestroyed) {
+        result = ResultBuilder.createInfoResult(message);
       } else {
-        result = ResultBuilder.createInfoResult(CliStrings.DESTROY_REGION__MSG__SPECIFY_REGIONPATH_TO_DESTROY);
+        result = ResultBuilder.createUserErrorResult(message);
       }
     } catch (IllegalStateException e) {
-      result = ResultBuilder.createUserErrorResult(CliStrings.format(CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1, new Object[] {regionPath, e.getMessage()}));
+      result = ResultBuilder.createUserErrorResult(
+          CliStrings.format(CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1,
+              new Object[]{regionPath, e.getMessage()}));
     } catch (Exception e) {
-      result = ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1, new Object[] {regionPath, e.getMessage()}));
+      result = ResultBuilder.createGemFireErrorResult(
+          CliStrings.format(CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1,
+              new Object[]{regionPath, e.getMessage()}));
     }
 
     if (xmlEntity != null) {
@@ -1121,32 +1074,36 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     return result;
   }
 
-  private Set<DistributedMember>[] findMembersForRegion(Cache cache, ManagementService managementService, String regionPath) {
-    Set<DistributedMember>[] membersList = null;
+  private Set<DistributedMember> findMembersForRegion(Cache cache, ManagementService managementService, String regionPath) {
+    Set<DistributedMember> membersList = new HashSet<>();
     Set<String> regionMemberIds = Collections.emptySet();
-    Set<String> localRegionMemberIds = Collections.emptySet();
     MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
     String queryExp = MessageFormat.format(MBeanJMXAdapter.OBJECTNAME__REGION_MXBEAN, new Object[] {regionPath, "*"});
-//    String queryExp = MessageFormat.format(MBeanJMXAdapter.OBJECTNAME__REGION_MXBEAN, new Object[] {MBeanJMXAdapter.makeCompliantRegionNameAppender(regionPath), "*"});
+
     try {
       ObjectName queryExpON = new ObjectName(queryExp);
       Set<ObjectName> queryNames = mbeanServer.queryNames(null, queryExpON);
       if (queryNames != null && queryNames.size() != 0) {
-        regionMemberIds      = new HashSet<String>();
-        localRegionMemberIds = new HashSet<String>();
-
-        membersList = (Set<DistributedMember>[])Array.newInstance(HashSet.class, 2);
+        regionMemberIds      = new HashSet<>();
       }
+
+      boolean addedOneRemote = false;
       for (ObjectName regionMBeanObjectName : queryNames) {
         try {
           RegionMXBean regionMXBean = managementService.getMBeanInstance(regionMBeanObjectName, RegionMXBean.class);
           if (regionMXBean != null) {
             RegionAttributesData regionAttributes = regionMXBean.listRegionAttributes();
             String scope = regionAttributes.getScope();
+            // For Scope.LOCAL regions we need to identify each hosting member, but for
+            // other scopes we just need a single member as the region destroy will be
+            // propagated.
             if (Scope.LOCAL.equals(Scope.fromString(scope))) {
-              localRegionMemberIds.add(regionMXBean.getMember());
-            } else {
               regionMemberIds.add(regionMXBean.getMember());
+            } else {
+              if (!addedOneRemote) {
+                regionMemberIds.add(regionMXBean.getMember());
+                addedOneRemote = true;
+              }
             }
           }
         } catch (ClassCastException e) {
@@ -1156,13 +1113,10 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
           }
         }
       }
+
       if (!regionMemberIds.isEmpty()) {
-        membersList[0] = getMembersByIds(cache, regionMemberIds);
+        membersList = getMembersByIds(cache, regionMemberIds);
       }
-      if (!localRegionMemberIds.isEmpty()) {
-        membersList[1] = getMembersByIds(cache, localRegionMemberIds);
-      }
-      
     } catch (MalformedObjectNameException e) {
       LogWrapper.getInstance().info(e.getMessage(), e);
     } catch (NullPointerException e) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ae7d4da9/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
index 7319934..10b37c1 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
@@ -22,6 +22,7 @@ import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionAttributes;
 import com.gemstone.gemfire.cache.RegionFactory;
 import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.Scope;
 import com.gemstone.gemfire.cache.asyncqueue.AsyncEvent;
 import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener;
 import com.gemstone.gemfire.cache.wan.GatewaySenderFactory;
@@ -45,8 +46,7 @@ import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
-import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.jayway.awaitility.Awaitility;
 
 import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
@@ -59,7 +59,9 @@ import java.text.MessageFormat;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
+import java.util.concurrent.Callable;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
 
 public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBase {
   private static final long serialVersionUID = 1L;
@@ -181,7 +183,7 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
   }
 
-  public void testDestroyRegion() {
+  public void testDestroyDistributedRegion() {
     createDefaultSetup(null);
 
     for (int i = 1; i <= 2; i++) {
@@ -198,32 +200,8 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
       });
     }
 
-    // Make sure that the region has been registered with the Manager MXBean
-    Host.getHost(0).getVM(0).invoke(() -> {
-      WaitCriterion wc = new WaitCriterion() {
-        @Override
-        public boolean done() {
-          try {
-            MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-            String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN,
-                new Object[]{"/Customer", "*"});
-            ObjectName queryExpON = new ObjectName(queryExp);
-            return !(mbeanServer.queryNames(null, queryExpON).isEmpty());
-          } catch (MalformedObjectNameException mone) {
-            LogWriterUtils.getLogWriter().error(mone);
-            fail(mone.getMessage());
-            return false;
-          }
-        }
-
-        @Override
-        public String description() {
-          return "Waiting for the region to be registed with the MXBean";
-        }
-      };
-
-      Wait.waitForCriterion(wc, 5000, 500, true);
-    });
+    waitForRegionMBeanCreation("/Customer", 2);
+    waitForRegionMBeanCreation("/Order", 2);
 
     // Test failure when region not found
     String command = "destroy region --name=DOESNOTEXIST";
@@ -260,6 +238,111 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
   }
 
+  public void testDestroyLocalRegions() {
+    createDefaultSetup(null);
+
+    for (int i = 1; i <= 3; i++) {
+      Host.getHost(0).getVM(i).invoke(() -> {
+        final Cache cache = getCache();
+
+        RegionFactory<Object, Object> factory = cache.createRegionFactory(RegionShortcut.REPLICATE);
+        factory.setScope(Scope.LOCAL);
+        factory.create("Customer");
+      });
+    }
+
+    waitForRegionMBeanCreation("/Customer", 3);
+
+    // Test failure when region not found
+    String command = "destroy region --name=DOESNOTEXIST";
+    LogWriterUtils.getLogWriter().info("testDestroyRegion command=" + command);
+    CommandResult cmdResult = executeCommand(command);
+    String strr = commandResultToString(cmdResult);
+    LogWriterUtils.getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertTrue(stringContainsLine(strr, "Could not find.*\"DOESNOTEXIST\".*"));
+    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
+
+    command = "destroy region --name=/Customer";
+    LogWriterUtils.getLogWriter().info("testDestroyRegion command=" + command);
+    cmdResult = executeCommand(command);
+    strr = commandResultToString(cmdResult);
+    assertTrue(stringContainsLine(strr, ".*Customer.*destroyed successfully.*"));
+    LogWriterUtils.getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    for (int i = 1; i <= 3; i++) {
+      final int x = i;
+      Host.getHost(0).getVM(i).invoke(() -> {
+        assertNull("Region still exists in VM " + x, getCache().getRegion("Customer"));
+      });
+    }
+  }
+
+  public void testDestroyLocalAndDistributedRegions() {
+    createDefaultSetup(null);
+
+    for (int i = 1; i <= 2; i++) {
+      Host.getHost(0).getVM(i).invoke(() -> {
+        final Cache cache = getCache();
+        RegionFactory<Object, Object> factory = cache.createRegionFactory(RegionShortcut.PARTITION);
+        factory.create("Customer");
+      });
+    }
+
+    Host.getHost(0).getVM(3).invoke(() -> {
+      final Cache cache = getCache();
+      RegionFactory<Object, Object> factory = cache.createRegionFactory(RegionShortcut.REPLICATE);
+      factory.setScope(Scope.LOCAL);
+      factory.create("Customer");
+    });
+
+    waitForRegionMBeanCreation("/Customer", 3);
+
+    // Test failure when region not found
+    String command = "destroy region --name=DOESNOTEXIST";
+    LogWriterUtils.getLogWriter().info("testDestroyRegion command=" + command);
+    CommandResult cmdResult = executeCommand(command);
+    String strr = commandResultToString(cmdResult);
+    LogWriterUtils.getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertTrue(stringContainsLine(strr, "Could not find.*\"DOESNOTEXIST\".*"));
+    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
+
+    command = "destroy region --name=/Customer";
+    LogWriterUtils.getLogWriter().info("testDestroyRegion command=" + command);
+    cmdResult = executeCommand(command);
+    strr = commandResultToString(cmdResult);
+    assertTrue(stringContainsLine(strr, ".*Customer.*destroyed successfully.*"));
+    LogWriterUtils.getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    for (int i = 1; i <= 3; i++) {
+      final int x = i;
+      Host.getHost(0).getVM(i).invoke(() -> {
+        assertNull("Region still exists in VM " + x, getCache().getRegion("Customer"));
+      });
+    }
+  }
+
+  private void waitForRegionMBeanCreation(final String regionPath, final int mbeanCount) {
+    Host.getHost(0).getVM(0).invoke(() -> {
+      Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(newRegionMBeanIsCreated(regionPath, mbeanCount));
+    });
+  }
+
+  private Callable<Boolean> newRegionMBeanIsCreated(final String regionPath, final int mbeanCount) {
+    return () -> {
+      try {
+        MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
+        String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN, new Object[]{regionPath, "*"});
+        ObjectName queryExpON = new ObjectName(queryExp);
+        return mbeanServer.queryNames(null, queryExpON).size() == mbeanCount;
+      } catch (MalformedObjectNameException mone) {
+        LogWriterUtils.getLogWriter().error(mone);
+        fail(mone.getMessage());
+        return false;
+      }
+    };
+  }
 
   public void testCreateRegion46391() throws IOException {
     createDefaultSetup(null);
@@ -669,6 +752,7 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     disconnectAllFromDS();
 
     final String regionName = "testRegionSharedConfigRegion";
+    final String regionPath = "/" + regionName;
     final String groupName = "testRegionSharedConfigGroup";
 
     // Start the Locator and wait for shared configuration to be available
@@ -684,18 +768,7 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
         final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, locatorLogFile, null,
             locatorProps);
 
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            return locator.isSharedConfigurationRunning();
-          }
-
-          @Override
-          public String description() {
-            return "Waiting for shared configuration to be started";
-          }
-        };
-        Wait.waitForCriterion(wc, 5000, 500, true);
+        Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> locator.isSharedConfigurationRunning());
       } catch (IOException ioex) {
         fail("Unable to create a locator with a shared configuration");
       }
@@ -728,31 +801,7 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Make sure that the region has been registered with the Manager MXBean
-    Host.getHost(0).getVM(0).invoke(() -> {
-      WaitCriterion wc = new WaitCriterion() {
-        @Override
-        public boolean done() {
-          try {
-            MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-            String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN,
-                new Object[]{"/" + regionName, "*"});
-            ObjectName queryExpON = new ObjectName(queryExp);
-            return !(mbeanServer.queryNames(null, queryExpON).isEmpty());
-          } catch (MalformedObjectNameException mone) {
-            LogWriterUtils.getLogWriter().error(mone);
-            fail(mone.getMessage());
-            return false;
-          }
-        }
-
-        @Override
-        public String description() {
-          return "Waiting for the region to be registed with the MXBean";
-        }
-      };
-
-      Wait.waitForCriterion(wc, 5000, 500, true);
-    });
+    waitForRegionMBeanCreation(regionPath, 1);
 
     // Make sure the region exists in the shared config
     Host.getHost(0).getVM(3).invoke(() -> {
@@ -836,6 +885,7 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     disconnectAllFromDS();
 
     final String regionName = "testRegionSharedConfigRegion";
+    final String regionPath = "/" + regionName;
     final String groupName = "testRegionSharedConfigGroup";
 
     // Start the Locator and wait for shared configuration to be available
@@ -851,18 +901,7 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
         final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, locatorLogFile, null,
             locatorProps);
 
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            return locator.isSharedConfigurationRunning();
-          }
-
-          @Override
-          public String description() {
-            return "Waiting for shared configuration to be started";
-          }
-        };
-        Wait.waitForCriterion(wc, 5000, 500, true);
+        Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> locator.isSharedConfigurationRunning());
       } catch (IOException ioex) {
         fail("Unable to create a locator with a shared configuration");
       }
@@ -895,31 +934,7 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Make sure that the region has been registered with the Manager MXBean
-    Host.getHost(0).getVM(0).invoke(() -> {
-      WaitCriterion wc = new WaitCriterion() {
-        @Override
-        public boolean done() {
-          try {
-            MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-            String queryExp = MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN,
-                new Object[]{"/" + regionName, "*"});
-            ObjectName queryExpON = new ObjectName(queryExp);
-            return !(mbeanServer.queryNames(null, queryExpON).isEmpty());
-          } catch (MalformedObjectNameException mone) {
-            LogWriterUtils.getLogWriter().error(mone);
-            fail(mone.getMessage());
-            return false;
-          }
-        }
-
-        @Override
-        public String description() {
-          return "Waiting for the region to be registed with the MXBean";
-        }
-      };
-
-      Wait.waitForCriterion(wc, 5000, 500, true);
-    });
+    waitForRegionMBeanCreation(regionPath, 1);
 
     // Make sure the region exists in the shared config
     Host.getHost(0).getVM(3).invoke(() -> {