geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [1/3] geode git commit: GEODE-2197: refactor cluster config
Date Tue, 03 Jan 2017 21:02:27 GMT
Repository: geode
Updated Branches:
  refs/heads/develop 017db36d2 -> 30891423d


GEODE-2197: refactor cluster config

 * not to save the xml, properties in the file system.
 * the cc region's change listener is to download the jar from other locators


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

Branch: refs/heads/develop
Commit: 07ed46544634f4165c1c5f1792061f0a556655d8
Parents: 017db36
Author: Jared Stewart <jstewart@pivotal.io>
Authored: Thu Dec 15 10:36:08 2016 -0800
Committer: Jinmei Liao <jiliao@pivotal.io>
Committed: Tue Jan 3 12:55:44 2017 -0800

----------------------------------------------------------------------
 .../internal/SharedConfiguration.java           | 385 ++++++-------------
 .../cache/ClusterConfigurationLoader.java       |  28 --
 .../internal/cli/commands/DeployCommands.java   |   3 +-
 ...ExportImportSharedConfigurationCommands.java | 147 +++----
 .../ExportSharedConfigurationFunction.java      |  48 +--
 ...ortSharedConfigurationArtifactsFunction.java |  10 +-
 .../SharedConfigurationWriter.java              |  81 ++--
 .../callbacks/ConfigurationChangeListener.java  |  71 +++-
 .../configuration/functions/AddJarFunction.java |   2 +-
 .../functions/GetAllJarsFunction.java           |  63 ---
 .../functions/UploadJarFunction.java            |  65 ++++
 .../ConnectToLocatorSSLDUnitTest.java           |   2 +-
 .../internal/configuration/ClusterConfig.java   |   8 +-
 .../configuration/ClusterConfigBaseTest.java    |   6 +-
 .../ClusterConfigImportDUnitTest.java           |   7 +-
 .../internal/configuration/ConfigGroup.java     |   2 -
 .../SharedConfigurationDUnitTest.java           |   6 +-
 .../dunit/rules/GfshShellConnectionRule.java    |   8 +
 18 files changed, 393 insertions(+), 549 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/distributed/internal/SharedConfiguration.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/SharedConfiguration.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/SharedConfiguration.java
index 3119823..3a2eb2d 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/SharedConfiguration.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/SharedConfiguration.java
@@ -43,18 +43,15 @@ import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.internal.cli.CliUtil;
-import org.apache.geode.management.internal.cli.functions.ImportSharedConfigurationArtifactsFunction;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.configuration.callbacks.ConfigurationChangeListener;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
 import org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
-import org.apache.geode.management.internal.configuration.functions.GetAllJarsFunction;
+import org.apache.geode.management.internal.configuration.functions.UploadJarFunction;
 import org.apache.geode.management.internal.configuration.messages.ConfigurationRequest;
 import org.apache.geode.management.internal.configuration.messages.ConfigurationResponse;
 import org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse;
 import org.apache.geode.management.internal.configuration.utils.XmlUtils;
-import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.logging.log4j.Logger;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
@@ -67,14 +64,15 @@ import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.sql.Timestamp;
+import java.nio.file.Path;
 import java.text.SimpleDateFormat;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
+import java.util.Objects;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
@@ -114,13 +112,12 @@ public class SharedConfiguration {
 
   private final String configDirPath;
   private final String configDiskDirName;
-  private final String configDiskDirPath;;
+  private final String configDiskDirPath;
 
   private final Set<PersistentMemberPattern> newerSharedConfigurationLocatorInfo =
       new HashSet<PersistentMemberPattern>();
   private final AtomicReference<SharedConfigurationStatus> status =
       new AtomicReference<SharedConfigurationStatus>();
-  private static final GetAllJarsFunction getAllJarsFunction = new GetAllJarsFunction();
   private static final JarFileFilter jarFileFilter = new JarFileFilter();
 
   private GemFireCacheImpl cache;
@@ -166,14 +163,13 @@ public class SharedConfiguration {
 
   /**
    * Add jar information into the shared configuration and save the jars in the file system
-   * 
    * @return true on success
    */
-  public boolean addJars(String[] jarNames, byte[][] jarBytes, String[] groups) {
+  public boolean addJarsToThisLocator(String[] jarNames, byte[][] jarBytes, String[] groups) {
     boolean success = true;
     try {
       if (groups == null) {
-        groups = new String[] {SharedConfiguration.CLUSTER_CONFIG};
+        groups = new String[]{SharedConfiguration.CLUSTER_CONFIG};
       }
       Region<String, Configuration> configRegion = getConfigurationRegion();
       for (String group : groups) {
@@ -181,12 +177,15 @@ public class SharedConfiguration {
 
         if (configuration == null) {
           configuration = new Configuration(group);
-          writeConfig(configuration);
+          createConfigDirIfNecessary(group);
         }
-        configuration.addJarNames(jarNames);
-        configRegion.put(group, configuration);
         String groupDir = FilenameUtils.concat(configDirPath, group);
         writeJarFiles(groupDir, jarNames, jarBytes);
+
+        // update the record after writing the jars to the file system, since the listener
+        // will need the jars on file to upload to other locators.
+        configuration.addJarNames(jarNames);
+        configRegion.put(group, configuration);
       }
     } catch (Exception e) {
       success = false;
@@ -201,7 +200,7 @@ public class SharedConfiguration {
   public void addXmlEntity(XmlEntity xmlEntity, String[] groups) throws Exception {
     Region<String, Configuration> configRegion = getConfigurationRegion();
     if (groups == null || groups.length == 0) {
-      groups = new String[] {SharedConfiguration.CLUSTER_CONFIG};
+      groups = new String[]{SharedConfiguration.CLUSTER_CONFIG};
     }
     for (String group : groups) {
       Configuration configuration = (Configuration) configRegion.get(group);
@@ -219,7 +218,7 @@ public class SharedConfiguration {
       XmlUtils.addNewNode(doc, xmlEntity);
       configuration.setCacheXmlContent(XmlUtils.prettyXml(doc));
       configRegion.put(group, configuration);
-      writeConfig(configuration);
+//      writeConfig(configuration);
     }
   }
 
@@ -232,9 +231,8 @@ public class SharedConfiguration {
 
   /**
    * Creates the shared configuration service
-   * 
    * @param loadSharedConfigFromDir when set to true, loads the configuration from the share_config
-   *        directory
+   * directory
    */
   public void initSharedConfiguration(boolean loadSharedConfigFromDir) throws Exception {
     status.set(SharedConfigurationStatus.STARTED);
@@ -247,34 +245,9 @@ public class SharedConfiguration {
             SharedConfiguration.CLUSTER_CONFIG_ARTIFACTS_DIR_NAME);
 
         Map<String, Configuration> sharedConfigMap = this.readSharedConfigurationFromDisk();
-        final DM dm = cache.getDistributedSystem().getDistributionManager();
-
-        if (dm.getNormalDistributionManagerIds().isEmpty()) {
-          Set<DistributedMember> locatorsWithSC = new HashSet<DistributedMember>(
-              dm.getAllHostedLocatorsWithSharedConfiguration().keySet());
-
-          // Send the config to other locators which host the shared configuration.
-          if (!locatorsWithSC.isEmpty()) {
-            final ImportSharedConfigurationArtifactsFunction fn =
-                new ImportSharedConfigurationArtifactsFunction();
-            final Date date = new Date();
-            String zipFileName = CliStrings.format(CliStrings.EXPORT_SHARED_CONFIG__FILE__NAME,
-                new Timestamp(date.getTime()).toString());
-            try {
-              ZipUtils.zip(getSharedConfigurationDirPath(), zipFileName);
-              File zipFile = new File(zipFileName);
-              byte[] zipBytes = FileUtils.readFileToByteArray(zipFile);
-              Object[] args = new Object[] {zipFileName, zipBytes};
-              // Make sure we wait for the result. The fn also does a clear on the config
-              // region so there is a race with the clear below.
-              CliUtil.executeFunction(fn, args, locatorsWithSC).getResult();
-            } catch (Exception e) {
-              logger.error(e.getMessage(), e);
-            }
-          }
-        }
         // Clear the configuration region and load the configuration read from the 'shared_config'
         // directory
+        // on region entry create/update, it will upload the jars to all other locators
         configRegion.clear();
         configRegion.putAll(sharedConfigMap);
       } finally {
@@ -284,21 +257,9 @@ public class SharedConfiguration {
       // Write out the existing configuration into the 'shared_config' directory
       // And get deployed jars from other locators.
       lockSharedConfiguration();
-      putSecurityPropsIntoClusterConfig(configRegion);
-
       try {
-        Set<Entry<String, Configuration>> configEntries = configRegion.entrySet();
-
-        for (Entry<String, Configuration> configEntry : configEntries) {
-          Configuration configuration = configEntry.getValue();
-          try {
-            this.writeConfig(configuration);
-          } catch (Exception e) {
-            logger.info(e.getMessage(), e);
-          }
-        }
-        logger.info("Completed writing the shared configuration to 'cluster_config' directory");
-        this.getAllJarsFromOtherLocators();
+        // on region entry create/update, it should download missing jars from other locators
+        putSecurityPropsIntoClusterConfig(configRegion);
       } finally {
         unlockSharedConfiguration();
       }
@@ -348,12 +309,11 @@ public class SharedConfiguration {
             configResponse.addConfiguration(configuration);
           }
 
-          Object[] jars = getAllJars(groups);
-          if (jars != null) {
-            String[] jarNames = (String[]) jars[0];
-            byte[][] jarBytes = (byte[][]) jars[1];
-            configResponse.addJarsToBeDeployed(jarNames, jarBytes);
-          }
+          Map<String, byte[]> jarNamesToJarBytes = getAllJarsFromThisLocator(groups);
+          String[] jarNames = jarNamesToJarBytes.keySet().stream().toArray(String[]::new);
+          byte[][] jarBytes = jarNamesToJarBytes.values().toArray(new byte[jarNames.length][]);
+
+          configResponse.addJarsToBeDeployed(jarNames, jarBytes);
           configResponse.setFailedToGetSharedConfig(false);
           return configResponse;
         }
@@ -363,16 +323,14 @@ public class SharedConfiguration {
 
     }
     configResponse.setFailedToGetSharedConfig(true);
-
     return configResponse;
   }
 
   /**
    * Create a response containing the status of the Shared configuration and information about other
    * locators containing newer shared configuration data (if at all)
-   * 
-   * @return {@link SharedConfigurationStatusResponse} containing the
-   *         {@link SharedConfigurationStatus}
+   * @return {@link SharedConfigurationStatusResponse} containing the {@link
+   * SharedConfigurationStatus}
    */
   public SharedConfigurationStatusResponse createStatusResponse() {
     SharedConfigurationStatusResponse response = new SharedConfigurationStatusResponse();
@@ -400,7 +358,7 @@ public class SharedConfiguration {
           XmlUtils.deleteNode(doc, xmlEntity);
           configuration.setCacheXmlContent(XmlUtils.prettyXml(doc));
           configRegion.put(group, configuration);
-          writeConfig(configuration);
+          //writeConfig(configuration);
         }
       }
     }
@@ -436,7 +394,7 @@ public class SharedConfiguration {
       // Change the xml content of the configuration and put it the config region
       configuration.setCacheXmlContent(XmlUtils.prettyXml(doc));
       configRegion.put(group, configuration);
-      writeConfig(configuration);
+      //writeConfig(configuration);
     }
   }
 
@@ -463,47 +421,42 @@ public class SharedConfiguration {
     }
   }
 
-  public Object[] getAllJars(Set<String> groups) throws Exception {
-    Set<String> jarsAdded = new HashSet<String>();
-    Object[] jars = new Object[2];
+  public byte[] getJarBytesFromThisLocator(String group, String jarName) throws Exception {
+    Configuration configuration = getConfiguration(group);
 
-    for (String group : groups) {
-      Configuration configuration = getConfiguration(group);
-      if (configuration != null) {
-        jarsAdded.addAll(configuration.getJarNames());
-      }
+    //TODO: Should we check  like this, or just check jar.exists below()?
+    if (configuration == null || !configuration.getJarNames().contains(jarName)) {
+      return null;
     }
-    int numJars = jarsAdded.size();
-    jarsAdded.clear();
 
-    if (numJars > 0) {
-      String[] jarNames = new String[numJars];
-      byte[][] jarBytes = new byte[numJars][];
-      int ctr = 0;
+    File jar = getPathToJarOnThisLocator(group, jarName).toFile();
+    return FileUtils.readFileToByteArray(jar);
+  }
 
-      for (String group : groups) {
-        Configuration configuration = getConfiguration(group);
-        if (configuration != null) {
-          Set<String> jarNameSet = configuration.getJarNames();
-          for (String jarName : jarNameSet) {
-            String groupDirPath = FilenameUtils.concat(configDirPath, group);
-            if (!jarsAdded.contains(jarName)) {
-              String jarFilePath = FilenameUtils.concat(groupDirPath, jarName);
-              jarNames[ctr] = jarName;
-              jarBytes[ctr] = FileUtils.readFileToByteArray(new File(jarFilePath));
-              ctr++;
-            }
-          }
-        }
+  public Path getPathToJarOnThisLocator(String groupName, String jarName) {
+    return new File(configDirPath).toPath().resolve(groupName).resolve(jarName);
+  }
+
+  public Map<String, byte[]> getAllJarsFromThisLocator(Set<String> groups) throws Exception {
+    Map<String, byte[]> jarNamesToJarBytes = new HashMap<>();
+
+    for (String group : groups) {
+      Configuration groupConfig = getConfiguration(group);
+      if (groupConfig == null) {
+        break;
       }
 
-      jars[0] = jarNames;
-      jars[1] = jarBytes;
+      Set<String> jars = groupConfig.getJarNames();
+      for (String jar : jars) {
+        byte[] jarBytes = getJarBytesFromThisLocator(group, jar);
+        jarNamesToJarBytes.put(jar, jarBytes);
+      }
     }
-    return jars;
+
+    return jarNamesToJarBytes;
   }
 
-  public Configuration getConfiguration(String groupName) throws Exception {
+  public Configuration getConfiguration(String groupName) {
     Configuration configuration = getConfigurationRegion().get(groupName);
     return configuration;
   }
@@ -515,7 +468,6 @@ public class SharedConfiguration {
 
   /**
    * Returns the path of Shared configuration directory
-   * 
    * @return {@link String} path of the shared configuration directory
    */
   public String getSharedConfigurationDirPath() {
@@ -525,7 +477,6 @@ public class SharedConfiguration {
   /**
    * Gets the current status of the SharedConfiguration If the status is started , it determines if
    * the shared configuration is waiting for new configuration on other locators
-   * 
    * @return {@link SharedConfigurationStatus}
    */
   public SharedConfigurationStatus getStatus() {
@@ -548,8 +499,6 @@ public class SharedConfiguration {
 
   /**
    * Loads the
-   * 
-   * @throws Exception
    */
   public void loadSharedConfigurationFromDisk() throws Exception {
     Map<String, Configuration> sharedConfigurationMap = readSharedConfigurationFromDisk();
@@ -559,7 +508,7 @@ public class SharedConfiguration {
 
   public void modifyProperties(final Properties properties, String[] groups) throws Exception {
     if (groups == null) {
-      groups = new String[] {SharedConfiguration.CLUSTER_CONFIG};
+      groups = new String[]{SharedConfiguration.CLUSTER_CONFIG};
     }
     Region<String, Configuration> configRegion = getConfigurationRegion();
     for (String group : groups) {
@@ -569,13 +518,12 @@ public class SharedConfiguration {
       }
       configuration.getGemfireProperties().putAll(properties);
       configRegion.put(group, configuration);
-      writeConfig(configuration);
+      //writeConfig(configuration);
     }
   }
 
   /**
    * Removes the jar files from the shared configuration.
-   * 
    * @param jarNames Names of the jar files.
    * @param groups Names of the groups which had the jar file deployed.
    * @return true on success.
@@ -585,25 +533,15 @@ public class SharedConfiguration {
     try {
       Region<String, Configuration> configRegion = getConfigurationRegion();
       if (groups == null) {
-        Set<String> groupSet = configRegion.keySet();
-        groups = groupSet.toArray(new String[groupSet.size()]);
+        groups = configRegion.keySet().stream().toArray(String[]::new);
       }
       for (String group : groups) {
-        Configuration configuration = (Configuration) configRegion.get(group);
-        if (configuration != null) {
-          String dirPath =
-              FilenameUtils.concat(getSharedConfigurationDirPath(), configuration.getConfigName());
-          removeJarFiles(dirPath, jarNames);
-        }
-      }
-      for (String group : groups) {
-        Configuration configuration = (Configuration) configRegion.get(group);
-        if (configuration != null) {
-          if (!configuration.getJarNames().isEmpty()) {
-            configuration.removeJarNames(jarNames);
-            configRegion.put(group, configuration);
-          }
+        Configuration configuration = configRegion.get(group);
+        if (configuration == null) {
+          break;
         }
+        configuration.removeJarNames(jarNames);
+        configRegion.put(group, configuration);
       }
     } catch (Exception e) {
       logger.info("Exception occurred while deleting the jar files", e);
@@ -627,26 +565,37 @@ public class SharedConfiguration {
   }
 
   /**
-   * Writes the contents of the {@link Configuration} to the file system
+   * Creates a directory for this configuration if it doesn't already exist.
    */
-  public void writeConfig(final Configuration configuration) throws Exception {
-    File configDir = new File(getSharedConfigurationDirPath());
-    if (!configDir.exists()) {
-      if (!configDir.mkdirs()) {
+  private File createConfigDirIfNecessary(final String configName) throws Exception {
+    File clusterConfigDir = new File(getSharedConfigurationDirPath());
+    if (!clusterConfigDir.exists()) {
+      if (!clusterConfigDir.mkdirs()) {
         throw new IOException("Cannot create directory : " + getSharedConfigurationDirPath());
       }
     }
-    String dirPath =
-        FilenameUtils.concat(getSharedConfigurationDirPath(), configuration.getConfigName());
-    File file = new File(dirPath);
-    if (!file.exists()) {
-      if (!file.mkdir()) {
-        throw new IOException("Cannot create directory : " + dirPath);
+    Path configDirPath = clusterConfigDir.toPath().resolve(configName);
+
+    File configDir = configDirPath.toFile();
+    if (!configDir.exists()) {
+      if (!configDir.mkdir()) {
+        throw new IOException("Cannot create directory : " + configDirPath);
       }
     }
 
-    writeProperties(dirPath, configuration);
-    writeCacheXml(dirPath, configuration);
+    return configDir;
+  }
+
+  public void writeConfig(final Configuration configuration) throws Exception {
+    File configDir = createConfigDirIfNecessary(configuration.getConfigName());
+
+    File propsFile = new File(configDir, configuration.getPropertiesFileName());
+    BufferedWriter bw = new BufferedWriter(new FileWriter(propsFile));
+    configuration.getGemfireProperties().store(bw, null);
+    bw.close();
+
+    File xmlFile = new File(configDir, configuration.getCacheXmlFileName());
+    FileUtils.writeStringToFile(xmlFile, configuration.getCacheXmlContent(), "UTF-8");
   }
 
   private boolean lockSharedConfiguration() {
@@ -657,85 +606,48 @@ public class SharedConfiguration {
     sharedConfigLockingService.unlock(SHARED_CONFIG_LOCK_NAME);
   }
 
-  /**
-   * Gets the Jar from existing locators in the system
-   */
-  private void getAllJarsFromOtherLocators() throws Exception {
+  public void addJarFromOtherLocators(String groupName, String jarName) throws Exception {
     logger.info("Getting Jar files from other locators");
     DM dm = cache.getDistributionManager();
     DistributedMember me = cache.getMyId();
     Set<DistributedMember> locators =
-        new HashSet<DistributedMember>(dm.getAllHostedLocatorsWithSharedConfiguration().keySet());
+        new HashSet<>(dm.getAllHostedLocatorsWithSharedConfiguration().keySet());
     locators.remove(me);
-    String[] jarNames = null;
-    byte[][] jarBytes = null;
-
-    if (locators.isEmpty()) {
-      logger.info("No other locators present");
-      return;
-    }
-    ResultCollector<?, List<Object>> rc = (ResultCollector<?, List<Object>>) CliUtil
-        .executeFunction(getAllJarsFunction, null, locators);
-
-    List<Object> results = rc.getResult();
-    for (Object result : results) {
-      if (result != null) {
-        if (!(result instanceof Exception)) {
-          Object[] jars = (Object[]) result;
-          jarNames = (String[]) jars[0];
-          jarBytes = (byte[][]) jars[1];
-          break;
-        }
-      }
-    }
 
-    if (jarNames != null && jarBytes != null) {
-      Map<String, Integer> jarIndex = new HashMap<String, Integer>();
+    createConfigDirIfNecessary(groupName);
 
-      for (int i = 0; i < jarNames.length; i++) {
-        String jarName = jarNames[i];
-        jarIndex.put(jarName, i);
-      }
+    byte[] jarBytes = locators.stream()
+        .map((DistributedMember locator) -> downloadJarFromLocator(locator, groupName, jarName))
+        .filter(Objects::nonNull)
+        .findFirst()
+        .orElseThrow(() -> new IllegalStateException(
+            "No locators have a deployed jar named " + jarName + " in " + groupName));
 
-      Map<String, Configuration> entireConfiguration = getEntireConfiguration();
-      Set<String> groups = entireConfiguration.keySet();
+    File jarToWrite = getPathToJarOnThisLocator(groupName, jarName).toFile();
+    FileUtils.writeByteArrayToFile(jarToWrite, jarBytes);
+  }
 
-      for (String group : groups) {
-        Configuration config = entireConfiguration.get(group);
-        Set<String> groupJarNames = config.getJarNames();
-        String groupDirPath = FilenameUtils.concat(configDirPath, group);
-
-        for (String groupJarName : groupJarNames) {
-          Integer index = jarIndex.get(groupJarName);
-
-          if (index != null) {
-            String jarFilePath = FilenameUtils.concat(groupDirPath, groupJarName);
-            byte[] jarData = jarBytes[index.intValue()];
-
-            try {
-              FileUtils.writeByteArrayToFile(new File(jarFilePath), jarData);
-            } catch (IOException e) {
-              logger.info(e.getMessage(), e);
-            }
-          } else {
-            // This should NEVER happen
-            logger.error("JarFile {} not delivered.", groupJarName);
-          }
-        }
-      }
-    } else {
-      logger.info("No deployed jars found on other locators.");
-    }
+  private byte[] downloadJarFromLocator(DistributedMember locator, String groupName,
+                                        String jarName) {
+    ResultCollector<byte[], List<byte[]>> rc = (ResultCollector<byte[], List<byte[]>>) CliUtil
+        .executeFunction(new UploadJarFunction(), new Object[]{groupName, jarName}, locator);
+
+    List<byte[]> result = rc.getResult();
+
+    // we should only get one byte[] back in the list
+    return result.stream()
+        .filter(Objects::nonNull)
+        .findFirst()
+        .orElse(null);
   }
 
   /**
    * Gets the region containing the shared configuration data. The region is created , if it does
    * not exist already. Note : this could block if this locator contains stale persistent
    * configuration data.
-   * 
    * @return {@link Region} ConfigurationRegion
    */
-  private Region<String, Configuration> getConfigurationRegion() throws Exception {
+  private Region<String, Configuration> getConfigurationRegion() {
     Region<String, Configuration> configRegion = cache.getRegion(CONFIG_REGION_NAME);
 
     try {
@@ -776,7 +688,7 @@ public class SharedConfiguration {
       if (configRegion == null) {
         this.status.set(SharedConfigurationStatus.STOPPED);
       }
-      throw new Exception("Error occurred while initializing cluster configuration", e);
+      throw new RuntimeException("Error occurred while initializing cluster configuration", e);
     }
 
     return configRegion;
@@ -785,14 +697,7 @@ public class SharedConfiguration {
   /**
    * Reads the configuration information from the shared configuration directory and returns a
    * {@link Configuration} object
-   * 
-   * @param configName
-   * @param configDirectory
    * @return {@link Configuration}
-   * @throws TransformerException
-   * @throws TransformerFactoryConfigurationError
-   * @throws ParserConfigurationException
-   * @throws SAXException
    */
   private Configuration readConfiguration(final String configName, final String configDirectory)
       throws SAXException, ParserConfigurationException, TransformerFactoryConfigurationError,
@@ -821,10 +726,7 @@ public class SharedConfiguration {
 
   /**
    * Reads the properties from the properties file.
-   * 
-   * @param propertiesFilePath
    * @return {@link Properties}
-   * @throws IOException
    */
   private Properties readProperties(final String propertiesFilePath) throws IOException {
     Properties properties = new Properties();
@@ -846,12 +748,7 @@ public class SharedConfiguration {
   /**
    * Reads the "shared_config" directory and loads all the cache.xml, gemfire.properties and
    * deployed jars information
-   * 
    * @return {@link Map}
-   * @throws TransformerException
-   * @throws TransformerFactoryConfigurationError
-   * @throws ParserConfigurationException
-   * @throws SAXException
    */
   private Map<String, Configuration> readSharedConfigurationFromDisk() throws SAXException,
       ParserConfigurationException, TransformerFactoryConfigurationError, TransformerException {
@@ -869,52 +766,13 @@ public class SharedConfiguration {
   }
 
   /**
-   * Removes the jar files from the given directory
-   * 
-   * @param dirPath Path of the configuration directory
-   * @param jarNames Names of the jar files
-   * @throws IOException
-   */
-  private void removeJarFiles(final String dirPath, final String[] jarNames) throws IOException {
-    if (jarNames != null) {
-      for (int i = 0; i < jarNames.length; i++) {
-        File jarFile = new File(FilenameUtils.concat(dirPath, jarNames[i]));
-        if (jarFile.exists()) {
-          FileUtils.forceDelete(jarFile);
-        }
-      }
-    } else {
-      File dir = new File(dirPath);
-      String[] jarFileNames = dir.list(jarFileFilter);
-      if (jarFileNames.length != 0) {
-        File jarFileToBeDeleted;
-        for (String jarFileName : jarFileNames) {
-          String fullPath = FilenameUtils.concat(dirPath, jarFileName);
-          jarFileToBeDeleted = new File(fullPath);
-          FileUtils.forceDelete(jarFileToBeDeleted);
-        }
-      }
-    }
-  }
-
-  /**
-   * Writes the cache.xml to the file , based on Configuration
-   */
-  private void writeCacheXml(final String dirPath, final Configuration configuration)
-      throws IOException {
-    String fullPath = FilenameUtils.concat(dirPath, configuration.getCacheXmlFileName());
-    FileUtils.writeStringToFile(new File(fullPath), configuration.getCacheXmlContent(), "UTF-8");
-  }
-
-  /**
    * Writes the
-   * 
    * @param dirPath target directory , where the jar files are to be written
    * @param jarNames Array containing the name of the jar files.
    * @param jarBytes Array of byte arrays for the jar files.
    */
   private void writeJarFiles(final String dirPath, final String[] jarNames,
-      final byte[][] jarBytes) {
+                             final byte[][] jarBytes) {
     for (int i = 0; i < jarNames.length; i++) {
       String filePath = FilenameUtils.concat(dirPath, jarNames[i]);
       File jarFile = new File(filePath);
@@ -927,21 +785,9 @@ public class SharedConfiguration {
   }
 
   /**
-   * Writes the properties to the file based on the {@link Configuration}
-   */
-  private void writeProperties(final String dirPath, final Configuration configuration)
-      throws IOException {
-    String fullPath = FilenameUtils.concat(dirPath, configuration.getPropertiesFileName());
-    BufferedWriter bw = new BufferedWriter(new FileWriter(fullPath));
-    configuration.getGemfireProperties().store(bw, "");
-    bw.close();
-  }
-
-  /**
    * Create a {@link Document} using {@link XmlUtils#createDocumentFromXml(String)} and if the
    * version attribute is not equal to the current version then update the XML to the current schema
    * and return the document.
-   *
    * @param xmlContent XML content to load and upgrade.
    * @return {@link Document} from xmlContent.
    * @since GemFire 8.1
@@ -960,10 +806,9 @@ public class SharedConfiguration {
 
   /**
    * Returns an array containing the names of the subdirectories in a given directory
-   * 
    * @param path Path of the directory whose subdirectories are listed
    * @return String[] names of first level subdirectories, null if no subdirectories are found or if
-   *         the path is incorrect
+   * the path is incorrect
    */
   private static String[] getSubdirectories(String path) {
     File directory = new File(path);

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java b/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
index 5e48d7c..19f998c 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
@@ -255,32 +255,4 @@ public class ClusterConfigurationLoader {
     return groups;
   }
 
-  /***
-   * Get the host and port information of the locators
-   * 
-   * @return List made up of a String array containing host and port
-   */
-  public static List<String[]> getLocatorsInfo(String locatorsString) {
-
-    List<String[]> locatorList = new ArrayList<String[]>();
-
-    if (!StringUtils.isBlank(locatorsString)) {
-      String[] bootstrappedlocators = locatorsString.split(",");
-      for (String bootstrappedlocator : bootstrappedlocators) {
-        locatorList.add(bootstrappedlocator.split("\\[|]"));
-      }
-    }
-    return locatorList;
-  }
-
-  public static List<String[]> getLocatorsInfo(List<String> locatorConnectionStrings) {
-    List<String[]> locatorList = new ArrayList<String[]>();
-
-    for (String locatorConnectionString : locatorConnectionStrings) {
-      locatorList.add(locatorConnectionString.split("\\[|]"));
-    }
-    return locatorList;
-  }
-
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
index a5302ea..7c887be 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
@@ -107,6 +107,7 @@ public final class DeployCommands extends AbstractCommandsSupport implements Com
         return e.getResult();
       }
 
+      // this deploys the jars to all the matching servers
       ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(this.deployFunction,
           new Object[] {jarNames, jarBytes}, targetMembers);
 
@@ -133,8 +134,6 @@ public final class DeployCommands extends AbstractCommandsSupport implements Com
         }
       }
 
-
-
       if (!accumulatedData) {
         // This really should never happen since if a JAR file is already deployed a result is
         // returned indicating that.

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportSharedConfigurationCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportSharedConfigurationCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportSharedConfigurationCommands.java
index 8d46773..cfeba0c 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportSharedConfigurationCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportSharedConfigurationCommands.java
@@ -14,16 +14,11 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import com.google.common.primitives.Booleans;
 
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.cli.CliMetaData;
@@ -37,6 +32,7 @@ import org.apache.geode.management.internal.cli.functions.ImportSharedConfigurat
 import org.apache.geode.management.internal.cli.functions.LoadSharedConfigurationFunction;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.remote.CommandExecutionContext;
+import org.apache.geode.management.internal.cli.result.ErrorResultData;
 import org.apache.geode.management.internal.cli.result.FileResult;
 import org.apache.geode.management.internal.cli.result.InfoResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
@@ -44,11 +40,20 @@ import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-
 import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
 /****
  * Commands for the shared configuration
  *
@@ -74,48 +79,40 @@ public class ExportImportSharedConfigurationCommands extends AbstractCommandsSup
 
       @CliOption(key = {CliStrings.EXPORT_SHARED_CONFIG__DIR},
           help = CliStrings.EXPORT_SHARED_CONFIG__DIR__HELP) String dir) {
-    Result result;
 
-    InfoResultData infoData = ResultBuilder.createInfoResultData();
-    TabularResultData errorTable = ResultBuilder.createTabularResultData();
     GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-    Set<DistributedMember> locators = new HashSet<DistributedMember>(
-        cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration().keySet());
-    byte[] byteData;
-    boolean success = false;
-
-    if (!locators.isEmpty()) {
-      for (DistributedMember locator : locators) {
-        ResultCollector<?, ?> rc =
-            CliUtil.executeFunction(exportSharedConfigurationFunction, null, locator);
-        @SuppressWarnings("unchecked")
-        List<CliFunctionResult> results = (List<CliFunctionResult>) rc.getResult();
-        CliFunctionResult functionResult = results.get(0);
-
-        if (functionResult.isSuccessful()) {
-          byteData = functionResult.getByteData();
-          infoData.addAsFile(zipFileName, byteData, InfoResultData.FILE_TYPE_BINARY,
-              CliStrings.EXPORT_SHARED_CONFIG__DOWNLOAD__MSG, false);
-          success = true;
-          break;
-        } else {
-          errorTable.accumulate(CliStrings.LOCATOR_HEADER, functionResult.getMemberIdOrName());
-          errorTable.accumulate(CliStrings.ERROR__MSG__HEADER, functionResult.getMessage());
-        }
-      }
-      if (success) {
-        result = ResultBuilder.buildResult(infoData);
-      } else {
-        errorTable.setStatus(Result.Status.ERROR);
-        result = ResultBuilder.buildResult(errorTable);
-      }
+    Set<? extends DistributedMember> locators =
+        cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration().keySet();
+
+    Optional<CliFunctionResult> functionResult = locators.stream()
+        .map((DistributedMember locator) -> exportSharedConfigurationFromLocator(locator, null))
+        .filter(CliFunctionResult::isSuccessful)
+        .findFirst();
+
+    Result result;
+    if (functionResult.isPresent()) {
+      InfoResultData infoData = ResultBuilder.createInfoResultData();
+      byte[] byteData = functionResult.get().getByteData();
+      infoData.addAsFile(zipFileName, byteData, InfoResultData.FILE_TYPE_BINARY,
+          CliStrings.EXPORT_SHARED_CONFIG__DOWNLOAD__MSG, false);
+      result = ResultBuilder.buildResult(infoData);
     } else {
-      result = ResultBuilder.createGemFireErrorResult(
-          CliStrings.SHARED_CONFIGURATION_NO_LOCATORS_WITH_SHARED_CONFIGURATION);
+      ErrorResultData errorData = ResultBuilder.createErrorResultData();
+      errorData.addLine("Export failed");
+      result = ResultBuilder.buildResult(errorData);
     }
+
     return result;
   }
 
+  private CliFunctionResult exportSharedConfigurationFromLocator(DistributedMember locator, Object[] args) {
+    ResultCollector rc = CliUtil.executeFunction(exportSharedConfigurationFunction, args, locator);
+    List<CliFunctionResult> results = (List<CliFunctionResult>) rc.getResult();
+
+    return results.get(0);
+  }
+
+
   @CliCommand(value = {CliStrings.IMPORT_SHARED_CONFIG},
       help = CliStrings.IMPORT_SHARED_CONFIG__HELP)
   @CliMetaData(
@@ -133,8 +130,8 @@ public class ExportImportSharedConfigurationCommands extends AbstractCommandsSup
           .createGemFireErrorResult(CliStrings.IMPORT_SHARED_CONFIG__CANNOT__IMPORT__MSG);
     }
 
-    Set<DistributedMember> locators = new HashSet<DistributedMember>(
-        cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration().keySet());
+    Set<? extends DistributedMember> locators =
+        cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration().keySet();
 
     if (locators.isEmpty()) {
       return ResultBuilder.createGemFireErrorResult(CliStrings.NO_LOCATORS_WITH_SHARED_CONFIG);
@@ -150,56 +147,32 @@ public class ExportImportSharedConfigurationCommands extends AbstractCommandsSup
 
     Object[] args = new Object[] {zipFileName, zipBytes};
 
-    InfoResultData infoData = ResultBuilder.createInfoResultData();
-    TabularResultData errorTable = ResultBuilder.createTabularResultData();
-
-    boolean success = false;
-    boolean copySuccess = false;
 
-    ResultCollector<?, ?> rc =
-        CliUtil.executeFunction(importSharedConfigurationFunction, args, locators);
-    List<CliFunctionResult> functionResults =
-        CliFunctionResult.cleanResults((List<CliFunctionResult>) rc.getResult());
+    Optional<CliFunctionResult> functionResult = locators.stream()
+        .map((DistributedMember locator) -> importSharedConfigurationFromLocator(locator, args))
+        .filter(CliFunctionResult::isSuccessful)
+        .findFirst();
 
-    for (CliFunctionResult functionResult : functionResults) {
-      if (!functionResult.isSuccessful()) {
-        errorTable.accumulate(CliStrings.LOCATOR_HEADER, functionResult.getMemberIdOrName());
-        errorTable.accumulate(CliStrings.ERROR__MSG__HEADER, functionResult.getMessage());
-      } else {
-        copySuccess = true;
-      }
-    }
-
-    if (!copySuccess) {
-      errorTable.setStatus(Result.Status.ERROR);
-      return ResultBuilder.buildResult(errorTable);
-    }
-
-    errorTable = ResultBuilder.createTabularResultData();
-
-    for (DistributedMember locator : locators) {
-      rc = CliUtil.executeFunction(loadSharedConfiguration, args, locator);
-      functionResults = (List<CliFunctionResult>) rc.getResult();
-      CliFunctionResult functionResult = functionResults.get(0);
-      if (functionResult.isSuccessful()) {
-        success = true;
-        infoData.addLine(functionResult.getMessage());
-        break;
-      } else {
-        errorTable.accumulate(CliStrings.LOCATOR_HEADER, functionResult.getMemberIdOrName());
-        errorTable.accumulate(CliStrings.ERROR__MSG__HEADER, functionResult.getMessage());
-      }
-    }
-
-    if (success) {
+    if (functionResult.isPresent()) {
+      InfoResultData infoData = ResultBuilder.createInfoResultData();
+      infoData.addLine(functionResult.get().getMessage());
       result = ResultBuilder.buildResult(infoData);
     } else {
-      errorTable.setStatus(Result.Status.ERROR);
-      result = ResultBuilder.buildResult(errorTable);
+      ErrorResultData errorData = ResultBuilder.createErrorResultData();
+      errorData.addLine("Import failed");
+      result = ResultBuilder.buildResult(errorData);
     }
+
     return result;
   }
 
+  private CliFunctionResult importSharedConfigurationFromLocator(DistributedMember locator, Object[] args) {
+    ResultCollector rc = CliUtil.executeFunction(importSharedConfigurationFunction, args, locator);
+    List<CliFunctionResult> results = (List<CliFunctionResult>) rc.getResult();
+
+    return results.get(0);
+  }
+
 
   @CliAvailabilityIndicator({CliStrings.EXPORT_SHARED_CONFIG, CliStrings.IMPORT_SHARED_CONFIG})
   public boolean sharedConfigCommandsAvailable() {

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportSharedConfigurationFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportSharedConfigurationFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportSharedConfigurationFunction.java
index 821e04b..66107d9 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportSharedConfigurationFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportSharedConfigurationFunction.java
@@ -14,20 +14,20 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
-import java.io.File;
-import java.util.UUID;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
-
 import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.distributed.internal.SharedConfiguration;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.configuration.domain.Configuration;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 
+import java.io.File;
+import java.util.UUID;
+
 public class ExportSharedConfigurationFunction extends FunctionAdapter implements InternalEntity {
 
   private static final long serialVersionUID = 1L;
@@ -37,28 +37,32 @@ public class ExportSharedConfigurationFunction extends FunctionAdapter implement
     InternalLocator locator = InternalLocator.getLocator();
     String memberName = locator.getDistributedSystem().getName();
 
-    if (locator.isSharedConfigurationRunning()) {
-      SharedConfiguration sc = locator.getSharedConfiguration();
+    if (!locator.isSharedConfigurationRunning()) {
+      CliFunctionResult result =
+          new CliFunctionResult(memberName, false, CliStrings.SHARED_CONFIGURATION_NOT_STARTED);
+      context.getResultSender().lastResult(result);
+      return;
+    }
 
-      String zipFileName =
-          CliStrings.format(CliStrings.EXPORT_SHARED_CONFIG__FILE__NAME, UUID.randomUUID());
+    SharedConfiguration sc = locator.getSharedConfiguration();
+    String zipFileName =
+        CliStrings.format(CliStrings.EXPORT_SHARED_CONFIG__FILE__NAME, UUID.randomUUID());
+    File zipFile = new File(sc.getSharedConfigurationDirPath(), zipFileName);
 
-      String targetFilePath = FilenameUtils.concat(sc.getSharedConfigurationDirPath(), zipFileName);
-      try {
-        ZipUtils.zip(sc.getSharedConfigurationDirPath(), targetFilePath);
-        File zippedSharedConfig = new File(targetFilePath);
-        byte[] zippedConfigData = FileUtils.readFileToByteArray(zippedSharedConfig);
-        FileUtils.forceDelete(zippedSharedConfig);
-        CliFunctionResult result = new CliFunctionResult(locator.getDistributedSystem().getName(),
-            zippedConfigData, new String[] {zipFileName});
-        context.getResultSender().lastResult(result);
-      } catch (Exception e) {
-        context.getResultSender().lastResult(new CliFunctionResult(memberName, e, e.getMessage()));
+    try {
+      for (Configuration config : sc.getEntireConfiguration().values()) {
+        sc.writeConfig(config);
       }
-    } else {
-      CliFunctionResult result =
-          new CliFunctionResult(memberName, false, CliStrings.SHARED_CONFIGURATION_NOT_STARTED);
+
+      ZipUtils.zip(sc.getSharedConfigurationDirPath(), zipFile.getCanonicalPath());
+
+      byte[] zippedConfigData = FileUtils.readFileToByteArray(zipFile);
+      FileUtils.forceDelete(zipFile);
+      CliFunctionResult result = new CliFunctionResult(locator.getDistributedSystem().getName(),
+          zippedConfigData, new String[]{zipFileName});
       context.getResultSender().lastResult(result);
+    } catch (Exception e) {
+      context.getResultSender().lastResult(new CliFunctionResult(memberName, e, e.getMessage()));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ImportSharedConfigurationArtifactsFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ImportSharedConfigurationArtifactsFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ImportSharedConfigurationArtifactsFunction.java
index 2ddeda6..0f17647 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ImportSharedConfigurationArtifactsFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ImportSharedConfigurationArtifactsFunction.java
@@ -55,8 +55,14 @@ public class ImportSharedConfigurationArtifactsFunction extends FunctionAdapter
         FileUtils.writeByteArrayToFile(zippedSharedConfiguration, zipFileData);
         ZipUtils.unzip(zipFileName, sc.getSharedConfigurationDirPath());
 
-        CliFunctionResult cliFunctionResult = new CliFunctionResult(memberName, true,
-            CliStrings.IMPORT_SHARED_CONFIG__ARTIFACTS__COPIED);
+        // load it from the disk
+        sc.loadSharedConfigurationFromDisk();
+
+        // do we need to delete the xml/properites? this should just be a stale copy.
+        // remember in the ExportSharedConfigurationFunction, we write them to the file system again
+
+        CliFunctionResult cliFunctionResult =
+            new CliFunctionResult(memberName, true, CliStrings.IMPORT_SHARED_CONFIG__SUCCESS__MSG);
         context.getResultSender().lastResult(cliFunctionResult);
       } catch (Exception e) {
         CliFunctionResult result =

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/management/internal/configuration/SharedConfigurationWriter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/SharedConfigurationWriter.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/SharedConfigurationWriter.java
index 3af5587..859b6a6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/SharedConfigurationWriter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/SharedConfigurationWriter.java
@@ -14,13 +14,6 @@
  */
 package org.apache.geode.management.internal.configuration;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.logging.log4j.Logger;
-
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
@@ -34,19 +27,27 @@ import org.apache.geode.management.internal.configuration.functions.AddXmlEntity
 import org.apache.geode.management.internal.configuration.functions.DeleteJarFunction;
 import org.apache.geode.management.internal.configuration.functions.DeleteXmlEntityFunction;
 import org.apache.geode.management.internal.configuration.functions.ModifyPropertiesFunction;
+import org.apache.logging.log4j.Logger;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.Set;
 
 /***
  * Class for writing configuration changes to the Shared Configuration at the Locator(s). This class
  * is used in the Gfsh commands, to persist the configuration changes to the shared configuration
  * hosted on locators.
- * 
+ *
  *
  */
 public class SharedConfigurationWriter {
   private static final Logger logger = LogService.getLogger();
 
   private GemFireCacheImpl cache;
-  private final AddJarFunction saveJarFunction = new AddJarFunction();
+  private final AddJarFunction addJarFunction = new AddJarFunction();
   private final DeleteJarFunction deleteJarFunction = new DeleteJarFunction();
   private final AddXmlEntityFunction addXmlEntityFunction = new AddXmlEntityFunction();
   private final DeleteXmlEntityFunction deleteXmlEntityFunction = new DeleteXmlEntityFunction();
@@ -89,7 +90,7 @@ public class SharedConfigurationWriter {
 
 
   public boolean modifyPropertiesAndCacheAttributes(Properties properties, XmlEntity xmlEntity,
-      String[] groups) {
+                                                    String[] groups) {
     Object[] args = new Object[3];
     args[0] = properties;
     args[1] = xmlEntity;
@@ -109,7 +110,7 @@ public class SharedConfigurationWriter {
     args[0] = jarNames;
     args[1] = jarBytes;
     args[2] = groups;
-    return saveConfigChangesAllLocators(saveJarFunction, args);
+    return saveConfigChanges(addJarFunction, args);
   }
 
   // /****
@@ -122,7 +123,7 @@ public class SharedConfigurationWriter {
     Object[] args = new Object[3];
     args[0] = jarNames;
     args[1] = groups;
-    return saveConfigChangesAllLocators(deleteJarFunction, args);
+    return saveConfigChanges(deleteJarFunction, args);
   }
 
 
@@ -130,55 +131,31 @@ public class SharedConfigurationWriter {
     if (!isSharedConfigEnabled) {
       return true;
     }
-    boolean success = false;
     Set<DistributedMember> locators = new HashSet<DistributedMember>(
         cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration().keySet());
 
-    if (!locators.isEmpty()) {
-      for (DistributedMember locator : locators) {
-        ResultCollector<?, ?> rc = CliUtil.executeFunction(function, args, locator);
-        @SuppressWarnings("unchecked")
-        List<ConfigurationChangeResult> results = (List<ConfigurationChangeResult>) rc.getResult();
-        if (!results.isEmpty()) {
-          ConfigurationChangeResult configChangeResult = results.get(0);
-          if (configChangeResult.isSuccessful()) {
-            logger.info("Configuration change successful");
-            success = true;
-            break;
-          } else {
-            logger.info("Failed to save the configuration change. {}", configChangeResult);
-            success = false;
-          }
-        }
-      }
+    boolean success = locators.stream()
+        .map((DistributedMember locator) -> saveConfigChangeOnLocator(locator, function, args))
+        .anyMatch((Boolean result) -> result);
+
+    if (!success) {
+      logger.error("Failed to save the configuration change.");
     }
+
     return success;
   }
 
+  private boolean saveConfigChangeOnLocator(DistributedMember locator, Function function,
+                                            Object[] args) {
+    ResultCollector<?, ?> rc = CliUtil.executeFunction(function, args, locator);
+    List<ConfigurationChangeResult> results = (List<ConfigurationChangeResult>) rc.getResult();
 
-  private boolean saveConfigChangesAllLocators(Function function, Object[] args) {
-    if (!isSharedConfigEnabled) {
-      return true;
-    }
-    boolean success = true;
-    Set<DistributedMember> locators = new HashSet<DistributedMember>(
-        cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration().keySet());
+    Optional<ConfigurationChangeResult> result = results.stream()
+        .filter(Objects::nonNull)
+        .filter(ConfigurationChangeResult::isSuccessful)
+        .findFirst();
 
-    if (!locators.isEmpty()) {
-      ResultCollector<?, ?> rc = CliUtil.executeFunction(function, args, locators);
-      @SuppressWarnings("unchecked")
-      List<ConfigurationChangeResult> results = (List<ConfigurationChangeResult>) rc.getResult();
-
-      if (!results.isEmpty()) {
-        for (ConfigurationChangeResult configChangeResult : results) {
-          if (!configChangeResult.isSuccessful()) {
-            success = false;
-            break;
-          }
-        }
-      }
-    }
-    return success;
+    return result.isPresent();
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/management/internal/configuration/callbacks/ConfigurationChangeListener.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/callbacks/ConfigurationChangeListener.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/callbacks/ConfigurationChangeListener.java
index c08ba92..01e6797 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/callbacks/ConfigurationChangeListener.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/callbacks/ConfigurationChangeListener.java
@@ -14,6 +14,10 @@
  */
 package org.apache.geode.management.internal.configuration.callbacks;
 
+import com.google.common.collect.Sets;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.cache.EntryEvent;
@@ -22,8 +26,13 @@ import org.apache.geode.distributed.internal.SharedConfiguration;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
 /****
- * CacheListener on ConfigRegion to write the configuration changes to file-system.
+ * CacheListener on ConfigRegion on Locators to write the configuration changes to file-system.
  *
  */
 public class ConfigurationChangeListener extends CacheListenerAdapter<String, Configuration> {
@@ -31,6 +40,9 @@ public class ConfigurationChangeListener extends CacheListenerAdapter<String, Co
 
   private final SharedConfiguration sharedConfig;
 
+  private static final String clusterConfigDirPath = GemFireCacheImpl.getInstance().getDistributedSystem().getConfig().getClusterConfigDir();
+  private static final File clusterConfigDir = new File(clusterConfigDirPath);
+
   public ConfigurationChangeListener(SharedConfiguration sharedConfig) {
     this.sharedConfig = sharedConfig;
   }
@@ -38,23 +50,62 @@ public class ConfigurationChangeListener extends CacheListenerAdapter<String, Co
   @Override
   public void afterUpdate(EntryEvent<String, Configuration> event) {
     super.afterUpdate(event);
-    writeToFileSystem(event);
+    addOrRemoveJarFromFilesystem(event);
   }
 
   @Override
   public void afterCreate(EntryEvent<String, Configuration> event) {
     super.afterCreate(event);
-    writeToFileSystem(event);
+    addOrRemoveJarFromFilesystem(event);
   }
 
-  private void writeToFileSystem(EntryEvent<String, Configuration> event) {
+  // when a new jar is added, if it exist in the current locator, upload to other locators,
+  // otherwise, download from other locators.
+  // when a jar is removed, remove it from all the locators' file system
+  private void addOrRemoveJarFromFilesystem(EntryEvent<String, Configuration> event) {
+    String group = event.getKey();
     Configuration newConfig = (Configuration) event.getNewValue();
-    try {
-      sharedConfig.writeConfig(newConfig);
-    } catch (Exception e) {
-      logger.info(
-          "Exception occurred while writing the configuration changes to the filesystem: {}",
-          e.getMessage(), e);
+    Configuration oldConfig = (Configuration) event.getOldValue();
+    Set<String> newJars = newConfig.getJarNames();
+    Set<String> oldJars = (oldConfig == null) ? new HashSet<>() : oldConfig.getJarNames();
+
+    Set<String> jarsAdded = Sets.difference(newJars, oldJars);
+    Set<String> jarsRemoved = Sets.difference(oldJars, newJars);
+
+    if (!jarsAdded.isEmpty() && !jarsRemoved.isEmpty()) {
+      throw new IllegalStateException("We don't expect to have jars both added and removed in one event");
+    }
+
+    for(String jarAdded: jarsAdded){
+      if (!jarExistsInFilesystem(group, jarAdded)){
+        try {
+          sharedConfig.addJarFromOtherLocators(group, jarAdded);
+        } catch (Exception e) {
+          logger.error("Unable to add jar: " + jarAdded, e);
+        }
+      }
     }
+
+    for(String jarRemoved: jarsRemoved){
+        File jar = sharedConfig.getPathToJarOnThisLocator(group,jarRemoved).toFile();
+        if (jar.exists()) {
+          try {
+            FileUtils.forceDelete(jar);
+          } catch (IOException e) {
+            logger.error(
+                "Exception occurred while attempting to delete a jar from the filesystem: {}",jarRemoved, e);
+          }
+        }
+    }
+
+    //locator1,2,3 already have an existing jar 1
+    //deploy jar --name=jar1  (new version of jar)
+    //locator1 overwrites jar1 on its filesystem
+    //listener is called on locator 1,2,3
   }
+
+  private boolean jarExistsInFilesystem(String groupName, String jarName) {
+    return sharedConfig.getPathToJarOnThisLocator(groupName, jarName).toFile().exists();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/AddJarFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/AddJarFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/AddJarFunction.java
index 605233f..b986372 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/AddJarFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/AddJarFunction.java
@@ -43,7 +43,7 @@ public class AddJarFunction extends FunctionAdapter implements InternalEntity {
         final String[] groups = (String[]) args[2];
 
         SharedConfiguration sharedConfiguration = locator.getSharedConfiguration();
-        sharedConfiguration.addJars(jarFilenames, jarBytes, groups);
+        sharedConfiguration.addJarsToThisLocator(jarFilenames, jarBytes, groups);
 
       } else {
         configChangeResult

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GetAllJarsFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GetAllJarsFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GetAllJarsFunction.java
deleted file mode 100644
index 0e50524..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GetAllJarsFunction.java
+++ /dev/null
@@ -1,63 +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.functions;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.geode.cache.execute.FunctionAdapter;
-import org.apache.geode.cache.execute.FunctionContext;
-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.InternalEntity;
-import org.apache.geode.management.internal.configuration.domain.Configuration;
-
-public class GetAllJarsFunction extends FunctionAdapter implements InternalEntity {
-
-  private static final long serialVersionUID = 1L;
-
-  public GetAllJarsFunction() {}
-
-  @Override
-  public void execute(FunctionContext context) {
-    InternalLocator locator = (InternalLocator) Locator.getLocator();
-
-    if (locator != null) {
-      SharedConfiguration sharedConfig = locator.getSharedConfiguration();
-      if (sharedConfig != null) {
-        try {
-          Map<String, Configuration> entireConfig = sharedConfig.getEntireConfiguration();
-          Set<String> configNames = entireConfig.keySet();
-          context.getResultSender().lastResult(sharedConfig.getAllJars(configNames));
-        } catch (IOException e) {
-          context.getResultSender().sendException(e);
-        } catch (Exception e) {
-          context.getResultSender().sendException(e);
-        }
-      }
-    }
-
-    context.getResultSender().lastResult(null);
-  }
-
-  @Override
-  public String getId() {
-    return GetAllJarsFunction.class.getName();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/UploadJarFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/UploadJarFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/UploadJarFunction.java
new file mode 100644
index 0000000..f5022f3
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/UploadJarFunction.java
@@ -0,0 +1,65 @@
+/*
+ * 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.functions;
+
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+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.InternalEntity;
+
+import java.io.IOException;
+
+public class UploadJarFunction implements Function, InternalEntity {
+
+  private static final long serialVersionUID = 1L;
+
+  @Override
+  public void execute(FunctionContext context) {
+    InternalLocator locator = (InternalLocator) Locator.getLocator();
+    Object[] args = (Object[]) context.getArguments();
+    String group = (String) args[0];
+    String jarName = (String) args[1];
+
+    if (locator != null && group != null && jarName != null) {
+      SharedConfiguration sharedConfig = locator.getSharedConfiguration();
+      if (sharedConfig != null) {
+        try {
+          byte[] jarBytes = sharedConfig.getJarBytesFromThisLocator(group, jarName);
+          context.getResultSender().lastResult(jarBytes);
+
+          //TODO: should we just return here if jarbytes was not null?
+        } catch (IOException e) {
+          context.getResultSender().sendException(e);
+        } catch (Exception e) {
+          context.getResultSender().sendException(e);
+        }
+      }
+    }
+
+    //TODO: Why does this not throw an IllegalStateException?
+    context.getResultSender().lastResult(null);
+  }
+
+  @Override
+  public String getId() {
+    return UploadJarFunction.class.getName();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
index 38f98e7..9d678e1 100644
--- a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
@@ -85,7 +85,7 @@ public class ConnectToLocatorSSLDUnitTest extends JUnit4DistributedTestCase {
 
     // saving the securityProps to a file
     OutputStream out = new FileOutputStream(securityPropsFile);
-    securityProps.store(out, "");
+    securityProps.store(out, null);
 
     GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule(
         lsRule.getMember(0).getPort(), GfshShellConnectionRule.PortType.locator);

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/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 f406d51..e95f6b2 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
@@ -39,6 +39,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
@@ -106,8 +107,8 @@ public class ClusterConfig implements Serializable {
     });
 
     File clusterConfigDir = new File(locator.getWorkingDir(), "/cluster_config");
-    Set<String> actualGroupDirs = toSetIgnoringHiddenFiles(clusterConfigDir.list());
-    assertThat(actualGroupDirs).isEqualTo(expectedGroupConfigs);
+//    Set<String> actualGroupDirs = toSetIgnoringHiddenFiles(clusterConfigDir.list());
+//    assertThat(actualGroupDirs).isEqualTo(expectedGroupConfigs);
 
     for (ConfigGroup configGroup : this.getGroups()) {
       Set<String> actualFiles =
@@ -162,6 +163,9 @@ public class ClusterConfig implements Serializable {
 
 
   private static Set<String> toSetIgnoringHiddenFiles(String[] array) {
+    if (array == null) {
+      return new HashSet<>();
+    }
     return Arrays.stream(array).filter((String name) -> !name.startsWith("."))
         .collect(Collectors.toSet());
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java
index 63c88dd..9613849 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java
@@ -32,11 +32,11 @@ public class ClusterConfigBaseTest extends JUnit4DistributedTestCase {
       ClusterConfigBaseTest.class.getResource(EXPORTED_CLUSTER_CONFIG_ZIP_FILENAME).getPath();
 
   public static final ConfigGroup CLUSTER = new ConfigGroup("cluster").regions("regionForCluster")
-      .jars("cluster.jar").maxLogFileSize("5000");
+      .jars("cluster.jar").maxLogFileSize("5000").configFiles("cluster.properties", "cluster.xml");
   public static final ConfigGroup GROUP1 = new ConfigGroup("group1").regions("regionForGroup1")
-      .jars("group1.jar").maxLogFileSize("6000");
+      .jars("group1.jar").maxLogFileSize("6000").configFiles("group1.properties", "group1.xml");
   public static final ConfigGroup GROUP2 = new ConfigGroup("group2").regions("regionForGroup2")
-      .jars("group2.jar").maxLogFileSize("7000");
+      .jars("group2.jar").maxLogFileSize("7000").configFiles("group2.properties", "group2.xml");
 
   public static final ClusterConfig CONFIG_FROM_ZIP = new ClusterConfig(CLUSTER, GROUP1, GROUP2);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
index c135f3d..e461b12 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
@@ -82,6 +82,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
     assertThat(result.getStatus()).isEqualTo(Result.Status.OK);
 
     // verify that the previous folder is backed up to "cluster_configxxxxxx".
+    //TODO: Expecting this functionality is a problem since the cluster_config dir will not contain .xml and .properties any longer, and hence not be a useful backup.
     assertThat(locator.getWorkingDir().listFiles())
         .filteredOn((File file) -> !file.getName().equals("cluster_config"))
         .filteredOn((File file) -> file.getName().startsWith("cluster_config")).isNotEmpty();
@@ -126,8 +127,12 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
     Set<String> actualZipEnries =
         new ZipFile(exportedZip).stream().map(ZipEntry::getName).collect(Collectors.toSet());
 
+
+    ConfigGroup exportedClusterGroup = cluster.configFiles("cluster.xml", "cluster.properties");
+    ClusterConfig expectedExportedClusterConfig = new ClusterConfig(exportedClusterGroup);
+
     Set<String> expectedZipEntries = new HashSet<>();
-    for (ConfigGroup group : expectedClusterConfig.getGroups()) {
+    for (ConfigGroup group : expectedExportedClusterConfig.getGroups()) {
       String groupDir = group.getName() + "/";
 
       expectedZipEntries.add(groupDir);

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ConfigGroup.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ConfigGroup.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ConfigGroup.java
index 971f667..8afd230 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ConfigGroup.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ConfigGroup.java
@@ -57,8 +57,6 @@ public class ConfigGroup implements Serializable {
 
   public ConfigGroup(String name) {
     this.name = name;
-    this.configFiles.add(name + ".xml");
-    this.configFiles.add(name + ".properties");
   }
 
   public ConfigGroup regions(String... regions) {

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/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
index 675f5fe..8fd888d 100644
--- 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
@@ -380,9 +380,9 @@ public class SharedConfigurationDUnitTest extends JUnit4CacheTestCase {
         assertNotNull(testGroupConfiguration.getCacheXmlContent());
         assertTrue(testGroupConfiguration.getCacheXmlContent().contains(REGION1));
 
-        Object[] jarData = sharedConfig.getAllJars(entireConfiguration.keySet());
-        String[] jarNames = (String[]) jarData[0];
-        byte[][] jarBytes = (byte[][]) jarData[1];
+        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);

http://git-wip-us.apache.org/repos/asf/geode/blob/07ed4654/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index 9e46ad0..6af9cf2 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -121,6 +121,14 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
     CliUtil.isGfshVM = false;
   }
 
+  public void closeQuietly() {
+    try {
+      this.close();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
   public HeadlessGfsh getGfsh() {
     return gfsh;
   }


Mime
View raw message