You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2017/08/11 20:06:16 UTC

[1/5] geode git commit: GEODE-3255: Refactor CreateAlterDestroyRegionCommands and tests

Repository: geode
Updated Branches:
  refs/heads/develop a7f29525d -> 756efe77c


http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
new file mode 100644
index 0000000..e178d8c
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
@@ -0,0 +1,388 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal.cli.commands;
+
+import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
+import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+import static org.awaitility.Awaitility.waitAtMost;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.MessageFormat;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.PartitionAttributesFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.distributed.Locator;
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.InternalLocator;
+import org.apache.geode.internal.AvailablePort;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.MBeanJMXAdapter;
+import org.apache.geode.management.internal.ManagementConstants;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+
+@Category(DistributedTest.class)
+public class DestroyRegionCommandDUnitTest extends CliCommandTestBase {
+  @Test
+  public void testDestroyDistributedRegion() {
+    setUpJmxManagerOnVm0ThenConnect(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");
+
+        PartitionAttributesFactory paFactory = new PartitionAttributesFactory();
+        paFactory.setColocatedWith("Customer");
+        factory.setPartitionAttributes(paFactory.create());
+        factory.create("Order");
+      });
+    }
+
+    waitForRegionMBeanCreation("/Customer", 2);
+    waitForRegionMBeanCreation("/Order", 2);
+
+    // Test failure when region not found
+    String command = "destroy region --name=DOESNOTEXIST";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    CommandResult cmdResult = executeCommand(command);
+    String strr = commandResultToString(cmdResult);
+    getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertTrue(stringContainsLine(strr, "Could not find.*\"DOESNOTEXIST\".*"));
+    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
+
+    // Test unable to destroy with co-location
+    command = "destroy region --name=/Customer";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    cmdResult = executeCommand(command);
+    strr = commandResultToString(cmdResult);
+    getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
+
+    // Test success
+    command = "destroy region --name=/Order";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    cmdResult = executeCommand(command);
+    strr = commandResultToString(cmdResult);
+    assertTrue(stringContainsLine(strr, ".*Order.*destroyed successfully.*"));
+    getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    command = "destroy region --name=/Customer";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    cmdResult = executeCommand(command);
+    strr = commandResultToString(cmdResult);
+    assertTrue(stringContainsLine(strr, ".*Customer.*destroyed successfully.*"));
+    getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+  }
+
+  @Test
+  public void testDestroyLocalRegions() {
+    setUpJmxManagerOnVm0ThenConnect(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";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    CommandResult cmdResult = executeCommand(command);
+    String strr = commandResultToString(cmdResult);
+    getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertTrue(stringContainsLine(strr, "Could not find.*\"DOESNOTEXIST\".*"));
+    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
+
+    command = "destroy region --name=/Customer";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    cmdResult = executeCommand(command);
+    strr = commandResultToString(cmdResult);
+    assertTrue(stringContainsLine(strr, ".*Customer.*destroyed successfully.*"));
+    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"));
+      });
+    }
+  }
+
+  @Test
+  public void testDestroyLocalAndDistributedRegions() {
+    setUpJmxManagerOnVm0ThenConnect(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");
+        factory.create("Customer-2");
+        factory.create("Customer_3");
+      });
+    }
+
+    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");
+      factory.create("Customer-2");
+      factory.create("Customer_3");
+    });
+
+    waitForRegionMBeanCreation("/Customer", 3);
+
+    // Test failure when region not found
+    String command = "destroy region --name=DOESNOTEXIST";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    CommandResult cmdResult = executeCommand(command);
+    String strr = commandResultToString(cmdResult);
+    getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertTrue(stringContainsLine(strr, "Could not find.*\"DOESNOTEXIST\".*"));
+    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
+
+    command = "destroy region --name=/Customer";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    cmdResult = executeCommand(command);
+    strr = commandResultToString(cmdResult);
+    assertTrue(stringContainsLine(strr, ".*Customer.*destroyed successfully.*"));
+    getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    command = "destroy region --name=/Customer_3";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    cmdResult = executeCommand(command);
+    strr = commandResultToString(cmdResult);
+    assertTrue(stringContainsLine(strr, ".*Customer_3.*destroyed successfully.*"));
+    getLogWriter().info("testDestroyRegion strr=" + strr);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    command = "destroy region --name=/Customer-2";
+    getLogWriter().info("testDestroyRegion command=" + command);
+    cmdResult = executeCommand(command);
+    strr = commandResultToString(cmdResult);
+    assertTrue(stringContainsLine(strr, ".*Customer-2.*destroyed successfully.*"));
+    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"));
+        assertNull("Region still exists in VM " + x, getCache().getRegion("Customer-2"));
+        assertNull("Region still exists in VM " + x, getCache().getRegion("Customer_3"));
+      });
+    }
+  }
+
+  @Test
+  public void testDestroyRegionWithSharedConfig() {
+    disconnectAllFromDS();
+
+    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    jmxPort = ports[0];
+    httpPort = ports[1];
+    try {
+      jmxHost = InetAddress.getLocalHost().getHostName();
+    } catch (UnknownHostException ignore) {
+      jmxHost = "localhost";
+    }
+
+
+    final String regionName = "testRegionSharedConfigRegion";
+    final String regionPath = "/" + regionName;
+    final String groupName = "testRegionSharedConfigGroup";
+
+    // Start the Locator and wait for shared configuration to be available
+    final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+
+    final Properties locatorProps = new Properties();
+    locatorProps.setProperty(NAME, "Locator");
+    locatorProps.setProperty(MCAST_PORT, "0");
+    locatorProps.setProperty(LOG_LEVEL, "fine");
+    locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
+    locatorProps.setProperty(JMX_MANAGER, "true");
+    locatorProps.setProperty(JMX_MANAGER_START, "true");
+    locatorProps.setProperty(JMX_MANAGER_BIND_ADDRESS, String.valueOf(jmxHost));
+    locatorProps.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort));
+    locatorProps.setProperty(HTTP_SERVICE_PORT, String.valueOf(httpPort));
+
+    Host.getHost(0).getVM(0).invoke(() -> {
+      final File locatorLogFile = new File("locator-" + locatorPort + ".log");
+      try {
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort,
+            locatorLogFile, null, locatorProps);
+
+        waitAtMost(5, TimeUnit.SECONDS).until(locator::isSharedConfigurationRunning);
+      } catch (IOException ioex) {
+        fail("Unable to create a locator with a shared configuration");
+      }
+    });
+
+    connect(jmxHost, jmxPort, httpPort, getDefaultShell());
+
+    // Create a cache in VM 1
+    VM vm = Host.getHost(0).getVM(1);
+    vm.invoke(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(MCAST_PORT, "0");
+      localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
+      localProps.setProperty(GROUPS, groupName);
+      getSystem(localProps);
+      assertNotNull(getCache());
+    });
+
+    // Test creating the region
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, regionName);
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__STATISTICSENABLED, "true");
+    commandStringBuilder.addOption(CliStrings.GROUP, groupName);
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    // Make sure that the region has been registered with the Manager MXBean
+    waitForRegionMBeanCreation(regionPath, 1);
+
+    // Make sure the region exists in the shared config
+    Host.getHost(0).getVM(0).invoke(() -> {
+      ClusterConfigurationService sharedConfig =
+          ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
+      try {
+        assertTrue(
+            sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains(regionName));
+      } catch (Exception e) {
+        fail("Error occurred in cluster configuration service");
+      }
+    });
+
+    // Test destroying the region
+    commandStringBuilder = new CommandStringBuilder(CliStrings.DESTROY_REGION);
+    commandStringBuilder.addOption(CliStrings.DESTROY_REGION__REGION, regionName);
+    cmdResult = executeCommand(commandStringBuilder.toString());
+    getLogWriter().info("#SB" + commandResultToString(cmdResult));
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    // Make sure the region was removed from the shared config
+    Host.getHost(0).getVM(0).invoke(() -> {
+      ClusterConfigurationService 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(() -> {
+      Cache cache = getCache();
+      assertNotNull(cache);
+      cache.close();
+      assertTrue(cache.isClosed());
+
+      Properties localProps = new Properties();
+      localProps.setProperty(MCAST_PORT, "0");
+      localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
+      localProps.setProperty(GROUPS, groupName);
+      localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
+      getSystem(localProps);
+      cache = getCache();
+      assertNotNull(cache);
+      Region region = cache.getRegion(regionName);
+      assertNull(region);
+
+      return null;
+    });
+  }
+
+  private void waitForRegionMBeanCreation(final String regionPath, final int mbeanCount) {
+    Host.getHost(0).getVM(0).invoke(() -> {
+      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, regionPath, "*");
+        ObjectName queryExpON = new ObjectName(queryExp);
+        return mbeanServer.queryNames(null, queryExpON).size() == mbeanCount;
+      } catch (MalformedObjectNameException mone) {
+        getLogWriter().error(mone);
+        fail(mone.getMessage());
+        return false;
+      }
+    };
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
index f380d88..318ca7a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
@@ -128,7 +128,7 @@ public class TestCommand {
     createTestCommand("describe config --member=Member1", clusterRead);
     createTestCommand("export config --member=member1", clusterRead);
 
-    // CreateAlterDestroyRegionCommands
+    // CreateRegionCommand, AlterRegionCommand, DestroyRegionCommand
     createTestCommand("alter region --name=RegionA --eviction-max=5000", regionAManage);
     createTestCommand("create region --name=region12 --type=REPLICATE", dataManage);
     createTestCommand("create region --name=region123 --type=PARTITION_PERSISTENT", dataManage,


[3/5] geode git commit: GEODE-3255: Refactor CreateAlterDestroyRegionCommands and tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandDUnitTest.java
new file mode 100644
index 0000000..30e8728
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandDUnitTest.java
@@ -0,0 +1,641 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal.cli.commands;
+
+import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.RegionAttributes;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.asyncqueue.AsyncEvent;
+import org.apache.geode.cache.asyncqueue.AsyncEventListener;
+import org.apache.geode.cache.wan.GatewaySenderFactory;
+import org.apache.geode.internal.ClassBuilder;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.FlakyTest;
+
+@Category(DistributedTest.class)
+public class AlterRegionCommandDUnitTest extends CliCommandTestBase {
+  private final String alterRegionName = "testAlterRegionRegion";
+  private final String alterAsyncEventQueueId1 = "testAlterRegionQueue1";
+  private final String alterAsyncEventQueueId2 = "testAlterRegionQueue2";
+  private final String alterAsyncEventQueueId3 = "testAlterRegionQueue3";
+  private final String alterGatewaySenderId1 = "testAlterRegionSender1";
+  private final String alterGatewaySenderId2 = "testAlterRegionSender2";
+  private final String alterGatewaySenderId3 = "testAlterRegionSender3";
+  private VM alterVm1;
+  private String alterVm1Name;
+  private VM alterVm2;
+  private String alterVm2Name;
+
+  private final List<String> filesToBeDeleted = new CopyOnWriteArrayList<String>();
+
+  @Ignore("bug51924")
+  @Test
+  public void testAlterRegion() throws IOException {
+    setUpJmxManagerOnVm0ThenConnect(null);
+
+    CommandResult cmdResult = executeCommand(CliStrings.LIST_REGION);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    assertTrue(commandResultToString(cmdResult).contains("No Regions Found"));
+
+    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(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(NAME, alterVm1Name);
+      localProps.setProperty(GROUPS, "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);
+    });
+
+    this.alterVm2 = Host.getHost(0).getVM(2);
+    this.alterVm2Name = "VM" + this.alterVm2.getPid();
+    this.alterVm2.invoke(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(NAME, alterVm2Name);
+      localProps.setProperty(GROUPS, "Group1,Group2");
+      getSystem(localProps);
+      Cache cache = getCache();
+
+      cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true)
+          .create(alterRegionName);
+    });
+
+    deployJarFilesForRegionAlter();
+    regionAlterGroupTest();
+    regionAlterSetAllTest();
+    regionAlterNoChangeTest();
+    regionAlterSetDefaultsTest();
+    regionAlterManipulatePlugInsTest();
+
+    this.alterVm1.invoke(() -> {
+      getCache().getRegion(alterRegionName).destroyRegion();
+    });
+  }
+
+  @Category(FlakyTest.class) // GEODE-3018
+  @Test
+  public void testAlterRegionResetCacheListeners() throws IOException {
+    setUpJmxManagerOnVm0ThenConnect(null);
+
+    CommandResult cmdResult = executeCommand(CliStrings.LIST_REGION);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    assertTrue(commandResultToString(cmdResult).contains("No Regions Found"));
+
+    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(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(NAME, alterVm1Name);
+      localProps.setProperty(GROUPS, "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);
+    });
+
+    this.alterVm2 = Host.getHost(0).getVM(2);
+    this.alterVm2Name = "VM" + this.alterVm2.getPid();
+    this.alterVm2.invoke(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(NAME, alterVm2Name);
+      localProps.setProperty(GROUPS, "Group1,Group2");
+      getSystem(localProps);
+      Cache cache = getCache();
+
+      cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true)
+          .create(alterRegionName);
+    });
+
+    deployJarFilesForRegionAlter();
+
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerA,com.cadrdunit.RegionAlterCacheListenerB,com.cadrdunit.RegionAlterCacheListenerC");
+
+    cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    String stringResult = commandResultToString(cmdResult);
+
+    assertEquals(5, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    this.alterVm1.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      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());
+    });
+
+    // Add 1 back to each of the sets
+    commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER, "''");
+    cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    stringResult = commandResultToString(cmdResult);
+    assertEquals(4, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    this.alterVm1.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(0, attributes.getCacheListeners().length);
+    });
+  }
+
+  private void deployJarFilesForRegionAlter() throws IOException {
+    ClassBuilder classBuilder = new ClassBuilder();
+    final File jarFile1 = new File(new File(".").getAbsolutePath(), "testAlterRegion1.jar");
+    this.filesToBeDeleted.add(jarFile1.getAbsolutePath());
+    final File jarFile2 = new File(new File(".").getAbsolutePath(), "testAlterRegion2.jar");
+    this.filesToBeDeleted.add(jarFile2.getAbsolutePath());
+    final File jarFile3 = new File(new File(".").getAbsolutePath(), "testAlterRegion3.jar");
+    this.filesToBeDeleted.add(jarFile3.getAbsolutePath());
+    final File jarFile4 = new File(new File(".").getAbsolutePath(), "testAlterRegion4.jar");
+    this.filesToBeDeleted.add(jarFile4.getAbsolutePath());
+    final File jarFile5 = new File(new File(".").getAbsolutePath(), "testAlterRegion5.jar");
+    this.filesToBeDeleted.add(jarFile5.getAbsolutePath());
+
+    byte[] jarBytes =
+        classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheListenerA",
+            "package com.cadrdunit;" + "import org.apache.geode.cache.util.CacheListenerAdapter;"
+                + "public class RegionAlterCacheListenerA extends CacheListenerAdapter {}");
+    writeJarBytesToFile(jarFile1, jarBytes);
+    CommandResult cmdResult = executeCommand("deploy --jar=testAlterRegion1.jar");
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    jarBytes = classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheListenerB",
+        "package com.cadrdunit;" + "import org.apache.geode.cache.util.CacheListenerAdapter;"
+            + "public class RegionAlterCacheListenerB extends CacheListenerAdapter {}");
+    writeJarBytesToFile(jarFile2, jarBytes);
+    cmdResult = executeCommand("deploy --jar=testAlterRegion2.jar");
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    jarBytes = classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheListenerC",
+        "package com.cadrdunit;" + "import org.apache.geode.cache.util.CacheListenerAdapter;"
+            + "public class RegionAlterCacheListenerC extends CacheListenerAdapter {}");
+    writeJarBytesToFile(jarFile3, jarBytes);
+    cmdResult = executeCommand("deploy --jar=testAlterRegion3.jar");
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    jarBytes = classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheLoader",
+        "package com.cadrdunit;" + "import org.apache.geode.cache.CacheLoader;"
+            + "import org.apache.geode.cache.CacheLoaderException;"
+            + "import org.apache.geode.cache.LoaderHelper;"
+            + "public class RegionAlterCacheLoader implements CacheLoader {"
+            + "public void close() {}"
+            + "public Object load(LoaderHelper helper) throws CacheLoaderException {return null;}}");
+    writeJarBytesToFile(jarFile4, jarBytes);
+    cmdResult = executeCommand("deploy --jar=testAlterRegion4.jar");
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    jarBytes = classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheWriter",
+        "package com.cadrdunit;" + "import org.apache.geode.cache.util.CacheWriterAdapter;"
+            + "public class RegionAlterCacheWriter extends CacheWriterAdapter {}");
+    writeJarBytesToFile(jarFile5, jarBytes);
+    cmdResult = executeCommand("deploy --jar=testAlterRegion5.jar");
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+  }
+
+  private void regionAlterGroupTest() {
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "5764");
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    String stringResult = commandResultToString(cmdResult);
+    assertEquals(4, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    this.alterVm1.invoke(() -> {
+      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);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.GROUP, "Group2");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "6963");
+    cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    stringResult = commandResultToString(cmdResult);
+    assertEquals(3, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertFalse(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    this.alterVm1.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
+    });
+
+    this.alterVm2.invoke(() -> {
+      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
+      assertEquals(6963, attributes.getEvictionAttributes().getMaximum());
+    });
+  }
+
+  private void regionAlterSetAllTest() {
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "35464");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CLONINGENABLED, "true");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
+        this.alterAsyncEventQueueId1);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME, "3453");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIMEACTION,
+        "DESTROY");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONTIMETOLIVE, "7563");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION, "DESTROY");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerA");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELOADER,
+        "com.cadrdunit.RegionAlterCacheLoader");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHEWRITER,
+        "com.cadrdunit.RegionAlterCacheWriter");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
+        this.alterGatewaySenderId1);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME, "6234");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION,
+        "DESTROY");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONTTL, "4562");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION, "DESTROY");
+
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    String stringResult = commandResultToString(cmdResult);
+    assertEquals(5, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertTrue(stringContainsLine(stringResult,
+        "Manager.*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    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());
+    });
+  }
+
+  private void regionAlterNoChangeTest() {
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CLONINGENABLED, "true");
+
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    String stringResult = commandResultToString(cmdResult);
+    assertEquals(4, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    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());
+    });
+  }
+
+  private void regionAlterSetDefaultsTest() {
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CLONINGENABLED);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELOADER);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHEWRITER);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION);
+
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    String stringResult = commandResultToString(cmdResult);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    assertEquals(4, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    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);
+    });
+  }
+
+  private void regionAlterManipulatePlugInsTest() {
+
+    // Start out by putting 3 entries into each of the plug-in sets
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
+        this.alterAsyncEventQueueId1);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
+        this.alterAsyncEventQueueId2);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
+        this.alterAsyncEventQueueId3);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
+        this.alterGatewaySenderId1);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
+        this.alterGatewaySenderId2);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
+        this.alterGatewaySenderId3);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerA");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerB");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerC");
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    String stringResult = commandResultToString(cmdResult);
+
+    assertEquals(4, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    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
+    commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
+        this.alterAsyncEventQueueId1);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
+        this.alterAsyncEventQueueId2);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
+        this.alterGatewaySenderId1);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
+        this.alterGatewaySenderId3);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerB");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerC");
+    cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    stringResult = commandResultToString(cmdResult);
+    assertEquals(4, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    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
+    commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
+    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
+        this.alterAsyncEventQueueId1);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
+        this.alterAsyncEventQueueId2);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
+        this.alterAsyncEventQueueId3);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
+        this.alterGatewaySenderId1);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
+        this.alterGatewaySenderId3);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
+        this.alterGatewaySenderId2);
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerB");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerC");
+    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
+        "com.cadrdunit.RegionAlterCacheListenerA");
+    cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+    stringResult = commandResultToString(cmdResult);
+    assertEquals(4, countLinesInString(stringResult, false));
+    assertEquals(false, stringResult.contains("ERROR"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+    assertTrue(stringContainsLine(stringResult,
+        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
+
+    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());
+    });
+  }
+
+  private void writeJarBytesToFile(File jarFile, byte[] jarBytes) throws IOException {
+    final OutputStream outStream = new FileOutputStream(jarFile);
+    outStream.write(jarBytes);
+    outStream.flush();
+    outStream.close();
+  }
+}


[4/5] geode git commit: GEODE-3255: Refactor CreateAlterDestroyRegionCommands and tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
new file mode 100644
index 0000000..8ba39b7
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
@@ -0,0 +1,741 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.commands;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.management.ObjectName;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.PartitionResolver;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionAttributes;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.compression.Compressor;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.internal.ClassPathLoader;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.management.DistributedRegionMXBean;
+import org.apache.geode.management.DistributedSystemMXBean;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.management.RegionAttributesData;
+import org.apache.geode.management.RegionMXBean;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.cli.ConverterHint;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.CliUtil;
+import org.apache.geode.management.internal.cli.LogWrapper;
+import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
+import org.apache.geode.management.internal.cli.functions.FetchRegionAttributesFunction;
+import org.apache.geode.management.internal.cli.functions.RegionCreateFunction;
+import org.apache.geode.management.internal.cli.functions.RegionFunctionArgs;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.result.TabularResultData;
+import org.apache.geode.management.internal.cli.util.RegionPath;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+import org.apache.geode.management.internal.security.ResourceOperation;
+import org.apache.geode.security.ResourcePermission;
+
+public class CreateRegionCommand implements GfshCommand {
+  public static final Set<RegionShortcut> PERSISTENT_OVERFLOW_SHORTCUTS = new TreeSet<>();
+
+  static {
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_PERSISTENT);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_OVERFLOW);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_REDUNDANT_OVERFLOW);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_PERSISTENT_OVERFLOW);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.REPLICATE_PERSISTENT);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.REPLICATE_OVERFLOW);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.REPLICATE_PERSISTENT_OVERFLOW);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.LOCAL_PERSISTENT);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.LOCAL_OVERFLOW);
+    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.LOCAL_PERSISTENT_OVERFLOW);
+  }
+
+  @CliCommand(value = CliStrings.CREATE_REGION, help = CliStrings.CREATE_REGION__HELP)
+  @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
+  @ResourceOperation(resource = ResourcePermission.Resource.DATA,
+      operation = ResourcePermission.Operation.MANAGE)
+  public Result createRegion(
+      @CliOption(key = CliStrings.CREATE_REGION__REGION, mandatory = true,
+          help = CliStrings.CREATE_REGION__REGION__HELP) String regionPath,
+      @CliOption(key = CliStrings.CREATE_REGION__REGIONSHORTCUT,
+          help = CliStrings.CREATE_REGION__REGIONSHORTCUT__HELP) RegionShortcut regionShortcut,
+      @CliOption(key = CliStrings.CREATE_REGION__USEATTRIBUTESFROM,
+          optionContext = ConverterHint.REGION_PATH,
+          help = CliStrings.CREATE_REGION__USEATTRIBUTESFROM__HELP) String useAttributesFrom,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
+          optionContext = ConverterHint.MEMBERGROUP,
+          help = CliStrings.CREATE_REGION__GROUP__HELP) String[] groups,
+      @CliOption(key = CliStrings.CREATE_REGION__SKIPIFEXISTS, unspecifiedDefaultValue = "true",
+          specifiedDefaultValue = "true",
+          help = CliStrings.CREATE_REGION__SKIPIFEXISTS__HELP) boolean skipIfExists,
+
+      // the following should all be in alphabetical order according to
+      // their key string
+      @CliOption(key = CliStrings.CREATE_REGION__ASYNCEVENTQUEUEID,
+          help = CliStrings.CREATE_REGION__ASYNCEVENTQUEUEID__HELP) String[] asyncEventQueueIds,
+      @CliOption(key = CliStrings.CREATE_REGION__CACHELISTENER,
+          help = CliStrings.CREATE_REGION__CACHELISTENER__HELP) String[] cacheListener,
+      @CliOption(key = CliStrings.CREATE_REGION__CACHELOADER,
+          help = CliStrings.CREATE_REGION__CACHELOADER__HELP) String cacheLoader,
+      @CliOption(key = CliStrings.CREATE_REGION__CACHEWRITER,
+          help = CliStrings.CREATE_REGION__CACHEWRITER__HELP) String cacheWriter,
+      @CliOption(key = CliStrings.CREATE_REGION__COLOCATEDWITH,
+          optionContext = ConverterHint.REGION_PATH,
+          help = CliStrings.CREATE_REGION__COLOCATEDWITH__HELP) String prColocatedWith,
+      @CliOption(key = CliStrings.CREATE_REGION__COMPRESSOR,
+          help = CliStrings.CREATE_REGION__COMPRESSOR__HELP) String compressor,
+      @CliOption(key = CliStrings.CREATE_REGION__CONCURRENCYLEVEL,
+          help = CliStrings.CREATE_REGION__CONCURRENCYLEVEL__HELP) Integer concurrencyLevel,
+      @CliOption(key = CliStrings.CREATE_REGION__DISKSTORE,
+          help = CliStrings.CREATE_REGION__DISKSTORE__HELP) String diskStore,
+      @CliOption(key = CliStrings.CREATE_REGION__ENABLEASYNCCONFLATION,
+          help = CliStrings.CREATE_REGION__ENABLEASYNCCONFLATION__HELP) Boolean enableAsyncConflation,
+      @CliOption(key = CliStrings.CREATE_REGION__CLONINGENABLED,
+          help = CliStrings.CREATE_REGION__CLONINGENABLED__HELP) Boolean cloningEnabled,
+      @CliOption(key = CliStrings.CREATE_REGION__CONCURRENCYCHECKSENABLED,
+          help = CliStrings.CREATE_REGION__CONCURRENCYCHECKSENABLED__HELP) Boolean concurrencyChecksEnabled,
+      @CliOption(key = CliStrings.CREATE_REGION__MULTICASTENABLED,
+          help = CliStrings.CREATE_REGION__MULTICASTENABLED__HELP) Boolean mcastEnabled,
+      @CliOption(key = CliStrings.CREATE_REGION__STATISTICSENABLED,
+          help = CliStrings.CREATE_REGION__STATISTICSENABLED__HELP) Boolean statisticsEnabled,
+      @CliOption(key = CliStrings.CREATE_REGION__ENABLESUBSCRIPTIONCONFLATION,
+          help = CliStrings.CREATE_REGION__ENABLESUBSCRIPTIONCONFLATION__HELP) Boolean enableSubscriptionConflation,
+      @CliOption(key = CliStrings.CREATE_REGION__DISKSYNCHRONOUS,
+          help = CliStrings.CREATE_REGION__DISKSYNCHRONOUS__HELP) Boolean diskSynchronous,
+      @CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIME,
+          help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIME__HELP) Integer entryExpirationIdleTime,
+      @CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIMEACTION,
+          help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIMEACTION__HELP) String entryExpirationIdleTimeAction,
+      @CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTIMETOLIVE,
+          help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTIMETOLIVE__HELP) Integer entryExpirationTTL,
+      @CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION,
+          help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION__HELP) String entryExpirationTTLAction,
+      @CliOption(key = CliStrings.CREATE_REGION__GATEWAYSENDERID,
+          help = CliStrings.CREATE_REGION__GATEWAYSENDERID__HELP) String[] gatewaySenderIds,
+      @CliOption(key = CliStrings.CREATE_REGION__KEYCONSTRAINT,
+          help = CliStrings.CREATE_REGION__KEYCONSTRAINT__HELP) String keyConstraint,
+      @CliOption(key = CliStrings.CREATE_REGION__LOCALMAXMEMORY,
+          help = CliStrings.CREATE_REGION__LOCALMAXMEMORY__HELP) Integer prLocalMaxMemory,
+      @CliOption(key = CliStrings.CREATE_REGION__OFF_HEAP, specifiedDefaultValue = "true",
+          help = CliStrings.CREATE_REGION__OFF_HEAP__HELP) Boolean offHeap,
+      @CliOption(key = CliStrings.CREATE_REGION__PARTITION_RESOLVER,
+          help = CliStrings.CREATE_REGION__PARTITION_RESOLVER__HELP) String partitionResolver,
+      @CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIME,
+          help = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIME__HELP) Integer regionExpirationIdleTime,
+      @CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIMEACTION,
+          help = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIMEACTION__HELP) String regionExpirationIdleTimeAction,
+      @CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTL,
+          help = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTL__HELP) Integer regionExpirationTTL,
+      @CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTLACTION,
+          help = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTLACTION__HELP) String regionExpirationTTLAction,
+      @CliOption(key = CliStrings.CREATE_REGION__RECOVERYDELAY,
+          help = CliStrings.CREATE_REGION__RECOVERYDELAY__HELP) Long prRecoveryDelay,
+      @CliOption(key = CliStrings.CREATE_REGION__REDUNDANTCOPIES,
+          help = CliStrings.CREATE_REGION__REDUNDANTCOPIES__HELP) Integer prRedundantCopies,
+      @CliOption(key = CliStrings.CREATE_REGION__STARTUPRECOVERYDDELAY,
+          help = CliStrings.CREATE_REGION__STARTUPRECOVERYDDELAY__HELP) Long prStartupRecoveryDelay,
+      @CliOption(key = CliStrings.CREATE_REGION__TOTALMAXMEMORY,
+          help = CliStrings.CREATE_REGION__TOTALMAXMEMORY__HELP) Long prTotalMaxMemory,
+      @CliOption(key = CliStrings.CREATE_REGION__TOTALNUMBUCKETS,
+          help = CliStrings.CREATE_REGION__TOTALNUMBUCKETS__HELP) Integer prTotalNumBuckets,
+      @CliOption(key = CliStrings.CREATE_REGION__VALUECONSTRAINT,
+          help = CliStrings.CREATE_REGION__VALUECONSTRAINT__HELP) String valueConstraint
+  // NOTICE: keep the region attributes params in alphabetical order
+  ) {
+    Result result;
+    AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
+
+    try {
+      InternalCache cache = getCache();
+
+      if (regionShortcut != null && useAttributesFrom != null) {
+        throw new IllegalArgumentException(
+            CliStrings.CREATE_REGION__MSG__ONLY_ONE_OF_REGIONSHORTCUT_AND_USEATTRIBUESFROM_CAN_BE_SPECIFIED);
+      } else if (regionShortcut == null && useAttributesFrom == null) {
+        throw new IllegalArgumentException(
+            CliStrings.CREATE_REGION__MSG__ONE_OF_REGIONSHORTCUT_AND_USEATTRIBUTESFROM_IS_REQUIRED);
+      }
+
+      validateRegionPathAndParent(cache, regionPath);
+      RegionCommandsUtils.validateGroups(cache, groups);
+
+      RegionFunctionArgs.ExpirationAttrs entryIdle = null;
+      if (entryExpirationIdleTime != null) {
+        entryIdle = new RegionFunctionArgs.ExpirationAttrs(
+            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.ENTRY_IDLE, entryExpirationIdleTime,
+            entryExpirationIdleTimeAction);
+      }
+      RegionFunctionArgs.ExpirationAttrs entryTTL = null;
+      if (entryExpirationTTL != null) {
+        entryTTL = new RegionFunctionArgs.ExpirationAttrs(
+            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.ENTRY_TTL, entryExpirationTTL,
+            entryExpirationTTLAction);
+      }
+      RegionFunctionArgs.ExpirationAttrs regionIdle = null;
+      if (regionExpirationIdleTime != null) {
+        regionIdle = new RegionFunctionArgs.ExpirationAttrs(
+            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.REGION_IDLE, regionExpirationIdleTime,
+            regionExpirationIdleTimeAction);
+      }
+      RegionFunctionArgs.ExpirationAttrs regionTTL = null;
+      if (regionExpirationTTL != null) {
+        regionTTL = new RegionFunctionArgs.ExpirationAttrs(
+            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.REGION_TTL, regionExpirationTTL,
+            regionExpirationTTLAction);
+      }
+
+      RegionFunctionArgs regionFunctionArgs;
+      if (useAttributesFrom != null) {
+        if (!regionExists(cache, useAttributesFrom)) {
+          throw new IllegalArgumentException(CliStrings.format(
+              CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH_FOR_0_REGIONPATH_1_NOT_FOUND,
+              new Object[] {CliStrings.CREATE_REGION__USEATTRIBUTESFROM, useAttributesFrom}));
+        }
+
+        FetchRegionAttributesFunction.FetchRegionAttributesFunctionResult<Object, Object> regionAttributesResult =
+            getRegionAttributes(cache, useAttributesFrom);
+        RegionAttributes<?, ?> regionAttributes = regionAttributesResult.getRegionAttributes();
+
+        // give preference to user specified plugins than the ones retrieved from other region
+        String[] cacheListenerClasses = cacheListener != null && cacheListener.length != 0
+            ? cacheListener : regionAttributesResult.getCacheListenerClasses();
+        String cacheLoaderClass =
+            cacheLoader != null ? cacheLoader : regionAttributesResult.getCacheLoaderClass();
+        String cacheWriterClass =
+            cacheWriter != null ? cacheWriter : regionAttributesResult.getCacheWriterClass();
+
+        regionFunctionArgs = new RegionFunctionArgs(regionPath, useAttributesFrom, skipIfExists,
+            keyConstraint, valueConstraint, statisticsEnabled, entryIdle, entryTTL, regionIdle,
+            regionTTL, diskStore, diskSynchronous, enableAsyncConflation,
+            enableSubscriptionConflation, cacheListenerClasses, cacheLoaderClass, cacheWriterClass,
+            asyncEventQueueIds, gatewaySenderIds, concurrencyChecksEnabled, cloningEnabled,
+            concurrencyLevel, prColocatedWith, prLocalMaxMemory, prRecoveryDelay, prRedundantCopies,
+            prStartupRecoveryDelay, prTotalMaxMemory, prTotalNumBuckets, offHeap, mcastEnabled,
+            regionAttributes, partitionResolver);
+
+        if (regionAttributes.getPartitionAttributes() == null
+            && regionFunctionArgs.hasPartitionAttributes()) {
+          throw new IllegalArgumentException(CliStrings.format(
+              CliStrings.CREATE_REGION__MSG__OPTION_0_CAN_BE_USED_ONLY_FOR_PARTITIONEDREGION,
+              regionFunctionArgs.getPartitionArgs().getUserSpecifiedPartitionAttributes()) + " "
+              + CliStrings.format(CliStrings.CREATE_REGION__MSG__0_IS_NOT_A_PARITIONEDREGION,
+                  useAttributesFrom));
+        }
+      } else {
+        regionFunctionArgs = new RegionFunctionArgs(regionPath, regionShortcut, useAttributesFrom,
+            skipIfExists, keyConstraint, valueConstraint, statisticsEnabled, entryIdle, entryTTL,
+            regionIdle, regionTTL, diskStore, diskSynchronous, enableAsyncConflation,
+            enableSubscriptionConflation, cacheListener, cacheLoader, cacheWriter,
+            asyncEventQueueIds, gatewaySenderIds, concurrencyChecksEnabled, cloningEnabled,
+            concurrencyLevel, prColocatedWith, prLocalMaxMemory, prRecoveryDelay, prRedundantCopies,
+            prStartupRecoveryDelay, prTotalMaxMemory, prTotalNumBuckets, null, compressor, offHeap,
+            mcastEnabled, partitionResolver);
+
+        if (!regionShortcut.name().startsWith("PARTITION")
+            && regionFunctionArgs.hasPartitionAttributes()) {
+          throw new IllegalArgumentException(CliStrings.format(
+              CliStrings.CREATE_REGION__MSG__OPTION_0_CAN_BE_USED_ONLY_FOR_PARTITIONEDREGION,
+              regionFunctionArgs.getPartitionArgs().getUserSpecifiedPartitionAttributes()) + " "
+              + CliStrings.format(CliStrings.CREATE_REGION__MSG__0_IS_NOT_A_PARITIONEDREGION,
+                  useAttributesFrom));
+        }
+      }
+
+      // Do we prefer to validate or authorize first?
+      validateRegionFunctionArgs(cache, regionFunctionArgs);
+      if (isPersistentShortcut(regionFunctionArgs.getRegionShortcut())
+          || isAttributePersistent(regionFunctionArgs.getRegionAttributes())) {
+        getSecurityService().authorize(ResourcePermission.Resource.CLUSTER,
+            ResourcePermission.Operation.WRITE, ResourcePermission.Target.DISK);
+      }
+
+      Set<DistributedMember> membersToCreateRegionOn;
+      if (groups != null && groups.length != 0) {
+        membersToCreateRegionOn = CliUtil.getDistributedMembersByGroup(cache, groups);
+        // have only normal members from the group
+        membersToCreateRegionOn
+            .removeIf(distributedMember -> ((InternalDistributedMember) distributedMember)
+                .getVmKind() == DistributionManager.LOCATOR_DM_TYPE);
+      } else {
+        membersToCreateRegionOn = CliUtil.getAllNormalMembers(cache);
+      }
+
+      if (membersToCreateRegionOn.isEmpty()) {
+        return ResultBuilder.createUserErrorResult(CliStrings.NO_CACHING_MEMBERS_FOUND_MESSAGE);
+      }
+
+      ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(RegionCreateFunction.INSTANCE,
+          regionFunctionArgs, membersToCreateRegionOn);
+      @SuppressWarnings("unchecked")
+      List<CliFunctionResult> regionCreateResults =
+          (List<CliFunctionResult>) resultCollector.getResult();
+
+      TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
+      final String errorPrefix = "ERROR: ";
+      for (CliFunctionResult regionCreateResult : regionCreateResults) {
+        boolean success = regionCreateResult.isSuccessful();
+        tabularResultData.accumulate("Member", regionCreateResult.getMemberIdOrName());
+        tabularResultData.accumulate("Status",
+            (success ? "" : errorPrefix) + regionCreateResult.getMessage());
+
+        if (success) {
+          xmlEntity.set(regionCreateResult.getXmlEntity());
+        }
+      }
+      result = ResultBuilder.buildResult(tabularResultData);
+      verifyDistributedRegionMbean(cache, regionPath);
+
+    } catch (IllegalArgumentException | IllegalStateException e) {
+      LogWrapper.getInstance().info(e.getMessage());
+      result = ResultBuilder.createUserErrorResult(e.getMessage());
+    }
+    if (xmlEntity.get() != null) {
+      persistClusterConfiguration(result,
+          () -> getSharedConfiguration().addXmlEntity(xmlEntity.get(), groups));
+    }
+
+    return result;
+  }
+
+  public boolean verifyDistributedRegionMbean(InternalCache cache, String regionName) {
+    int federationInterval =
+        cache.getInternalDistributedSystem().getConfig().getJmxManagerUpdateRate();
+    long timeEnd = System.currentTimeMillis() + federationInterval + 50;
+
+    for (; System.currentTimeMillis() <= timeEnd;) {
+      try {
+        DistributedRegionMXBean bean =
+            ManagementService.getManagementService(cache).getDistributedRegionMXBean(regionName);
+        if (bean == null) {
+          bean = ManagementService.getManagementService(cache)
+              .getDistributedRegionMXBean(Region.SEPARATOR + regionName);
+        }
+        if (bean != null) {
+          return true;
+        } else {
+          Thread.sleep(2);
+        }
+      } catch (Exception ignored) {
+      }
+    }
+    return false;
+  }
+
+  void validateRegionFunctionArgs(InternalCache cache, RegionFunctionArgs regionFunctionArgs) {
+    if (regionFunctionArgs.getRegionPath() == null) {
+      throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH);
+    }
+
+    DistributedSystemMXBean dsMBean = getDSMBean(cache);
+
+    String useAttributesFrom = regionFunctionArgs.getUseAttributesFrom();
+    if (useAttributesFrom != null && !useAttributesFrom.isEmpty()
+        && regionExists(cache, useAttributesFrom)) {
+      if (!regionExists(cache, useAttributesFrom)) { // check already done in createRegion !!!
+        throw new IllegalArgumentException(CliStrings.format(
+            CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH_FOR_0_REGIONPATH_1_NOT_FOUND,
+            new Object[] {CliStrings.CREATE_REGION__USEATTRIBUTESFROM, useAttributesFrom}));
+      }
+      if (!regionFunctionArgs.isSetUseAttributesFrom()
+          || regionFunctionArgs.getRegionAttributes() == null) {
+        throw new IllegalArgumentException(CliStrings.format(
+            CliStrings.CREATE_REGION__MSG__COULD_NOT_RETRIEVE_REGION_ATTRS_FOR_PATH_0_VERIFY_REGION_EXISTS,
+            useAttributesFrom));
+      }
+    }
+
+    if (regionFunctionArgs.hasPartitionAttributes()) {
+      RegionFunctionArgs.PartitionArgs partitionArgs = regionFunctionArgs.getPartitionArgs();
+      String colocatedWith = partitionArgs.getPrColocatedWith();
+      if (colocatedWith != null && !colocatedWith.isEmpty()) {
+        String[] listAllRegionPaths = dsMBean.listAllRegionPaths();
+        String foundRegionPath = null;
+        for (String regionPath : listAllRegionPaths) {
+          if (regionPath.equals(colocatedWith)) {
+            foundRegionPath = regionPath;
+            break;
+          }
+        }
+        if (foundRegionPath == null) {
+          throw new IllegalArgumentException(CliStrings.format(
+              CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH_FOR_0_REGIONPATH_1_NOT_FOUND,
+              new Object[] {CliStrings.CREATE_REGION__COLOCATEDWITH, colocatedWith}));
+        }
+        ManagementService mgmtService = ManagementService.getExistingManagementService(cache);
+        DistributedRegionMXBean distributedRegionMXBean =
+            mgmtService.getDistributedRegionMXBean(foundRegionPath);
+        String regionType = distributedRegionMXBean.getRegionType();
+        if (!(DataPolicy.PARTITION.toString().equals(regionType)
+            || DataPolicy.PERSISTENT_PARTITION.toString().equals(regionType))) {
+          throw new IllegalArgumentException(CliStrings.format(
+              CliStrings.CREATE_REGION__MSG__COLOCATEDWITH_REGION_0_IS_NOT_PARTITIONEDREGION,
+              new Object[] {colocatedWith}));
+        }
+      }
+      if (partitionArgs.isSetPRLocalMaxMemory()) {
+        int prLocalMaxMemory = partitionArgs.getPrLocalMaxMemory();
+        if (prLocalMaxMemory < 0) {
+          throw new IllegalArgumentException(
+              LocalizedStrings.AttributesFactory_PARTITIONATTRIBUTES_LOCALMAXMEMORY_MUST_NOT_BE_NEGATIVE
+                  .toLocalizedString());
+        }
+      }
+      if (partitionArgs.isSetPRTotalMaxMemory()) {
+        long prTotalMaxMemory = partitionArgs.getPrTotalMaxMemory();
+        if (prTotalMaxMemory <= 0) {
+          throw new IllegalArgumentException(
+              LocalizedStrings.AttributesFactory_TOTAL_SIZE_OF_PARTITION_REGION_MUST_BE_0
+                  .toLocalizedString());
+        }
+      }
+      if (partitionArgs.isSetPRRedundantCopies()) {
+        int prRedundantCopies = partitionArgs.getPrRedundantCopies();
+        switch (prRedundantCopies) {
+          case 0:
+          case 1:
+          case 2:
+          case 3:
+            break;
+          default:
+            throw new IllegalArgumentException(CliStrings.format(
+                CliStrings.CREATE_REGION__MSG__REDUNDANT_COPIES_SHOULD_BE_ONE_OF_0123,
+                new Object[] {prRedundantCopies}));
+        }
+      }
+    }
+
+    String keyConstraint = regionFunctionArgs.getKeyConstraint();
+    if (keyConstraint != null && !RegionCommandsUtils.isClassNameValid(keyConstraint)) {
+      throw new IllegalArgumentException(CliStrings.format(
+          CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_KEYCONSTRAINT_0_IS_INVALID,
+          new Object[] {keyConstraint}));
+    }
+
+    String valueConstraint = regionFunctionArgs.getValueConstraint();
+    if (valueConstraint != null && !RegionCommandsUtils.isClassNameValid(valueConstraint)) {
+      throw new IllegalArgumentException(CliStrings.format(
+          CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_VALUECONSTRAINT_0_IS_INVALID,
+          new Object[] {valueConstraint}));
+    }
+
+    Set<String> cacheListeners = regionFunctionArgs.getCacheListeners();
+    if (cacheListeners != null && !cacheListeners.isEmpty()) {
+      for (String cacheListener : cacheListeners) {
+        if (!RegionCommandsUtils.isClassNameValid(cacheListener)) {
+          throw new IllegalArgumentException(CliStrings.format(
+              CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELISTENER_0_IS_INVALID,
+              new Object[] {cacheListener}));
+        }
+      }
+    }
+
+    String cacheLoader = regionFunctionArgs.getCacheLoader();
+    if (cacheLoader != null && !RegionCommandsUtils.isClassNameValid(cacheLoader)) {
+      throw new IllegalArgumentException(CliStrings.format(
+          CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELOADER_0_IS_INVALID,
+          new Object[] {cacheLoader}));
+    }
+
+    String cacheWriter = regionFunctionArgs.getCacheWriter();
+    if (cacheWriter != null && !RegionCommandsUtils.isClassNameValid(cacheWriter)) {
+      throw new IllegalArgumentException(CliStrings.format(
+          CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHEWRITER_0_IS_INVALID,
+          new Object[] {cacheWriter}));
+    }
+
+    Set<String> gatewaySenderIds = regionFunctionArgs.getGatewaySenderIds();
+    if (gatewaySenderIds != null && !gatewaySenderIds.isEmpty()) {
+      String[] gatewaySenders = dsMBean.listGatewaySenders();
+      if (gatewaySenders.length == 0) {
+        throw new IllegalArgumentException(
+            CliStrings.CREATE_REGION__MSG__NO_GATEWAYSENDERS_IN_THE_SYSTEM);
+      } else {
+        List<String> gatewaySendersList = new ArrayList<>(Arrays.asList(gatewaySenders));
+        gatewaySenderIds = new HashSet<>(gatewaySenderIds);
+        gatewaySenderIds.removeAll(gatewaySendersList);
+        if (!gatewaySenderIds.isEmpty()) {
+          throw new IllegalArgumentException(CliStrings.format(
+              CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_GATEWAYSENDER_ID_UNKNOWN_0,
+              new Object[] {gatewaySenderIds}));
+        }
+      }
+    }
+
+    if (regionFunctionArgs.isSetConcurrencyLevel()) {
+      int concurrencyLevel = regionFunctionArgs.getConcurrencyLevel();
+      if (concurrencyLevel < 0) {
+        throw new IllegalArgumentException(CliStrings.format(
+            CliStrings.CREATE_REGION__MSG__SPECIFY_POSITIVE_INT_FOR_CONCURRENCYLEVEL_0_IS_NOT_VALID,
+            new Object[] {concurrencyLevel}));
+      }
+    }
+
+    String diskStore = regionFunctionArgs.getDiskStore();
+    if (diskStore != null) {
+      RegionShortcut regionShortcut = regionFunctionArgs.getRegionShortcut();
+      if (regionShortcut != null && !PERSISTENT_OVERFLOW_SHORTCUTS.contains(regionShortcut)) {
+        String subMessage =
+            LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString();
+        String message = subMessage + ". "
+            + CliStrings.format(CliStrings.CREATE_REGION__MSG__USE_ONE_OF_THESE_SHORTCUTS_0,
+                new Object[] {String.valueOf(PERSISTENT_OVERFLOW_SHORTCUTS)});
+
+        throw new IllegalArgumentException(message);
+      }
+
+      RegionAttributes<?, ?> regionAttributes = regionFunctionArgs.getRegionAttributes();
+      if (regionAttributes != null && !regionAttributes.getDataPolicy().withPersistence()) {
+        String subMessage =
+            LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString();
+        String message = subMessage + ". "
+            + CliStrings.format(
+                CliStrings.CREATE_REGION__MSG__USE_ATTRIBUTES_FROM_REGION_0_IS_NOT_WITH_PERSISTENCE,
+                new Object[] {String.valueOf(regionFunctionArgs.getUseAttributesFrom())});
+
+        throw new IllegalArgumentException(message);
+      }
+
+      if (!diskStoreExists(cache, diskStore)) {
+        throw new IllegalArgumentException(CliStrings.format(
+            CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_DISKSTORE_UNKNOWN_DISKSTORE_0,
+            new Object[] {diskStore}));
+      }
+    }
+
+    RegionFunctionArgs.ExpirationAttrs entryExpirationIdleTime =
+        regionFunctionArgs.getEntryExpirationIdleTime();
+    RegionFunctionArgs.ExpirationAttrs entryExpirationTTL =
+        regionFunctionArgs.getEntryExpirationTTL();
+    RegionFunctionArgs.ExpirationAttrs regionExpirationIdleTime =
+        regionFunctionArgs.getRegionExpirationIdleTime();
+    RegionFunctionArgs.ExpirationAttrs regionExpirationTTL =
+        regionFunctionArgs.getRegionExpirationTTL();
+
+    if ((!regionFunctionArgs.isSetStatisticsEnabled() || !regionFunctionArgs.isStatisticsEnabled())
+        && (entryExpirationIdleTime != null || entryExpirationTTL != null
+            || regionExpirationIdleTime != null || regionExpirationTTL != null)) {
+      String message = LocalizedStrings.AttributesFactory_STATISTICS_MUST_BE_ENABLED_FOR_EXPIRATION
+          .toLocalizedString();
+      throw new IllegalArgumentException(message + ".");
+    }
+
+    boolean compressorFailure = false;
+    if (regionFunctionArgs.isSetCompressor()) {
+      String compressorClassName = regionFunctionArgs.getCompressor();
+      Object compressor = null;
+      try {
+        Class<?> compressorClass = ClassPathLoader.getLatest().forName(compressorClassName);
+        compressor = compressorClass.newInstance();
+      } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
+        compressorFailure = true;
+      }
+
+      if (compressorFailure || !(compressor instanceof Compressor)) {
+        throw new IllegalArgumentException(
+            CliStrings.format(CliStrings.CREATE_REGION__MSG__INVALID_COMPRESSOR,
+                new Object[] {regionFunctionArgs.getCompressor()}));
+      }
+    }
+
+    if (regionFunctionArgs.hasPartitionAttributes()) {
+      if (regionFunctionArgs.isPartitionResolverSet()) {
+        String partitionResolverClassName = regionFunctionArgs.getPartitionResolver();
+        try {
+          Class<PartitionResolver> resolverClass = (Class<PartitionResolver>) ClassPathLoader
+              .getLatest().forName(partitionResolverClassName);
+          PartitionResolver partitionResolver = resolverClass.newInstance();
+        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+          throw new IllegalArgumentException(
+              CliStrings.format(CliStrings.CREATE_REGION__MSG__INVALID_PARTITION_RESOLVER,
+                  new Object[] {regionFunctionArgs.getPartitionResolver()}),
+              e);
+        }
+      }
+    }
+  }
+
+  private boolean diskStoreExists(InternalCache cache, String diskStoreName) {
+    ManagementService managementService = ManagementService.getExistingManagementService(cache);
+    DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
+    Map<String, String[]> diskstore = dsMXBean.listMemberDiskstore();
+
+    Set<Map.Entry<String, String[]>> entrySet = diskstore.entrySet();
+
+    for (Map.Entry<String, String[]> entry : entrySet) {
+      String[] value = entry.getValue();
+      if (CliUtil.contains(value, diskStoreName)) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  private void validateRegionPathAndParent(InternalCache cache, String regionPath) {
+    if (StringUtils.isEmpty(regionPath)) {
+      throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH);
+    }
+    // If a region path indicates a sub-region, check whether the parent region exists
+    RegionPath regionPathData = new RegionPath(regionPath);
+    String parentRegionPath = regionPathData.getParent();
+    if (parentRegionPath != null && !Region.SEPARATOR.equals(parentRegionPath)) {
+      if (!regionExists(cache, parentRegionPath)) {
+        throw new IllegalArgumentException(
+            CliStrings.format(CliStrings.CREATE_REGION__MSG__PARENT_REGION_FOR_0_DOES_NOT_EXIST,
+                new Object[] {regionPath}));
+      }
+    }
+  }
+
+  private static <K, V> FetchRegionAttributesFunction.FetchRegionAttributesFunctionResult<K, V> getRegionAttributes(
+      InternalCache cache, String regionPath) {
+    if (!isClusterWideSameConfig(cache, regionPath)) {
+      throw new IllegalStateException(CliStrings.format(
+          CliStrings.CREATE_REGION__MSG__USE_ATTRIBUTES_FORM_REGIONS_EXISTS_BUT_DIFFERENT_SCOPE_OR_DATAPOLICY_USE_DESCRIBE_REGION_FOR_0,
+          regionPath));
+    }
+    FetchRegionAttributesFunction.FetchRegionAttributesFunctionResult<K, V> attributes = null;
+
+    // First check whether the region exists on a this manager, if yes then no
+    // need to use FetchRegionAttributesFunction to fetch RegionAttributes
+    try {
+      attributes = FetchRegionAttributesFunction.getRegionAttributes(regionPath);
+    } catch (IllegalArgumentException e) {
+      /* region doesn't exist on the manager */
+    }
+
+    if (attributes == null) {
+      // find first member which has the region
+      Set<DistributedMember> regionAssociatedMembers =
+          CliUtil.getRegionAssociatedMembers(regionPath, cache, false);
+      if (regionAssociatedMembers != null && !regionAssociatedMembers.isEmpty()) {
+        DistributedMember distributedMember = regionAssociatedMembers.iterator().next();
+        ResultCollector<?, ?> resultCollector = CliUtil
+            .executeFunction(FetchRegionAttributesFunction.INSTANCE, regionPath, distributedMember);
+        List<?> resultsList = (List<?>) resultCollector.getResult();
+
+        if (resultsList != null && !resultsList.isEmpty()) {
+          for (Object object : resultsList) {
+            if (object instanceof IllegalArgumentException) {
+              throw (IllegalArgumentException) object;
+            } else if (object instanceof Throwable) {
+              Throwable th = (Throwable) object;
+              LogWrapper.getInstance().info(CliUtil.stackTraceAsString((th)));
+              throw new IllegalArgumentException(CliStrings.format(
+                  CliStrings.CREATE_REGION__MSG__COULD_NOT_RETRIEVE_REGION_ATTRS_FOR_PATH_0_REASON_1,
+                  new Object[] {regionPath, th.getMessage()}));
+            } else { // has to be RegionAttributes
+              @SuppressWarnings("unchecked") // to avoid warning :(
+              FetchRegionAttributesFunction.FetchRegionAttributesFunctionResult<K, V> regAttr =
+                  ((FetchRegionAttributesFunction.FetchRegionAttributesFunctionResult<K, V>) object);
+              if (attributes == null) {
+                attributes = regAttr;
+                break;
+              } // attributes null check
+            } // not IllegalArgumentException or other throwable
+          } // iterate over list - there should be only one result in the list
+        } // result list is not null or empty
+      } // regionAssociatedMembers is not-empty
+    } // attributes are null because do not exist on local member
+
+    return attributes;
+  }
+
+  private static boolean isClusterWideSameConfig(InternalCache cache, String regionPath) {
+    ManagementService managementService = ManagementService.getExistingManagementService(cache);
+
+    DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
+
+    Set<DistributedMember> allMembers = CliUtil.getAllNormalMembers(cache);
+
+    RegionAttributesData regionAttributesToValidateAgainst = null;
+    for (DistributedMember distributedMember : allMembers) {
+      ObjectName regionObjectName;
+      try {
+        regionObjectName = dsMXBean
+            .fetchRegionObjectName(CliUtil.getMemberNameOrId(distributedMember), regionPath);
+        RegionMXBean regionMBean =
+            managementService.getMBeanInstance(regionObjectName, RegionMXBean.class);
+        RegionAttributesData regionAttributes = regionMBean.listRegionAttributes();
+
+        if (regionAttributesToValidateAgainst == null) {
+          regionAttributesToValidateAgainst = regionAttributes;
+        } else if (!(regionAttributesToValidateAgainst.getScope()
+            .equals(regionAttributes.getScope())
+            || regionAttributesToValidateAgainst.getDataPolicy()
+                .equals(regionAttributes.getDataPolicy()))) {
+          return false;
+        }
+      } catch (Exception e) {
+        // ignore
+      }
+    }
+
+    return true;
+  }
+
+  private boolean isPersistentShortcut(RegionShortcut shortcut) {
+    return shortcut == RegionShortcut.LOCAL_PERSISTENT
+        || shortcut == RegionShortcut.LOCAL_PERSISTENT_OVERFLOW
+        || shortcut == RegionShortcut.PARTITION_PERSISTENT
+        || shortcut == RegionShortcut.PARTITION_PERSISTENT_OVERFLOW
+        || shortcut == RegionShortcut.PARTITION_REDUNDANT_PERSISTENT
+        || shortcut == RegionShortcut.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW
+        || shortcut == RegionShortcut.REPLICATE_PERSISTENT
+        || shortcut == RegionShortcut.REPLICATE_PERSISTENT_OVERFLOW;
+  }
+
+  private boolean isAttributePersistent(RegionAttributes attributes) {
+    return attributes != null && attributes.getDataPolicy() != null
+        && attributes.getDataPolicy().toString().contains("PERSISTENT");
+  }
+
+  public static boolean regionExists(InternalCache cache, String regionPath) {
+    if (regionPath == null || Region.SEPARATOR.equals(regionPath)) {
+      return false;
+    }
+
+    ManagementService managementService = ManagementService.getExistingManagementService(cache);
+    DistributedSystemMXBean dsMBean = managementService.getDistributedSystemMXBean();
+
+    String[] allRegionPaths = dsMBean.listAllRegionPaths();
+    return Arrays.stream(allRegionPaths).anyMatch(regionPath::equals);
+  }
+
+  public DistributedSystemMXBean getDSMBean(InternalCache cache) {
+    ManagementService managementService = ManagementService.getExistingManagementService(cache);
+    return managementService.getDistributedSystemMXBean();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommand.java
new file mode 100644
index 0000000..12b6dc1
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommand.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.commands;
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import org.apache.geode.LogWriter;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.management.RegionAttributesData;
+import org.apache.geode.management.RegionMXBean;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.cli.ConverterHint;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.MBeanJMXAdapter;
+import org.apache.geode.management.internal.cli.CliUtil;
+import org.apache.geode.management.internal.cli.LogWrapper;
+import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
+import org.apache.geode.management.internal.cli.functions.RegionDestroyFunction;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+import org.apache.geode.management.internal.security.ResourceOperation;
+import org.apache.geode.security.ResourcePermission;
+
+public class DestroyRegionCommand implements GfshCommand {
+  @CliCommand(value = {CliStrings.DESTROY_REGION}, help = CliStrings.DESTROY_REGION__HELP)
+  @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
+  @ResourceOperation(resource = ResourcePermission.Resource.DATA,
+      operation = ResourcePermission.Operation.MANAGE)
+  public Result destroyRegion(
+      @CliOption(key = CliStrings.DESTROY_REGION__REGION, optionContext = ConverterHint.REGION_PATH,
+          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 (StringUtils.isBlank(regionPath) || regionPath.equals(Region.SEPARATOR)) {
+      return ResultBuilder.createInfoResult(CliStrings.format(
+          CliStrings.DESTROY_REGION__MSG__REGIONPATH_0_NOT_VALID, new Object[] {regionPath}));
+    }
+
+    Result result;
+    AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
+    try {
+      InternalCache cache = getCache();
+      ManagementService managementService = ManagementService.getExistingManagementService(cache);
+      String regionPathToUse = regionPath;
+
+      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__COULD_NOT_FIND_REGIONPATH_0_IN_GEODE,
+                regionPath, "jmx-manager-update-rate milliseconds"));
+      }
+
+      CliFunctionResult destroyRegionResult;
+
+      ResultCollector<?, ?> resultCollector =
+          CliUtil.executeFunction(RegionDestroyFunction.INSTANCE, regionPath, regionMembersList);
+      List<CliFunctionResult> resultsList = (List<CliFunctionResult>) resultCollector.getResult();
+      String message =
+          CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED, regionPath, "");
+
+      // Only if there is an error is this set to false
+      boolean isRegionDestroyed = true;
+      for (CliFunctionResult aResultsList : resultsList) {
+        destroyRegionResult = aResultsList;
+        if (destroyRegionResult.isSuccessful()) {
+          xmlEntity.set(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,
+              regionPath, t.getMessage());
+          isRegionDestroyed = false;
+        } else {
+          message = CliStrings.format(
+              CliStrings.DESTROY_REGION__MSG__UNKNOWN_RESULT_WHILE_DESTROYING_REGION_0_REASON_1,
+              regionPath, destroyRegionResult.getMessage());
+          isRegionDestroyed = false;
+        }
+      }
+      if (isRegionDestroyed) {
+        result = ResultBuilder.createInfoResult(message);
+      } else {
+        result = ResultBuilder.createUserErrorResult(message);
+      }
+    } catch (IllegalStateException e) {
+      result = ResultBuilder.createUserErrorResult(CliStrings.format(
+          CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1, regionPath,
+          e.getMessage()));
+    } catch (Exception e) {
+      result = ResultBuilder.createGemFireErrorResult(CliStrings.format(
+          CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1, regionPath,
+          e.getMessage()));
+    }
+
+    if (xmlEntity.get() != null) {
+      persistClusterConfiguration(result,
+          () -> getSharedConfiguration().deleteXmlEntity(xmlEntity.get(), null));
+    }
+
+    return result;
+  }
+
+  private Set<DistributedMember> findMembersForRegion(InternalCache cache,
+      ManagementService managementService, String regionPath) {
+    Set<DistributedMember> membersList = new HashSet<>();
+    Set<String> regionMemberIds = new HashSet<>();
+    MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
+
+    // needs to be escaped with quotes if it contains a hyphen
+    if (regionPath.contains("-")) {
+      regionPath = "\"" + regionPath + "\"";
+    }
+
+    String queryExp =
+        MessageFormat.format(MBeanJMXAdapter.OBJECTNAME__REGION_MXBEAN, regionPath, "*");
+
+    try {
+      ObjectName queryExpON = new ObjectName(queryExp);
+      Set<ObjectName> queryNames = mbeanServer.queryNames(null, queryExpON);
+      if (queryNames == null || queryNames.isEmpty()) {
+        return membersList; // protects against null pointer exception below
+      }
+
+      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))) {
+              regionMemberIds.add(regionMXBean.getMember());
+            } else {
+              if (!addedOneRemote) {
+                regionMemberIds.add(regionMXBean.getMember());
+                addedOneRemote = true;
+              }
+            }
+          }
+        } catch (ClassCastException e) {
+          LogWriter logger = cache.getLogger();
+          if (logger.finerEnabled()) {
+            logger.finer(regionMBeanObjectName + " is not a " + RegionMXBean.class.getSimpleName(),
+                e);
+          }
+        }
+      }
+
+      if (!regionMemberIds.isEmpty()) {
+        membersList = getMembersByIds(cache, regionMemberIds);
+      }
+    } catch (MalformedObjectNameException | NullPointerException e) {
+      LogWrapper.getInstance().info(e.getMessage(), e);
+    }
+
+    return membersList;
+  }
+
+  private Set<DistributedMember> getMembersByIds(InternalCache cache, Set<String> memberIds) {
+    Set<DistributedMember> foundMembers = Collections.emptySet();
+    if (memberIds != null && !memberIds.isEmpty()) {
+      foundMembers = new HashSet<>();
+      Set<DistributedMember> allNormalMembers = CliUtil.getAllNormalMembers(cache);
+
+      for (String memberId : memberIds) {
+        for (DistributedMember distributedMember : allNormalMembers) {
+          if (memberId.equals(distributedMember.getId())
+              || memberId.equals(distributedMember.getName())) {
+            foundMembers.add(distributedMember);
+          }
+        }
+      }
+    }
+    return foundMembers;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommandsUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommandsUtils.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommandsUtils.java
new file mode 100644
index 0000000..49eb520
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommandsUtils.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal.cli.commands;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.management.internal.cli.CliUtil;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+
+public class RegionCommandsUtils {
+
+  static void validateGroups(InternalCache cache, String[] groups) {
+    if (groups != null && groups.length != 0) {
+      Set<String> existingGroups = new HashSet<>();
+      Set<DistributedMember> members = CliUtil.getAllNormalMembers(cache);
+      for (DistributedMember distributedMember : members) {
+        List<String> memberGroups = distributedMember.getGroups();
+        existingGroups.addAll(memberGroups);
+      }
+      List<String> groupsList = new ArrayList<>(Arrays.asList(groups));
+      groupsList.removeAll(existingGroups);
+
+      if (!groupsList.isEmpty()) {
+        throw new IllegalArgumentException(
+            CliStrings.format(CliStrings.CREATE_REGION__MSG__GROUPS_0_ARE_INVALID,
+                new Object[] {String.valueOf(groupsList)}));
+      }
+    }
+  }
+
+  static boolean isClassNameValid(String fqcn) {
+    if (fqcn.isEmpty()) {
+      return true;
+    }
+    String regex = "([\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*";
+    return Pattern.matches(regex, fqcn);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
index 6ae10a3..ee9520d 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
@@ -43,7 +43,7 @@ import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.internal.cli.CliUtil;
-import org.apache.geode.management.internal.cli.commands.CreateAlterDestroyRegionCommands;
+import org.apache.geode.management.internal.cli.commands.CreateRegionCommand;
 import org.apache.geode.management.internal.cli.exceptions.CreateSubregionException;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.util.RegionPath;
@@ -100,9 +100,9 @@ public class RegionCreateFunction extends FunctionAdapter implements InternalEnt
       String localizedString =
           LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString();
       if (localizedString.equals(e.getMessage())) {
-        exceptionMsg = exceptionMsg + " " + CliStrings
-            .format(CliStrings.CREATE_REGION__MSG__USE_ONE_OF_THESE_SHORTCUTS_0, new Object[] {
-                String.valueOf(CreateAlterDestroyRegionCommands.PERSISTENT_OVERFLOW_SHORTCUTS)});
+        exceptionMsg = exceptionMsg + " "
+            + CliStrings.format(CliStrings.CREATE_REGION__MSG__USE_ONE_OF_THESE_SHORTCUTS_0,
+                new Object[] {String.valueOf(CreateRegionCommand.PERSISTENT_OVERFLOW_SHORTCUTS)});
       }
       resultSender.lastResult(handleException(memberNameOrId, exceptionMsg, null/* do not log */));
     } catch (IllegalArgumentException e) {

http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java b/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
index 94ff50c..a626c62 100644
--- a/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
+++ b/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
@@ -40,14 +40,14 @@ import org.apache.geode.cache.query.QueryInvalidException;
 import org.apache.geode.cache.query.QueryService;
 import org.apache.geode.cache.query.RegionNotFoundException;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.redis.internal.executor.ExpirationExecutor;
-import org.apache.geode.redis.internal.executor.ListQuery;
-import org.apache.geode.redis.internal.executor.SortedSetQuery;
 import org.apache.geode.internal.hll.HyperLogLogPlus;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.cli.Result.Status;
-import org.apache.geode.management.internal.cli.commands.CreateAlterDestroyRegionCommands;
+import org.apache.geode.management.internal.cli.commands.CreateRegionCommand;
 import org.apache.geode.redis.GeodeRedisServer;
+import org.apache.geode.redis.internal.executor.ExpirationExecutor;
+import org.apache.geode.redis.internal.executor.ListQuery;
+import org.apache.geode.redis.internal.executor.SortedSetQuery;
 
 /**
  * This class stands between {@link Executor} and {@link Cache#getRegion(String)}. This is needed
@@ -85,8 +85,7 @@ public class RegionProvider implements Closeable {
   private final ConcurrentMap<ByteArrayWrapper, ScheduledFuture<?>> expirationsMap;
   private final ScheduledExecutorService expirationExecutor;
   private final RegionShortcut defaultRegionType;
-  private static final CreateAlterDestroyRegionCommands cliCmds =
-      new CreateAlterDestroyRegionCommands();
+  private static final CreateRegionCommand createRegionCmd = new CreateRegionCommand();
   private final ConcurrentHashMap<String, Lock> locks;
 
   public RegionProvider(Region<ByteArrayWrapper, ByteArrayWrapper> stringsRegion,
@@ -400,10 +399,10 @@ public class RegionProvider implements Closeable {
     if (r != null)
       return r;
     do {
-      Result result = cliCmds.createRegion(key, defaultRegionType, null, null, true, null, null,
+      Result result = createRegionCmd.createRegion(key, defaultRegionType, null, null, true, null,
           null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
           null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
-          null, null);
+          null, null, null);
       r = cache.getRegion(key);
       if (result.getStatus() == Status.ERROR && r == null) {
         String err = "";


[2/5] geode git commit: GEODE-3255: Refactor CreateAlterDestroyRegionCommands and tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
index e913746..a1b9ade 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsDUnitTest.java
@@ -27,37 +27,39 @@ import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
 import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.assertFalse;
 import static org.apache.geode.test.dunit.Assert.assertNotNull;
-import static org.apache.geode.test.dunit.Assert.assertNull;
 import static org.apache.geode.test.dunit.Assert.assertTrue;
 import static org.apache.geode.test.dunit.Assert.fail;
 import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
 import static org.awaitility.Awaitility.waitAtMost;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
 import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.PartitionAttributes;
-import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.PartitionResolver;
 import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionAttributes;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.cache.asyncqueue.AsyncEvent;
-import org.apache.geode.cache.asyncqueue.AsyncEventListener;
-import org.apache.geode.cache.wan.GatewaySenderFactory;
-import org.apache.geode.compression.SnappyCompressor;
 import org.apache.geode.distributed.Locator;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.ClassBuilder;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.cache.PartitionedRegion;
-import org.apache.geode.internal.cache.RegionEntryContext;
 import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.MBeanJMXAdapter;
@@ -70,330 +72,26 @@ import org.apache.geode.test.dunit.SerializableCallable;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-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;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
 
 @Category(DistributedTest.class)
 public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBase {
-
   private static final long serialVersionUID = 1L;
+  private final List<String> filesToBeDeleted = new CopyOnWriteArrayList<String>();
 
-  final String alterRegionName = "testAlterRegionRegion";
-  final String alterAsyncEventQueueId1 = "testAlterRegionQueue1";
-  final String alterAsyncEventQueueId2 = "testAlterRegionQueue2";
-  final String alterAsyncEventQueueId3 = "testAlterRegionQueue3";
-  final String alterGatewaySenderId1 = "testAlterRegionSender1";
-  final String alterGatewaySenderId2 = "testAlterRegionSender2";
-  final String alterGatewaySenderId3 = "testAlterRegionSender3";
-  final String region46391 = "region46391";
-  VM alterVm1;
-  String alterVm1Name;
-  VM alterVm2;
-  String alterVm2Name;
-
-  final List<String> filesToBeDeleted = new CopyOnWriteArrayList<String>();
-
-  /**
-   * Asserts that the "compressor" option for the "create region" command succeeds for a recognized
-   * compressor.
-   */
-  @Test
-  public void testCreateRegionWithGoodCompressor() {
-    setUpJmxManagerOnVm0ThenConnect(null);
-    VM vm = Host.getHost(0).getVM(1);
-
-    // Create a cache in vm 1
-    vm.invoke(() -> {
-      assertNotNull(getCache());
-    });
-
-    // Run create region command with compression
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "compressedRegion");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__COMPRESSOR,
-        RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER);
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    // Make sure our region exists with compression enabled
-    vm.invoke(() -> {
-      Region region = getCache().getRegion("compressedRegion");
-      assertNotNull(region);
-      assertTrue(
-          SnappyCompressor.getDefaultInstance().equals(region.getAttributes().getCompressor()));
-    });
-
-    // cleanup
-    commandStringBuilder = new CommandStringBuilder(CliStrings.DESTROY_REGION);
-    commandStringBuilder.addOption(CliStrings.DESTROY_REGION__REGION, "compressedRegion");
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-  }
-
-  /**
-   * Asserts that the "compressor" option for the "create region" command fails for an unrecognized
-   * compressorc.
-   */
-  @Test
-  public void testCreateRegionWithBadCompressor() {
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    VM vm = Host.getHost(0).getVM(1);
-
-    // Create a cache in vm 1
-    vm.invoke(() -> {
-      assertNotNull(getCache());
-    });
-
-    // Create a region with an unrecognized compressor
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "compressedRegion");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__COMPRESSOR, "BAD_COMPRESSOR");
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
-
-    // Assert that our region was not created
-    vm.invoke(() -> {
-      Region region = getCache().getRegion("compressedRegion");
-      assertNull(region);
-    });
-  }
-
-  /**
-   * Asserts that a missing "compressor" option for the "create region" command results in a region
-   * with no compression.
-   */
-  @Test
-  public void testCreateRegionWithNoCompressor() {
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    VM vm = Host.getHost(0).getVM(1);
-
-    // Create a cache in vm 1
-    vm.invoke(() -> {
-      assertNotNull(getCache());
-    });
-
-    // Create a region with no compression
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "testRegion");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    // Assert that our newly created region has no compression
-    vm.invoke(() -> {
-      Region region = getCache().getRegion("testRegion");
-      assertNotNull(region);
-      assertNull(region.getAttributes().getCompressor());
-    });
-
-    // Cleanup
-    commandStringBuilder = new CommandStringBuilder(CliStrings.DESTROY_REGION);
-    commandStringBuilder.addOption(CliStrings.DESTROY_REGION__REGION, "testRegion");
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-  }
-
-  @Test
-  public void testDestroyDistributedRegion() {
-    setUpJmxManagerOnVm0ThenConnect(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");
-
-        PartitionAttributesFactory paFactory = new PartitionAttributesFactory();
-        paFactory.setColocatedWith("Customer");
-        factory.setPartitionAttributes(paFactory.create());
-        factory.create("Order");
-      });
-    }
-
-    waitForRegionMBeanCreation("/Customer", 2);
-    waitForRegionMBeanCreation("/Order", 2);
-
-    // Test failure when region not found
-    String command = "destroy region --name=DOESNOTEXIST";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    CommandResult cmdResult = executeCommand(command);
-    String strr = commandResultToString(cmdResult);
-    getLogWriter().info("testDestroyRegion strr=" + strr);
-    assertTrue(stringContainsLine(strr, "Could not find.*\"DOESNOTEXIST\".*"));
-    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
-
-    // Test unable to destroy with co-location
-    command = "destroy region --name=/Customer";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    cmdResult = executeCommand(command);
-    strr = commandResultToString(cmdResult);
-    getLogWriter().info("testDestroyRegion strr=" + strr);
-    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
-
-    // Test success
-    command = "destroy region --name=/Order";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    cmdResult = executeCommand(command);
-    strr = commandResultToString(cmdResult);
-    assertTrue(stringContainsLine(strr, ".*Order.*destroyed successfully.*"));
-    getLogWriter().info("testDestroyRegion strr=" + strr);
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    command = "destroy region --name=/Customer";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    cmdResult = executeCommand(command);
-    strr = commandResultToString(cmdResult);
-    assertTrue(stringContainsLine(strr, ".*Customer.*destroyed successfully.*"));
-    getLogWriter().info("testDestroyRegion strr=" + strr);
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-  }
-
-  @Test
-  public void testDestroyLocalRegions() {
-    setUpJmxManagerOnVm0ThenConnect(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";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    CommandResult cmdResult = executeCommand(command);
-    String strr = commandResultToString(cmdResult);
-    getLogWriter().info("testDestroyRegion strr=" + strr);
-    assertTrue(stringContainsLine(strr, "Could not find.*\"DOESNOTEXIST\".*"));
-    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
-
-    command = "destroy region --name=/Customer";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    cmdResult = executeCommand(command);
-    strr = commandResultToString(cmdResult);
-    assertTrue(stringContainsLine(strr, ".*Customer.*destroyed successfully.*"));
-    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"));
-      });
-    }
-  }
-
-  @Test
-  public void testDestroyLocalAndDistributedRegions() {
-    setUpJmxManagerOnVm0ThenConnect(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");
-        factory.create("Customer-2");
-        factory.create("Customer_3");
-      });
-    }
-
-    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");
-      factory.create("Customer-2");
-      factory.create("Customer_3");
-    });
-
-    waitForRegionMBeanCreation("/Customer", 3);
-
-    // Test failure when region not found
-    String command = "destroy region --name=DOESNOTEXIST";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    CommandResult cmdResult = executeCommand(command);
-    String strr = commandResultToString(cmdResult);
-    getLogWriter().info("testDestroyRegion strr=" + strr);
-    assertTrue(stringContainsLine(strr, "Could not find.*\"DOESNOTEXIST\".*"));
-    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
-
-    command = "destroy region --name=/Customer";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    cmdResult = executeCommand(command);
-    strr = commandResultToString(cmdResult);
-    assertTrue(stringContainsLine(strr, ".*Customer.*destroyed successfully.*"));
-    getLogWriter().info("testDestroyRegion strr=" + strr);
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    command = "destroy region --name=/Customer_3";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    cmdResult = executeCommand(command);
-    strr = commandResultToString(cmdResult);
-    assertTrue(stringContainsLine(strr, ".*Customer_3.*destroyed successfully.*"));
-    getLogWriter().info("testDestroyRegion strr=" + strr);
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    command = "destroy region --name=/Customer-2";
-    getLogWriter().info("testDestroyRegion command=" + command);
-    cmdResult = executeCommand(command);
-    strr = commandResultToString(cmdResult);
-    assertTrue(stringContainsLine(strr, ".*Customer-2.*destroyed successfully.*"));
-    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"));
-        assertNull("Region still exists in VM " + x, getCache().getRegion("Customer-2"));
-        assertNull("Region still exists in VM " + x, getCache().getRegion("Customer_3"));
-      });
-    }
-  }
-
-  private void waitForRegionMBeanCreation(final String regionPath, final int mbeanCount) {
+  private void waitForRegionMBeanCreation(final String regionPath) {
     Host.getHost(0).getVM(0).invoke(() -> {
-      waitAtMost(5, TimeUnit.SECONDS).until(newRegionMBeanIsCreated(regionPath, mbeanCount));
+      waitAtMost(5, TimeUnit.SECONDS).until(newRegionMBeanIsCreated(regionPath));
     });
   }
 
-  private Callable<Boolean> newRegionMBeanIsCreated(final String regionPath, final int mbeanCount) {
+  private Callable<Boolean> newRegionMBeanIsCreated(final String regionPath) {
     return () -> {
       try {
         MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
         String queryExp =
             MessageFormat.format(ManagementConstants.OBJECTNAME__REGION_MXBEAN, regionPath, "*");
         ObjectName queryExpON = new ObjectName(queryExp);
-        return mbeanServer.queryNames(null, queryExpON).size() == mbeanCount;
+        return mbeanServer.queryNames(null, queryExpON).size() == 1;
       } catch (MalformedObjectNameException mone) {
         getLogWriter().error(mone);
         fail(mone.getMessage());
@@ -402,556 +100,6 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     };
   }
 
-  @Category(FlakyTest.class) // GEODE-973: random ports, BindException,
-                             // java.rmi.server.ExportException: Port already in use
-  @Test
-  public void testCreateRegion46391() throws IOException {
-    setUpJmxManagerOnVm0ThenConnect(null); // GEODE-973: getRandomAvailablePort
-    String command = CliStrings.CREATE_REGION + " --" + CliStrings.CREATE_REGION__REGION + "="
-        + this.region46391 + " --" + CliStrings.CREATE_REGION__REGIONSHORTCUT + "=REPLICATE";
-
-    getLogWriter().info("testCreateRegion46391 create region command=" + command);
-
-    CommandResult cmdResult = executeCommand(command);
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    command = CliStrings.PUT + " --" + CliStrings.PUT__KEY + "=k1" + " --" + CliStrings.PUT__VALUE
-        + "=k1" + " --" + CliStrings.PUT__REGIONNAME + "=" + this.region46391;
-
-    getLogWriter().info("testCreateRegion46391 put command=" + command);
-
-    CommandResult cmdResult2 = executeCommand(command);
-    assertEquals(Result.Status.OK, cmdResult2.getStatus());
-
-    getLogWriter().info("testCreateRegion46391  cmdResult2=" + commandResultToString(cmdResult2));
-    String str1 = "Result      : true";
-    String str2 = "Key         : k1";
-    String str3 = "Key Class   : java.lang.String";
-    String str4 = "Value Class : java.lang.String";
-    String str5 = "Old Value   : <NULL>";
-
-    assertTrue(commandResultToString(cmdResult)
-        .contains("Region \"/" + this.region46391 + "\" created on"));
-
-    assertTrue(commandResultToString(cmdResult2).contains(str1));
-    assertTrue(commandResultToString(cmdResult2).contains(str2));
-    assertTrue(commandResultToString(cmdResult2).contains(str3));
-    assertTrue(commandResultToString(cmdResult2).contains(str4));
-    assertTrue(commandResultToString(cmdResult2).contains(str5));
-  }
-
-  @Ignore("bug51924")
-  @Test
-  public void testAlterRegion() throws IOException {
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    CommandResult cmdResult = executeCommand(CliStrings.LIST_REGION);
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    assertTrue(commandResultToString(cmdResult).contains("No Regions Found"));
-
-    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(() -> {
-      Properties localProps = new Properties();
-      localProps.setProperty(NAME, alterVm1Name);
-      localProps.setProperty(GROUPS, "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);
-    });
-
-    this.alterVm2 = Host.getHost(0).getVM(2);
-    this.alterVm2Name = "VM" + this.alterVm2.getPid();
-    this.alterVm2.invoke(() -> {
-      Properties localProps = new Properties();
-      localProps.setProperty(NAME, alterVm2Name);
-      localProps.setProperty(GROUPS, "Group1,Group2");
-      getSystem(localProps);
-      Cache cache = getCache();
-
-      cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true)
-          .create(alterRegionName);
-    });
-
-    deployJarFilesForRegionAlter();
-    regionAlterGroupTest();
-    regionAlterSetAllTest();
-    regionAlterNoChangeTest();
-    regionAlterSetDefaultsTest();
-    regionAlterManipulatePlugInsTest();
-
-    this.alterVm1.invoke(() -> {
-      getCache().getRegion(alterRegionName).destroyRegion();
-    });
-  }
-
-  private void regionAlterGroupTest() {
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "5764");
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    String stringResult = commandResultToString(cmdResult);
-    assertEquals(4, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    this.alterVm1.invoke(() -> {
-      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);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.GROUP, "Group2");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "6963");
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    stringResult = commandResultToString(cmdResult);
-    assertEquals(3, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertFalse(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    this.alterVm1.invoke(() -> {
-      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-      assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
-    });
-
-    this.alterVm2.invoke(() -> {
-      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-      assertEquals(6963, attributes.getEvictionAttributes().getMaximum());
-    });
-  }
-
-  private void regionAlterSetAllTest() {
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "35464");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CLONINGENABLED, "true");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
-        this.alterAsyncEventQueueId1);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME, "3453");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIMEACTION,
-        "DESTROY");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONTIMETOLIVE, "7563");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION, "DESTROY");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerA");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELOADER,
-        "com.cadrdunit.RegionAlterCacheLoader");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHEWRITER,
-        "com.cadrdunit.RegionAlterCacheWriter");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
-        this.alterGatewaySenderId1);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME, "6234");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION,
-        "DESTROY");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONTTL, "4562");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION, "DESTROY");
-
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    String stringResult = commandResultToString(cmdResult);
-    assertEquals(5, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertTrue(stringContainsLine(stringResult,
-        "Manager.*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    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());
-    });
-  }
-
-  private void regionAlterNoChangeTest() {
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CLONINGENABLED, "true");
-
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    String stringResult = commandResultToString(cmdResult);
-    assertEquals(4, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    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());
-    });
-  }
-
-  private void regionAlterSetDefaultsTest() {
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CLONINGENABLED);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELOADER);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHEWRITER);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION);
-
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    String stringResult = commandResultToString(cmdResult);
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    assertEquals(4, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    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);
-    });
-  }
-
-  private void regionAlterManipulatePlugInsTest() {
-
-    // Start out by putting 3 entries into each of the plug-in sets
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
-        this.alterAsyncEventQueueId1);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
-        this.alterAsyncEventQueueId2);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
-        this.alterAsyncEventQueueId3);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
-        this.alterGatewaySenderId1);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
-        this.alterGatewaySenderId2);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
-        this.alterGatewaySenderId3);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerA");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerB");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerC");
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    String stringResult = commandResultToString(cmdResult);
-
-    assertEquals(4, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    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
-    commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
-        this.alterAsyncEventQueueId1);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
-        this.alterAsyncEventQueueId2);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
-        this.alterGatewaySenderId1);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
-        this.alterGatewaySenderId3);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerB");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerC");
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    stringResult = commandResultToString(cmdResult);
-    assertEquals(4, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    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
-    commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
-        this.alterAsyncEventQueueId1);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
-        this.alterAsyncEventQueueId2);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID,
-        this.alterAsyncEventQueueId3);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
-        this.alterGatewaySenderId1);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
-        this.alterGatewaySenderId3);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GATEWAYSENDERID,
-        this.alterGatewaySenderId2);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerB");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerC");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerA");
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    stringResult = commandResultToString(cmdResult);
-    assertEquals(4, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    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());
-    });
-  }
-
-  @Category(FlakyTest.class) // GEODE-3018
-  @Test
-  public void testAlterRegionResetCacheListeners() throws IOException {
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    CommandResult cmdResult = executeCommand(CliStrings.LIST_REGION);
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    assertTrue(commandResultToString(cmdResult).contains("No Regions Found"));
-
-    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(() -> {
-      Properties localProps = new Properties();
-      localProps.setProperty(NAME, alterVm1Name);
-      localProps.setProperty(GROUPS, "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);
-    });
-
-    this.alterVm2 = Host.getHost(0).getVM(2);
-    this.alterVm2Name = "VM" + this.alterVm2.getPid();
-    this.alterVm2.invoke(() -> {
-      Properties localProps = new Properties();
-      localProps.setProperty(NAME, alterVm2Name);
-      localProps.setProperty(GROUPS, "Group1,Group2");
-      getSystem(localProps);
-      Cache cache = getCache();
-
-      cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true)
-          .create(alterRegionName);
-    });
-
-    deployJarFilesForRegionAlter();
-
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER,
-        "com.cadrdunit.RegionAlterCacheListenerA,com.cadrdunit.RegionAlterCacheListenerB,com.cadrdunit.RegionAlterCacheListenerC");
-
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    String stringResult = commandResultToString(cmdResult);
-
-    assertEquals(5, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    this.alterVm1.invoke(() -> {
-      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-      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());
-    });
-
-    // Add 1 back to each of the sets
-    commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
-    commandStringBuilder.addOption(CliStrings.GROUP, "Group1");
-    commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER, "''");
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-    stringResult = commandResultToString(cmdResult);
-    assertEquals(4, countLinesInString(stringResult, false));
-    assertEquals(false, stringResult.contains("ERROR"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-    assertTrue(stringContainsLine(stringResult,
-        this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
-
-    this.alterVm1.invoke(() -> {
-      RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
-      assertEquals(0, attributes.getCacheListeners().length);
-    });
-  }
-
   /**
    * Asserts that creating, altering and destroying regions correctly updates the shared
    * configuration.
@@ -969,7 +117,6 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
       jmxHost = "localhost";
     }
 
-
     final String regionName = "testRegionSharedConfigRegion";
     final String regionPath = "/" + regionName;
     final String groupName = "testRegionSharedConfigGroup";
@@ -994,7 +141,7 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
         final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort,
             locatorLogFile, null, locatorProps);
 
-        waitAtMost(5, TimeUnit.SECONDS).until(() -> locator.isSharedConfigurationRunning());
+        waitAtMost(5, TimeUnit.SECONDS).until(locator::isSharedConfigurationRunning);
 
         ManagementService managementService =
             ManagementService.getExistingManagementService(GemFireCacheImpl.getInstance());
@@ -1030,7 +177,7 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Make sure that the region has been registered with the Manager MXBean
-    waitForRegionMBeanCreation(regionPath, 1);
+    waitForRegionMBeanCreation(regionPath);
 
     // Make sure the region exists in the shared config
     Host.getHost(0).getVM(0).invoke(() -> {
@@ -1109,251 +256,8 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
         return null;
       }
     });
-
-  }
-
-  @Test
-  public void testDestroyRegionWithSharedConfig() {
-    disconnectAllFromDS();
-
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-    jmxPort = ports[0];
-    httpPort = ports[1];
-    try {
-      jmxHost = InetAddress.getLocalHost().getHostName();
-    } catch (UnknownHostException ignore) {
-      jmxHost = "localhost";
-    }
-
-
-    final String regionName = "testRegionSharedConfigRegion";
-    final String regionPath = "/" + regionName;
-    final String groupName = "testRegionSharedConfigGroup";
-
-    // Start the Locator and wait for shared configuration to be available
-    final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
-    final Properties locatorProps = new Properties();
-    locatorProps.setProperty(NAME, "Locator");
-    locatorProps.setProperty(MCAST_PORT, "0");
-    locatorProps.setProperty(LOG_LEVEL, "fine");
-    locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
-    locatorProps.setProperty(JMX_MANAGER, "true");
-    locatorProps.setProperty(JMX_MANAGER_START, "true");
-    locatorProps.setProperty(JMX_MANAGER_BIND_ADDRESS, String.valueOf(jmxHost));
-    locatorProps.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort));
-    locatorProps.setProperty(HTTP_SERVICE_PORT, String.valueOf(httpPort));
-
-    Host.getHost(0).getVM(0).invoke(() -> {
-      final File locatorLogFile = new File("locator-" + locatorPort + ".log");
-      try {
-        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort,
-            locatorLogFile, null, locatorProps);
-
-        waitAtMost(5, TimeUnit.SECONDS).until(() -> locator.isSharedConfigurationRunning());
-      } catch (IOException ioex) {
-        fail("Unable to create a locator with a shared configuration");
-      }
-    });
-
-    connect(jmxHost, jmxPort, httpPort, getDefaultShell());
-
-    // Create a cache in VM 1
-    VM vm = Host.getHost(0).getVM(1);
-    vm.invoke(() -> {
-      Properties localProps = new Properties();
-      localProps.setProperty(MCAST_PORT, "0");
-      localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
-      localProps.setProperty(GROUPS, groupName);
-      getSystem(localProps);
-      assertNotNull(getCache());
-    });
-
-    // Test creating the region
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, regionName);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__STATISTICSENABLED, "true");
-    commandStringBuilder.addOption(CliStrings.GROUP, groupName);
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    // Make sure that the region has been registered with the Manager MXBean
-    waitForRegionMBeanCreation(regionPath, 1);
-
-    // Make sure the region exists in the shared config
-    Host.getHost(0).getVM(0).invoke(() -> {
-      ClusterConfigurationService sharedConfig =
-          ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
-      try {
-        assertTrue(
-            sharedConfig.getConfiguration(groupName).getCacheXmlContent().contains(regionName));
-      } catch (Exception e) {
-        fail("Error occurred in cluster configuration service");
-      }
-    });
-
-    // Test destroying the region
-    commandStringBuilder = new CommandStringBuilder(CliStrings.DESTROY_REGION);
-    commandStringBuilder.addOption(CliStrings.DESTROY_REGION__REGION, regionName);
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    getLogWriter().info("#SB" + commandResultToString(cmdResult));
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    // Make sure the region was removed from the shared config
-    Host.getHost(0).getVM(0).invoke(() -> {
-      ClusterConfigurationService 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(() -> {
-      Cache cache = getCache();
-      assertNotNull(cache);
-      cache.close();
-      assertTrue(cache.isClosed());
-
-      Properties localProps = new Properties();
-      localProps.setProperty(MCAST_PORT, "0");
-      localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
-      localProps.setProperty(GROUPS, groupName);
-      localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
-      getSystem(localProps);
-      cache = getCache();
-      assertNotNull(cache);
-      Region region = cache.getRegion(regionName);
-      assertNull(region);
-
-      return null;
-    });
   }
 
-
-  final String PR_STRING = " package com.cadrdunit;"
-      + " public class TestPartitionResolver implements org.apache.geode.cache.PartitionResolver { "
-      + "   @Override" + "   public void close() {" + "   }" + "   @Override"
-      + "   public Object getRoutingObject(org.apache.geode.cache.EntryOperation opDetails) { "
-      + "    return null; " + "   }" + "   @Override" + "   public String getName() { "
-      + "    return \"TestPartitionResolver\";" + "   }" + " }";
-
-  /**
-   * Test Description 1. Deploy a JAR with Custom Partition Resolver 2. Create Region with Partition
-   * Resolver 3. Region should get created with no Errors 4. Verify Region Partition Attributes for
-   * Partition Resolver
-   */
-  @Test
-  public void testCreateRegionWithPartitionResolver() throws IOException {
-    setUpJmxManagerOnVm0ThenConnect(null);
-    VM vm = Host.getHost(0).getVM(1);
-    // Create a cache in vm 1
-    vm.invoke(() -> {
-      assertNotNull(getCache());
-    });
-
-    ClassBuilder classBuilder = new ClassBuilder();
-    // classBuilder.addToClassPath(".");
-    final File prJarFile = new File(temporaryFolder.getRoot().getCanonicalPath() + File.separator,
-        "myPartitionResolver.jar");
-    this.filesToBeDeleted.add(prJarFile.getAbsolutePath());
-    byte[] jarBytes =
-        classBuilder.createJarFromClassContent("com/cadrdunit/TestPartitionResolver", PR_STRING);
-    writeJarBytesToFile(prJarFile, jarBytes);
-
-    CommandResult cmdResult = executeCommand("deploy --jar=" + prJarFile.getAbsolutePath());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-
-    // Create a region with an unrecognized compressor
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "regionWithPartitionResolver");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "PARTITION");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__PARTITION_RESOLVER,
-        "com.cadrdunit.TestPartitionResolver");
-    CommandResult cmdResult1 = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult1.getStatus());
-
-    // Assert that our region was not created
-    vm.invoke(() -> {
-      Region region = getCache().getRegion("regionWithPartitionResolver");
-      assertNotNull(region);
-
-      PartitionedRegion pr = (PartitionedRegion) region;
-      PartitionAttributes partitionAttributes = pr.getPartitionAttributes();
-      assertNotNull(partitionAttributes);
-      PartitionResolver partitionResolver = partitionAttributes.getPartitionResolver();
-      assertNotNull(partitionResolver);
-      assertEquals("TestPartitionResolver", partitionResolver.getName());
-    });
-
-    vm.invoke(() -> {
-      getCache().getRegion("regionWithPartitionResolver").destroyRegion();
-    });
-  }
-
-  @Test
-  public void testCreateRegionWithInvalidPartitionResolver() {
-    setUpJmxManagerOnVm0ThenConnect(null);
-    VM vm = Host.getHost(0).getVM(1);
-    // Create a cache in vm 1
-    vm.invoke(() -> {
-      assertNotNull(getCache());
-    });
-
-    // Create a region with an unrecognized compressor
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION,
-        "testCreateRegionWithInvalidPartitionResolver");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "PARTITION");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__PARTITION_RESOLVER, "a.b.c.d");
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
-
-    // Assert that our region was not created
-    vm.invoke(() -> {
-      Region region = getCache().getRegion("testCreateRegionWithInvalidPartitionResolver");
-      assertNull(region);
-    });
-  }
-
-  /**
-   * Test Description Try creating region of type REPLICATED and specify partition resolver Region
-   * Creation should fail.
-   */
-  @Test
-  public void testCreateRegionForReplicatedRegionWithParitionResolver() {
-    setUpJmxManagerOnVm0ThenConnect(null);
-    VM vm = Host.getHost(0).getVM(1);
-    // Create a cache in vm 1
-    vm.invoke(() -> {
-      assertNotNull(getCache());
-    });
-
-    // Create a region with an unrecognized compressor
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION,
-        "testCreateRegionForReplicatedRegionWithParitionResolver");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__PARTITION_RESOLVER, "a.b.c.d");
-    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
-
-    // Assert that our region was not created
-    vm.invoke(() -> {
-      Region region =
-          getCache().getRegion("testCreateRegionForReplicatedRegionWithParitionResolver");
-      assertNull(region);
-    });
-  }
-
-
   @Override
   protected final void preTearDownCliCommandTestBase() throws Exception {
     for (String path : this.filesToBeDeleted) {
@@ -1369,69 +273,4 @@ public class CreateAlterDestroyRegionCommandsDUnitTest extends CliCommandTestBas
     }
     this.filesToBeDeleted.clear();
   }
-
-  /**
-   * Deploys JAR files which contain classes to be instantiated by the "alter region" test.
-   */
-  private void deployJarFilesForRegionAlter() throws IOException {
-    ClassBuilder classBuilder = new ClassBuilder();
-    final File jarFile1 = new File(new File(".").getAbsolutePath(), "testAlterRegion1.jar");
-    this.filesToBeDeleted.add(jarFile1.getAbsolutePath());
-    final File jarFile2 = new File(new File(".").getAbsolutePath(), "testAlterRegion2.jar");
-    this.filesToBeDeleted.add(jarFile2.getAbsolutePath());
-    final File jarFile3 = new File(new File(".").getAbsolutePath(), "testAlterRegion3.jar");
-    this.filesToBeDeleted.add(jarFile3.getAbsolutePath());
-    final File jarFile4 = new File(new File(".").getAbsolutePath(), "testAlterRegion4.jar");
-    this.filesToBeDeleted.add(jarFile4.getAbsolutePath());
-    final File jarFile5 = new File(new File(".").getAbsolutePath(), "testAlterRegion5.jar");
-    this.filesToBeDeleted.add(jarFile5.getAbsolutePath());
-
-    byte[] jarBytes =
-        classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheListenerA",
-            "package com.cadrdunit;" + "import org.apache.geode.cache.util.CacheListenerAdapter;"
-                + "public class RegionAlterCacheListenerA extends CacheListenerAdapter {}");
-    writeJarBytesToFile(jarFile1, jarBytes);
-    CommandResult cmdResult = executeCommand("deploy --jar=testAlterRegion1.jar");
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    jarBytes = classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheListenerB",
-        "package com.cadrdunit;" + "import org.apache.geode.cache.util.CacheListenerAdapter;"
-            + "public class RegionAlterCacheListenerB extends CacheListenerAdapter {}");
-    writeJarBytesToFile(jarFile2, jarBytes);
-    cmdResult = executeCommand("deploy --jar=testAlterRegion2.jar");
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    jarBytes = classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheListenerC",
-        "package com.cadrdunit;" + "import org.apache.geode.cache.util.CacheListenerAdapter;"
-            + "public class RegionAlterCacheListenerC extends CacheListenerAdapter {}");
-    writeJarBytesToFile(jarFile3, jarBytes);
-    cmdResult = executeCommand("deploy --jar=testAlterRegion3.jar");
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    jarBytes = classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheLoader",
-        "package com.cadrdunit;" + "import org.apache.geode.cache.CacheLoader;"
-            + "import org.apache.geode.cache.CacheLoaderException;"
-            + "import org.apache.geode.cache.LoaderHelper;"
-            + "public class RegionAlterCacheLoader implements CacheLoader {"
-            + "public void close() {}"
-            + "public Object load(LoaderHelper helper) throws CacheLoaderException {return null;}}");
-    writeJarBytesToFile(jarFile4, jarBytes);
-    cmdResult = executeCommand("deploy --jar=testAlterRegion4.jar");
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    jarBytes = classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheWriter",
-        "package com.cadrdunit;" + "import org.apache.geode.cache.util.CacheWriterAdapter;"
-            + "public class RegionAlterCacheWriter extends CacheWriterAdapter {}");
-    writeJarBytesToFile(jarFile5, jarBytes);
-    cmdResult = executeCommand("deploy --jar=testAlterRegion5.jar");
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-  }
-
-  private void writeJarBytesToFile(File jarFile, byte[] jarBytes) throws IOException {
-    final OutputStream outStream = new FileOutputStream(jarFile);
-    outStream.write(jarBytes);
-    outStream.flush();
-    outStream.close();
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
deleted file mode 100644
index 85b660d..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.geode.management.internal.cli.commands;
-
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
-
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.management.DistributedSystemMXBean;
-import org.apache.geode.test.dunit.rules.GfshParserRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-
-@Category(IntegrationTest.class)
-public class CreateAlterDestroyRegionCommandsTest {
-
-  @Rule
-  public GfshParserRule parser = new GfshParserRule();
-
-  @Test
-  public void testCreateRegionWithInvalidPartitionResolver() throws Exception {
-    InternalCache cache = mock(InternalCache.class);
-    DistributedSystemMXBean dsMBean = mock(DistributedSystemMXBean.class);
-    CreateAlterDestroyRegionCommands spy = Mockito.spy(CreateAlterDestroyRegionCommands.class);
-
-    doReturn(cache).when(spy).getCache();
-    doReturn(dsMBean).when(spy).getDSMBean(cache);
-
-    String command = "create region --name=region3 --type=PARTITION --partition-resolver=Foo";
-
-    assertThatThrownBy(() -> parser.executeCommandWithInstance(spy, command))
-        .hasMessageContaining("Foo is an invalid Partition Resolver");
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
new file mode 100644
index 0000000..04168d5
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
@@ -0,0 +1,318 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal.cli.commands;
+
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.PartitionAttributes;
+import org.apache.geode.cache.PartitionResolver;
+import org.apache.geode.cache.Region;
+import org.apache.geode.compression.SnappyCompressor;
+import org.apache.geode.internal.ClassBuilder;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.RegionEntryContext;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.FlakyTest;
+
+@Category(DistributedTest.class)
+public class CreateRegionCommandDUnitTest extends CliCommandTestBase {
+  private final List<String> filesToBeDeleted = new CopyOnWriteArrayList<String>();
+
+  /**
+   * Asserts that the "compressor" option for the "create region" command succeeds for a recognized
+   * compressor.
+   */
+  @Test
+  public void testCreateRegionWithGoodCompressor() {
+    setUpJmxManagerOnVm0ThenConnect(null);
+    VM vm = Host.getHost(0).getVM(1);
+
+    // Create a cache in vm 1
+    vm.invoke(() -> {
+      assertNotNull(getCache());
+    });
+
+    // Run create region command with compression
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "compressedRegion");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__COMPRESSOR,
+        RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER);
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    // Make sure our region exists with compression enabled
+    vm.invoke(() -> {
+      Region region = getCache().getRegion("compressedRegion");
+      assertNotNull(region);
+      assertTrue(
+          SnappyCompressor.getDefaultInstance().equals(region.getAttributes().getCompressor()));
+    });
+
+    // cleanup
+    commandStringBuilder = new CommandStringBuilder(CliStrings.DESTROY_REGION);
+    commandStringBuilder.addOption(CliStrings.DESTROY_REGION__REGION, "compressedRegion");
+    cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+  }
+
+  /**
+   * Asserts that the "compressor" option for the "create region" command fails for an unrecognized
+   * compressorc.
+   */
+  @Test
+  public void testCreateRegionWithBadCompressor() {
+    setUpJmxManagerOnVm0ThenConnect(null);
+
+    VM vm = Host.getHost(0).getVM(1);
+
+    // Create a cache in vm 1
+    vm.invoke(() -> {
+      assertNotNull(getCache());
+    });
+
+    // Create a region with an unrecognized compressor
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "compressedRegion");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__COMPRESSOR, "BAD_COMPRESSOR");
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
+
+    // Assert that our region was not created
+    vm.invoke(() -> {
+      Region region = getCache().getRegion("compressedRegion");
+      assertNull(region);
+    });
+  }
+
+  /**
+   * Asserts that a missing "compressor" option for the "create region" command results in a region
+   * with no compression.
+   */
+  @Test
+  public void testCreateRegionWithNoCompressor() {
+    setUpJmxManagerOnVm0ThenConnect(null);
+
+    VM vm = Host.getHost(0).getVM(1);
+
+    // Create a cache in vm 1
+    vm.invoke(() -> {
+      assertNotNull(getCache());
+    });
+
+    // Create a region with no compression
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "testRegion");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    // Assert that our newly created region has no compression
+    vm.invoke(() -> {
+      Region region = getCache().getRegion("testRegion");
+      assertNotNull(region);
+      assertNull(region.getAttributes().getCompressor());
+    });
+
+    // Cleanup
+    commandStringBuilder = new CommandStringBuilder(CliStrings.DESTROY_REGION);
+    commandStringBuilder.addOption(CliStrings.DESTROY_REGION__REGION, "testRegion");
+    cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+  }
+
+  @Category(FlakyTest.class) // GEODE-973: random ports, BindException,
+  // java.rmi.server.ExportException: Port already in use
+  @Test
+  public void testCreateRegion46391() throws IOException {
+    setUpJmxManagerOnVm0ThenConnect(null); // GEODE-973: getRandomAvailablePort
+    String region46391 = "region46391";
+    String command = CliStrings.CREATE_REGION + " --" + CliStrings.CREATE_REGION__REGION + "="
+        + region46391 + " --" + CliStrings.CREATE_REGION__REGIONSHORTCUT + "=REPLICATE";
+
+    getLogWriter().info("testCreateRegion46391 create region command=" + command);
+
+    CommandResult cmdResult = executeCommand(command);
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    command = CliStrings.PUT + " --" + CliStrings.PUT__KEY + "=k1" + " --" + CliStrings.PUT__VALUE
+        + "=k1" + " --" + CliStrings.PUT__REGIONNAME + "=" + region46391;
+
+    getLogWriter().info("testCreateRegion46391 put command=" + command);
+
+    CommandResult cmdResult2 = executeCommand(command);
+    assertEquals(Result.Status.OK, cmdResult2.getStatus());
+
+    getLogWriter().info("testCreateRegion46391  cmdResult2=" + commandResultToString(cmdResult2));
+    String str1 = "Result      : true";
+    String str2 = "Key         : k1";
+    String str3 = "Key Class   : java.lang.String";
+    String str4 = "Value Class : java.lang.String";
+    String str5 = "Old Value   : <NULL>";
+
+    assertTrue(
+        commandResultToString(cmdResult).contains("Region \"/" + region46391 + "\" created on"));
+
+    assertTrue(commandResultToString(cmdResult2).contains(str1));
+    assertTrue(commandResultToString(cmdResult2).contains(str2));
+    assertTrue(commandResultToString(cmdResult2).contains(str3));
+    assertTrue(commandResultToString(cmdResult2).contains(str4));
+    assertTrue(commandResultToString(cmdResult2).contains(str5));
+  }
+
+  /**
+   * Test Description 1. Deploy a JAR with Custom Partition Resolver 2. Create Region with Partition
+   * Resolver 3. Region should get created with no Errors 4. Verify Region Partition Attributes for
+   * Partition Resolver
+   */
+  @Test
+  public void testCreateRegionWithPartitionResolver() throws IOException {
+    setUpJmxManagerOnVm0ThenConnect(null);
+    VM vm = Host.getHost(0).getVM(1);
+    // Create a cache in vm 1
+    vm.invoke(() -> {
+      assertNotNull(getCache());
+    });
+
+    ClassBuilder classBuilder = new ClassBuilder();
+    // classBuilder.addToClassPath(".");
+    final File prJarFile = new File(temporaryFolder.getRoot().getCanonicalPath() + File.separator,
+        "myPartitionResolver.jar");
+    this.filesToBeDeleted.add(prJarFile.getAbsolutePath());
+    String PR_STRING = " package com.cadrdunit;"
+        + " public class TestPartitionResolver implements org.apache.geode.cache.PartitionResolver { "
+        + "   @Override" + "   public void close() {" + "   }" + "   @Override"
+        + "   public Object getRoutingObject(org.apache.geode.cache.EntryOperation opDetails) { "
+        + "    return null; " + "   }" + "   @Override" + "   public String getName() { "
+        + "    return \"TestPartitionResolver\";" + "   }" + " }";
+    byte[] jarBytes =
+        classBuilder.createJarFromClassContent("com/cadrdunit/TestPartitionResolver", PR_STRING);
+    writeJarBytesToFile(prJarFile, jarBytes);
+
+    CommandResult cmdResult = executeCommand("deploy --jar=" + prJarFile.getAbsolutePath());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+
+    // Create a region with an unrecognized compressor
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "regionWithPartitionResolver");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "PARTITION");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__PARTITION_RESOLVER,
+        "com.cadrdunit.TestPartitionResolver");
+    CommandResult cmdResult1 = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult1.getStatus());
+
+    // Assert that our region was not created
+    vm.invoke(() -> {
+      Region region = getCache().getRegion("regionWithPartitionResolver");
+      assertNotNull(region);
+
+      PartitionedRegion pr = (PartitionedRegion) region;
+      PartitionAttributes partitionAttributes = pr.getPartitionAttributes();
+      assertNotNull(partitionAttributes);
+      PartitionResolver partitionResolver = partitionAttributes.getPartitionResolver();
+      assertNotNull(partitionResolver);
+      assertEquals("TestPartitionResolver", partitionResolver.getName());
+    });
+
+    vm.invoke(() -> {
+      getCache().getRegion("regionWithPartitionResolver").destroyRegion();
+    });
+  }
+
+  @Test
+  public void testCreateRegionWithInvalidPartitionResolver() {
+    setUpJmxManagerOnVm0ThenConnect(null);
+    VM vm = Host.getHost(0).getVM(1);
+    // Create a cache in vm 1
+    vm.invoke(() -> {
+      assertNotNull(getCache());
+    });
+
+    // Create a region with an unrecognized compressor
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION,
+        "testCreateRegionWithInvalidPartitionResolver");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "PARTITION");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__PARTITION_RESOLVER, "a.b.c.d");
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
+
+    // Assert that our region was not created
+    vm.invoke(() -> {
+      Region region = getCache().getRegion("testCreateRegionWithInvalidPartitionResolver");
+      assertNull(region);
+    });
+  }
+
+  /**
+   * Test Description Try creating region of type REPLICATED and specify partition resolver Region
+   * Creation should fail.
+   */
+  @Test
+  public void testCreateRegionForReplicatedRegionWithParitionResolver() {
+    setUpJmxManagerOnVm0ThenConnect(null);
+    VM vm = Host.getHost(0).getVM(1);
+    // Create a cache in vm 1
+    vm.invoke(() -> {
+      assertNotNull(getCache());
+    });
+
+    // Create a region with an unrecognized compressor
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION,
+        "testCreateRegionForReplicatedRegionWithParitionResolver");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__PARTITION_RESOLVER, "a.b.c.d");
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.ERROR, cmdResult.getStatus());
+
+    // Assert that our region was not created
+    vm.invoke(() -> {
+      Region region =
+          getCache().getRegion("testCreateRegionForReplicatedRegionWithParitionResolver");
+      assertNull(region);
+    });
+  }
+
+  private void writeJarBytesToFile(File jarFile, byte[] jarBytes) throws IOException {
+    final OutputStream outStream = new FileOutputStream(jarFile);
+    outStream.write(jarBytes);
+    outStream.flush();
+    outStream.close();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
new file mode 100644
index 0000000..5011d78
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal.cli.commands;
+
+import static org.apache.geode.management.internal.cli.commands.CreateRegionCommand.regionExists;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.Mockito;
+
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.management.DistributedSystemMXBean;
+import org.apache.geode.test.dunit.rules.GfshParserRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class CreateRegionCommandTest {
+  @Rule
+  public GfshParserRule parser = new GfshParserRule();
+
+  @Test
+  public void testCreateRegionWithInvalidPartitionResolver() throws Exception {
+    InternalCache cache = mock(InternalCache.class);
+    DistributedSystemMXBean dsMBean = mock(DistributedSystemMXBean.class);
+    CreateRegionCommand spy = Mockito.spy(CreateRegionCommand.class);
+
+    doReturn(cache).when(spy).getCache();
+    doReturn(dsMBean).when(spy).getDSMBean(cache);
+
+    String command = "create region --name=region3 --type=PARTITION --partition-resolver=Foo";
+    assertThatThrownBy(() -> parser.executeCommandWithInstance(spy, command))
+        .hasMessageContaining("Foo is an invalid Partition Resolver");
+  }
+
+  @Test
+  public void testRegionExistsReturnsCorrectValue() throws Exception {
+    InternalCache cache = mock(InternalCache.class);
+    assertThat(regionExists(cache, null)).isFalse();
+  }
+}


[5/5] geode git commit: GEODE-3255: Refactor CreateAlterDestroyRegionCommands and tests

Posted by kl...@apache.org.
GEODE-3255: Refactor CreateAlterDestroyRegionCommands and tests

This closes #671


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

Branch: refs/heads/develop
Commit: 756efe77c86bb03ac9984655e7bd040659e85890
Parents: a7f2952
Author: YehEmily <em...@gmail.com>
Authored: Fri Jul 28 14:23:25 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Fri Aug 11 12:57:32 2017 -0700

----------------------------------------------------------------------
 .../cli/commands/AlterRegionCommand.java        |  229 ++++
 .../CreateAlterDestroyRegionCommands.java       | 1146 -----------------
 .../cli/commands/CreateRegionCommand.java       |  741 +++++++++++
 .../cli/commands/DestroyRegionCommand.java      |  222 ++++
 .../cli/commands/RegionCommandsUtils.java       |   59 +
 .../cli/functions/RegionCreateFunction.java     |    8 +-
 .../geode/redis/internal/RegionProvider.java    |   15 +-
 .../commands/AlterRegionCommandDUnitTest.java   |  641 +++++++++
 ...eateAlterDestroyRegionCommandsDUnitTest.java | 1211 +-----------------
 .../CreateAlterDestroyRegionCommandsTest.java   |   53 -
 .../commands/CreateRegionCommandDUnitTest.java  |  318 +++++
 .../cli/commands/CreateRegionCommandTest.java   |   58 +
 .../commands/DestroyRegionCommandDUnitTest.java |  388 ++++++
 .../internal/security/TestCommand.java          |    2 +-
 14 files changed, 2693 insertions(+), 2398 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommand.java
new file mode 100644
index 0000000..0f9b5d8
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommand.java
@@ -0,0 +1,229 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.commands;
+
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import org.apache.geode.cache.ExpirationAttributes;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.cli.ConverterHint;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.CliUtil;
+import org.apache.geode.management.internal.cli.LogWrapper;
+import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
+import org.apache.geode.management.internal.cli.functions.RegionAlterFunction;
+import org.apache.geode.management.internal.cli.functions.RegionFunctionArgs;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.result.TabularResultData;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+
+public class AlterRegionCommand implements GfshCommand {
+  @CliCommand(value = CliStrings.ALTER_REGION, help = CliStrings.ALTER_REGION__HELP)
+  @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
+  public Result alterRegion(
+      @CliOption(key = CliStrings.ALTER_REGION__REGION, mandatory = true,
+          help = CliStrings.ALTER_REGION__REGION__HELP) String regionPath,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
+          optionContext = ConverterHint.MEMBERGROUP,
+          help = CliStrings.ALTER_REGION__GROUP__HELP) String[] groups,
+      @CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME,
+          specifiedDefaultValue = "-1",
+          help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME__HELP) Integer entryExpirationIdleTime,
+      @CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIMEACTION,
+          specifiedDefaultValue = "INVALIDATE",
+          help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIMEACTION__HELP) String entryExpirationIdleTimeAction,
+      @CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTIMETOLIVE,
+          specifiedDefaultValue = "-1",
+          help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTIMETOLIVE__HELP) Integer entryExpirationTTL,
+      @CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION,
+          specifiedDefaultValue = "INVALIDATE",
+          help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION__HELP) String entryExpirationTTLAction,
+      @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME,
+          specifiedDefaultValue = "-1",
+          help = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME__HELP) Integer regionExpirationIdleTime,
+      @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION,
+          specifiedDefaultValue = "INVALIDATE",
+          help = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION__HELP) String regionExpirationIdleTimeAction,
+      @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTL, specifiedDefaultValue = "-1",
+          help = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTL__HELP) Integer regionExpirationTTL,
+      @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION,
+          specifiedDefaultValue = "INVALIDATE",
+          help = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION__HELP) String regionExpirationTTLAction,
+      @CliOption(key = CliStrings.ALTER_REGION__CACHELISTENER, specifiedDefaultValue = "",
+          help = CliStrings.ALTER_REGION__CACHELISTENER__HELP) String[] cacheListeners,
+      @CliOption(key = CliStrings.ALTER_REGION__CACHELOADER, specifiedDefaultValue = "",
+          help = CliStrings.ALTER_REGION__CACHELOADER__HELP) String cacheLoader,
+      @CliOption(key = CliStrings.ALTER_REGION__CACHEWRITER, specifiedDefaultValue = "",
+          help = CliStrings.ALTER_REGION__CACHEWRITER__HELP) String cacheWriter,
+      @CliOption(key = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID, specifiedDefaultValue = "",
+          help = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID__HELP) String[] asyncEventQueueIds,
+      @CliOption(key = CliStrings.ALTER_REGION__GATEWAYSENDERID, specifiedDefaultValue = "",
+          help = CliStrings.ALTER_REGION__GATEWAYSENDERID__HELP) String[] gatewaySenderIds,
+      @CliOption(key = CliStrings.ALTER_REGION__CLONINGENABLED, specifiedDefaultValue = "false",
+          help = CliStrings.ALTER_REGION__CLONINGENABLED__HELP) Boolean cloningEnabled,
+      @CliOption(key = CliStrings.ALTER_REGION__EVICTIONMAX, specifiedDefaultValue = "0",
+          help = CliStrings.ALTER_REGION__EVICTIONMAX__HELP) Integer evictionMax) {
+    Result result;
+    AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
+
+    getSecurityService().authorizeRegionManage(regionPath);
+
+    try {
+      InternalCache cache = getCache();
+
+      if (groups != null) {
+        RegionCommandsUtils.validateGroups(cache, groups);
+      }
+
+      RegionFunctionArgs.ExpirationAttrs entryIdle = null;
+      if (entryExpirationIdleTime != null || entryExpirationIdleTimeAction != null) {
+        if (entryExpirationIdleTime != null && entryExpirationIdleTime == -1) {
+          entryExpirationIdleTime = ExpirationAttributes.DEFAULT.getTimeout();
+        }
+        if (CliMetaData.ANNOTATION_DEFAULT_VALUE.equals(entryExpirationIdleTimeAction)) {
+          entryExpirationIdleTimeAction = ExpirationAttributes.DEFAULT.getAction().toString();
+        }
+        entryIdle = new RegionFunctionArgs.ExpirationAttrs(
+            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.ENTRY_IDLE, entryExpirationIdleTime,
+            entryExpirationIdleTimeAction);
+      }
+      RegionFunctionArgs.ExpirationAttrs entryTTL = null;
+      if (entryExpirationTTL != null || entryExpirationTTLAction != null) {
+        if (entryExpirationTTL != null && entryExpirationTTL == -1) {
+          entryExpirationTTL = ExpirationAttributes.DEFAULT.getTimeout();
+        }
+        if (CliMetaData.ANNOTATION_DEFAULT_VALUE.equals(entryExpirationTTLAction)) {
+          entryExpirationTTLAction = ExpirationAttributes.DEFAULT.getAction().toString();
+        }
+        entryTTL = new RegionFunctionArgs.ExpirationAttrs(
+            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.ENTRY_TTL, entryExpirationTTL,
+            entryExpirationTTLAction);
+      }
+      RegionFunctionArgs.ExpirationAttrs regionIdle = null;
+      if (regionExpirationIdleTime != null || regionExpirationIdleTimeAction != null) {
+        if (regionExpirationIdleTime != null && regionExpirationIdleTime == -1) {
+          regionExpirationIdleTime = ExpirationAttributes.DEFAULT.getTimeout();
+        }
+        if (CliMetaData.ANNOTATION_DEFAULT_VALUE.equals(regionExpirationIdleTimeAction)) {
+          regionExpirationIdleTimeAction = ExpirationAttributes.DEFAULT.getAction().toString();
+        }
+        regionIdle = new RegionFunctionArgs.ExpirationAttrs(
+            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.REGION_IDLE, regionExpirationIdleTime,
+            regionExpirationIdleTimeAction);
+      }
+      RegionFunctionArgs.ExpirationAttrs regionTTL = null;
+      if (regionExpirationTTL != null || regionExpirationTTLAction != null) {
+        if (regionExpirationTTL != null && regionExpirationTTL == -1) {
+          regionExpirationTTL = ExpirationAttributes.DEFAULT.getTimeout();
+        }
+        if (CliMetaData.ANNOTATION_DEFAULT_VALUE.equals(regionExpirationTTLAction)) {
+          regionExpirationTTLAction = ExpirationAttributes.DEFAULT.getAction().toString();
+        }
+        regionTTL = new RegionFunctionArgs.ExpirationAttrs(
+            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.REGION_TTL, regionExpirationTTL,
+            regionExpirationTTLAction);
+      }
+
+      cacheLoader = convertDefaultValue(cacheLoader, StringUtils.EMPTY);
+      cacheWriter = convertDefaultValue(cacheWriter, StringUtils.EMPTY);
+
+      RegionFunctionArgs regionFunctionArgs;
+      regionFunctionArgs = new RegionFunctionArgs(regionPath, null, null, false, null, null, null,
+          entryIdle, entryTTL, regionIdle, regionTTL, null, null, null, null, cacheListeners,
+          cacheLoader, cacheWriter, asyncEventQueueIds, gatewaySenderIds, null, cloningEnabled,
+          null, null, null, null, null, null, null, null, evictionMax, null, null, null, null);
+
+      Set<String> cacheListenersSet = regionFunctionArgs.getCacheListeners();
+      if (cacheListenersSet != null && !cacheListenersSet.isEmpty()) {
+        for (String cacheListener : cacheListenersSet) {
+          if (!RegionCommandsUtils.isClassNameValid(cacheListener)) {
+            throw new IllegalArgumentException(CliStrings.format(
+                CliStrings.ALTER_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELISTENER_0_IS_INVALID,
+                new Object[] {cacheListener}));
+          }
+        }
+      }
+
+      if (cacheLoader != null && !RegionCommandsUtils.isClassNameValid(cacheLoader)) {
+        throw new IllegalArgumentException(CliStrings.format(
+            CliStrings.ALTER_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELOADER_0_IS_INVALID,
+            new Object[] {cacheLoader}));
+      }
+
+      if (cacheWriter != null && !RegionCommandsUtils.isClassNameValid(cacheWriter)) {
+        throw new IllegalArgumentException(CliStrings.format(
+            CliStrings.ALTER_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHEWRITER_0_IS_INVALID,
+            new Object[] {cacheWriter}));
+      }
+
+      if (evictionMax != null && evictionMax < 0) {
+        throw new IllegalArgumentException(CliStrings.format(
+            CliStrings.ALTER_REGION__MSG__SPECIFY_POSITIVE_INT_FOR_EVICTIONMAX_0_IS_NOT_VALID,
+            new Object[] {evictionMax}));
+      }
+
+      Set<DistributedMember> targetMembers = CliUtil.findMembers(groups, null);
+
+      if (targetMembers.isEmpty()) {
+        return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
+      }
+
+      ResultCollector<?, ?> resultCollector =
+          CliUtil.executeFunction(new RegionAlterFunction(), regionFunctionArgs, targetMembers);
+      List<CliFunctionResult> regionAlterResults =
+          (List<CliFunctionResult>) resultCollector.getResult();
+
+      TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
+      final String errorPrefix = "ERROR: ";
+      for (CliFunctionResult regionAlterResult : regionAlterResults) {
+        boolean success = regionAlterResult.isSuccessful();
+        tabularResultData.accumulate("Member", regionAlterResult.getMemberIdOrName());
+        if (success) {
+          tabularResultData.accumulate("Status", regionAlterResult.getMessage());
+          xmlEntity.set(regionAlterResult.getXmlEntity());
+        } else {
+          tabularResultData.accumulate("Status", errorPrefix + regionAlterResult.getMessage());
+          tabularResultData.setStatus(Result.Status.ERROR);
+        }
+      }
+      result = ResultBuilder.buildResult(tabularResultData);
+    } catch (IllegalArgumentException | IllegalStateException e) {
+      LogWrapper.getInstance().info(e.getMessage());
+      result = ResultBuilder.createUserErrorResult(e.getMessage());
+    } catch (RuntimeException e) {
+      LogWrapper.getInstance().info(e.getMessage(), e);
+      result = ResultBuilder.createGemFireErrorResult(e.getMessage());
+    }
+
+    if (xmlEntity.get() != null) {
+      persistClusterConfiguration(result,
+          () -> getSharedConfiguration().addXmlEntity(xmlEntity.get(), groups));
+    }
+    return result;
+  }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/756efe77/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
deleted file mode 100644
index 2c61b73..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
+++ /dev/null
@@ -1,1146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.commands;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Pattern;
-
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.commons.lang.StringUtils;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import org.apache.geode.LogWriter;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.ExpirationAttributes;
-import org.apache.geode.cache.PartitionResolver;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionAttributes;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.compression.Compressor;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.internal.DistributionManager;
-import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.management.DistributedRegionMXBean;
-import org.apache.geode.management.DistributedSystemMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.RegionAttributesData;
-import org.apache.geode.management.RegionMXBean;
-import org.apache.geode.management.cli.CliMetaData;
-import org.apache.geode.management.cli.ConverterHint;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.cli.Result.Status;
-import org.apache.geode.management.internal.MBeanJMXAdapter;
-import org.apache.geode.management.internal.cli.CliUtil;
-import org.apache.geode.management.internal.cli.LogWrapper;
-import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
-import org.apache.geode.management.internal.cli.functions.FetchRegionAttributesFunction;
-import org.apache.geode.management.internal.cli.functions.FetchRegionAttributesFunction.FetchRegionAttributesFunctionResult;
-import org.apache.geode.management.internal.cli.functions.RegionAlterFunction;
-import org.apache.geode.management.internal.cli.functions.RegionCreateFunction;
-import org.apache.geode.management.internal.cli.functions.RegionDestroyFunction;
-import org.apache.geode.management.internal.cli.functions.RegionFunctionArgs;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.ResultBuilder;
-import org.apache.geode.management.internal.cli.result.TabularResultData;
-import org.apache.geode.management.internal.cli.util.RegionPath;
-import org.apache.geode.management.internal.configuration.domain.XmlEntity;
-import org.apache.geode.management.internal.security.ResourceOperation;
-import org.apache.geode.security.ResourcePermission.Operation;
-import org.apache.geode.security.ResourcePermission.Resource;
-import org.apache.geode.security.ResourcePermission.Target;
-
-/**
- * @since GemFire 7.0
- */
-public class CreateAlterDestroyRegionCommands implements GfshCommand {
-
-  public static final Set<RegionShortcut> PERSISTENT_OVERFLOW_SHORTCUTS = new TreeSet<>();
-
-  static {
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_PERSISTENT);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_OVERFLOW);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_REDUNDANT_OVERFLOW);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_PERSISTENT_OVERFLOW);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.REPLICATE_PERSISTENT);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.REPLICATE_OVERFLOW);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.REPLICATE_PERSISTENT_OVERFLOW);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.LOCAL_PERSISTENT);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.LOCAL_OVERFLOW);
-    PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.LOCAL_PERSISTENT_OVERFLOW);
-  }
-
-  /**
-   * Internally, we also verify the resource operation permissions CLUSTER:WRITE:DISK if the region
-   * is persistent
-   */
-  @CliCommand(value = CliStrings.CREATE_REGION, help = CliStrings.CREATE_REGION__HELP)
-  @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public Result createRegion(
-      @CliOption(key = CliStrings.CREATE_REGION__REGION, mandatory = true,
-          help = CliStrings.CREATE_REGION__REGION__HELP) String regionPath,
-      @CliOption(key = CliStrings.CREATE_REGION__REGIONSHORTCUT,
-          help = CliStrings.CREATE_REGION__REGIONSHORTCUT__HELP) RegionShortcut regionShortcut,
-      @CliOption(key = CliStrings.CREATE_REGION__USEATTRIBUTESFROM,
-          optionContext = ConverterHint.REGION_PATH,
-          help = CliStrings.CREATE_REGION__USEATTRIBUTESFROM__HELP) String useAttributesFrom,
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          optionContext = ConverterHint.MEMBERGROUP,
-          help = CliStrings.CREATE_REGION__GROUP__HELP) String[] groups,
-      @CliOption(key = CliStrings.CREATE_REGION__SKIPIFEXISTS, unspecifiedDefaultValue = "true",
-          specifiedDefaultValue = "true",
-          help = CliStrings.CREATE_REGION__SKIPIFEXISTS__HELP) boolean skipIfExists,
-
-      // the following should all be in alphabetical order according to
-      // their key string
-      @CliOption(key = CliStrings.CREATE_REGION__ASYNCEVENTQUEUEID,
-          help = CliStrings.CREATE_REGION__ASYNCEVENTQUEUEID__HELP) String[] asyncEventQueueIds,
-      @CliOption(key = CliStrings.CREATE_REGION__CACHELISTENER,
-          help = CliStrings.CREATE_REGION__CACHELISTENER__HELP) String[] cacheListener,
-      @CliOption(key = CliStrings.CREATE_REGION__CACHELOADER,
-          help = CliStrings.CREATE_REGION__CACHELOADER__HELP) String cacheLoader,
-      @CliOption(key = CliStrings.CREATE_REGION__CACHEWRITER,
-          help = CliStrings.CREATE_REGION__CACHEWRITER__HELP) String cacheWriter,
-      @CliOption(key = CliStrings.CREATE_REGION__COLOCATEDWITH,
-          optionContext = ConverterHint.REGION_PATH,
-          help = CliStrings.CREATE_REGION__COLOCATEDWITH__HELP) String prColocatedWith,
-      @CliOption(key = CliStrings.CREATE_REGION__COMPRESSOR,
-          help = CliStrings.CREATE_REGION__COMPRESSOR__HELP) String compressor,
-      @CliOption(key = CliStrings.CREATE_REGION__CONCURRENCYLEVEL,
-          help = CliStrings.CREATE_REGION__CONCURRENCYLEVEL__HELP) Integer concurrencyLevel,
-      @CliOption(key = CliStrings.CREATE_REGION__DISKSTORE,
-          help = CliStrings.CREATE_REGION__DISKSTORE__HELP) String diskStore,
-      @CliOption(key = CliStrings.CREATE_REGION__ENABLEASYNCCONFLATION,
-          help = CliStrings.CREATE_REGION__ENABLEASYNCCONFLATION__HELP) Boolean enableAsyncConflation,
-      @CliOption(key = CliStrings.CREATE_REGION__CLONINGENABLED,
-          help = CliStrings.CREATE_REGION__CLONINGENABLED__HELP) Boolean cloningEnabled,
-      @CliOption(key = CliStrings.CREATE_REGION__CONCURRENCYCHECKSENABLED,
-          help = CliStrings.CREATE_REGION__CONCURRENCYCHECKSENABLED__HELP) Boolean concurrencyChecksEnabled,
-      @CliOption(key = CliStrings.CREATE_REGION__MULTICASTENABLED,
-          help = CliStrings.CREATE_REGION__MULTICASTENABLED__HELP) Boolean mcastEnabled,
-      @CliOption(key = CliStrings.CREATE_REGION__STATISTICSENABLED,
-          help = CliStrings.CREATE_REGION__STATISTICSENABLED__HELP) Boolean statisticsEnabled,
-      @CliOption(key = CliStrings.CREATE_REGION__ENABLESUBSCRIPTIONCONFLATION,
-          help = CliStrings.CREATE_REGION__ENABLESUBSCRIPTIONCONFLATION__HELP) Boolean enableSubscriptionConflation,
-      @CliOption(key = CliStrings.CREATE_REGION__DISKSYNCHRONOUS,
-          help = CliStrings.CREATE_REGION__DISKSYNCHRONOUS__HELP) Boolean diskSynchronous,
-      @CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIME,
-          help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIME__HELP) Integer entryExpirationIdleTime,
-      @CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIMEACTION,
-          help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIMEACTION__HELP) String entryExpirationIdleTimeAction,
-      @CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTIMETOLIVE,
-          help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTIMETOLIVE__HELP) Integer entryExpirationTTL,
-      @CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION,
-          help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION__HELP) String entryExpirationTTLAction,
-      @CliOption(key = CliStrings.CREATE_REGION__GATEWAYSENDERID,
-          help = CliStrings.CREATE_REGION__GATEWAYSENDERID__HELP) String[] gatewaySenderIds,
-      @CliOption(key = CliStrings.CREATE_REGION__KEYCONSTRAINT,
-          help = CliStrings.CREATE_REGION__KEYCONSTRAINT__HELP) String keyConstraint,
-      @CliOption(key = CliStrings.CREATE_REGION__LOCALMAXMEMORY,
-          help = CliStrings.CREATE_REGION__LOCALMAXMEMORY__HELP) Integer prLocalMaxMemory,
-      @CliOption(key = CliStrings.CREATE_REGION__OFF_HEAP, specifiedDefaultValue = "true",
-          help = CliStrings.CREATE_REGION__OFF_HEAP__HELP) Boolean offHeap,
-      @CliOption(key = CliStrings.CREATE_REGION__PARTITION_RESOLVER,
-          help = CliStrings.CREATE_REGION__PARTITION_RESOLVER__HELP) String partitionResolver,
-      @CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIME,
-          help = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIME__HELP) Integer regionExpirationIdleTime,
-      @CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIMEACTION,
-          help = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIMEACTION__HELP) String regionExpirationIdleTimeAction,
-      @CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTL,
-          help = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTL__HELP) Integer regionExpirationTTL,
-      @CliOption(key = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTLACTION,
-          help = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTLACTION__HELP) String regionExpirationTTLAction,
-      @CliOption(key = CliStrings.CREATE_REGION__RECOVERYDELAY,
-          help = CliStrings.CREATE_REGION__RECOVERYDELAY__HELP) Long prRecoveryDelay,
-      @CliOption(key = CliStrings.CREATE_REGION__REDUNDANTCOPIES,
-          help = CliStrings.CREATE_REGION__REDUNDANTCOPIES__HELP) Integer prRedundantCopies,
-      @CliOption(key = CliStrings.CREATE_REGION__STARTUPRECOVERYDDELAY,
-          help = CliStrings.CREATE_REGION__STARTUPRECOVERYDDELAY__HELP) Long prStartupRecoveryDelay,
-      @CliOption(key = CliStrings.CREATE_REGION__TOTALMAXMEMORY,
-          help = CliStrings.CREATE_REGION__TOTALMAXMEMORY__HELP) Long prTotalMaxMemory,
-      @CliOption(key = CliStrings.CREATE_REGION__TOTALNUMBUCKETS,
-          help = CliStrings.CREATE_REGION__TOTALNUMBUCKETS__HELP) Integer prTotalNumBuckets,
-      @CliOption(key = CliStrings.CREATE_REGION__VALUECONSTRAINT,
-          help = CliStrings.CREATE_REGION__VALUECONSTRAINT__HELP) String valueConstraint
-  // NOTICE: keep the region attributes params in alphabetical order
-  ) {
-    Result result;
-    AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
-
-    try {
-      InternalCache cache = getCache();
-
-      if (regionShortcut != null && useAttributesFrom != null) {
-        throw new IllegalArgumentException(
-            CliStrings.CREATE_REGION__MSG__ONLY_ONE_OF_REGIONSHORTCUT_AND_USEATTRIBUESFROM_CAN_BE_SPECIFIED);
-      } else if (regionShortcut == null && useAttributesFrom == null) {
-        throw new IllegalArgumentException(
-            CliStrings.CREATE_REGION__MSG__ONE_OF_REGIONSHORTCUT_AND_USEATTRIBUTESFROM_IS_REQUIRED);
-      }
-
-      validateRegionPathAndParent(cache, regionPath);
-      validateGroups(cache, groups);
-
-      RegionFunctionArgs.ExpirationAttrs entryIdle = null;
-      if (entryExpirationIdleTime != null) {
-        entryIdle = new RegionFunctionArgs.ExpirationAttrs(
-            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.ENTRY_IDLE, entryExpirationIdleTime,
-            entryExpirationIdleTimeAction);
-      }
-      RegionFunctionArgs.ExpirationAttrs entryTTL = null;
-      if (entryExpirationTTL != null) {
-        entryTTL = new RegionFunctionArgs.ExpirationAttrs(
-            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.ENTRY_TTL, entryExpirationTTL,
-            entryExpirationTTLAction);
-      }
-      RegionFunctionArgs.ExpirationAttrs regionIdle = null;
-      if (regionExpirationIdleTime != null) {
-        regionIdle = new RegionFunctionArgs.ExpirationAttrs(
-            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.REGION_IDLE, regionExpirationIdleTime,
-            regionExpirationIdleTimeAction);
-      }
-      RegionFunctionArgs.ExpirationAttrs regionTTL = null;
-      if (regionExpirationTTL != null) {
-        regionTTL = new RegionFunctionArgs.ExpirationAttrs(
-            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.REGION_TTL, regionExpirationTTL,
-            regionExpirationTTLAction);
-      }
-
-      RegionFunctionArgs regionFunctionArgs;
-      if (useAttributesFrom != null) {
-        if (!regionExists(cache, useAttributesFrom)) {
-          throw new IllegalArgumentException(CliStrings.format(
-              CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH_FOR_0_REGIONPATH_1_NOT_FOUND,
-              new Object[] {CliStrings.CREATE_REGION__USEATTRIBUTESFROM, useAttributesFrom}));
-        }
-
-        FetchRegionAttributesFunctionResult<Object, Object> regionAttributesResult =
-            getRegionAttributes(cache, useAttributesFrom);
-        RegionAttributes<?, ?> regionAttributes = regionAttributesResult.getRegionAttributes();
-
-        // give preference to user specified plugins than the ones retrieved from other region
-        String[] cacheListenerClasses = cacheListener != null && cacheListener.length != 0
-            ? cacheListener : regionAttributesResult.getCacheListenerClasses();
-        String cacheLoaderClass =
-            cacheLoader != null ? cacheLoader : regionAttributesResult.getCacheLoaderClass();
-        String cacheWriterClass =
-            cacheWriter != null ? cacheWriter : regionAttributesResult.getCacheWriterClass();
-
-        regionFunctionArgs = new RegionFunctionArgs(regionPath, useAttributesFrom, skipIfExists,
-            keyConstraint, valueConstraint, statisticsEnabled, entryIdle, entryTTL, regionIdle,
-            regionTTL, diskStore, diskSynchronous, enableAsyncConflation,
-            enableSubscriptionConflation, cacheListenerClasses, cacheLoaderClass, cacheWriterClass,
-            asyncEventQueueIds, gatewaySenderIds, concurrencyChecksEnabled, cloningEnabled,
-            concurrencyLevel, prColocatedWith, prLocalMaxMemory, prRecoveryDelay, prRedundantCopies,
-            prStartupRecoveryDelay, prTotalMaxMemory, prTotalNumBuckets, offHeap, mcastEnabled,
-            regionAttributes, partitionResolver);
-
-        if (regionAttributes.getPartitionAttributes() == null
-            && regionFunctionArgs.hasPartitionAttributes()) {
-          throw new IllegalArgumentException(CliStrings.format(
-              CliStrings.CREATE_REGION__MSG__OPTION_0_CAN_BE_USED_ONLY_FOR_PARTITIONEDREGION,
-              regionFunctionArgs.getPartitionArgs().getUserSpecifiedPartitionAttributes()) + " "
-              + CliStrings.format(CliStrings.CREATE_REGION__MSG__0_IS_NOT_A_PARITIONEDREGION,
-                  useAttributesFrom));
-        }
-      } else {
-        regionFunctionArgs = new RegionFunctionArgs(regionPath, regionShortcut, useAttributesFrom,
-            skipIfExists, keyConstraint, valueConstraint, statisticsEnabled, entryIdle, entryTTL,
-            regionIdle, regionTTL, diskStore, diskSynchronous, enableAsyncConflation,
-            enableSubscriptionConflation, cacheListener, cacheLoader, cacheWriter,
-            asyncEventQueueIds, gatewaySenderIds, concurrencyChecksEnabled, cloningEnabled,
-            concurrencyLevel, prColocatedWith, prLocalMaxMemory, prRecoveryDelay, prRedundantCopies,
-            prStartupRecoveryDelay, prTotalMaxMemory, prTotalNumBuckets, null, compressor, offHeap,
-            mcastEnabled, partitionResolver);
-
-        if (!regionShortcut.name().startsWith("PARTITION")
-            && regionFunctionArgs.hasPartitionAttributes()) {
-          throw new IllegalArgumentException(CliStrings.format(
-              CliStrings.CREATE_REGION__MSG__OPTION_0_CAN_BE_USED_ONLY_FOR_PARTITIONEDREGION,
-              regionFunctionArgs.getPartitionArgs().getUserSpecifiedPartitionAttributes()) + " "
-              + CliStrings.format(CliStrings.CREATE_REGION__MSG__0_IS_NOT_A_PARITIONEDREGION,
-                  useAttributesFrom));
-        }
-      }
-
-      // Do we prefer to validate or authorize first?
-      validateRegionFunctionArgs(cache, regionFunctionArgs);
-      if (isPersistentShortcut(regionFunctionArgs.getRegionShortcut())
-          || isAttributePersistent(regionFunctionArgs.getRegionAttributes())) {
-        getSecurityService().authorize(Resource.CLUSTER, Operation.WRITE, Target.DISK);
-      }
-
-      Set<DistributedMember> membersToCreateRegionOn;
-      if (groups != null && groups.length != 0) {
-        membersToCreateRegionOn = CliUtil.getDistributedMembersByGroup(cache, groups);
-        // have only normal members from the group
-        membersToCreateRegionOn
-            .removeIf(distributedMember -> ((InternalDistributedMember) distributedMember)
-                .getVmKind() == DistributionManager.LOCATOR_DM_TYPE);
-      } else {
-        membersToCreateRegionOn = CliUtil.getAllNormalMembers(cache);
-      }
-
-      if (membersToCreateRegionOn.isEmpty()) {
-        return ResultBuilder.createUserErrorResult(CliStrings.NO_CACHING_MEMBERS_FOUND_MESSAGE);
-      }
-
-      ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(RegionCreateFunction.INSTANCE,
-          regionFunctionArgs, membersToCreateRegionOn);
-      @SuppressWarnings("unchecked")
-      List<CliFunctionResult> regionCreateResults =
-          (List<CliFunctionResult>) resultCollector.getResult();
-
-      TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
-      final String errorPrefix = "ERROR: ";
-      for (CliFunctionResult regionCreateResult : regionCreateResults) {
-        boolean success = regionCreateResult.isSuccessful();
-        tabularResultData.accumulate("Member", regionCreateResult.getMemberIdOrName());
-        tabularResultData.accumulate("Status",
-            (success ? "" : errorPrefix) + regionCreateResult.getMessage());
-
-        if (success) {
-          xmlEntity.set(regionCreateResult.getXmlEntity());
-        }
-      }
-      result = ResultBuilder.buildResult(tabularResultData);
-      verifyDistributedRegionMbean(cache, regionPath);
-
-    } catch (IllegalArgumentException | IllegalStateException e) {
-      LogWrapper.getInstance().info(e.getMessage());
-      result = ResultBuilder.createUserErrorResult(e.getMessage());
-    }
-    if (xmlEntity.get() != null) {
-      persistClusterConfiguration(result,
-          () -> getSharedConfiguration().addXmlEntity(xmlEntity.get(), groups));
-    }
-
-    return result;
-  }
-
-  public boolean verifyDistributedRegionMbean(InternalCache cache, String regionName) {
-    int federationInterval =
-        cache.getInternalDistributedSystem().getConfig().getJmxManagerUpdateRate();
-    long timeEnd = System.currentTimeMillis() + federationInterval + 50;
-
-    for (; System.currentTimeMillis() <= timeEnd;) {
-      try {
-        DistributedRegionMXBean bean =
-            ManagementService.getManagementService(cache).getDistributedRegionMXBean(regionName);
-        if (bean == null) {
-          bean = ManagementService.getManagementService(cache)
-              .getDistributedRegionMXBean(Region.SEPARATOR + regionName);
-        }
-        if (bean != null) {
-          return true;
-        } else {
-          Thread.sleep(2);
-        }
-      } catch (Exception ignored) {
-      }
-    }
-    return false;
-  }
-
-  @CliCommand(value = CliStrings.ALTER_REGION, help = CliStrings.ALTER_REGION__HELP)
-  @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
-  public Result alterRegion(
-      @CliOption(key = CliStrings.ALTER_REGION__REGION, mandatory = true,
-          help = CliStrings.ALTER_REGION__REGION__HELP) String regionPath,
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          optionContext = ConverterHint.MEMBERGROUP,
-          help = CliStrings.ALTER_REGION__GROUP__HELP) String[] groups,
-      @CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME,
-          specifiedDefaultValue = "-1",
-          help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME__HELP) Integer entryExpirationIdleTime,
-      @CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIMEACTION,
-          specifiedDefaultValue = "INVALIDATE",
-          help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIMEACTION__HELP) String entryExpirationIdleTimeAction,
-      @CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTIMETOLIVE,
-          specifiedDefaultValue = "-1",
-          help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTIMETOLIVE__HELP) Integer entryExpirationTTL,
-      @CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION,
-          specifiedDefaultValue = "INVALIDATE",
-          help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION__HELP) String entryExpirationTTLAction,
-      @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME,
-          specifiedDefaultValue = "-1",
-          help = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME__HELP) Integer regionExpirationIdleTime,
-      @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION,
-          specifiedDefaultValue = "INVALIDATE",
-          help = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION__HELP) String regionExpirationIdleTimeAction,
-      @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTL, specifiedDefaultValue = "-1",
-          help = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTL__HELP) Integer regionExpirationTTL,
-      @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION,
-          specifiedDefaultValue = "INVALIDATE",
-          help = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION__HELP) String regionExpirationTTLAction,
-      @CliOption(key = CliStrings.ALTER_REGION__CACHELISTENER, specifiedDefaultValue = "",
-          help = CliStrings.ALTER_REGION__CACHELISTENER__HELP) String[] cacheListeners,
-      @CliOption(key = CliStrings.ALTER_REGION__CACHELOADER, specifiedDefaultValue = "",
-          help = CliStrings.ALTER_REGION__CACHELOADER__HELP) String cacheLoader,
-      @CliOption(key = CliStrings.ALTER_REGION__CACHEWRITER, specifiedDefaultValue = "",
-          help = CliStrings.ALTER_REGION__CACHEWRITER__HELP) String cacheWriter,
-      @CliOption(key = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID, specifiedDefaultValue = "",
-          help = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID__HELP) String[] asyncEventQueueIds,
-      @CliOption(key = CliStrings.ALTER_REGION__GATEWAYSENDERID, specifiedDefaultValue = "",
-          help = CliStrings.ALTER_REGION__GATEWAYSENDERID__HELP) String[] gatewaySenderIds,
-      @CliOption(key = CliStrings.ALTER_REGION__CLONINGENABLED, specifiedDefaultValue = "false",
-          help = CliStrings.ALTER_REGION__CLONINGENABLED__HELP) Boolean cloningEnabled,
-      @CliOption(key = CliStrings.ALTER_REGION__EVICTIONMAX, specifiedDefaultValue = "0",
-          help = CliStrings.ALTER_REGION__EVICTIONMAX__HELP) Integer evictionMax) {
-    Result result;
-    AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
-
-    getSecurityService().authorizeRegionManage(regionPath);
-
-    try {
-      InternalCache cache = getCache();
-
-      if (groups != null) {
-        validateGroups(cache, groups);
-      }
-
-      RegionFunctionArgs.ExpirationAttrs entryIdle = null;
-      if (entryExpirationIdleTime != null || entryExpirationIdleTimeAction != null) {
-        if (entryExpirationIdleTime != null && entryExpirationIdleTime == -1) {
-          entryExpirationIdleTime = ExpirationAttributes.DEFAULT.getTimeout();
-        }
-        if (CliMetaData.ANNOTATION_DEFAULT_VALUE.equals(entryExpirationIdleTimeAction)) {
-          entryExpirationIdleTimeAction = ExpirationAttributes.DEFAULT.getAction().toString();
-        }
-        entryIdle = new RegionFunctionArgs.ExpirationAttrs(
-            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.ENTRY_IDLE, entryExpirationIdleTime,
-            entryExpirationIdleTimeAction);
-      }
-      RegionFunctionArgs.ExpirationAttrs entryTTL = null;
-      if (entryExpirationTTL != null || entryExpirationTTLAction != null) {
-        if (entryExpirationTTL != null && entryExpirationTTL == -1) {
-          entryExpirationTTL = ExpirationAttributes.DEFAULT.getTimeout();
-        }
-        if (CliMetaData.ANNOTATION_DEFAULT_VALUE.equals(entryExpirationTTLAction)) {
-          entryExpirationTTLAction = ExpirationAttributes.DEFAULT.getAction().toString();
-        }
-        entryTTL = new RegionFunctionArgs.ExpirationAttrs(
-            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.ENTRY_TTL, entryExpirationTTL,
-            entryExpirationTTLAction);
-      }
-      RegionFunctionArgs.ExpirationAttrs regionIdle = null;
-      if (regionExpirationIdleTime != null || regionExpirationIdleTimeAction != null) {
-        if (regionExpirationIdleTime != null && regionExpirationIdleTime == -1) {
-          regionExpirationIdleTime = ExpirationAttributes.DEFAULT.getTimeout();
-        }
-        if (CliMetaData.ANNOTATION_DEFAULT_VALUE.equals(regionExpirationIdleTimeAction)) {
-          regionExpirationIdleTimeAction = ExpirationAttributes.DEFAULT.getAction().toString();
-        }
-        regionIdle = new RegionFunctionArgs.ExpirationAttrs(
-            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.REGION_IDLE, regionExpirationIdleTime,
-            regionExpirationIdleTimeAction);
-      }
-      RegionFunctionArgs.ExpirationAttrs regionTTL = null;
-      if (regionExpirationTTL != null || regionExpirationTTLAction != null) {
-        if (regionExpirationTTL != null && regionExpirationTTL == -1) {
-          regionExpirationTTL = ExpirationAttributes.DEFAULT.getTimeout();
-        }
-        if (CliMetaData.ANNOTATION_DEFAULT_VALUE.equals(regionExpirationTTLAction)) {
-          regionExpirationTTLAction = ExpirationAttributes.DEFAULT.getAction().toString();
-        }
-        regionTTL = new RegionFunctionArgs.ExpirationAttrs(
-            RegionFunctionArgs.ExpirationAttrs.ExpirationFor.REGION_TTL, regionExpirationTTL,
-            regionExpirationTTLAction);
-      }
-
-      cacheLoader = convertDefaultValue(cacheLoader, StringUtils.EMPTY);
-      cacheWriter = convertDefaultValue(cacheWriter, StringUtils.EMPTY);
-
-      RegionFunctionArgs regionFunctionArgs;
-      regionFunctionArgs = new RegionFunctionArgs(regionPath, null, null, false, null, null, null,
-          entryIdle, entryTTL, regionIdle, regionTTL, null, null, null, null, cacheListeners,
-          cacheLoader, cacheWriter, asyncEventQueueIds, gatewaySenderIds, null, cloningEnabled,
-          null, null, null, null, null, null, null, null, evictionMax, null, null, null, null);
-
-      Set<String> cacheListenersSet = regionFunctionArgs.getCacheListeners();
-      if (cacheListenersSet != null && !cacheListenersSet.isEmpty()) {
-        for (String cacheListener : cacheListenersSet) {
-          if (!isClassNameValid(cacheListener)) {
-            throw new IllegalArgumentException(CliStrings.format(
-                CliStrings.ALTER_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELISTENER_0_IS_INVALID,
-                new Object[] {cacheListener}));
-          }
-        }
-      }
-
-      if (cacheLoader != null && !isClassNameValid(cacheLoader)) {
-        throw new IllegalArgumentException(CliStrings.format(
-            CliStrings.ALTER_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELOADER_0_IS_INVALID,
-            new Object[] {cacheLoader}));
-      }
-
-      if (cacheWriter != null && !isClassNameValid(cacheWriter)) {
-        throw new IllegalArgumentException(CliStrings.format(
-            CliStrings.ALTER_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHEWRITER_0_IS_INVALID,
-            new Object[] {cacheWriter}));
-      }
-
-      if (evictionMax != null && evictionMax < 0) {
-        throw new IllegalArgumentException(CliStrings.format(
-            CliStrings.ALTER_REGION__MSG__SPECIFY_POSITIVE_INT_FOR_EVICTIONMAX_0_IS_NOT_VALID,
-            new Object[] {evictionMax}));
-      }
-
-      Set<DistributedMember> targetMembers = CliUtil.findMembers(groups, null);
-
-      if (targetMembers.isEmpty()) {
-        return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
-      }
-
-      ResultCollector<?, ?> resultCollector =
-          CliUtil.executeFunction(new RegionAlterFunction(), regionFunctionArgs, targetMembers);
-      List<CliFunctionResult> regionAlterResults =
-          (List<CliFunctionResult>) resultCollector.getResult();
-
-      TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
-      final String errorPrefix = "ERROR: ";
-      for (CliFunctionResult regionAlterResult : regionAlterResults) {
-        boolean success = regionAlterResult.isSuccessful();
-        tabularResultData.accumulate("Member", regionAlterResult.getMemberIdOrName());
-        if (success) {
-          tabularResultData.accumulate("Status", regionAlterResult.getMessage());
-          xmlEntity.set(regionAlterResult.getXmlEntity());
-        } else {
-          tabularResultData.accumulate("Status", errorPrefix + regionAlterResult.getMessage());
-          tabularResultData.setStatus(Status.ERROR);
-        }
-      }
-      result = ResultBuilder.buildResult(tabularResultData);
-    } catch (IllegalArgumentException | IllegalStateException e) {
-      LogWrapper.getInstance().info(e.getMessage());
-      result = ResultBuilder.createUserErrorResult(e.getMessage());
-    } catch (RuntimeException e) {
-      LogWrapper.getInstance().info(e.getMessage(), e);
-      result = ResultBuilder.createGemFireErrorResult(e.getMessage());
-    }
-
-    if (xmlEntity.get() != null) {
-      persistClusterConfiguration(result,
-          () -> getSharedConfiguration().addXmlEntity(xmlEntity.get(), groups));
-    }
-    return result;
-  }
-
-  private static boolean regionExists(InternalCache cache, String regionPath) {
-    boolean regionFound = false;
-    if (regionPath != null && !Region.SEPARATOR.equals(regionPath)) {
-      ManagementService managementService = ManagementService.getExistingManagementService(cache);
-      DistributedSystemMXBean dsMBean = managementService.getDistributedSystemMXBean();
-
-      String[] allRegionPaths = dsMBean.listAllRegionPaths();
-      for (String allRegionPath : allRegionPaths) {
-        if (allRegionPath.equals(regionPath)) {
-          regionFound = true;
-          break;
-        }
-      }
-    }
-    return regionFound;
-  }
-
-  private void validateRegionPathAndParent(InternalCache cache, String regionPath) {
-    if (StringUtils.isEmpty(regionPath)) {
-      throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH);
-    }
-    // If a region path indicates a sub-region, check whether the parent region exists
-    RegionPath regionPathData = new RegionPath(regionPath);
-    String parentRegionPath = regionPathData.getParent();
-    if (parentRegionPath != null && !Region.SEPARATOR.equals(parentRegionPath)) {
-      if (!regionExists(cache, parentRegionPath)) {
-        throw new IllegalArgumentException(
-            CliStrings.format(CliStrings.CREATE_REGION__MSG__PARENT_REGION_FOR_0_DOES_NOT_EXIST,
-                new Object[] {regionPath}));
-      }
-    }
-  }
-
-  private void validateGroups(InternalCache cache, String[] groups) {
-    if (groups != null && groups.length != 0) {
-      Set<String> existingGroups = new HashSet<>();
-      Set<DistributedMember> members = CliUtil.getAllNormalMembers(cache);
-      for (DistributedMember distributedMember : members) {
-        List<String> memberGroups = distributedMember.getGroups();
-        existingGroups.addAll(memberGroups);
-      }
-      List<String> groupsList = new ArrayList<>(Arrays.asList(groups));
-      groupsList.removeAll(existingGroups);
-
-      if (!groupsList.isEmpty()) {
-        throw new IllegalArgumentException(
-            CliStrings.format(CliStrings.CREATE_REGION__MSG__GROUPS_0_ARE_INVALID,
-                new Object[] {String.valueOf(groupsList)}));
-      }
-    }
-  }
-
-  DistributedSystemMXBean getDSMBean(InternalCache cache) {
-    ManagementService managementService = ManagementService.getExistingManagementService(cache);
-    return managementService.getDistributedSystemMXBean();
-  }
-
-  void validateRegionFunctionArgs(InternalCache cache, RegionFunctionArgs regionFunctionArgs) {
-    if (regionFunctionArgs.getRegionPath() == null) {
-      throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH);
-    }
-
-    DistributedSystemMXBean dsMBean = getDSMBean(cache);
-
-    String useAttributesFrom = regionFunctionArgs.getUseAttributesFrom();
-    if (useAttributesFrom != null && !useAttributesFrom.isEmpty()
-        && regionExists(cache, useAttributesFrom)) {
-      if (!regionExists(cache, useAttributesFrom)) { // check already done in createRegion !!!
-        throw new IllegalArgumentException(CliStrings.format(
-            CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH_FOR_0_REGIONPATH_1_NOT_FOUND,
-            new Object[] {CliStrings.CREATE_REGION__USEATTRIBUTESFROM, useAttributesFrom}));
-      }
-      if (!regionFunctionArgs.isSetUseAttributesFrom()
-          || regionFunctionArgs.getRegionAttributes() == null) {
-        throw new IllegalArgumentException(CliStrings.format(
-            CliStrings.CREATE_REGION__MSG__COULD_NOT_RETRIEVE_REGION_ATTRS_FOR_PATH_0_VERIFY_REGION_EXISTS,
-            useAttributesFrom));
-      }
-    }
-
-    if (regionFunctionArgs.hasPartitionAttributes()) {
-      RegionFunctionArgs.PartitionArgs partitionArgs = regionFunctionArgs.getPartitionArgs();
-      String colocatedWith = partitionArgs.getPrColocatedWith();
-      if (colocatedWith != null && !colocatedWith.isEmpty()) {
-        String[] listAllRegionPaths = dsMBean.listAllRegionPaths();
-        String foundRegionPath = null;
-        for (String regionPath : listAllRegionPaths) {
-          if (regionPath.equals(colocatedWith)) {
-            foundRegionPath = regionPath;
-            break;
-          }
-        }
-        if (foundRegionPath == null) {
-          throw new IllegalArgumentException(CliStrings.format(
-              CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH_FOR_0_REGIONPATH_1_NOT_FOUND,
-              new Object[] {CliStrings.CREATE_REGION__COLOCATEDWITH, colocatedWith}));
-        }
-        ManagementService mgmtService = ManagementService.getExistingManagementService(cache);
-        DistributedRegionMXBean distributedRegionMXBean =
-            mgmtService.getDistributedRegionMXBean(foundRegionPath);
-        String regionType = distributedRegionMXBean.getRegionType();
-        if (!(DataPolicy.PARTITION.toString().equals(regionType)
-            || DataPolicy.PERSISTENT_PARTITION.toString().equals(regionType))) {
-          throw new IllegalArgumentException(CliStrings.format(
-              CliStrings.CREATE_REGION__MSG__COLOCATEDWITH_REGION_0_IS_NOT_PARTITIONEDREGION,
-              new Object[] {colocatedWith}));
-        }
-      }
-      if (partitionArgs.isSetPRLocalMaxMemory()) {
-        int prLocalMaxMemory = partitionArgs.getPrLocalMaxMemory();
-        if (prLocalMaxMemory < 0) {
-          throw new IllegalArgumentException(
-              LocalizedStrings.AttributesFactory_PARTITIONATTRIBUTES_LOCALMAXMEMORY_MUST_NOT_BE_NEGATIVE
-                  .toLocalizedString());
-        }
-      }
-      if (partitionArgs.isSetPRTotalMaxMemory()) {
-        long prTotalMaxMemory = partitionArgs.getPrTotalMaxMemory();
-        if (prTotalMaxMemory <= 0) {
-          throw new IllegalArgumentException(
-              LocalizedStrings.AttributesFactory_TOTAL_SIZE_OF_PARTITION_REGION_MUST_BE_0
-                  .toLocalizedString());
-        }
-      }
-      if (partitionArgs.isSetPRRedundantCopies()) {
-        int prRedundantCopies = partitionArgs.getPrRedundantCopies();
-        switch (prRedundantCopies) {
-          case 0:
-          case 1:
-          case 2:
-          case 3:
-            break;
-          default:
-            throw new IllegalArgumentException(CliStrings.format(
-                CliStrings.CREATE_REGION__MSG__REDUNDANT_COPIES_SHOULD_BE_ONE_OF_0123,
-                new Object[] {prRedundantCopies}));
-        }
-      }
-    }
-
-    String keyConstraint = regionFunctionArgs.getKeyConstraint();
-    if (keyConstraint != null && !isClassNameValid(keyConstraint)) {
-      throw new IllegalArgumentException(CliStrings.format(
-          CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_KEYCONSTRAINT_0_IS_INVALID,
-          new Object[] {keyConstraint}));
-    }
-
-    String valueConstraint = regionFunctionArgs.getValueConstraint();
-    if (valueConstraint != null && !isClassNameValid(valueConstraint)) {
-      throw new IllegalArgumentException(CliStrings.format(
-          CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_VALUECONSTRAINT_0_IS_INVALID,
-          new Object[] {valueConstraint}));
-    }
-
-    Set<String> cacheListeners = regionFunctionArgs.getCacheListeners();
-    if (cacheListeners != null && !cacheListeners.isEmpty()) {
-      for (String cacheListener : cacheListeners) {
-        if (!isClassNameValid(cacheListener)) {
-          throw new IllegalArgumentException(CliStrings.format(
-              CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELISTENER_0_IS_INVALID,
-              new Object[] {cacheListener}));
-        }
-      }
-    }
-
-    String cacheLoader = regionFunctionArgs.getCacheLoader();
-    if (cacheLoader != null && !isClassNameValid(cacheLoader)) {
-      throw new IllegalArgumentException(CliStrings.format(
-          CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELOADER_0_IS_INVALID,
-          new Object[] {cacheLoader}));
-    }
-
-    String cacheWriter = regionFunctionArgs.getCacheWriter();
-    if (cacheWriter != null && !isClassNameValid(cacheWriter)) {
-      throw new IllegalArgumentException(CliStrings.format(
-          CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHEWRITER_0_IS_INVALID,
-          new Object[] {cacheWriter}));
-    }
-
-    Set<String> gatewaySenderIds = regionFunctionArgs.getGatewaySenderIds();
-    if (gatewaySenderIds != null && !gatewaySenderIds.isEmpty()) {
-      String[] gatewaySenders = dsMBean.listGatewaySenders();
-      if (gatewaySenders.length == 0) {
-        throw new IllegalArgumentException(
-            CliStrings.CREATE_REGION__MSG__NO_GATEWAYSENDERS_IN_THE_SYSTEM);
-      } else {
-        List<String> gatewaySendersList = new ArrayList<>(Arrays.asList(gatewaySenders));
-        gatewaySenderIds = new HashSet<>(gatewaySenderIds);
-        gatewaySenderIds.removeAll(gatewaySendersList);
-        if (!gatewaySenderIds.isEmpty()) {
-          throw new IllegalArgumentException(CliStrings.format(
-              CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_GATEWAYSENDER_ID_UNKNOWN_0,
-              new Object[] {gatewaySenderIds}));
-        }
-      }
-    }
-
-    if (regionFunctionArgs.isSetConcurrencyLevel()) {
-      int concurrencyLevel = regionFunctionArgs.getConcurrencyLevel();
-      if (concurrencyLevel < 0) {
-        throw new IllegalArgumentException(CliStrings.format(
-            CliStrings.CREATE_REGION__MSG__SPECIFY_POSITIVE_INT_FOR_CONCURRENCYLEVEL_0_IS_NOT_VALID,
-            new Object[] {concurrencyLevel}));
-      }
-    }
-
-    String diskStore = regionFunctionArgs.getDiskStore();
-    if (diskStore != null) {
-      RegionShortcut regionShortcut = regionFunctionArgs.getRegionShortcut();
-      if (regionShortcut != null && !PERSISTENT_OVERFLOW_SHORTCUTS.contains(regionShortcut)) {
-        String subMessage =
-            LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString();
-        String message = subMessage + ". "
-            + CliStrings.format(CliStrings.CREATE_REGION__MSG__USE_ONE_OF_THESE_SHORTCUTS_0,
-                new Object[] {String.valueOf(PERSISTENT_OVERFLOW_SHORTCUTS)});
-
-        throw new IllegalArgumentException(message);
-      }
-
-      RegionAttributes<?, ?> regionAttributes = regionFunctionArgs.getRegionAttributes();
-      if (regionAttributes != null && !regionAttributes.getDataPolicy().withPersistence()) {
-        String subMessage =
-            LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString();
-        String message = subMessage + ". "
-            + CliStrings.format(
-                CliStrings.CREATE_REGION__MSG__USE_ATTRIBUTES_FROM_REGION_0_IS_NOT_WITH_PERSISTENCE,
-                new Object[] {String.valueOf(regionFunctionArgs.getUseAttributesFrom())});
-
-        throw new IllegalArgumentException(message);
-      }
-
-      if (!diskStoreExists(cache, diskStore)) {
-        throw new IllegalArgumentException(CliStrings.format(
-            CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_DISKSTORE_UNKNOWN_DISKSTORE_0,
-            new Object[] {diskStore}));
-      }
-    }
-
-    RegionFunctionArgs.ExpirationAttrs entryExpirationIdleTime =
-        regionFunctionArgs.getEntryExpirationIdleTime();
-    RegionFunctionArgs.ExpirationAttrs entryExpirationTTL =
-        regionFunctionArgs.getEntryExpirationTTL();
-    RegionFunctionArgs.ExpirationAttrs regionExpirationIdleTime =
-        regionFunctionArgs.getRegionExpirationIdleTime();
-    RegionFunctionArgs.ExpirationAttrs regionExpirationTTL =
-        regionFunctionArgs.getRegionExpirationTTL();
-
-    if ((!regionFunctionArgs.isSetStatisticsEnabled() || !regionFunctionArgs.isStatisticsEnabled())
-        && (entryExpirationIdleTime != null || entryExpirationTTL != null
-            || regionExpirationIdleTime != null || regionExpirationTTL != null)) {
-      String message = LocalizedStrings.AttributesFactory_STATISTICS_MUST_BE_ENABLED_FOR_EXPIRATION
-          .toLocalizedString();
-      throw new IllegalArgumentException(message + ".");
-    }
-
-    boolean compressorFailure = false;
-    if (regionFunctionArgs.isSetCompressor()) {
-      String compressorClassName = regionFunctionArgs.getCompressor();
-      Object compressor = null;
-      try {
-        Class<?> compressorClass = ClassPathLoader.getLatest().forName(compressorClassName);
-        compressor = compressorClass.newInstance();
-      } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
-        compressorFailure = true;
-      }
-
-      if (compressorFailure || !(compressor instanceof Compressor)) {
-        throw new IllegalArgumentException(
-            CliStrings.format(CliStrings.CREATE_REGION__MSG__INVALID_COMPRESSOR,
-                new Object[] {regionFunctionArgs.getCompressor()}));
-      }
-    }
-
-    if (regionFunctionArgs.hasPartitionAttributes()) {
-      if (regionFunctionArgs.isPartitionResolverSet()) {
-        String partitionResolverClassName = regionFunctionArgs.getPartitionResolver();
-        try {
-          Class<PartitionResolver> resolverClass = (Class<PartitionResolver>) ClassPathLoader
-              .getLatest().forName(partitionResolverClassName);
-          PartitionResolver partitionResolver = resolverClass.newInstance();
-        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
-          throw new IllegalArgumentException(
-              CliStrings.format(CliStrings.CREATE_REGION__MSG__INVALID_PARTITION_RESOLVER,
-                  new Object[] {regionFunctionArgs.getPartitionResolver()}),
-              e);
-        }
-      }
-    }
-  }
-
-  private boolean diskStoreExists(InternalCache cache, String diskStoreName) {
-    ManagementService managementService = ManagementService.getExistingManagementService(cache);
-    DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
-    Map<String, String[]> diskstore = dsMXBean.listMemberDiskstore();
-
-    Set<Entry<String, String[]>> entrySet = diskstore.entrySet();
-
-    for (Entry<String, String[]> entry : entrySet) {
-      String[] value = entry.getValue();
-      if (CliUtil.contains(value, diskStoreName)) {
-        return true;
-      }
-    }
-
-    return false;
-  }
-
-  private static <K, V> FetchRegionAttributesFunctionResult<K, V> getRegionAttributes(
-      InternalCache cache, String regionPath) {
-    if (!isClusterWideSameConfig(cache, regionPath)) {
-      throw new IllegalStateException(CliStrings.format(
-          CliStrings.CREATE_REGION__MSG__USE_ATTRIBUTES_FORM_REGIONS_EXISTS_BUT_DIFFERENT_SCOPE_OR_DATAPOLICY_USE_DESCRIBE_REGION_FOR_0,
-          regionPath));
-    }
-    FetchRegionAttributesFunctionResult<K, V> attributes = null;
-
-    // First check whether the region exists on a this manager, if yes then no
-    // need to use FetchRegionAttributesFunction to fetch RegionAttributes
-    try {
-      attributes = FetchRegionAttributesFunction.getRegionAttributes(regionPath);
-    } catch (IllegalArgumentException e) {
-      /* region doesn't exist on the manager */
-    }
-
-    if (attributes == null) {
-      // find first member which has the region
-      Set<DistributedMember> regionAssociatedMembers =
-          CliUtil.getRegionAssociatedMembers(regionPath, cache, false);
-      if (regionAssociatedMembers != null && !regionAssociatedMembers.isEmpty()) {
-        DistributedMember distributedMember = regionAssociatedMembers.iterator().next();
-        ResultCollector<?, ?> resultCollector = CliUtil
-            .executeFunction(FetchRegionAttributesFunction.INSTANCE, regionPath, distributedMember);
-        List<?> resultsList = (List<?>) resultCollector.getResult();
-
-        if (resultsList != null && !resultsList.isEmpty()) {
-          for (Object object : resultsList) {
-            if (object instanceof IllegalArgumentException) {
-              throw (IllegalArgumentException) object;
-            } else if (object instanceof Throwable) {
-              Throwable th = (Throwable) object;
-              LogWrapper.getInstance().info(CliUtil.stackTraceAsString((th)));
-              throw new IllegalArgumentException(CliStrings.format(
-                  CliStrings.CREATE_REGION__MSG__COULD_NOT_RETRIEVE_REGION_ATTRS_FOR_PATH_0_REASON_1,
-                  new Object[] {regionPath, th.getMessage()}));
-            } else { // has to be RegionAttributes
-              @SuppressWarnings("unchecked") // to avoid warning :(
-              FetchRegionAttributesFunctionResult<K, V> regAttr =
-                  ((FetchRegionAttributesFunctionResult<K, V>) object);
-              if (attributes == null) {
-                attributes = regAttr;
-                break;
-              } // attributes null check
-            } // not IllegalArgumentException or other throwable
-          } // iterate over list - there should be only one result in the list
-        } // result list is not null or empty
-      } // regionAssociatedMembers is not-empty
-    } // attributes are null because do not exist on local member
-
-    return attributes;
-  }
-
-  private static boolean isClusterWideSameConfig(InternalCache cache, String regionPath) {
-    ManagementService managementService = ManagementService.getExistingManagementService(cache);
-
-    DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
-
-    Set<DistributedMember> allMembers = CliUtil.getAllNormalMembers(cache);
-
-    RegionAttributesData regionAttributesToValidateAgainst = null;
-    for (DistributedMember distributedMember : allMembers) {
-      ObjectName regionObjectName;
-      try {
-        regionObjectName = dsMXBean
-            .fetchRegionObjectName(CliUtil.getMemberNameOrId(distributedMember), regionPath);
-        RegionMXBean regionMBean =
-            managementService.getMBeanInstance(regionObjectName, RegionMXBean.class);
-        RegionAttributesData regionAttributes = regionMBean.listRegionAttributes();
-
-        if (regionAttributesToValidateAgainst == null) {
-          regionAttributesToValidateAgainst = regionAttributes;
-        } else if (!(regionAttributesToValidateAgainst.getScope()
-            .equals(regionAttributes.getScope())
-            || regionAttributesToValidateAgainst.getDataPolicy()
-                .equals(regionAttributes.getDataPolicy()))) {
-          return false;
-        }
-      } catch (Exception e) {
-        // ignore
-      }
-    }
-
-    return true;
-  }
-
-  private boolean isClassNameValid(String fqcn) {
-    if (fqcn.isEmpty()) {
-      return true;
-    }
-
-    String regex = "([\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*";
-    return Pattern.matches(regex, fqcn);
-  }
-
-  @CliCommand(value = {CliStrings.DESTROY_REGION}, help = CliStrings.DESTROY_REGION__HELP)
-  @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public Result destroyRegion(
-      @CliOption(key = CliStrings.DESTROY_REGION__REGION, optionContext = ConverterHint.REGION_PATH,
-          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 (StringUtils.isBlank(regionPath) || regionPath.equals(Region.SEPARATOR)) {
-      return ResultBuilder.createInfoResult(CliStrings.format(
-          CliStrings.DESTROY_REGION__MSG__REGIONPATH_0_NOT_VALID, new Object[] {regionPath}));
-    }
-
-    Result result;
-    AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
-    try {
-      InternalCache cache = getCache();
-      ManagementService managementService = ManagementService.getExistingManagementService(cache);
-      String regionPathToUse = regionPath;
-
-      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__COULD_NOT_FIND_REGIONPATH_0_IN_GEODE,
-                regionPath, "jmx-manager-update-rate milliseconds"));
-      }
-
-      CliFunctionResult destroyRegionResult;
-
-      ResultCollector<?, ?> resultCollector =
-          CliUtil.executeFunction(RegionDestroyFunction.INSTANCE, regionPath, regionMembersList);
-      List<CliFunctionResult> resultsList = (List<CliFunctionResult>) resultCollector.getResult();
-      String message =
-          CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED, regionPath, "");
-
-      // Only if there is an error is this set to false
-      boolean isRegionDestroyed = true;
-      for (CliFunctionResult aResultsList : resultsList) {
-        destroyRegionResult = aResultsList;
-        if (destroyRegionResult.isSuccessful()) {
-          xmlEntity.set(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,
-              regionPath, t.getMessage());
-          isRegionDestroyed = false;
-        } else {
-          message = CliStrings.format(
-              CliStrings.DESTROY_REGION__MSG__UNKNOWN_RESULT_WHILE_DESTROYING_REGION_0_REASON_1,
-              regionPath, destroyRegionResult.getMessage());
-          isRegionDestroyed = false;
-        }
-      }
-      if (isRegionDestroyed) {
-        result = ResultBuilder.createInfoResult(message);
-      } else {
-        result = ResultBuilder.createUserErrorResult(message);
-      }
-    } catch (IllegalStateException e) {
-      result = ResultBuilder.createUserErrorResult(CliStrings.format(
-          CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1, regionPath,
-          e.getMessage()));
-    } catch (Exception e) {
-      result = ResultBuilder.createGemFireErrorResult(CliStrings.format(
-          CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1, regionPath,
-          e.getMessage()));
-    }
-
-    if (xmlEntity.get() != null) {
-      persistClusterConfiguration(result,
-          () -> getSharedConfiguration().deleteXmlEntity(xmlEntity.get(), null));
-    }
-
-    return result;
-  }
-
-  private Set<DistributedMember> findMembersForRegion(InternalCache cache,
-      ManagementService managementService, String regionPath) {
-    Set<DistributedMember> membersList = new HashSet<>();
-    Set<String> regionMemberIds = new HashSet<>();
-    MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-
-    // needs to be escaped with quotes if it contains a hyphen
-    if (regionPath.contains("-")) {
-      regionPath = "\"" + regionPath + "\"";
-    }
-
-    String queryExp =
-        MessageFormat.format(MBeanJMXAdapter.OBJECTNAME__REGION_MXBEAN, regionPath, "*");
-
-    try {
-      ObjectName queryExpON = new ObjectName(queryExp);
-      Set<ObjectName> queryNames = mbeanServer.queryNames(null, queryExpON);
-      if (queryNames == null || queryNames.isEmpty()) {
-        return membersList; // protects against null pointer exception below
-      }
-
-      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))) {
-              regionMemberIds.add(regionMXBean.getMember());
-            } else {
-              if (!addedOneRemote) {
-                regionMemberIds.add(regionMXBean.getMember());
-                addedOneRemote = true;
-              }
-            }
-          }
-        } catch (ClassCastException e) {
-          LogWriter logger = cache.getLogger();
-          if (logger.finerEnabled()) {
-            logger.finer(regionMBeanObjectName + " is not a " + RegionMXBean.class.getSimpleName(),
-                e);
-          }
-        }
-      }
-
-      if (!regionMemberIds.isEmpty()) {
-        membersList = getMembersByIds(cache, regionMemberIds);
-      }
-    } catch (MalformedObjectNameException | NullPointerException e) {
-      LogWrapper.getInstance().info(e.getMessage(), e);
-    }
-
-    return membersList;
-  }
-
-  private Set<DistributedMember> getMembersByIds(InternalCache cache, Set<String> memberIds) {
-    Set<DistributedMember> foundMembers = Collections.emptySet();
-    if (memberIds != null && !memberIds.isEmpty()) {
-      foundMembers = new HashSet<>();
-      Set<DistributedMember> allNormalMembers = CliUtil.getAllNormalMembers(cache);
-
-      for (String memberId : memberIds) {
-        for (DistributedMember distributedMember : allNormalMembers) {
-          if (memberId.equals(distributedMember.getId())
-              || memberId.equals(distributedMember.getName())) {
-            foundMembers.add(distributedMember);
-          }
-        }
-      }
-    }
-    return foundMembers;
-  }
-
-  private boolean isPersistentShortcut(RegionShortcut shortcut) {
-    return shortcut == RegionShortcut.LOCAL_PERSISTENT
-        || shortcut == RegionShortcut.LOCAL_PERSISTENT_OVERFLOW
-        || shortcut == RegionShortcut.PARTITION_PERSISTENT
-        || shortcut == RegionShortcut.PARTITION_PERSISTENT_OVERFLOW
-        || shortcut == RegionShortcut.PARTITION_REDUNDANT_PERSISTENT
-        || shortcut == RegionShortcut.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW
-        || shortcut == RegionShortcut.REPLICATE_PERSISTENT
-        || shortcut == RegionShortcut.REPLICATE_PERSISTENT_OVERFLOW;
-  }
-
-  private boolean isAttributePersistent(RegionAttributes attributes) {
-    return attributes != null && attributes.getDataPolicy() != null
-        && attributes.getDataPolicy().toString().contains("PERSISTENT");
-  }
-}