geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [04/17] geode git commit: GEODE-2261: rename SharedConfig to ClusterConfigurationService
Date Thu, 12 Jan 2017 23:25:36 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
index a04bbe8..3729416 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
@@ -54,7 +54,7 @@ import org.apache.geode.compression.SnappyCompressor;
 import org.apache.geode.distributed.DistributedSystemDisconnectedException;
 import org.apache.geode.distributed.Locator;
 import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.SharedConfiguration;
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.FileUtil;
@@ -813,7 +813,7 @@ public class DiskStoreCommandsDUnitTest extends CliCommandTestBase {
     Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
       @Override
       public void run() {
-        SharedConfiguration sharedConfig =
+        ClusterConfigurationService sharedConfig =
             ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
         String xmlFromConfig;
         try {
@@ -865,7 +865,7 @@ public class DiskStoreCommandsDUnitTest extends CliCommandTestBase {
     Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
       @Override
       public void run() {
-        SharedConfiguration sharedConfig =
+        ClusterConfigurationService sharedConfig =
             ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
         String xmlFromConfig;
         try {

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsDUnitTest.java
index 81c4545..a0a599f 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsDUnitTest.java
@@ -42,8 +42,8 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionFactory;
 import org.apache.geode.cache.query.Index;
 import org.apache.geode.distributed.Locator;
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.SharedConfiguration;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.management.cli.Result;
@@ -711,7 +711,7 @@ public class IndexCommandsDUnitTest extends CliCommandTestBase {
     Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
       @Override
       public void run() {
-        SharedConfiguration sharedConfig =
+        ClusterConfigurationService sharedConfig =
             ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
         String xmlFromConfig;
         try {
@@ -757,7 +757,7 @@ public class IndexCommandsDUnitTest extends CliCommandTestBase {
     Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
       @Override
       public void run() {
-        SharedConfiguration sharedConfig =
+        ClusterConfigurationService sharedConfig =
             ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
         String xmlFromConfig;
         try {

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java
index 98014a4..685bd48 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java
@@ -38,7 +38,7 @@ import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
 import org.apache.geode.distributed.Locator;
 import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.SharedConfiguration;
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.ClassBuilder;
@@ -375,7 +375,7 @@ public class QueueCommandsDUnitTest extends CliCommandTestBase {
     Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
       @Override
       public void run() {
-        SharedConfiguration sharedConfig =
+        ClusterConfigurationService sharedConfig =
             ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
         String xmlFromConfig;
         try {

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/SharedConfigurationCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/SharedConfigurationCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/SharedConfigurationCommandsDUnitTest.java
deleted file mode 100644
index 096f0d8..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/SharedConfigurationCommandsDUnitTest.java
+++ /dev/null
@@ -1,343 +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 org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.Locator;
-import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.SharedConfiguration;
-import org.apache.geode.internal.ClassBuilder;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.cli.Result.Status;
-import org.apache.geode.management.internal.cli.HeadlessGfsh;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.management.internal.configuration.SharedConfigurationTestUtils;
-import org.apache.geode.management.internal.configuration.domain.Configuration;
-import org.apache.geode.test.dunit.SerializableCallable;
-import org.apache.geode.test.dunit.SerializableRunnable;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.WaitCriterion;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.Set;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
-import static org.apache.geode.management.internal.cli.CliUtil.getAllNormalMembers;
-import static org.apache.geode.management.internal.cli.i18n.CliStrings.*;
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.Host.getHost;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-import static org.apache.geode.test.dunit.NetworkUtils.getIPLiteral;
-import static org.apache.geode.test.dunit.Wait.waitForCriterion;
-
-/**
- * DUnit test to test export and import of shared configuration.
- */
-@Category(DistributedTest.class)
-@SuppressWarnings("unchecked")
-public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
-
-  private static final int TIMEOUT = 10000;
-  private static final int INTERVAL = 500;
-
-  private final String region1Name = "r1";
-  private final String region2Name = "r2";
-  private final String logLevel = "info";
-
-  private String groupName;
-
-  private String deployedJarName;
-  private File newDeployableJarFile;
-  private ClassBuilder classBuilder;
-
-  private String sharedConfigZipFileName;
-  private String startArchiveFileName;
-  private int[] ports;
-
-  private int locator1Port;
-  private String locator1Name;
-  private String locator1LogFilePath;
-
-  private int locator2Port;
-  private String locator2Name;
-  private String locator2LogFilePath;
-
-  private int locator1HttpPort;
-  private int locator1JmxPort;
-  private String locator1JmxHost;
-
-  @Override
-  protected final void postSetUpCliCommandTestBase() throws Exception {
-    disconnectAllFromDS();
-
-    this.groupName = getName();
-    this.deployedJarName = "DeployCommandsDUnit1.jar";
-    this.newDeployableJarFile = new File(
-        this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + deployedJarName);
-    this.classBuilder = new ClassBuilder();
-
-    this.sharedConfigZipFileName =
-        this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + "sharedConfig.zip";
-    this.startArchiveFileName =
-        this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + "stats.gfs";
-    this.ports = getRandomAvailableTCPPorts(4);
-
-    this.locator1Port = this.ports[0];
-    this.locator1Name = "locator1-" + this.locator1Port;
-    this.locator1LogFilePath = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator
-        + "locator-" + this.locator1Port + ".log";
-
-    this.locator2Port = this.ports[1];
-    this.locator2Name = "Locator2-" + this.locator2Port;
-    this.locator2LogFilePath = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator
-        + "locator-" + this.locator2Port + ".log";
-
-    this.locator1HttpPort = ports[2];
-    this.locator1JmxPort = ports[3];
-    this.locator1JmxHost = getIPLiteral();
-  }
-
-  @Override
-  public final void postTearDownCacheTestCase() throws Exception {
-    for (int i = 0; i < 4; i++) {
-      getHost(0).getVM(i).invoke(SharedConfigurationTestUtils.cleanupLocator);
-    }
-  }
-
-  @Category(FlakyTest.class) // GEODE-1519
-  @Test
-  public void testExportImportSharedConfiguration() throws IOException {
-    // Start the Locator and wait for shared configuration to be available
-    VM locatorAndMgr = getHost(0).getVM(3);
-    Set<DistributedMember> normalMembers1 =
-        (Set<DistributedMember>) locatorAndMgr.invoke(new SerializableCallable() {
-          @Override
-          public Object call() {
-            final File locatorLogFile = new File(locator1LogFilePath);
-
-            final Properties locatorProps = new Properties();
-            locatorProps.setProperty(NAME, locator1Name);
-            locatorProps.setProperty(MCAST_PORT, "0");
-            locatorProps.setProperty(LOG_LEVEL, "config");
-            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(locator1JmxHost));
-            locatorProps.setProperty(JMX_MANAGER_PORT, String.valueOf(locator1JmxPort));
-            locatorProps.setProperty(HTTP_SERVICE_PORT, String.valueOf(locator1HttpPort));
-
-            try {
-              final InternalLocator locator = (InternalLocator) Locator
-                  .startLocatorAndDS(locator1Port, locatorLogFile, null, locatorProps);
-
-              WaitCriterion wc = new WaitCriterion() {
-                @Override
-                public boolean done() {
-                  return locator.isSharedConfigurationRunning();
-                }
-
-                @Override
-                public String description() {
-                  return "Waiting for shared configuration to be started";
-                }
-              };
-              waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-
-            } catch (IOException e) {
-              fail("Unable to create a locator with a shared configuration", e);
-            }
-
-            return getAllNormalMembers(CacheFactory.getAnyInstance());
-          }
-        });
-
-    HeadlessGfsh gfsh = getDefaultShell();
-    connect(locator1JmxHost, locator1JmxPort, locator1HttpPort, gfsh);
-
-    // Create a cache in VM 1
-    VM dataMember = getHost(0).getVM(1);
-    normalMembers1 = (Set<DistributedMember>) dataMember.invoke(new SerializableCallable() {
-      @Override
-      public Object call() {
-        Properties localProps = new Properties();
-        localProps.setProperty(MCAST_PORT, "0");
-        localProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]");
-        localProps.setProperty(GROUPS, groupName);
-        localProps.setProperty(NAME, "DataMember");
-        getSystem(localProps);
-        Cache cache = getCache();
-        assertNotNull(cache);
-        return getAllNormalMembers(cache);
-      }
-    });
-
-    // Create a JAR file
-    this.classBuilder.writeJarFromName("DeployCommandsDUnitA", this.newDeployableJarFile);
-
-    // Deploy the JAR
-    CommandResult cmdResult =
-        executeCommand("deploy --jar=" + this.newDeployableJarFile.getCanonicalPath());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    // Create the region1 on the group
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CREATE_REGION);
-    commandStringBuilder.addOption(CREATE_REGION__REGION, region1Name);
-    commandStringBuilder.addOption(CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
-    commandStringBuilder.addOption(CREATE_REGION__STATISTICSENABLED, "true");
-    commandStringBuilder.addOption(CREATE_REGION__GROUP, groupName);
-
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    commandStringBuilder = new CommandStringBuilder(CREATE_REGION);
-    commandStringBuilder.addOption(CREATE_REGION__REGION, region2Name);
-    commandStringBuilder.addOption(CREATE_REGION__REGIONSHORTCUT, "PARTITION");
-    commandStringBuilder.addOption(CREATE_REGION__STATISTICSENABLED, "true");
-    cmdResult = executeCommand(commandStringBuilder.toString());
-    assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-    // Alter runtime configuration
-    commandStringBuilder = new CommandStringBuilder(ALTER_RUNTIME_CONFIG);
-    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__LOG__LEVEL, logLevel);
-    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
-    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "32");
-    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "49");
-    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "120");
-    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE,
-        this.startArchiveFileName);
-    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "true");
-    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
-    cmdResult = executeCommand(commandStringBuilder.getCommandString());
-    String resultString = commandResultToString(cmdResult);
-
-    getLogWriter().info("#SB Result\n");
-    getLogWriter().info(resultString);
-    assertEquals(true, cmdResult.getStatus().equals(Status.OK));
-
-    commandStringBuilder = new CommandStringBuilder(STATUS_SHARED_CONFIG);
-    cmdResult = executeCommand(commandStringBuilder.getCommandString());
-    resultString = commandResultToString(cmdResult);
-    getLogWriter().info("#SB Result\n");
-    getLogWriter().info(resultString);
-    assertEquals(Status.OK, cmdResult.getStatus());
-
-    commandStringBuilder = new CommandStringBuilder(EXPORT_SHARED_CONFIG);
-    commandStringBuilder.addOption(EXPORT_SHARED_CONFIG__FILE, this.sharedConfigZipFileName);
-    cmdResult = executeCommand(commandStringBuilder.getCommandString());
-    resultString = commandResultToString(cmdResult);
-    getLogWriter().info("#SB Result\n");
-    getLogWriter().info(resultString);
-    assertEquals(Status.OK, cmdResult.getStatus());
-
-    // Import into a running system should fail
-    commandStringBuilder = new CommandStringBuilder(IMPORT_SHARED_CONFIG);
-    commandStringBuilder.addOption(IMPORT_SHARED_CONFIG__ZIP, this.sharedConfigZipFileName);
-    cmdResult = executeCommand(commandStringBuilder.getCommandString());
-    assertEquals(Status.ERROR, cmdResult.getStatus());
-
-    // Stop the data members and remove the shared configuration in the locator.
-    dataMember.invoke(new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        Cache cache = getCache();
-        cache.close();
-        assertTrue(cache.isClosed());
-        disconnectFromDS();
-        return null;
-      }
-    });
-
-    // Clear shared configuration in this locator to test the import shared configuration
-    locatorAndMgr.invoke(new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        InternalLocator locator = InternalLocator.getLocator();
-        SharedConfiguration sc = locator.getSharedConfiguration();
-        assertNotNull(sc);
-        sc.clearSharedConfiguration();
-        return null;
-      }
-    });
-
-    // Now execute import shared configuration
-    // Now import the shared configuration and it should succeed.
-    commandStringBuilder = new CommandStringBuilder(IMPORT_SHARED_CONFIG);
-    commandStringBuilder.addOption(IMPORT_SHARED_CONFIG__ZIP, this.sharedConfigZipFileName);
-    cmdResult = executeCommand(commandStringBuilder.getCommandString());
-    assertEquals(Status.OK, cmdResult.getStatus());
-
-    // Start a new locator , test if it has all the imported shared configuration artifacts
-    VM newLocator = getHost(0).getVM(2);
-    newLocator.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        final File locatorLogFile = new File(locator2LogFilePath);
-        final Properties locatorProps = new Properties();
-        locatorProps.setProperty(NAME, locator2Name);
-        locatorProps.setProperty(MCAST_PORT, "0");
-        locatorProps.setProperty(LOG_LEVEL, "fine");
-        locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
-        locatorProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]");
-
-        try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port,
-              locatorLogFile, null, locatorProps);
-
-          WaitCriterion wc = new WaitCriterion() {
-            @Override
-            public boolean done() {
-              return locator.isSharedConfigurationRunning();
-            }
-
-            @Override
-            public String description() {
-              return "Waiting for shared configuration to be started";
-            }
-          };
-          waitForCriterion(wc, 5000, 500, true);
-
-          SharedConfiguration sc = locator.getSharedConfiguration();
-          assertNotNull(sc);
-          Configuration groupConfig = sc.getConfiguration(groupName);
-          assertNotNull(groupConfig);
-          assertTrue(groupConfig.getCacheXmlContent().contains(region1Name));
-
-          Configuration clusterConfig = sc.getConfiguration(SharedConfiguration.CLUSTER_CONFIG);
-          assertNotNull(clusterConfig);
-          assertTrue(clusterConfig.getCacheXmlContent().contains(region2Name));
-          assertTrue(clusterConfig.getJarNames().contains(deployedJarName));
-          assertTrue(clusterConfig.getGemfireProperties().getProperty(LOG_LEVEL).equals(logLevel));
-          assertTrue(clusterConfig.getGemfireProperties().getProperty(STATISTIC_ARCHIVE_FILE)
-              .equals(startArchiveFileName));
-
-        } catch (IOException e) {
-          fail("Unable to create a locator with a shared configuration", e);
-        } catch (Exception e) {
-          fail("Error occurred in cluster configuration service", e);
-        }
-      }
-    });
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
index 73ffbdd..c2d511d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
@@ -22,7 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.SharedConfiguration;
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.internal.JarClassLoader;
 import org.apache.geode.internal.JarDeployer;
@@ -91,7 +91,7 @@ public class ClusterConfig implements Serializable {
     // verify info exists in memeory
     locator.invoke(() -> {
       InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.locator;
-      SharedConfiguration sc = internalLocator.getSharedConfiguration();
+      ClusterConfigurationService sc = internalLocator.getSharedConfiguration();
 
       // verify no extra configs exist in memory
       Set<String> actualGroupConfigs = sc.getEntireConfiguration().keySet();

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationServiceDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationServiceDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationServiceDUnitTest.java
new file mode 100644
index 0000000..74fb1418
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationServiceDUnitTest.java
@@ -0,0 +1,407 @@
+/*
+ * 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.configuration;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.DiskStoreFactory;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.distributed.Locator;
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.DM;
+import org.apache.geode.distributed.internal.InternalLocator;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.distributed.internal.tcpserver.TcpClient;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.management.internal.configuration.domain.Configuration;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+import org.apache.geode.management.internal.configuration.handlers.ConfigurationRequestHandler;
+import org.apache.geode.management.internal.configuration.messages.ConfigurationRequest;
+import org.apache.geode.management.internal.configuration.messages.ConfigurationResponse;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.WaitCriterion;
+import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.*;
+
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
+import static org.apache.geode.test.dunit.Assert.*;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.apache.geode.test.dunit.Wait.waitForCriterion;
+
+/**
+ * Tests the starting up of shared configuration, installation of
+ * {@link ConfigurationRequestHandler}
+ */
+@Category(DistributedTest.class)
+public class ClusterConfigurationServiceDUnitTest extends JUnit4CacheTestCase {
+
+  private static final String REGION1 = "region1";
+  private static final int TIMEOUT = 10000;
+  private static final int INTERVAL = 500;
+  private static final String DISKSTORENAME = "diskStore1";
+
+  @Override
+  public final void postSetUp() throws Exception {
+    disconnectAllFromDS();
+  }
+
+  @Override
+  public final void postTearDownCacheTestCase() throws Exception {
+    for (int i = 0; i < 4; i++) {
+      getHost(0).getVM(i).invoke(SharedConfigurationTestUtils.cleanupLocator);
+    }
+  }
+
+  @Test
+  public void testGetHostedLocatorsWithSharedConfiguration() throws Exception {
+    final VM locator1Vm = getHost(0).getVM(1);
+    final VM locator2Vm = getHost(0).getVM(2);
+
+    final String testName = getName();
+
+    final int[] ports = getRandomAvailableTCPPorts(3);
+
+    final int locator1Port = ports[0];
+    final String locator1Name = "locator1" + locator1Port;
+
+    locator1Vm.invoke(() -> {
+      final File locatorLogFile = new File(testName + "-locator-" + locator1Port + ".log");
+
+      final Properties locatorProps = new Properties();
+      locatorProps.setProperty(NAME, locator1Name);
+      locatorProps.setProperty(MCAST_PORT, "0");
+      locatorProps.setProperty(LOG_LEVEL, "fine");
+      locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
+
+      try {
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port,
+            locatorLogFile, null, locatorProps);
+
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
+
+      } catch (IOException e) {
+        fail("Unable to create a locator with a shared configuration", e);
+      }
+
+      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      InternalDistributedMember me = cache.getMyId();
+      DM dm = cache.getDistributionManager();
+
+      Map<InternalDistributedMember, Collection<String>> hostedLocators = dm.getAllHostedLocators();
+      assertFalse(hostedLocators.isEmpty());
+
+      Map<InternalDistributedMember, Collection<String>> hostedLocatorsWithSharedConfiguration =
+          dm.getAllHostedLocatorsWithSharedConfiguration();
+      assertFalse(hostedLocatorsWithSharedConfiguration.isEmpty());
+
+      assertNotNull(hostedLocators.get(me));
+      assertNotNull(hostedLocatorsWithSharedConfiguration.get(me));
+      return null;
+    });
+
+    final int locator2Port = ports[1];
+    final String locator2Name = "locator2" + locator2Port;
+
+    locator2Vm.invoke(() -> {
+      final File locatorLogFile = new File(testName + "-locator-" + locator2Port + ".log");
+
+      final Properties locatorProps = new Properties();
+      locatorProps.setProperty(NAME, locator2Name);
+      locatorProps.setProperty(MCAST_PORT, "0");
+      locatorProps.setProperty(LOG_LEVEL, "fine");
+      locatorProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]");
+      locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
+
+      final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port,
+          locatorLogFile, null, locatorProps);
+
+      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      InternalDistributedMember me = cache.getMyId();
+      DM dm = cache.getDistributionManager();
+
+      Map<InternalDistributedMember, Collection<String>> hostedLocators = dm.getAllHostedLocators();
+      assertFalse(hostedLocators.isEmpty());
+
+      Map<InternalDistributedMember, Collection<String>> hostedLocatorsWithSharedConfiguration =
+          dm.getAllHostedLocatorsWithSharedConfiguration();
+      assertFalse(hostedLocatorsWithSharedConfiguration.isEmpty());
+      assertNotNull(hostedLocators.get(me));
+      assertNull(hostedLocatorsWithSharedConfiguration.get(me));
+      assertTrue(hostedLocators.size() == 2);
+      assertTrue(hostedLocatorsWithSharedConfiguration.size() == 1);
+
+      Set<InternalDistributedMember> locatorsWithSharedConfig =
+          hostedLocatorsWithSharedConfiguration.keySet();
+      Set<String> locatorsWithSharedConfigNames = new HashSet<String>();
+
+      for (InternalDistributedMember locatorWithSharedConfig : locatorsWithSharedConfig) {
+        locatorsWithSharedConfigNames.add(locatorWithSharedConfig.getName());
+      }
+      assertTrue(locatorsWithSharedConfigNames.contains(locator1Name));
+
+      return null;
+    });
+
+    locator1Vm.invoke(() -> {
+      InternalLocator locator = (InternalLocator) Locator.getLocator();
+      ClusterConfigurationService sharedConfig = locator.getSharedConfiguration();
+      sharedConfig.destroySharedConfiguration();
+      locator.stop();
+      return null;
+    });
+
+    locator2Vm.invoke(() -> {
+      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      InternalDistributedMember me = cache.getMyId();
+      DM dm = cache.getDistributionManager();
+      Map<InternalDistributedMember, Collection<String>> hostedLocators = dm.getAllHostedLocators();
+      assertFalse(hostedLocators.isEmpty());
+      Map<InternalDistributedMember, Collection<String>> hostedLocatorsWithSharedConfiguration =
+          dm.getAllHostedLocatorsWithSharedConfiguration();
+      assertTrue(hostedLocatorsWithSharedConfiguration.isEmpty());
+      assertNotNull(hostedLocators.get(me));
+      assertNull(hostedLocatorsWithSharedConfiguration.get(me));
+      assertTrue(hostedLocators.size() == 1);
+      assertTrue(hostedLocatorsWithSharedConfiguration.size() == 0);
+      return null;
+    });
+  }
+
+  @Test
+  public void testSharedConfigurationService() throws Exception {
+    // Start the Locator and wait for shared configuration to be available
+    final String testGroup = "G1";
+    final String clusterLogLevel = "error";
+    final String groupLogLevel = "fine";
+
+    final String testName = getName();
+
+    final VM locator1Vm = getHost(0).getVM(1);
+    final VM dataMemberVm = getHost(0).getVM(2);
+    final VM locator2Vm = getHost(0).getVM(3);
+
+    final int[] ports = getRandomAvailableTCPPorts(3);
+    final int locator1Port = ports[0];
+
+    locator1Vm.invoke(() -> {
+      final File locatorLogFile = new File(testName + "-locator-" + locator1Port + ".log");
+
+      final Properties locatorProps = new Properties();
+      locatorProps.setProperty(NAME, "Locator1");
+      locatorProps.setProperty(MCAST_PORT, "0");
+      locatorProps.setProperty(LOG_LEVEL, "info");
+      locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
+
+      try {
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port,
+            locatorLogFile, null, locatorProps);
+
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
+
+      } catch (IOException e) {
+        fail("Unable to create a locator with a shared configuration", e);
+      }
+    });
+
+    XmlEntity xmlEntity = dataMemberVm.invoke(() -> {
+      Properties localProps = new Properties();
+      localProps.setProperty(MCAST_PORT, "0");
+      localProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]");
+      localProps.setProperty(GROUPS, testGroup);
+
+      getSystem(localProps);
+      Cache cache = getCache();
+      assertNotNull(cache);
+
+      DiskStoreFactory dsFactory = cache.createDiskStoreFactory();
+      File dsDir = new File("dsDir");
+      if (!dsDir.exists()) {
+        dsDir.mkdir();
+      }
+      dsFactory.setDiskDirs(new File[] {dsDir});
+      dsFactory.create(DISKSTORENAME);
+
+      RegionFactory regionFactory = getCache().createRegionFactory(RegionShortcut.REPLICATE);
+      regionFactory.create(REGION1);
+      return new XmlEntity(CacheXml.REGION, "name", REGION1);
+    });
+
+    locator1Vm.invoke(() -> {
+      ClusterConfigurationService sc = InternalLocator.getLocator().getSharedConfiguration();
+      sc.addXmlEntity(xmlEntity, new String[] {testGroup});
+
+      // Modify property and cache attributes
+      Properties clusterProperties = new Properties();
+      clusterProperties.setProperty(LOG_LEVEL, clusterLogLevel);
+      XmlEntity cacheEntity = XmlEntity.builder().withType(CacheXml.CACHE).build();
+      Map<String, String> cacheAttributes = new HashMap<String, String>();
+      cacheAttributes.put(CacheXml.COPY_ON_READ, "true");
+
+      sc.modifyXmlAndProperties(clusterProperties, cacheEntity, null);
+
+      clusterProperties.setProperty(LOG_LEVEL, groupLogLevel);
+      sc.modifyXmlAndProperties(clusterProperties, cacheEntity, new String[] {testGroup});
+
+      // Add a jar
+      byte[][] jarBytes = new byte[1][];
+      jarBytes[0] = "Hello".getBytes();
+      assertTrue(sc.addJarsToThisLocator(new String[] {"foo.jar"}, jarBytes, null));
+
+      // Add a jar for the group
+      jarBytes = new byte[1][];
+      jarBytes[0] = "Hello".getBytes();
+      assertTrue(
+          sc.addJarsToThisLocator(new String[] {"bar.jar"}, jarBytes, new String[] {testGroup}));
+    });
+
+    final int locator2Port = ports[1];
+
+    // Create another locator in VM2
+    locator2Vm.invoke(() -> {
+      final File locatorLogFile = new File(testName + "-locator-" + locator2Port + ".log");
+
+      final Properties locatorProps = new Properties();
+      locatorProps.setProperty(NAME, "Locator2");
+      locatorProps.setProperty(MCAST_PORT, "0");
+      locatorProps.setProperty(LOG_LEVEL, "info");
+      locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
+      locatorProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]");
+
+      try {
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port,
+            locatorLogFile, null, locatorProps);
+
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
+
+      } catch (IOException e) {
+        fail("Unable to create a locator with a shared configuration", e);
+      }
+
+      InternalLocator locator = (InternalLocator) Locator.getLocator();
+      ClusterConfigurationService sharedConfig = locator.getSharedConfiguration();
+      Map<String, Configuration> entireConfiguration = sharedConfig.getEntireConfiguration();
+      Configuration clusterConfig =
+          entireConfiguration.get(ClusterConfigurationService.CLUSTER_CONFIG);
+      assertNotNull(clusterConfig);
+      assertNotNull(clusterConfig.getJarNames());
+      assertTrue(clusterConfig.getJarNames().contains("foo.jar"));
+      assertTrue(
+          clusterConfig.getGemfireProperties().getProperty(LOG_LEVEL).equals(clusterLogLevel));
+      assertNotNull(clusterConfig.getCacheXmlContent());
+
+      Configuration testGroupConfiguration = entireConfiguration.get(testGroup);
+      assertNotNull(testGroupConfiguration);
+      assertNotNull(testGroupConfiguration.getJarNames());
+      assertTrue(testGroupConfiguration.getJarNames().contains("bar.jar"));
+      assertTrue(testGroupConfiguration.getGemfireProperties().getProperty(LOG_LEVEL)
+          .equals(groupLogLevel));
+      assertNotNull(testGroupConfiguration.getCacheXmlContent());
+      assertTrue(testGroupConfiguration.getCacheXmlContent().contains(REGION1));
+
+      Map<String, byte[]> jarData =
+          sharedConfig.getAllJarsFromThisLocator(entireConfiguration.keySet());
+      String[] jarNames = jarData.keySet().stream().toArray(String[]::new);
+      byte[][] jarBytes = jarData.values().toArray(new byte[jarNames.length][]);
+
+      assertNotNull(jarNames);
+      assertNotNull(jarBytes);
+
+      sharedConfig.deleteXmlEntity(new XmlEntity(CacheXml.REGION, "name", REGION1),
+          new String[] {testGroup});
+      sharedConfig.removeJars(new String[] {"foo.jar"}, null);
+      sharedConfig.removeJars(null, null);
+    });
+
+    dataMemberVm.invoke(() -> {
+      Set<String> groups = new HashSet<String>();
+      groups.add(testGroup);
+      ConfigurationRequest configRequest = new ConfigurationRequest(groups);
+      ConfigurationResponse configResponse = (ConfigurationResponse) new TcpClient()
+          .requestToServer(InetAddress.getByName("localhost"), locator2Port, configRequest, 1000);
+      assertNotNull(configResponse);
+
+      Map<String, Configuration> requestedConfiguration =
+          configResponse.getRequestedConfiguration();
+      Configuration clusterConfiguration =
+          requestedConfiguration.get(ClusterConfigurationService.CLUSTER_CONFIG);
+      assertNotNull(clusterConfiguration);
+      assertTrue(configResponse.getJarNames().length == 0);
+      assertTrue(configResponse.getJars().length == 0);
+      assertTrue(clusterConfiguration.getJarNames().isEmpty());
+      assertTrue(clusterConfiguration.getGemfireProperties().getProperty(LOG_LEVEL)
+          .equals(clusterLogLevel));
+
+      Configuration testGroupConfiguration = requestedConfiguration.get(testGroup);
+      assertNotNull(testGroupConfiguration);
+      assertFalse(testGroupConfiguration.getCacheXmlContent().contains(REGION1));
+      assertTrue(testGroupConfiguration.getJarNames().isEmpty());
+      assertTrue(testGroupConfiguration.getGemfireProperties().getProperty(LOG_LEVEL)
+          .equals(groupLogLevel));
+
+      GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
+      Map<InternalDistributedMember, Collection<String>> locatorsWithSharedConfiguration =
+          cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration();
+      assertFalse(locatorsWithSharedConfiguration.isEmpty());
+      assertTrue(locatorsWithSharedConfiguration.size() == 2);
+      Set<InternalDistributedMember> locatorMembers = locatorsWithSharedConfiguration.keySet();
+      for (InternalDistributedMember locatorMember : locatorMembers) {
+        System.out.println(locatorMember);
+      }
+      return null;
+    });
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationServiceUsingDirDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationServiceUsingDirDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationServiceUsingDirDUnitTest.java
new file mode 100644
index 0000000..fff7681
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationServiceUsingDirDUnitTest.java
@@ -0,0 +1,334 @@
+/*
+ * 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.configuration;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.stream.Collectors.joining;
+import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
+import static org.apache.geode.distributed.ConfigurationProperties.LOAD_CLUSTER_CONFIGURATION_FROM_DIR;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
+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.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import com.jayway.awaitility.Awaitility;
+import com.jayway.awaitility.core.ConditionFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.distributed.Locator;
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.InternalLocator;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.FlakyTest;
+import org.apache.geode.util.test.TestUtil;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.Arrays;
+import java.util.Properties;
+
+@Category({DistributedTest.class, FlakyTest.class}) // GEODE-1165
+public class ClusterConfigurationServiceUsingDirDUnitTest extends JUnit4CacheTestCase {
+
+  @Override
+  public final void preTearDownCacheTestCase() throws Exception {
+    for (int i = 0; i < 2; i++) {
+      VM vm = getHost(0).getVM(i);
+      vm.invoke("Removing shared configuration", () -> {
+        InternalLocator locator = InternalLocator.getLocator();
+        if (locator == null) {
+          return;
+        }
+
+        ClusterConfigurationService sharedConfig = locator.getSharedConfiguration();
+        if (sharedConfig != null) {
+          sharedConfig.destroySharedConfiguration();
+        }
+      });
+    }
+  }
+
+  @Test
+  public void basicClusterConfigDirWithOneLocator() throws Exception {
+    final int[] ports = getRandomAvailableTCPPorts(1);
+    final int locatorCount = ports.length;
+
+    for (int i = 0; i < locatorCount; i++) {
+      VM vm = getHost(0).getVM(i);
+      copyClusterXml(vm, "cluster-region.xml");
+      startLocator(vm, i, ports);
+      waitForSharedConfiguration(vm);
+    }
+
+    for (int i = 2; i < 4; i++) {
+      VM vm = getHost(0).getVM(i);
+      restartCache(vm, i, ports);
+
+      vm.invoke("Checking for region presence", () -> {
+        await().until(() -> getRootRegion("newReplicatedRegion") != null);
+      });
+    }
+  }
+
+  @Test
+  public void basicClusterConfigDirWithTwoLocators() throws Exception {
+    final int[] ports = getRandomAvailableTCPPorts(2);
+    final int locatorCount = ports.length;
+
+    for (int i = 0; i < locatorCount; i++) {
+      VM vm = getHost(0).getVM(i);
+      copyClusterXml(vm, "cluster-region.xml");
+      startLocator(vm, i, ports);
+      waitForSharedConfiguration(vm);
+    }
+
+    for (int i = 2; i < 4; i++) {
+      VM vm = getHost(0).getVM(i);
+      restartCache(vm, i, ports);
+
+      vm.invoke("Checking for region presence", () -> {
+        await().until(() -> getRootRegion("newReplicatedRegion") != null);
+      });
+    }
+  }
+
+  @Test
+  public void updateClusterConfigDirWithTwoLocatorsNoRollingServerRestart() throws Exception {
+    final int[] ports = getRandomAvailableTCPPorts(2);
+    final int locatorCount = ports.length;
+
+    for (int i = 0; i < locatorCount; i++) {
+      VM vm = getHost(0).getVM(i);
+      copyClusterXml(vm, "cluster-empty.xml");
+      startLocator(vm, i, ports);
+      waitForSharedConfiguration(vm);
+    }
+
+    for (int i = 2; i < 4; i++) {
+      VM vm = getHost(0).getVM(i);
+      restartCache(vm, i, ports);
+
+      vm.invoke("Checking for region absence", () -> {
+        Region r = getRootRegion("newReplicatedRegion");
+        assertNull("Region does exist", r);
+      });
+    }
+
+    // Shut down the locators in reverse order to how we will start them up in the next step.
+    // Unless we start them asynchronously, the older one will want to wait for a new diskstore
+    // to become available and will time out.
+    for (int i = locatorCount; i > 0; i--) {
+      VM vm = getHost(0).getVM(i - 1);
+      stopLocator(vm);
+    }
+
+    for (int i = 0; i < locatorCount; i++) {
+      VM vm = getHost(0).getVM(i);
+      copyClusterXml(vm, "cluster-region.xml");
+      startLocator(vm, i, ports);
+      waitForSharedConfiguration(vm);
+    }
+
+    for (int i = 2; i < 4; i++) {
+      VM vm = getHost(0).getVM(i);
+      vm.invoke(() -> disconnectFromDS());
+    }
+
+    for (int i = 2; i < 4; i++) {
+      VM vm = getHost(0).getVM(i);
+      restartCache(vm, i, ports);
+
+      vm.invoke("Checking for region presence", () -> {
+        await().until(() -> getRootRegion("newReplicatedRegion") != null);
+      });
+    }
+  }
+
+  @Test
+  public void updateClusterConfigDirWithTwoLocatorsAndRollingServerRestart() throws Exception {
+    final int[] ports = getRandomAvailableTCPPorts(2);
+    final int locatorCount = ports.length;
+
+    for (int i = 0; i < locatorCount; i++) {
+      VM vm = getHost(0).getVM(i);
+      copyClusterXml(vm, "cluster-empty.xml");
+      startLocator(vm, i, ports);
+      waitForSharedConfiguration(vm);
+    }
+
+    for (int i = 2; i < 4; i++) {
+      VM vm = getHost(0).getVM(i);
+      restartCache(vm, i, ports);
+
+      vm.invoke("Checking for region absence", () -> {
+        Region r = getRootRegion("newReplicatedRegion");
+        assertNull("Region does exist", r);
+      });
+    }
+
+    // Shut down the locators in reverse order to how we will start them up in the next step.
+    // Unless we start them asynchronously, the older one will want to wait for a new diskstore
+    // to become available and will time out.
+    for (int i = locatorCount; i > 0; i--) {
+      VM vm = getHost(0).getVM(i - 1);
+      stopLocator(vm);
+    }
+
+    for (int i = 0; i < locatorCount; i++) {
+      VM vm = getHost(0).getVM(i);
+      copyClusterXml(vm, "cluster-region.xml");
+      startLocator(vm, i, ports);
+      waitForSharedConfiguration(vm);
+    }
+
+    for (int i = 2; i < 4; i++) {
+      VM vm = getHost(0).getVM(i);
+      restartCache(vm, i, ports);
+
+      vm.invoke("Checking for region presence", () -> {
+        await().until(() -> getRootRegion("newReplicatedRegion") != null);
+      });
+    }
+  }
+
+  @Test
+  public void updateClusterConfigDirWithTwoLocatorsRollingRestartAndRollingServerRestart()
+      throws Exception {
+    final int[] ports = getRandomAvailableTCPPorts(2);
+    final int locatorCount = ports.length;
+
+    for (int i = 0; i < locatorCount; i++) {
+      VM vm = getHost(0).getVM(i);
+      copyClusterXml(vm, "cluster-empty.xml");
+      startLocator(vm, i, ports);
+      waitForSharedConfiguration(vm);
+    }
+
+    for (int i = 2; i < 4; i++) {
+      VM vm = getHost(0).getVM(i);
+      restartCache(vm, i, ports);
+
+      vm.invoke("Checking for region absence", () -> {
+        Region r = getRootRegion("newReplicatedRegion");
+        assertNull("Region does exist", r);
+      });
+    }
+
+    // Roll the locators
+    for (int i = locatorCount - 1; i >= 0; i--) {
+      VM vm = getHost(0).getVM(i);
+      stopLocator(vm);
+      copyClusterXml(vm, "cluster-region.xml");
+      startLocator(vm, i, ports);
+      waitForSharedConfiguration(vm);
+    }
+
+    // Roll the servers
+    for (int i = 2; i < 4; i++) {
+      VM vm = getHost(0).getVM(i);
+      restartCache(vm, i, ports);
+
+      vm.invoke("Checking for region presence", () -> {
+        await().until(() -> getRootRegion("newReplicatedRegion") != null);
+      });
+    }
+  }
+
+  private void copyClusterXml(final VM vm, final String clusterXml) {
+    vm.invoke("Copying new cluster.xml from " + clusterXml, () -> {
+      String clusterXmlPath =
+          TestUtil.getResourcePath(ClusterConfigurationServiceUsingDirDUnitTest.class, clusterXml);
+      InputStream cacheXml = new FileInputStream(clusterXmlPath);
+      assertNotNull("Could not create InputStream from " + clusterXmlPath, cacheXml);
+      Files.createDirectories(Paths.get("cluster_config", "cluster"));
+      Files.copy(cacheXml, Paths.get("cluster_config", "cluster", "cluster.xml"),
+          StandardCopyOption.REPLACE_EXISTING);
+    });
+  }
+
+  private void startLocator(final VM vm, final int i, final int[] locatorPorts) {
+    vm.invoke("Creating locator on " + vm, () -> {
+      final String locatorName = "locator" + i;
+      final File logFile = new File("locator-" + i + ".log");
+      final Properties props = new Properties();
+      props.setProperty(NAME, locatorName);
+      props.setProperty(MCAST_PORT, "0");
+      props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
+      props.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR, "true");
+
+      if (locatorPorts.length > 1) {
+        int otherLocatorPort = locatorPorts[(i + 1) % locatorPorts.length];
+        props.setProperty(LOCATORS, "localhost[" + otherLocatorPort + "]");
+      }
+
+      Locator.startLocatorAndDS(locatorPorts[i], logFile, props);
+    });
+  }
+
+  private void waitForSharedConfiguration(final VM vm) {
+    vm.invoke("Waiting for shared configuration", () -> {
+      final InternalLocator locator = InternalLocator.getLocator();
+      await().until(() -> {
+        return locator.isSharedConfigurationRunning();
+      });
+    });
+  }
+
+  private void stopLocator(final VM vm) {
+    vm.invoke("Stopping locator on " + vm, () -> {
+      InternalLocator locator = InternalLocator.getLocator();
+      assertNotNull("No locator found", locator);
+      locator.stop();
+      disconnectAllFromDS();
+    });
+  }
+
+  private void restartCache(final VM vm, final int i, final int[] locatorPorts) {
+    vm.invoke("Creating cache on VM " + i, () -> {
+      disconnectFromDS();
+
+      final Properties props = new Properties();
+      props.setProperty(NAME, "member" + i);
+      props.setProperty(MCAST_PORT, "0");
+      props.setProperty(LOCATORS, getLocatorStr(locatorPorts));
+      props.setProperty(LOG_FILE, "server-" + i + ".log");
+      props.setProperty(USE_CLUSTER_CONFIGURATION, "true");
+      props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
+
+      getSystem(props);
+      getCache();
+    });
+  }
+
+  private String getLocatorStr(final int[] locatorPorts) {
+    return Arrays.stream(locatorPorts).mapToObj(p -> "localhost[" + p + "]").collect(joining(","));
+  }
+
+  private ConditionFactory await() {
+    return Awaitility.await().atMost(2, MINUTES);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationDUnitTest.java
deleted file mode 100644
index b310c50..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationDUnitTest.java
+++ /dev/null
@@ -1,407 +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.configuration;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.DiskStoreFactory;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.distributed.Locator;
-import org.apache.geode.distributed.internal.DM;
-import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.SharedConfiguration;
-import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
-import org.apache.geode.distributed.internal.tcpserver.TcpClient;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.cache.xmlcache.CacheXml;
-import org.apache.geode.management.internal.configuration.domain.Configuration;
-import org.apache.geode.management.internal.configuration.domain.XmlEntity;
-import org.apache.geode.management.internal.configuration.handlers.ConfigurationRequestHandler;
-import org.apache.geode.management.internal.configuration.messages.ConfigurationRequest;
-import org.apache.geode.management.internal.configuration.messages.ConfigurationResponse;
-import org.apache.geode.test.dunit.SerializableCallable;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.WaitCriterion;
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.*;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.Host.getHost;
-import static org.apache.geode.test.dunit.Wait.waitForCriterion;
-
-/**
- * Tests the starting up of shared configuration, installation of
- * {@link ConfigurationRequestHandler}
- */
-@Category(DistributedTest.class)
-public class SharedConfigurationDUnitTest extends JUnit4CacheTestCase {
-
-  private static final String REGION1 = "region1";
-  private static final int TIMEOUT = 10000;
-  private static final int INTERVAL = 500;
-  private static final String DISKSTORENAME = "diskStore1";
-
-  @Override
-  public final void postSetUp() throws Exception {
-    disconnectAllFromDS();
-  }
-
-  @Override
-  public final void postTearDownCacheTestCase() throws Exception {
-    for (int i = 0; i < 4; i++) {
-      getHost(0).getVM(i).invoke(SharedConfigurationTestUtils.cleanupLocator);
-    }
-  }
-
-  @Test
-  public void testGetHostedLocatorsWithSharedConfiguration() throws Exception {
-    final VM locator1Vm = getHost(0).getVM(1);
-    final VM locator2Vm = getHost(0).getVM(2);
-
-    final String testName = getName();
-
-    final int[] ports = getRandomAvailableTCPPorts(3);
-
-    final int locator1Port = ports[0];
-    final String locator1Name = "locator1" + locator1Port;
-
-    locator1Vm.invoke(() -> {
-      final File locatorLogFile = new File(testName + "-locator-" + locator1Port + ".log");
-
-      final Properties locatorProps = new Properties();
-      locatorProps.setProperty(NAME, locator1Name);
-      locatorProps.setProperty(MCAST_PORT, "0");
-      locatorProps.setProperty(LOG_LEVEL, "fine");
-      locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
-
-      try {
-        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port,
-            locatorLogFile, null, locatorProps);
-
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            return locator.isSharedConfigurationRunning();
-          }
-
-          @Override
-          public String description() {
-            return "Waiting for shared configuration to be started";
-          }
-        };
-        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-
-      } catch (IOException e) {
-        fail("Unable to create a locator with a shared configuration", e);
-      }
-
-      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-      InternalDistributedMember me = cache.getMyId();
-      DM dm = cache.getDistributionManager();
-
-      Map<InternalDistributedMember, Collection<String>> hostedLocators = dm.getAllHostedLocators();
-      assertFalse(hostedLocators.isEmpty());
-
-      Map<InternalDistributedMember, Collection<String>> hostedLocatorsWithSharedConfiguration =
-          dm.getAllHostedLocatorsWithSharedConfiguration();
-      assertFalse(hostedLocatorsWithSharedConfiguration.isEmpty());
-
-      assertNotNull(hostedLocators.get(me));
-      assertNotNull(hostedLocatorsWithSharedConfiguration.get(me));
-      return null;
-    });
-
-    final int locator2Port = ports[1];
-    final String locator2Name = "locator2" + locator2Port;
-
-    locator2Vm.invoke(() -> {
-      final File locatorLogFile = new File(testName + "-locator-" + locator2Port + ".log");
-
-      final Properties locatorProps = new Properties();
-      locatorProps.setProperty(NAME, locator2Name);
-      locatorProps.setProperty(MCAST_PORT, "0");
-      locatorProps.setProperty(LOG_LEVEL, "fine");
-      locatorProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]");
-      locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
-
-      final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port,
-          locatorLogFile, null, locatorProps);
-
-      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-      InternalDistributedMember me = cache.getMyId();
-      DM dm = cache.getDistributionManager();
-
-      Map<InternalDistributedMember, Collection<String>> hostedLocators = dm.getAllHostedLocators();
-      assertFalse(hostedLocators.isEmpty());
-
-      Map<InternalDistributedMember, Collection<String>> hostedLocatorsWithSharedConfiguration =
-          dm.getAllHostedLocatorsWithSharedConfiguration();
-      assertFalse(hostedLocatorsWithSharedConfiguration.isEmpty());
-      assertNotNull(hostedLocators.get(me));
-      assertNull(hostedLocatorsWithSharedConfiguration.get(me));
-      assertTrue(hostedLocators.size() == 2);
-      assertTrue(hostedLocatorsWithSharedConfiguration.size() == 1);
-
-      Set<InternalDistributedMember> locatorsWithSharedConfig =
-          hostedLocatorsWithSharedConfiguration.keySet();
-      Set<String> locatorsWithSharedConfigNames = new HashSet<String>();
-
-      for (InternalDistributedMember locatorWithSharedConfig : locatorsWithSharedConfig) {
-        locatorsWithSharedConfigNames.add(locatorWithSharedConfig.getName());
-      }
-      assertTrue(locatorsWithSharedConfigNames.contains(locator1Name));
-
-      return null;
-    });
-
-    locator1Vm.invoke(() -> {
-      InternalLocator locator = (InternalLocator) Locator.getLocator();
-      SharedConfiguration sharedConfig = locator.getSharedConfiguration();
-      sharedConfig.destroySharedConfiguration();
-      locator.stop();
-      return null;
-    });
-
-    locator2Vm.invoke(() -> {
-      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-      InternalDistributedMember me = cache.getMyId();
-      DM dm = cache.getDistributionManager();
-      Map<InternalDistributedMember, Collection<String>> hostedLocators = dm.getAllHostedLocators();
-      assertFalse(hostedLocators.isEmpty());
-      Map<InternalDistributedMember, Collection<String>> hostedLocatorsWithSharedConfiguration =
-          dm.getAllHostedLocatorsWithSharedConfiguration();
-      assertTrue(hostedLocatorsWithSharedConfiguration.isEmpty());
-      assertNotNull(hostedLocators.get(me));
-      assertNull(hostedLocatorsWithSharedConfiguration.get(me));
-      assertTrue(hostedLocators.size() == 1);
-      assertTrue(hostedLocatorsWithSharedConfiguration.size() == 0);
-      return null;
-    });
-  }
-
-  @Test
-  public void testSharedConfigurationService() throws Exception {
-    // Start the Locator and wait for shared configuration to be available
-    final String testGroup = "G1";
-    final String clusterLogLevel = "error";
-    final String groupLogLevel = "fine";
-
-    final String testName = getName();
-
-    final VM locator1Vm = getHost(0).getVM(1);
-    final VM dataMemberVm = getHost(0).getVM(2);
-    final VM locator2Vm = getHost(0).getVM(3);
-
-    final int[] ports = getRandomAvailableTCPPorts(3);
-    final int locator1Port = ports[0];
-
-    locator1Vm.invoke(() -> {
-      final File locatorLogFile = new File(testName + "-locator-" + locator1Port + ".log");
-
-      final Properties locatorProps = new Properties();
-      locatorProps.setProperty(NAME, "Locator1");
-      locatorProps.setProperty(MCAST_PORT, "0");
-      locatorProps.setProperty(LOG_LEVEL, "info");
-      locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
-
-      try {
-        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port,
-            locatorLogFile, null, locatorProps);
-
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            return locator.isSharedConfigurationRunning();
-          }
-
-          @Override
-          public String description() {
-            return "Waiting for shared configuration to be started";
-          }
-        };
-        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-
-      } catch (IOException e) {
-        fail("Unable to create a locator with a shared configuration", e);
-      }
-    });
-
-    XmlEntity xmlEntity = dataMemberVm.invoke(() -> {
-      Properties localProps = new Properties();
-      localProps.setProperty(MCAST_PORT, "0");
-      localProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]");
-      localProps.setProperty(GROUPS, testGroup);
-
-      getSystem(localProps);
-      Cache cache = getCache();
-      assertNotNull(cache);
-
-      DiskStoreFactory dsFactory = cache.createDiskStoreFactory();
-      File dsDir = new File("dsDir");
-      if (!dsDir.exists()) {
-        dsDir.mkdir();
-      }
-      dsFactory.setDiskDirs(new File[] {dsDir});
-      dsFactory.create(DISKSTORENAME);
-
-      RegionFactory regionFactory = getCache().createRegionFactory(RegionShortcut.REPLICATE);
-      regionFactory.create(REGION1);
-      return new XmlEntity(CacheXml.REGION, "name", REGION1);
-    });
-
-    locator1Vm.invoke(() -> {
-      SharedConfiguration sc = InternalLocator.getLocator().getSharedConfiguration();
-      sc.addXmlEntity(xmlEntity, new String[] {testGroup});
-
-      // Modify property and cache attributes
-      Properties clusterProperties = new Properties();
-      clusterProperties.setProperty(LOG_LEVEL, clusterLogLevel);
-      XmlEntity cacheEntity = XmlEntity.builder().withType(CacheXml.CACHE).build();
-      Map<String, String> cacheAttributes = new HashMap<String, String>();
-      cacheAttributes.put(CacheXml.COPY_ON_READ, "true");
-
-      sc.modifyXmlAndProperties(clusterProperties, cacheEntity, null);
-
-      clusterProperties.setProperty(LOG_LEVEL, groupLogLevel);
-      sc.modifyXmlAndProperties(clusterProperties, cacheEntity, new String[] {testGroup});
-
-      // Add a jar
-      byte[][] jarBytes = new byte[1][];
-      jarBytes[0] = "Hello".getBytes();
-      assertTrue(sc.addJarsToThisLocator(new String[] {"foo.jar"}, jarBytes, null));
-
-      // Add a jar for the group
-      jarBytes = new byte[1][];
-      jarBytes[0] = "Hello".getBytes();
-      assertTrue(
-          sc.addJarsToThisLocator(new String[] {"bar.jar"}, jarBytes, new String[] {testGroup}));
-    });
-
-    final int locator2Port = ports[1];
-
-    // Create another locator in VM2
-    locator2Vm.invoke(() -> {
-      final File locatorLogFile = new File(testName + "-locator-" + locator2Port + ".log");
-
-      final Properties locatorProps = new Properties();
-      locatorProps.setProperty(NAME, "Locator2");
-      locatorProps.setProperty(MCAST_PORT, "0");
-      locatorProps.setProperty(LOG_LEVEL, "info");
-      locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
-      locatorProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]");
-
-      try {
-        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port,
-            locatorLogFile, null, locatorProps);
-
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            return locator.isSharedConfigurationRunning();
-          }
-
-          @Override
-          public String description() {
-            return "Waiting for shared configuration to be started";
-          }
-        };
-        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-
-      } catch (IOException e) {
-        fail("Unable to create a locator with a shared configuration", e);
-      }
-
-      InternalLocator locator = (InternalLocator) Locator.getLocator();
-      SharedConfiguration sharedConfig = locator.getSharedConfiguration();
-      Map<String, Configuration> entireConfiguration = sharedConfig.getEntireConfiguration();
-      Configuration clusterConfig = entireConfiguration.get(SharedConfiguration.CLUSTER_CONFIG);
-      assertNotNull(clusterConfig);
-      assertNotNull(clusterConfig.getJarNames());
-      assertTrue(clusterConfig.getJarNames().contains("foo.jar"));
-      assertTrue(
-          clusterConfig.getGemfireProperties().getProperty(LOG_LEVEL).equals(clusterLogLevel));
-      assertNotNull(clusterConfig.getCacheXmlContent());
-
-      Configuration testGroupConfiguration = entireConfiguration.get(testGroup);
-      assertNotNull(testGroupConfiguration);
-      assertNotNull(testGroupConfiguration.getJarNames());
-      assertTrue(testGroupConfiguration.getJarNames().contains("bar.jar"));
-      assertTrue(testGroupConfiguration.getGemfireProperties().getProperty(LOG_LEVEL)
-          .equals(groupLogLevel));
-      assertNotNull(testGroupConfiguration.getCacheXmlContent());
-      assertTrue(testGroupConfiguration.getCacheXmlContent().contains(REGION1));
-
-      Map<String, byte[]> jarData =
-          sharedConfig.getAllJarsFromThisLocator(entireConfiguration.keySet());
-      String[] jarNames = jarData.keySet().stream().toArray(String[]::new);
-      byte[][] jarBytes = jarData.values().toArray(new byte[jarNames.length][]);
-
-      assertNotNull(jarNames);
-      assertNotNull(jarBytes);
-
-      sharedConfig.deleteXmlEntity(new XmlEntity(CacheXml.REGION, "name", REGION1),
-          new String[] {testGroup});
-      sharedConfig.removeJars(new String[] {"foo.jar"}, null);
-      sharedConfig.removeJars(null, null);
-    });
-
-    dataMemberVm.invoke(() -> {
-      Set<String> groups = new HashSet<String>();
-      groups.add(testGroup);
-      ConfigurationRequest configRequest = new ConfigurationRequest(groups);
-      ConfigurationResponse configResponse = (ConfigurationResponse) new TcpClient()
-          .requestToServer(InetAddress.getByName("localhost"), locator2Port, configRequest, 1000);
-      assertNotNull(configResponse);
-
-      Map<String, Configuration> requestedConfiguration =
-          configResponse.getRequestedConfiguration();
-      Configuration clusterConfiguration =
-          requestedConfiguration.get(SharedConfiguration.CLUSTER_CONFIG);
-      assertNotNull(clusterConfiguration);
-      assertTrue(configResponse.getJarNames().length == 0);
-      assertTrue(configResponse.getJars().length == 0);
-      assertTrue(clusterConfiguration.getJarNames().isEmpty());
-      assertTrue(clusterConfiguration.getGemfireProperties().getProperty(LOG_LEVEL)
-          .equals(clusterLogLevel));
-
-      Configuration testGroupConfiguration = requestedConfiguration.get(testGroup);
-      assertNotNull(testGroupConfiguration);
-      assertFalse(testGroupConfiguration.getCacheXmlContent().contains(REGION1));
-      assertTrue(testGroupConfiguration.getJarNames().isEmpty());
-      assertTrue(testGroupConfiguration.getGemfireProperties().getProperty(LOG_LEVEL)
-          .equals(groupLogLevel));
-
-      GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
-      Map<InternalDistributedMember, Collection<String>> locatorsWithSharedConfiguration =
-          cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration();
-      assertFalse(locatorsWithSharedConfiguration.isEmpty());
-      assertTrue(locatorsWithSharedConfiguration.size() == 2);
-      Set<InternalDistributedMember> locatorMembers = locatorsWithSharedConfiguration.keySet();
-      for (InternalDistributedMember locatorMember : locatorMembers) {
-        System.out.println(locatorMember);
-      }
-      return null;
-    });
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationTestUtils.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationTestUtils.java
index 80c510a..eddaad2 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationTestUtils.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationTestUtils.java
@@ -14,8 +14,8 @@
  */
 package org.apache.geode.management.internal.configuration;
 
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.SharedConfiguration;
 import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.internal.JUnit3DistributedTestCase;
 
@@ -26,7 +26,7 @@ public class SharedConfigurationTestUtils {
     public void run() {
       InternalLocator locator = InternalLocator.getLocator();
       if (locator != null) {
-        SharedConfiguration sharedConfig = locator.getSharedConfiguration();
+        ClusterConfigurationService sharedConfig = locator.getSharedConfiguration();
         if (sharedConfig != null) {
           sharedConfig.destroySharedConfiguration();
         }

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
deleted file mode 100644
index a434f05..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
+++ /dev/null
@@ -1,334 +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.configuration;
-
-import static java.util.concurrent.TimeUnit.MINUTES;
-import static java.util.stream.Collectors.joining;
-import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
-import static org.apache.geode.distributed.ConfigurationProperties.LOAD_CLUSTER_CONFIGURATION_FROM_DIR;
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
-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.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
-import static org.apache.geode.test.dunit.Host.getHost;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import com.jayway.awaitility.Awaitility;
-import com.jayway.awaitility.core.ConditionFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.distributed.Locator;
-import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.SharedConfiguration;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
-import org.apache.geode.util.test.TestUtil;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.Arrays;
-import java.util.Properties;
-
-@Category({DistributedTest.class, FlakyTest.class}) // GEODE-1165
-public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
-
-  @Override
-  public final void preTearDownCacheTestCase() throws Exception {
-    for (int i = 0; i < 2; i++) {
-      VM vm = getHost(0).getVM(i);
-      vm.invoke("Removing shared configuration", () -> {
-        InternalLocator locator = InternalLocator.getLocator();
-        if (locator == null) {
-          return;
-        }
-
-        SharedConfiguration sharedConfig = locator.getSharedConfiguration();
-        if (sharedConfig != null) {
-          sharedConfig.destroySharedConfiguration();
-        }
-      });
-    }
-  }
-
-  @Test
-  public void basicClusterConfigDirWithOneLocator() throws Exception {
-    final int[] ports = getRandomAvailableTCPPorts(1);
-    final int locatorCount = ports.length;
-
-    for (int i = 0; i < locatorCount; i++) {
-      VM vm = getHost(0).getVM(i);
-      copyClusterXml(vm, "cluster-region.xml");
-      startLocator(vm, i, ports);
-      waitForSharedConfiguration(vm);
-    }
-
-    for (int i = 2; i < 4; i++) {
-      VM vm = getHost(0).getVM(i);
-      restartCache(vm, i, ports);
-
-      vm.invoke("Checking for region presence", () -> {
-        await().until(() -> getRootRegion("newReplicatedRegion") != null);
-      });
-    }
-  }
-
-  @Test
-  public void basicClusterConfigDirWithTwoLocators() throws Exception {
-    final int[] ports = getRandomAvailableTCPPorts(2);
-    final int locatorCount = ports.length;
-
-    for (int i = 0; i < locatorCount; i++) {
-      VM vm = getHost(0).getVM(i);
-      copyClusterXml(vm, "cluster-region.xml");
-      startLocator(vm, i, ports);
-      waitForSharedConfiguration(vm);
-    }
-
-    for (int i = 2; i < 4; i++) {
-      VM vm = getHost(0).getVM(i);
-      restartCache(vm, i, ports);
-
-      vm.invoke("Checking for region presence", () -> {
-        await().until(() -> getRootRegion("newReplicatedRegion") != null);
-      });
-    }
-  }
-
-  @Test
-  public void updateClusterConfigDirWithTwoLocatorsNoRollingServerRestart() throws Exception {
-    final int[] ports = getRandomAvailableTCPPorts(2);
-    final int locatorCount = ports.length;
-
-    for (int i = 0; i < locatorCount; i++) {
-      VM vm = getHost(0).getVM(i);
-      copyClusterXml(vm, "cluster-empty.xml");
-      startLocator(vm, i, ports);
-      waitForSharedConfiguration(vm);
-    }
-
-    for (int i = 2; i < 4; i++) {
-      VM vm = getHost(0).getVM(i);
-      restartCache(vm, i, ports);
-
-      vm.invoke("Checking for region absence", () -> {
-        Region r = getRootRegion("newReplicatedRegion");
-        assertNull("Region does exist", r);
-      });
-    }
-
-    // Shut down the locators in reverse order to how we will start them up in the next step.
-    // Unless we start them asynchronously, the older one will want to wait for a new diskstore
-    // to become available and will time out.
-    for (int i = locatorCount; i > 0; i--) {
-      VM vm = getHost(0).getVM(i - 1);
-      stopLocator(vm);
-    }
-
-    for (int i = 0; i < locatorCount; i++) {
-      VM vm = getHost(0).getVM(i);
-      copyClusterXml(vm, "cluster-region.xml");
-      startLocator(vm, i, ports);
-      waitForSharedConfiguration(vm);
-    }
-
-    for (int i = 2; i < 4; i++) {
-      VM vm = getHost(0).getVM(i);
-      vm.invoke(() -> disconnectFromDS());
-    }
-
-    for (int i = 2; i < 4; i++) {
-      VM vm = getHost(0).getVM(i);
-      restartCache(vm, i, ports);
-
-      vm.invoke("Checking for region presence", () -> {
-        await().until(() -> getRootRegion("newReplicatedRegion") != null);
-      });
-    }
-  }
-
-  @Test
-  public void updateClusterConfigDirWithTwoLocatorsAndRollingServerRestart() throws Exception {
-    final int[] ports = getRandomAvailableTCPPorts(2);
-    final int locatorCount = ports.length;
-
-    for (int i = 0; i < locatorCount; i++) {
-      VM vm = getHost(0).getVM(i);
-      copyClusterXml(vm, "cluster-empty.xml");
-      startLocator(vm, i, ports);
-      waitForSharedConfiguration(vm);
-    }
-
-    for (int i = 2; i < 4; i++) {
-      VM vm = getHost(0).getVM(i);
-      restartCache(vm, i, ports);
-
-      vm.invoke("Checking for region absence", () -> {
-        Region r = getRootRegion("newReplicatedRegion");
-        assertNull("Region does exist", r);
-      });
-    }
-
-    // Shut down the locators in reverse order to how we will start them up in the next step.
-    // Unless we start them asynchronously, the older one will want to wait for a new diskstore
-    // to become available and will time out.
-    for (int i = locatorCount; i > 0; i--) {
-      VM vm = getHost(0).getVM(i - 1);
-      stopLocator(vm);
-    }
-
-    for (int i = 0; i < locatorCount; i++) {
-      VM vm = getHost(0).getVM(i);
-      copyClusterXml(vm, "cluster-region.xml");
-      startLocator(vm, i, ports);
-      waitForSharedConfiguration(vm);
-    }
-
-    for (int i = 2; i < 4; i++) {
-      VM vm = getHost(0).getVM(i);
-      restartCache(vm, i, ports);
-
-      vm.invoke("Checking for region presence", () -> {
-        await().until(() -> getRootRegion("newReplicatedRegion") != null);
-      });
-    }
-  }
-
-  @Test
-  public void updateClusterConfigDirWithTwoLocatorsRollingRestartAndRollingServerRestart()
-      throws Exception {
-    final int[] ports = getRandomAvailableTCPPorts(2);
-    final int locatorCount = ports.length;
-
-    for (int i = 0; i < locatorCount; i++) {
-      VM vm = getHost(0).getVM(i);
-      copyClusterXml(vm, "cluster-empty.xml");
-      startLocator(vm, i, ports);
-      waitForSharedConfiguration(vm);
-    }
-
-    for (int i = 2; i < 4; i++) {
-      VM vm = getHost(0).getVM(i);
-      restartCache(vm, i, ports);
-
-      vm.invoke("Checking for region absence", () -> {
-        Region r = getRootRegion("newReplicatedRegion");
-        assertNull("Region does exist", r);
-      });
-    }
-
-    // Roll the locators
-    for (int i = locatorCount - 1; i >= 0; i--) {
-      VM vm = getHost(0).getVM(i);
-      stopLocator(vm);
-      copyClusterXml(vm, "cluster-region.xml");
-      startLocator(vm, i, ports);
-      waitForSharedConfiguration(vm);
-    }
-
-    // Roll the servers
-    for (int i = 2; i < 4; i++) {
-      VM vm = getHost(0).getVM(i);
-      restartCache(vm, i, ports);
-
-      vm.invoke("Checking for region presence", () -> {
-        await().until(() -> getRootRegion("newReplicatedRegion") != null);
-      });
-    }
-  }
-
-  private void copyClusterXml(final VM vm, final String clusterXml) {
-    vm.invoke("Copying new cluster.xml from " + clusterXml, () -> {
-      String clusterXmlPath =
-          TestUtil.getResourcePath(SharedConfigurationUsingDirDUnitTest.class, clusterXml);
-      InputStream cacheXml = new FileInputStream(clusterXmlPath);
-      assertNotNull("Could not create InputStream from " + clusterXmlPath, cacheXml);
-      Files.createDirectories(Paths.get("cluster_config", "cluster"));
-      Files.copy(cacheXml, Paths.get("cluster_config", "cluster", "cluster.xml"),
-          StandardCopyOption.REPLACE_EXISTING);
-    });
-  }
-
-  private void startLocator(final VM vm, final int i, final int[] locatorPorts) {
-    vm.invoke("Creating locator on " + vm, () -> {
-      final String locatorName = "locator" + i;
-      final File logFile = new File("locator-" + i + ".log");
-      final Properties props = new Properties();
-      props.setProperty(NAME, locatorName);
-      props.setProperty(MCAST_PORT, "0");
-      props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
-      props.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR, "true");
-
-      if (locatorPorts.length > 1) {
-        int otherLocatorPort = locatorPorts[(i + 1) % locatorPorts.length];
-        props.setProperty(LOCATORS, "localhost[" + otherLocatorPort + "]");
-      }
-
-      Locator.startLocatorAndDS(locatorPorts[i], logFile, props);
-    });
-  }
-
-  private void waitForSharedConfiguration(final VM vm) {
-    vm.invoke("Waiting for shared configuration", () -> {
-      final InternalLocator locator = InternalLocator.getLocator();
-      await().until(() -> {
-        return locator.isSharedConfigurationRunning();
-      });
-    });
-  }
-
-  private void stopLocator(final VM vm) {
-    vm.invoke("Stopping locator on " + vm, () -> {
-      InternalLocator locator = InternalLocator.getLocator();
-      assertNotNull("No locator found", locator);
-      locator.stop();
-      disconnectAllFromDS();
-    });
-  }
-
-  private void restartCache(final VM vm, final int i, final int[] locatorPorts) {
-    vm.invoke("Creating cache on VM " + i, () -> {
-      disconnectFromDS();
-
-      final Properties props = new Properties();
-      props.setProperty(NAME, "member" + i);
-      props.setProperty(MCAST_PORT, "0");
-      props.setProperty(LOCATORS, getLocatorStr(locatorPorts));
-      props.setProperty(LOG_FILE, "server-" + i + ".log");
-      props.setProperty(USE_CLUSTER_CONFIGURATION, "true");
-      props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
-
-      getSystem(props);
-      getCache();
-    });
-  }
-
-  private String getLocatorStr(final int[] locatorPorts) {
-    return Arrays.stream(locatorPorts).mapToObj(p -> "localhost[" + p + "]").collect(joining(","));
-  }
-
-  private ConditionFactory await() {
-    return Awaitility.await().atMost(2, MINUTES);
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/e79e0103/geode-core/src/test/java/org/apache/geode/management/internal/configuration/utils/XmlUtilsAddNewNodeJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/utils/XmlUtilsAddNewNodeJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/utils/XmlUtilsAddNewNodeJUnitTest.java
index 66406a7..d7204fb 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/utils/XmlUtilsAddNewNodeJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/utils/XmlUtilsAddNewNodeJUnitTest.java
@@ -16,7 +16,7 @@ package org.apache.geode.management.internal.configuration.utils;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.distributed.internal.SharedConfiguration;
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.internal.cache.extension.Extension;
 import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
@@ -45,9 +45,9 @@ import static org.junit.Assert.assertEquals;
 
 /**
  * Unit tests for {@link XmlUtils#addNewNode(Document, XmlEntity)} and
- * {@link XmlUtils#deleteNode(Document, XmlEntity)}. Simulates the {@link SharedConfiguration}
- * method of extracting {@link XmlEntity} from the new config and applying it to the current shared
- * config.
+ * {@link XmlUtils#deleteNode(Document, XmlEntity)}. Simulates the
+ * {@link ClusterConfigurationService} method of extracting {@link XmlEntity} from the new config
+ * and applying it to the current shared config.
  * 
  *
  * @since GemFire 8.1


Mime
View raw message