geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [geode] branch develop updated: GEODE-3539: Consolidate CliUtil and DataCommandUtils, DataCommandsUtil (#992)
Date Tue, 31 Oct 2017 16:44:22 GMT
This is an automated email from the ASF dual-hosted git repository.

jinmeiliao pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 19e5f8c  GEODE-3539: Consolidate CliUtil and DataCommandUtils, DataCommandsUtil (#992)
19e5f8c is described below

commit 19e5f8ce4995257fded70817436c3e8740115dd0
Author: jinmeiliao <jiliao@pivotal.io>
AuthorDate: Tue Oct 31 09:44:20 2017 -0700

    GEODE-3539: Consolidate CliUtil and DataCommandUtils, DataCommandsUtil (#992)
    
    * GEODE-3539: Consolidate CliUtil and DataCommandUtils, DataCommandsUtil
    
    * remove DataCommandsUtil
    * move method from DataCommandUtils to CliUtil if applicable.
    * move moethds from DataCommandUtils to individual command if only used by one command
---
 .../internal/ClusterConfigurationService.java      |  64 +++---
 .../internal/beans/QueryDataFunction.java          |  36 ++--
 .../geode/management/internal/cli/CliUtil.java     | 153 +++++++-------
 .../internal/cli/commands/CreateRegionCommand.java |   7 +-
 .../internal/cli/commands/DataCommandUtil.java     |  44 ----
 .../internal/cli/commands/DataCommandsUtils.java   | 229 ---------------------
 .../cli/commands/DescribeConfigCommand.java        |   2 +-
 .../cli/commands/DescribeMemberCommand.java        |   3 +-
 .../cli/commands/ExecuteFunctionCommand.java       |   5 +-
 .../internal/cli/commands/ExportDataCommand.java   |   5 +-
 .../ExportImportClusterConfigurationCommands.java  |   4 +-
 .../internal/cli/commands/ExportLogsCommand.java   |   4 +-
 .../internal/cli/commands/GetCommand.java          |   3 +-
 .../internal/cli/commands/GfshCommand.java         |  11 +-
 .../internal/cli/commands/ImportDataCommand.java   |   5 +-
 .../internal/cli/commands/LocateEntryCommand.java  |   3 +-
 .../internal/cli/commands/NetstatCommand.java      |  27 ++-
 .../internal/cli/commands/PutCommand.java          |   3 +-
 .../internal/cli/commands/QueryCommand.java        |   3 +-
 .../internal/cli/commands/RebalanceCommand.java    | 157 +++++++++++---
 .../internal/cli/commands/RemoveCommand.java       |   3 +-
 .../internal/cli/domain/DataCommandResult.java     |   4 -
 .../management/internal/cli/CliUtilDUnitTest.java  |   6 +-
 .../QueryCommandUnitTest.java => CliUtilTest.java} |  17 +-
 .../cli/commands/CreateRegionCommandTest.java      |   5 +-
 .../ExecuteFunctionCommandSecurityTest.java        |   4 +-
 .../cli/commands/GemfireDataCommandsDUnitTest.java |   3 +-
 .../cli/commands/RemoveCommandDUnitTest.java       |   4 +-
 .../cli/commands/RemoveCommandJsonDUnitTest.java   |   4 +-
 .../internal/cli/LuceneIndexCommandsJUnitTest.java |   8 +-
 30 files changed, 337 insertions(+), 489 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java
index d990015..2eefb89 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java
@@ -18,10 +18,41 @@ import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_CONFI
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_POST_PROCESSOR;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Path;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Collections;
+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;
+import java.util.stream.Collectors;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.filefilter.DirectoryFileFilter;
 import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Logger;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
 import org.apache.geode.CancelException;
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.CacheLoaderException;
@@ -53,34 +84,6 @@ import org.apache.geode.management.internal.configuration.messages.Configuration
 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.logging.log4j.Logger;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.file.Path;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-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;
-import java.util.stream.Collectors;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
 
 @SuppressWarnings({"deprecation", "unchecked"})
 public class ClusterConfigurationService {
@@ -671,8 +674,9 @@ public class ClusterConfigurationService {
 
   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);
+    ResultCollector<byte[], List<byte[]>> rc =
+        (ResultCollector<byte[], List<byte[]>>) CliUtil.executeFunction(new UploadJarFunction(),
+            new Object[] {groupName, jarName}, Collections.singleton(locator));
 
     List<byte[]> result = rc.getResult();
 
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/QueryDataFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/QueryDataFunction.java
index 0b4470d..0771f33 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/QueryDataFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/QueryDataFunction.java
@@ -14,7 +14,21 @@
  */
 package org.apache.geode.management.internal.beans;
 
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.DataPolicy;
@@ -46,23 +60,10 @@ import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.internal.ManagementConstants;
 import org.apache.geode.management.internal.ManagementStrings;
 import org.apache.geode.management.internal.SystemManagementService;
-import org.apache.geode.management.internal.cli.commands.DataCommandsUtils;
+import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.json.GfJsonException;
 import org.apache.geode.management.internal.cli.json.GfJsonObject;
 import org.apache.geode.management.internal.cli.json.TypedJson;
-import org.apache.logging.log4j.Logger;
-
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  * This function is executed on one or multiple members based on the member input to
@@ -365,7 +366,7 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
                     .toString();
           } else {
             Set<DistributedMember> associatedMembers =
-                DataCommandsUtils.getRegionAssociatedMembers(regionPath, cache, true);
+                CliUtil.getRegionAssociatedMembers(regionPath, cache, true);
 
             if (inputMembers != null && inputMembers.size() > 0) {
               if (!associatedMembers.containsAll(inputMembers)) {
@@ -396,10 +397,9 @@ public class QueryDataFunction extends FunctionAdapter implements InternalEntity
 
       String randomRegion = regionsInQuery.iterator().next();
 
+      // get the first available member
       Set<DistributedMember> associatedMembers =
-          DataCommandsUtils.getQueryRegionsAssociatedMembers(regionsInQuery, cache, false);// First
-      // available
-      // member
+          CliUtil.getQueryRegionsAssociatedMembers(regionsInQuery, cache, false);
 
       if (associatedMembers != null && associatedMembers.size() > 0) {
         Object[] functionArgs = new Object[6];
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
index 4848f8b..c6ab852 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
@@ -31,13 +31,13 @@ import java.net.URLDecoder;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.stream.Collectors;
 import java.util.zip.DataFormatException;
 import java.util.zip.Deflater;
 import java.util.zip.Inflater;
@@ -58,11 +58,13 @@ import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
 import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy;
 import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.management.DistributedSystemMXBean;
+import org.apache.geode.management.DistributedRegionMXBean;
 import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.MBeanJMXAdapter;
 import org.apache.geode.management.internal.cli.functions.MembersForRegionFunction;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 
 /**
@@ -386,6 +388,26 @@ public class CliUtil {
     return instance;
   }
 
+  public static Result getFunctionResult(ResultCollector<?, ?> rc, String commandName) {
+    Result result;
+    List<Object> results = (List<Object>) rc.getResult();
+    if (results != null) {
+      Object resultObj = results.get(0);
+      if (resultObj instanceof String) {
+        result = ResultBuilder.createInfoResult((String) resultObj);
+      } else if (resultObj instanceof Exception) {
+        result = ResultBuilder.createGemFireErrorResult(((Exception) resultObj).getMessage());
+      } else {
+        result = ResultBuilder.createGemFireErrorResult(
+            CliStrings.format(CliStrings.COMMAND_FAILURE_MESSAGE, commandName));
+      }
+    } else {
+      result = ResultBuilder.createGemFireErrorResult(
+          CliStrings.format(CliStrings.COMMAND_FAILURE_MESSAGE, commandName));
+    }
+    return result;
+  }
+
   static class CustomFileFilter implements FileFilter {
     private String extensionWithDot;
 
@@ -492,8 +514,7 @@ public class CliUtil {
    */
   @SuppressWarnings("unchecked")
   public static Set<DistributedMember> getAllMembers(InternalCache cache) {
-    return new HashSet<DistributedMember>(
-        cache.getInternalDistributedSystem().getDistributionManager().getDistributionManagerIds());
+    return getAllMembers(cache.getInternalDistributedSystem());
   }
 
   @SuppressWarnings("unchecked")
@@ -502,19 +523,6 @@ public class CliUtil {
         internalDS.getDistributionManager().getDistributionManagerIds());
   }
 
-  /**
-   * Returns a set of all the members of the distributed system for the given groups.
-   */
-  public static Set<DistributedMember> getDistributedMembersByGroup(InternalCache cache,
-      String[] groups) {
-    Set<DistributedMember> groupMembers = new HashSet<>();
-    for (String group : groups) {
-      groupMembers.addAll(
-          cache.getInternalDistributedSystem().getDistributionManager().getGroupMembers(group));
-    }
-    return groupMembers;
-  }
-
   /***
    * Executes a function with arguments on a set of members , ignores the departed members.
    * 
@@ -539,29 +547,6 @@ public class CliUtil {
     return execution.execute(function);
   }
 
-  /***
-   * Executes a function with arguments on a member , ignores the departed member.
-   * 
-   * @param function Function to be executed
-   * @param args Arguments passed to the function, pass null if you wish to pass no arguments to the
-   *        function.
-   * @param targetMember Member on which the function is to be executed.
-   * @return ResultCollector
-   */
-  public static ResultCollector<?, ?> executeFunction(final Function function, Object args,
-      final DistributedMember targetMember) {
-    Execution execution;
-
-    if (args != null) {
-      execution = FunctionService.onMember(targetMember).setArguments(args);
-    } else {
-      execution = FunctionService.onMember(targetMember);
-    }
-
-    ((AbstractExecution) execution).setIgnoreDepartedMembers(true);
-    return execution.execute(function);
-  }
-
   /**
    * Returns a Set of DistributedMember for members that have the specified <code>region</code>.
    * <code>returnAll</code> indicates whether to return all members or only the first member we
@@ -569,39 +554,69 @@ public class CliUtil {
    *
    * @param region region path for which members that have this region are required
    * @param cache cache instance to use to find members
+   * @param returnAll if true, returns all matching members, else returns only first one found.
    * @return a Set of DistributedMember for members that have the specified <code>region</code>.
    */
   public static Set<DistributedMember> getRegionAssociatedMembers(String region,
-      final InternalCache cache) {
+      final InternalCache cache, boolean returnAll) {
     if (region == null || region.isEmpty()) {
-      return null;
+      return Collections.emptySet();
     }
 
     if (!region.startsWith(Region.SEPARATOR)) {
       region = Region.SEPARATOR + region;
     }
 
-    ManagementService managementService = ManagementService.getExistingManagementService(cache);
-    DistributedSystemMXBean distributedSystemMXBean =
-        managementService.getDistributedSystemMXBean();
-    Set<DistributedMember> matchedMembers = new HashSet<>();
+    DistributedRegionMXBean regionMXBean =
+        ManagementService.getManagementService(cache).getDistributedRegionMXBean(region);
 
+    if (regionMXBean == null) {
+      return Collections.emptySet();
+    }
+
+    String[] regionAssociatedMemberNames = regionMXBean.getMembers();
+    Set<DistributedMember> matchedMembers = new HashSet<>();
     Set<DistributedMember> allClusterMembers = new HashSet<>();
     allClusterMembers.addAll(cache.getMembers());
     allClusterMembers.add(cache.getDistributedSystem().getDistributedMember());
 
     for (DistributedMember member : allClusterMembers) {
-      try {
-        if (distributedSystemMXBean.fetchRegionObjectName(CliUtil.getMemberNameOrId(member),
-            region) != null) {
+      for (String regionAssociatedMemberName : regionAssociatedMemberNames) {
+        String name = MBeanJMXAdapter.getMemberNameOrId(member);
+        if (name.equals(regionAssociatedMemberName)) {
           matchedMembers.add(member);
+          if (!returnAll) {
+            return matchedMembers;
+          }
         }
-      } catch (Exception ignored) {
       }
     }
     return matchedMembers;
   }
 
+  /**
+   * this finds the member that hosts all the regions passed in.
+   * 
+   * @param regions
+   * @param cache
+   * @param returnAll: if true, returns all matching members, otherwise, returns only one.
+   */
+  public static Set<DistributedMember> getQueryRegionsAssociatedMembers(Set<String> regions,
+      final InternalCache cache, boolean returnAll) {
+    Set<DistributedMember> results = regions.stream()
+        .map(region -> getRegionAssociatedMembers(region, cache, true)).reduce((s1, s2) -> {
+          s1.retainAll(s2);
+          return s1;
+        }).get();
+
+    if (returnAll || results.size() <= 1) {
+      return results;
+    }
+
+    // returns a set of only one item
+    return Collections.singleton(results.iterator().next());
+  }
+
   public static String getMemberNameOrId(DistributedMember distributedMember) {
     String nameOrId = null;
     if (distributedMember != null) {
@@ -611,41 +626,11 @@ public class CliUtil {
     return nameOrId;
   }
 
-  public static String collectionToString(Collection<?> col, int newlineAfter) {
-    if (col != null) {
-      StringBuilder builder = new StringBuilder();
-      int lastNewlineAt = 0;
-
-      for (Iterator<?> it = col.iterator(); it.hasNext();) {
-        Object object = it.next();
-        builder.append(String.valueOf(object));
-        if (it.hasNext()) {
-          builder.append(", ");
-        }
-        if (newlineAfter > 0 && (builder.length() - lastNewlineAt) / newlineAfter >= 1) {
-          builder.append(GfshParser.LINE_SEPARATOR);
-        }
-      }
-      return builder.toString();
-    } else {
-      return "" + null;
-    }
-  }
-
   public static <T> String arrayToString(T[] array) {
-    if (array != null) {
-      StringBuilder builder = new StringBuilder();
-      for (int i = 0; i < array.length; i++) {
-        Object object = array[i];
-        builder.append(String.valueOf(object));
-        if (i < array.length - 1) {
-          builder.append(", ");
-        }
-      }
-      return builder.toString();
-    } else {
-      return "" + null;
+    if (array == null) {
+      return "null";
     }
+    return Arrays.stream(array).map(String::valueOf).collect(Collectors.joining(", "));
   }
 
   public static String decodeWithDefaultCharSet(String urlToDecode) {
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
index ca79cf1..a4b2f72 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
@@ -418,12 +418,11 @@ public class CreateRegionCommand implements GfshCommand {
 
     if (attributes == null) {
       // find first member which has the region
-      Set<DistributedMember> regionAssociatedMembers =
-          CliUtil.getRegionAssociatedMembers(regionPath, cache);
+      Set<DistributedMember> regionAssociatedMembers = findMembersForRegion(cache, regionPath);
       if (regionAssociatedMembers != null && !regionAssociatedMembers.isEmpty()) {
         DistributedMember distributedMember = regionAssociatedMembers.iterator().next();
-        ResultCollector<?, ?> resultCollector = CliUtil
-            .executeFunction(FetchRegionAttributesFunction.INSTANCE, regionPath, distributedMember);
+        ResultCollector<?, ?> resultCollector =
+            executeFunction(FetchRegionAttributesFunction.INSTANCE, regionPath, distributedMember);
         List<?> resultsList = (List<?>) resultCollector.getResult();
 
         if (resultsList != null && !resultsList.isEmpty()) {
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommandUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommandUtil.java
deleted file mode 100644
index b15a958..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommandUtil.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * * Licensed to the Apache Software Foundation (ASF) under one or more contributor license *
- * agreements. See the NOTICE file distributed with this work for additional information regarding *
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * * "License"); you may not use this file except in compliance with the License. You may obtain a *
- * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by
- * applicable law or agreed to in writing, software distributed under the License * is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied.
- * See the License for the specific language governing permissions and limitations under * the
- * License. *
- *
- */
-
-package org.apache.geode.management.internal.cli.commands;
-
-import java.util.List;
-
-import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.ResultBuilder;
-
-public class DataCommandUtil {
-  public static Result getFunctionResult(ResultCollector<?, ?> rc, String commandName) {
-    Result result;
-    List<Object> results = (List<Object>) rc.getResult();
-    if (results != null) {
-      Object resultObj = results.get(0);
-      if (resultObj instanceof String) {
-        result = ResultBuilder.createInfoResult((String) resultObj);
-      } else if (resultObj instanceof Exception) {
-        result = ResultBuilder.createGemFireErrorResult(((Exception) resultObj).getMessage());
-      } else {
-        result = ResultBuilder.createGemFireErrorResult(
-            CliStrings.format(CliStrings.COMMAND_FAILURE_MESSAGE, commandName));
-      }
-    } else {
-      result = ResultBuilder.createGemFireErrorResult(
-          CliStrings.format(CliStrings.COMMAND_FAILURE_MESSAGE, commandName));
-    }
-    return result;
-  }
-}
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommandsUtils.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommandsUtils.java
index bca315f..7a6bfbc 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommandsUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommandsUtils.java
@@ -15,153 +15,19 @@
 
 package org.apache.geode.management.internal.cli.commands;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-import java.util.StringTokenizer;
 
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-
-import org.apache.geode.LogWriter;
-import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.management.DistributedRegionMXBean;
-import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.MBeanJMXAdapter;
-import org.apache.geode.management.internal.cli.CliUtil;
-import org.apache.geode.management.internal.cli.LogWrapper;
 import org.apache.geode.management.internal.cli.domain.DataCommandRequest;
 import org.apache.geode.management.internal.cli.domain.DataCommandResult;
 import org.apache.geode.management.internal.cli.functions.DataCommandFunction;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CompositeResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
-import org.apache.geode.management.internal.cli.result.TabularResultData;
 
 public class DataCommandsUtils {
-  static boolean checkResultList(CompositeResultData rebalanceResultData, List resultList,
-      DistributedMember member) {
-    boolean toContinueForOtherMembers = false;
-    if (CollectionUtils.isNotEmpty(resultList)) {
-      for (Object object : resultList) {
-        if (object instanceof Exception) {
-          rebalanceResultData.addSection().addData(
-              CliStrings.format(CliStrings.REBALANCE__MSG__NO_EXECUTION, member.getId()),
-              ((Exception) object).getMessage());
-
-          LogWrapper.getInstance().info(CliStrings.REBALANCE__MSG__NO_EXECUTION + member.getId()
-              + " exception=" + ((Throwable) object).getMessage(), ((Throwable) object));
-
-          toContinueForOtherMembers = true;
-          break;
-        } else if (object instanceof Throwable) {
-          rebalanceResultData.addSection().addData(
-              CliStrings.format(CliStrings.REBALANCE__MSG__NO_EXECUTION, member.getId()),
-              ((Throwable) object).getMessage());
-
-          LogWrapper.getInstance().info(CliStrings.REBALANCE__MSG__NO_EXECUTION + member.getId()
-              + " exception=" + ((Throwable) object).getMessage(), ((Throwable) object));
-
-          toContinueForOtherMembers = true;
-          break;
-        }
-      }
-    } else {
-      LogWrapper.getInstance().info(
-          "Rebalancing for member=" + member.getId() + ", resultList is either null or empty");
-      rebalanceResultData.addSection().addData("Rebalancing for member=" + member.getId(),
-          ", resultList is either null or empty");
-      toContinueForOtherMembers = true;
-    }
-    return toContinueForOtherMembers;
-  }
-
-  static List<String> tokenize(String str, String separator) {
-    StringTokenizer st = new StringTokenizer(str, separator);
-    List<String> rstList = new ArrayList<>();
-    while (st.hasMoreTokens()) {
-      rstList.add(st.nextToken());
-
-    }
-    return rstList;
-  }
-
-  static CompositeResultData toCompositeResultData(CompositeResultData rebalanceResultData,
-      ArrayList<String> rstlist, int index, boolean simulate, InternalCache cache) {
-    int resultItemCount = 9;
-    // add only if there are any valid regions in results
-    if (rstlist.size() > resultItemCount && StringUtils.isNotEmpty(rstlist.get(resultItemCount))) {
-      TabularResultData table1 = rebalanceResultData.addSection().addTable("Table" + index);
-      String newLine = System.getProperty("line.separator");
-      StringBuilder resultStr = new StringBuilder();
-      resultStr.append(newLine);
-      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETCREATEBYTES);
-      table1.accumulate("Value", rstlist.get(0));
-      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETCREATEBYTES).append(" = ")
-          .append(rstlist.get(0)).append(newLine);
-      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETCREATETIM);
-      table1.accumulate("Value", rstlist.get(1));
-      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETCREATETIM).append(" = ")
-          .append(rstlist.get(1)).append(newLine);
-
-      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETCREATESCOMPLETED);
-      table1.accumulate("Value", rstlist.get(2));
-      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETCREATESCOMPLETED).append(" = ")
-          .append(rstlist.get(2)).append(newLine);
-
-      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERBYTES);
-      table1.accumulate("Value", rstlist.get(3));
-      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERBYTES).append(" = ")
-          .append(rstlist.get(3)).append(newLine);
-
-      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERTIME);
-      table1.accumulate("Value", rstlist.get(4));
-      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERTIME).append(" = ")
-          .append(rstlist.get(4)).append(newLine);
-
-      table1.accumulate("Rebalanced Stats",
-          CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERSCOMPLETED);
-      table1.accumulate("Value", rstlist.get(5));
-      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERSCOMPLETED).append(" = ")
-          .append(rstlist.get(5)).append(newLine);
-
-      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERTIME);
-      table1.accumulate("Value", rstlist.get(6));
-      resultStr.append(CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERTIME).append(" = ")
-          .append(rstlist.get(6)).append(newLine);
-
-      table1.accumulate("Rebalanced Stats",
-          CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERSCOMPLETED);
-      table1.accumulate("Value", rstlist.get(7));
-      resultStr.append(CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERSCOMPLETED).append(" = ")
-          .append(rstlist.get(7)).append(newLine);
-
-      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALTIME);
-      table1.accumulate("Value", rstlist.get(8));
-      resultStr.append(CliStrings.REBALANCE__MSG__TOTALTIME).append(" = ").append(rstlist.get(8))
-          .append(newLine);
-
-      String headerText;
-      if (simulate) {
-        headerText = "Simulated partition regions ";
-      } else {
-        headerText = "Rebalanced partition regions ";
-      }
-      for (int i = resultItemCount; i < rstlist.size(); i++) {
-        headerText = headerText + " " + rstlist.get(i);
-      }
-      table1.setHeader(headerText);
-      cache.getLogger().info(headerText + resultStr);
-    }
-    return rebalanceResultData;
-  }
 
   static Result makePresentationResult(DataCommandResult dataResult) {
     if (dataResult != null) {
@@ -171,52 +37,6 @@ public class DataCommandsUtils {
     }
   }
 
-  public static Set<DistributedMember> getRegionAssociatedMembers(String region,
-      final InternalCache cache, boolean returnAll) {
-    DistributedMember member;
-    if (StringUtils.isEmpty(region)) {
-      return null;
-    }
-    DistributedRegionMXBean bean =
-        ManagementService.getManagementService(cache).getDistributedRegionMXBean(region);
-    if (bean == null) {
-      // try with slash ahead
-      bean = ManagementService.getManagementService(cache)
-          .getDistributedRegionMXBean(Region.SEPARATOR + region);
-    }
-    if (bean == null) {
-      return null;
-    }
-    String[] membersName = bean.getMembers();
-    Set<DistributedMember> dsMembers = cache.getMembers();
-    Set<DistributedMember> dsMembersWithThisMember = new HashSet<>();
-    dsMembersWithThisMember.addAll(dsMembers);
-    dsMembersWithThisMember.add(cache.getDistributedSystem().getDistributedMember());
-    Iterator it = dsMembersWithThisMember.iterator();
-    Set<DistributedMember> matchedMembers = new HashSet<>();
-
-    if (membersName.length > 0) {
-      while (it.hasNext()) {
-        DistributedMember dsmember = (DistributedMember) it.next();
-        for (String memberName : membersName) {
-          String name = MBeanJMXAdapter.getMemberNameOrId(dsmember);
-          if (name.equals(memberName)) {
-            member = dsmember;
-            matchedMembers.add(member);
-            if (!returnAll) {
-              return matchedMembers;
-            }
-          }
-        }
-      }
-    }
-    // try with function calls
-    if (matchedMembers.size() == 0) {
-      matchedMembers = CliUtil.getMembersForeRegionViaFunction(cache, region, true);
-    }
-    return matchedMembers;
-  }
-
   static DataCommandResult callFunctionForRegion(DataCommandRequest request,
       DataCommandFunction putfn, Set<DistributedMember> members) {
     if (members.size() == 1) {
@@ -259,53 +79,4 @@ public class DataCommandsUtils {
       return result;
     }
   }
-
-  public static Set<DistributedMember> getQueryRegionsAssociatedMembers(Set<String> regions,
-      final InternalCache cache, boolean returnAll) {
-    LogWriter logger = cache.getLogger();
-    Set<DistributedMember> members;
-    Set<DistributedMember> newMembers = null;
-    Iterator<String> iterator = regions.iterator();
-    String region = iterator.next();
-    members = getRegionAssociatedMembers(region, cache, true);
-    if (logger.fineEnabled()) {
-      logger.fine("Members for region " + region + " Members " + members);
-    }
-    List<String> regionAndingList = new ArrayList<>();
-    regionAndingList.add(region);
-    if (regions.size() == 1) {
-      newMembers = members;
-    } else {
-      if (CollectionUtils.isNotEmpty(members)) {
-        while (iterator.hasNext()) {
-          region = iterator.next();
-          newMembers = getRegionAssociatedMembers(region, cache, true);
-          if (newMembers == null) {
-            newMembers = new HashSet<>();
-          }
-          if (logger.fineEnabled()) {
-            logger.fine("Members for region " + region + " Members " + newMembers);
-          }
-          regionAndingList.add(region);
-          newMembers.retainAll(members);
-          members = newMembers;
-          if (logger.fineEnabled()) {
-            logger.fine(
-                "Members after anding for regions " + regionAndingList + " List : " + newMembers);
-          }
-        }
-      }
-    }
-    members = new HashSet<>();
-    if (newMembers == null) {
-      return members;
-    }
-    for (DistributedMember newMember : newMembers) {
-      members.add(newMember);
-      if (!returnAll) {
-        return members;
-      }
-    }
-    return members;
-  }
 }
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommand.java
index 824063a..b7b1f08 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommand.java
@@ -64,7 +64,7 @@ public class DescribeConfigCommand implements GfshCommand {
       }
       if (targetMember != null) {
         ResultCollector<?, ?> rc =
-            CliUtil.executeFunction(getMemberConfigFunction, hideDefaults, targetMember);
+            executeFunction(getMemberConfigFunction, hideDefaults, targetMember);
         ArrayList<?> output = (ArrayList<?>) rc.getResult();
         Object obj = output.get(0);
 
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeMemberCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeMemberCommand.java
index 9f742ef..dfe2a57 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeMemberCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeMemberCommand.java
@@ -56,8 +56,7 @@ public class DescribeMemberCommand implements GfshCommand {
           CliUtil.getDistributedMemberByNameOrId(memberNameOrId);
 
       if (memberToBeDescribed != null) {
-        ResultCollector<?, ?> rc =
-            CliUtil.executeFunction(getMemberInformation, null, memberToBeDescribed);
+        ResultCollector<?, ?> rc = executeFunction(getMemberInformation, null, memberToBeDescribed);
 
         ArrayList<?> output = (ArrayList<?>) rc.getResult();
         Object obj = output.get(0);
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommand.java
index 057edec..2c419f1 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommand.java
@@ -34,7 +34,6 @@ import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.ConverterHint;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.CliAroundInterceptor;
-import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.GfshParseResult;
 import org.apache.geode.management.internal.cli.functions.UserFunctionExecution;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
@@ -75,9 +74,9 @@ public class ExecuteFunctionCommand implements GfshCommand {
     Set<DistributedMember> dsMembers;
     if (onRegion == null) {
       // find the members based on the groups or members
-      dsMembers = CliUtil.findMembers(onGroups, onMembers);
+      dsMembers = findMembers(onGroups, onMembers);
     } else {
-      dsMembers = CliUtil.getRegionAssociatedMembers(onRegion, getCache());
+      dsMembers = findMembersForRegion(getCache(), onRegion);
     }
 
     if (dsMembers.size() == 0) {
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportDataCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportDataCommand.java
index dc74d12..5f7a6d1 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportDataCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportDataCommand.java
@@ -16,7 +16,6 @@
 package org.apache.geode.management.internal.cli.commands;
 
 import java.io.File;
-import java.util.List;
 import java.util.Optional;
 
 import org.springframework.shell.core.annotation.CliCommand;
@@ -73,8 +72,8 @@ public class ExportDataCommand implements GfshCommand {
       String path = dirPath != null ? defaultFileName(dirPath, regionName) : filePath;
       final String args[] = {regionName, path, Boolean.toString(parallel)};
 
-      ResultCollector<?, ?> rc = CliUtil.executeFunction(exportDataFunction, args, targetMember);
-      result = DataCommandUtil.getFunctionResult(rc, CliStrings.EXPORT_DATA);
+      ResultCollector<?, ?> rc = executeFunction(exportDataFunction, args, targetMember);
+      result = CliUtil.getFunctionResult(rc, CliStrings.EXPORT_DATA);
     } catch (CacheClosedException e) {
       result = ResultBuilder.createGemFireErrorResult(e.getMessage());
     } catch (FunctionInvocationTargetException e) {
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
index 8d24250..89e452d 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
@@ -206,14 +206,14 @@ public class ExportImportClusterConfigurationCommands implements GfshCommand {
   }
 
   private Set<String> getRegionNamesOnServer(DistributedMember server) {
-    ResultCollector rc = CliUtil.executeFunction(new GetRegionNamesFunction(), null, server);
+    ResultCollector rc = executeFunction(new GetRegionNamesFunction(), null, server);
     List<Set<String>> results = (List<Set<String>>) rc.getResult();
 
     return results.get(0);
   }
 
   private CliFunctionResult reCreateCache(DistributedMember server) {
-    ResultCollector rc = CliUtil.executeFunction(new RecreateCacheFunction(), null, server);
+    ResultCollector rc = executeFunction(new RecreateCacheFunction(), null, server);
     List<CliFunctionResult> results = (List<CliFunctionResult>) rc.getResult();
 
     return results.get(0);
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
index 45b183b..dd56bc9 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
@@ -157,7 +157,7 @@ public class ExportLogsCommand implements GfshCommand {
 
         cacheWriter.startFile(server.getName());
 
-        CliUtil.executeFunction(new ExportLogsFunction(),
+        executeFunction(new ExportLogsFunction(),
             new ExportLogsFunction.Args(start, end, logLevel, onlyLogLevel, logsOnly, statsOnly),
             server).getResult();
         Path zipFile = cacheWriter.endFile();
@@ -224,7 +224,7 @@ public class ExportLogsCommand implements GfshCommand {
    * Wrapper to enable stubbing of static method call for unit testing
    */
   ResultCollector estimateLogSize(SizeExportLogsFunction.Args args, DistributedMember member) {
-    return CliUtil.executeFunction(new SizeExportLogsFunction(), args, member);
+    return executeFunction(new SizeExportLogsFunction(), args, member);
   }
 
   /**
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GetCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GetCommand.java
index ed7ab26..9f3501a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GetCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GetCommand.java
@@ -16,7 +16,6 @@
 package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.callFunctionForRegion;
-import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.getRegionAssociatedMembers;
 import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.makePresentationResult;
 
 import java.util.Set;
@@ -64,7 +63,7 @@ public class GetCommand implements GfshCommand {
     Region region = cache.getRegion(regionPath);
     DataCommandFunction getfn = new DataCommandFunction();
     if (region == null) {
-      Set<DistributedMember> memberList = getRegionAssociatedMembers(regionPath, getCache(), false);
+      Set<DistributedMember> memberList = findAnyMembersForRegion(getCache(), regionPath);
       if (CollectionUtils.isNotEmpty(memberList)) {
         DataCommandRequest request = new DataCommandRequest();
         request.setCommand(CliStrings.GET);
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
index a785068..5e2f2d8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
@@ -16,6 +16,7 @@ package org.apache.geode.management.internal.cli.commands;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -153,7 +154,7 @@ public interface GfshCommand extends CommandMarker {
   }
 
   default Set<DistributedMember> findMembersForRegion(InternalCache cache, String regionPath) {
-    return CliUtil.getRegionAssociatedMembers(regionPath, cache);
+    return CliUtil.getRegionAssociatedMembers(regionPath, cache, true);
   }
 
   default ResultCollector<?, ?> executeFunction(final Function function, Object args,
@@ -161,4 +162,12 @@ public interface GfshCommand extends CommandMarker {
     return CliUtil.executeFunction(function, args, targetMembers);
   }
 
+  default ResultCollector<?, ?> executeFunction(final Function function, Object args,
+      final DistributedMember targetMember) {
+    return executeFunction(function, args, Collections.singleton(targetMember));
+  }
+
+  default Set<DistributedMember> findAnyMembersForRegion(InternalCache cache, String regionPath) {
+    return CliUtil.getRegionAssociatedMembers(regionPath, cache, false);
+  }
 }
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ImportDataCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ImportDataCommand.java
index f81c3f0..7e4f1d7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ImportDataCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ImportDataCommand.java
@@ -15,7 +15,6 @@
 
 package org.apache.geode.management.internal.cli.commands;
 
-import java.util.List;
 import java.util.Optional;
 
 import org.springframework.shell.core.annotation.CliCommand;
@@ -74,8 +73,8 @@ public class ImportDataCommand implements GfshCommand {
       String path = dirPath != null ? dirPath : filePath;
       final Object args[] = {regionName, path, invokeCallbacks, parallel};
 
-      ResultCollector<?, ?> rc = CliUtil.executeFunction(importDataFunction, args, targetMember);
-      result = DataCommandUtil.getFunctionResult(rc, CliStrings.IMPORT_DATA);
+      ResultCollector<?, ?> rc = executeFunction(importDataFunction, args, targetMember);
+      result = CliUtil.getFunctionResult(rc, CliStrings.IMPORT_DATA);
     } catch (CacheClosedException e) {
       result = ResultBuilder.createGemFireErrorResult(e.getMessage());
     } catch (FunctionInvocationTargetException e) {
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LocateEntryCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LocateEntryCommand.java
index d3746c5..1d1aa4b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LocateEntryCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LocateEntryCommand.java
@@ -16,7 +16,6 @@
 package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.callFunctionForRegion;
-import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.getRegionAssociatedMembers;
 import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.makePresentationResult;
 
 import java.util.Set;
@@ -58,7 +57,7 @@ public class LocateEntryCommand implements GfshCommand {
     DataCommandResult dataResult;
 
     DataCommandFunction locateEntry = new DataCommandFunction();
-    Set<DistributedMember> memberList = getRegionAssociatedMembers(regionPath, getCache(), true);
+    Set<DistributedMember> memberList = findMembersForRegion(getCache(), regionPath);
     if (CollectionUtils.isNotEmpty(memberList)) {
       DataCommandRequest request = new DataCommandRequest();
       request.setCommand(CliStrings.LOCATE_ENTRY);
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/NetstatCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/NetstatCommand.java
index a5d62fa..0bf2d40 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/NetstatCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/NetstatCommand.java
@@ -18,8 +18,10 @@ package org.apache.geode.management.internal.cli.commands;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -102,7 +104,7 @@ public class NetstatCommand implements GfshCommand {
         if (!notFoundMembers.isEmpty()) {
           throw new IllegalArgumentException(
               CliStrings.format(CliStrings.NETSTAT__MSG__COULD_NOT_FIND_MEMBERS_0,
-                  new Object[] {CliUtil.collectionToString(notFoundMembers, -1)}));
+                  new Object[] {collectionToString(notFoundMembers, -1)}));
         }
       } else {
         Set<DistributedMember> membersToExecuteOn;
@@ -145,7 +147,7 @@ public class NetstatCommand implements GfshCommand {
             String remoteHost = netstatFunctionResult.getHost();
             List<String> membersList = hostMemberListMap.get(remoteHost);
             resultInfo.append(MessageFormat.format(netstatFunctionResult.getHeaderInfo(),
-                CliUtil.collectionToString(membersList, 120)));
+                collectionToString(membersList, 120)));
             CliUtil.DeflaterInflaterData uncompressedBytes = CliUtil.uncompressBytes(
                 deflaterInflaterData.getData(), deflaterInflaterData.getDataLength());
             resultInfo.append(new String(uncompressedBytes.getData()));
@@ -189,6 +191,27 @@ public class NetstatCommand implements GfshCommand {
     return result;
   }
 
+  String collectionToString(Collection<?> col, int newlineAfter) {
+    if (col != null) {
+      StringBuilder builder = new StringBuilder();
+      int lastNewlineAt = 0;
+
+      for (Iterator<?> it = col.iterator(); it.hasNext();) {
+        Object object = it.next();
+        builder.append(String.valueOf(object));
+        if (it.hasNext()) {
+          builder.append(", ");
+        }
+        if (newlineAfter > 0 && (builder.length() - lastNewlineAt) / newlineAfter >= 1) {
+          builder.append(GfshParser.LINE_SEPARATOR);
+        }
+      }
+      return builder.toString();
+    } else {
+      return "" + null;
+    }
+  }
+
   private void buildMaps(Map<String, DistributedMember> hostMemberMap,
       Map<String, List<String>> hostMemberListMap, String memberIdOrName,
       DistributedMember distributedMember) {
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PutCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PutCommand.java
index b20aeb1..ca167a9 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PutCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PutCommand.java
@@ -16,7 +16,6 @@
 package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.callFunctionForRegion;
-import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.getRegionAssociatedMembers;
 import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.makePresentationResult;
 
 import java.util.Set;
@@ -64,7 +63,7 @@ public class PutCommand implements GfshCommand {
     Region region = cache.getRegion(regionPath);
     DataCommandFunction putfn = new DataCommandFunction();
     if (region == null) {
-      Set<DistributedMember> memberList = getRegionAssociatedMembers(regionPath, getCache(), false);
+      Set<DistributedMember> memberList = findAnyMembersForRegion(getCache(), regionPath);
       if (CollectionUtils.isNotEmpty(memberList)) {
         DataCommandRequest request = new DataCommandRequest();
         request.setCommand(CliStrings.PUT);
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommand.java
index e216964..4fd9555 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommand.java
@@ -39,6 +39,7 @@ import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.ConverterHint;
 import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.domain.DataCommandRequest;
 import org.apache.geode.management.internal.cli.domain.DataCommandResult;
 import org.apache.geode.management.internal.cli.functions.DataCommandFunction;
@@ -100,7 +101,7 @@ public class QueryCommand implements GfshCommand {
       regionsInQuery = Collections.unmodifiableSet(regions);
       if (regionsInQuery.size() > 0) {
         Set<DistributedMember> members =
-            DataCommandsUtils.getQueryRegionsAssociatedMembers(regionsInQuery, cache, false);
+            CliUtil.getQueryRegionsAssociatedMembers(regionsInQuery, cache, false);
         if (members != null && members.size() > 0) {
           DataCommandFunction function = new DataCommandFunction();
           DataCommandRequest request = new DataCommandRequest();
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommand.java
index 85801ba..d0e1fd4 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommand.java
@@ -15,11 +15,8 @@
 
 package org.apache.geode.management.internal.cli.commands;
 
-import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.checkResultList;
-import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.toCompositeResultData;
-import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.tokenize;
-
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -32,6 +29,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.shell.core.annotation.CliCommand;
@@ -77,7 +75,8 @@ public class RebalanceCommand implements GfshCommand {
           help = CliStrings.REBALANCE__TIMEOUT__HELP) long timeout,
       @CliOption(key = CliStrings.REBALANCE__SIMULATE, specifiedDefaultValue = "true",
           unspecifiedDefaultValue = "false",
-          help = CliStrings.REBALANCE__SIMULATE__HELP) boolean simulate) {
+          help = CliStrings.REBALANCE__SIMULATE__HELP) boolean simulate)
+      throws Exception {
 
     ExecutorService commandExecutors = Executors.newSingleThreadExecutor();
     List<Future<Result>> commandResult = new ArrayList<>();
@@ -91,21 +90,125 @@ public class RebalanceCommand implements GfshCommand {
         result = fs.get(timeout, TimeUnit.SECONDS);
       } else {
         result = fs.get();
-
       }
     } catch (TimeoutException timeoutException) {
       result = ResultBuilder.createInfoResult(CliStrings.REBALANCE__MSG__REBALANCE_WILL_CONTINUE);
-
-    } catch (Exception ex) {
-      result = ResultBuilder.createGemFireErrorResult(CliStrings.format(
-          CliStrings.REBALANCE__MSG__EXCEPTION_OCCURRED_WHILE_REBALANCING_0, ex.getMessage()));
     }
     LogWrapper.getInstance().info("Rebalance returning result >>>" + result);
     return result;
   }
 
+  private boolean checkResultList(CompositeResultData rebalanceResultData, List resultList,
+      DistributedMember member) {
+    boolean toContinueForOtherMembers = false;
+    if (CollectionUtils.isNotEmpty(resultList)) {
+      for (Object object : resultList) {
+        if (object instanceof Exception) {
+          rebalanceResultData.addSection().addData(
+              CliStrings.format(CliStrings.REBALANCE__MSG__NO_EXECUTION, member.getId()),
+              ((Exception) object).getMessage());
+
+          LogWrapper.getInstance().info(CliStrings.REBALANCE__MSG__NO_EXECUTION + member.getId()
+              + " exception=" + ((Throwable) object).getMessage(), ((Throwable) object));
+
+          toContinueForOtherMembers = true;
+          break;
+        } else if (object instanceof Throwable) {
+          rebalanceResultData.addSection().addData(
+              CliStrings.format(CliStrings.REBALANCE__MSG__NO_EXECUTION, member.getId()),
+              ((Throwable) object).getMessage());
+
+          LogWrapper.getInstance().info(CliStrings.REBALANCE__MSG__NO_EXECUTION + member.getId()
+              + " exception=" + ((Throwable) object).getMessage(), ((Throwable) object));
+
+          toContinueForOtherMembers = true;
+          break;
+        }
+      }
+    } else {
+      LogWrapper.getInstance().info(
+          "Rebalancing for member=" + member.getId() + ", resultList is either null or empty");
+      rebalanceResultData.addSection().addData("Rebalancing for member=" + member.getId(),
+          ", resultList is either null or empty");
+      toContinueForOtherMembers = true;
+    }
+    return toContinueForOtherMembers;
+  }
+
+  private CompositeResultData toCompositeResultData(CompositeResultData rebalanceResultData,
+      List<String> rstlist, int index, boolean simulate, InternalCache cache) {
+    int resultItemCount = 9;
+    // add only if there are any valid regions in results
+    if (rstlist.size() > resultItemCount && StringUtils.isNotEmpty(rstlist.get(resultItemCount))) {
+      TabularResultData table1 = rebalanceResultData.addSection().addTable("Table" + index);
+      String newLine = System.getProperty("line.separator");
+      StringBuilder resultStr = new StringBuilder();
+      resultStr.append(newLine);
+      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETCREATEBYTES);
+      table1.accumulate("Value", rstlist.get(0));
+      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETCREATEBYTES).append(" = ")
+          .append(rstlist.get(0)).append(newLine);
+      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETCREATETIM);
+      table1.accumulate("Value", rstlist.get(1));
+      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETCREATETIM).append(" = ")
+          .append(rstlist.get(1)).append(newLine);
+
+      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETCREATESCOMPLETED);
+      table1.accumulate("Value", rstlist.get(2));
+      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETCREATESCOMPLETED).append(" = ")
+          .append(rstlist.get(2)).append(newLine);
+
+      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERBYTES);
+      table1.accumulate("Value", rstlist.get(3));
+      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERBYTES).append(" = ")
+          .append(rstlist.get(3)).append(newLine);
+
+      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERTIME);
+      table1.accumulate("Value", rstlist.get(4));
+      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERTIME).append(" = ")
+          .append(rstlist.get(4)).append(newLine);
+
+      table1.accumulate("Rebalanced Stats",
+          CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERSCOMPLETED);
+      table1.accumulate("Value", rstlist.get(5));
+      resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERSCOMPLETED).append(" = ")
+          .append(rstlist.get(5)).append(newLine);
+
+      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERTIME);
+      table1.accumulate("Value", rstlist.get(6));
+      resultStr.append(CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERTIME).append(" = ")
+          .append(rstlist.get(6)).append(newLine);
+
+      table1.accumulate("Rebalanced Stats",
+          CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERSCOMPLETED);
+      table1.accumulate("Value", rstlist.get(7));
+      resultStr.append(CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERSCOMPLETED).append(" = ")
+          .append(rstlist.get(7)).append(newLine);
+
+      table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALTIME);
+      table1.accumulate("Value", rstlist.get(8));
+      resultStr.append(CliStrings.REBALANCE__MSG__TOTALTIME).append(" = ").append(rstlist.get(8))
+          .append(newLine);
+
+      String headerText;
+      if (simulate) {
+        headerText = "Simulated partition regions ";
+      } else {
+        headerText = "Rebalanced partition regions ";
+      }
+      for (int i = resultItemCount; i < rstlist.size(); i++) {
+        headerText = headerText + " " + rstlist.get(i);
+      }
+      table1.setHeader(headerText);
+      cache.getLogger().info(headerText + resultStr);
+    }
+    return rebalanceResultData;
+  }
+
+
   // TODO EY Move this to its own class
   private class ExecuteRebalanceWithTimeout implements Callable<Result> {
+
     String[] includeRegions = null;
     String[] excludeRegions = null;
     boolean simulate;
@@ -165,8 +268,8 @@ public class RebalanceCommand implements GfshCommand {
               if (simulate) {
                 List resultList;
                 try {
-                  resultList = (ArrayList) CliUtil
-                      .executeFunction(rebalanceFunction, functionArgs, member).getResult();
+                  resultList = (ArrayList) executeFunction(rebalanceFunction, functionArgs, member)
+                      .getResult();
                 } catch (Exception ex) {
                   LogWrapper.getInstance()
                       .info(CliStrings.format(
@@ -184,15 +287,15 @@ public class RebalanceCommand implements GfshCommand {
                   result = ResultBuilder.buildResult(rebalanceResultData);
                   continue;
                 }
-                List<String> rstList = tokenize((String) resultList.get(0), ",");
+                List<String> rstList = Arrays.asList(((String) resultList.get(0)).split(","));
 
-                result = ResultBuilder.buildResult(toCompositeResultData(rebalanceResultData,
-                    (ArrayList) rstList, index, true, cache));
+                result = ResultBuilder.buildResult(
+                    toCompositeResultData(rebalanceResultData, rstList, index, true, cache));
               } else {
                 List resultList;
                 try {
-                  resultList = (ArrayList) CliUtil
-                      .executeFunction(rebalanceFunction, functionArgs, member).getResult();
+                  resultList = (ArrayList) executeFunction(rebalanceFunction, functionArgs, member)
+                      .getResult();
                 } catch (Exception ex) {
                   LogWrapper.getInstance()
                       .info(CliStrings.format(
@@ -210,10 +313,10 @@ public class RebalanceCommand implements GfshCommand {
                   result = ResultBuilder.buildResult(rebalanceResultData);
                   continue;
                 }
-                List<String> rstList = tokenize((String) resultList.get(0), ",");
+                List<String> rstList = Arrays.asList(((String) resultList.get(0)).split(","));
 
-                result = ResultBuilder.buildResult(toCompositeResultData(rebalanceResultData,
-                    (ArrayList) rstList, index, false, cache));
+                result = ResultBuilder.buildResult(
+                    toCompositeResultData(rebalanceResultData, rstList, index, false, cache));
               }
 
             } else {
@@ -426,17 +529,17 @@ public class RebalanceCommand implements GfshCommand {
 
             try {
               if (checkMemberPresence(dsMember, cache)) {
-                resultList = (ArrayList) CliUtil
-                    .executeFunction(rebalanceFunction, functionArgs, dsMember).getResult();
+                resultList = (ArrayList) executeFunction(rebalanceFunction, functionArgs, dsMember)
+                    .getResult();
 
                 if (checkResultList(rebalanceResultData, resultList, dsMember)) {
                   result = ResultBuilder.buildResult(rebalanceResultData);
                   continue;
                 }
 
-                List<String> rstList = tokenize((String) resultList.get(0), ",");
+                List<String> rstList = Arrays.asList(((String) resultList.get(0)).split(","));
                 result = ResultBuilder.buildResult(toCompositeResultData(rebalanceResultData,
-                    (ArrayList) rstList, index, simulate.equals("true"), cache));
+                    rstList, index, simulate.equals("true"), cache));
                 index++;
 
                 // Rebalancing for region is done so break and continue with other region
@@ -471,9 +574,9 @@ public class RebalanceCommand implements GfshCommand {
               continue;
             }
 
-            List<String> rstList = tokenize((String) resultList.get(0), ",");
-            result = ResultBuilder.buildResult(toCompositeResultData(rebalanceResultData,
-                (ArrayList) rstList, index, simulate.equals("true"), cache));
+            List<String> rstList = Arrays.asList(((String) resultList.get(0)).split(","));
+            result = ResultBuilder.buildResult(toCompositeResultData(rebalanceResultData, rstList,
+                index, simulate.equals("true"), cache));
             index++;
           }
         }
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RemoveCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RemoveCommand.java
index 1318cdf..c34805d 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RemoveCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RemoveCommand.java
@@ -16,7 +16,6 @@
 package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.callFunctionForRegion;
-import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.getRegionAssociatedMembers;
 import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.makePresentationResult;
 import static org.apache.geode.management.internal.cli.result.ResultBuilder.createUserErrorResult;
 
@@ -70,7 +69,7 @@ public class RemoveCommand implements GfshCommand {
     DataCommandFunction removefn = new DataCommandFunction();
     DataCommandResult dataResult;
     if (region == null) {
-      Set<DistributedMember> memberList = getRegionAssociatedMembers(regionPath, getCache(), false);
+      Set<DistributedMember> memberList = findAnyMembersForRegion(getCache(), regionPath);
 
       if (CollectionUtils.isEmpty(memberList)) {
         return createUserErrorResult(String.format(REGION_NOT_FOUND, regionPath));
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DataCommandResult.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DataCommandResult.java
index 5ad88c3..429c329 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DataCommandResult.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DataCommandResult.java
@@ -56,10 +56,6 @@ public class DataCommandResult implements Serializable {
   private List<SelectResultRow> selectResult;
   private String queryTraceString;
 
-  public static final String QUERY_PAGE_START = "startCount";
-  public static final String QUERY_PAGE_END = "endCount";
-  public static final String QUERY_TRACE = "Query Trace";
-
   public static final String RESULT_FLAG = "Result";
   public static final String NUM_ROWS = "Rows";
 
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/CliUtilDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/CliUtilDUnitTest.java
index fdcd888..6d2e9cc 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/CliUtilDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/CliUtilDUnitTest.java
@@ -331,7 +331,7 @@ public class CliUtilDUnitTest extends JUnit4CacheTestCase {
 
     InternalCache cache = getCache();
 
-    Set<DistributedMember> set = CliUtil.getRegionAssociatedMembers(region1, cache);
+    Set<DistributedMember> set = CliUtil.getRegionAssociatedMembers(region1, cache, true);
     assertNotNull(set);
     assertEquals(4, set.size());
     assertEquals(true, containsMember(set, MEMBER_1_GROUP1));
@@ -345,13 +345,13 @@ public class CliUtilDUnitTest extends JUnit4CacheTestCase {
      * assertIndexDetailsEquals(1, set.size());
      */
 
-    set = CliUtil.getRegionAssociatedMembers(region_group1, cache);
+    set = CliUtil.getRegionAssociatedMembers(region_group1, cache, true);
     assertNotNull(set);
     assertEquals(2, set.size());
     assertEquals(true, containsMember(set, MEMBER_1_GROUP1));
     assertEquals(true, containsMember(set, MEMBER_2_GROUP1));
 
-    set = CliUtil.getRegionAssociatedMembers(region_member2_group1, cache);
+    set = CliUtil.getRegionAssociatedMembers(region_member2_group1, cache, true);
     assertNotNull(set);
     assertEquals(1, set.size());
     assertEquals(true, containsMember(set, MEMBER_2_GROUP1));
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueryCommandUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/CliUtilTest.java
similarity index 62%
rename from geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueryCommandUnitTest.java
rename to geode-core/src/test/java/org/apache/geode/management/internal/cli/CliUtilTest.java
index 11da4b7..9f049c2 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueryCommandUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/CliUtilTest.java
@@ -13,18 +13,27 @@
  * the License.
  */
 
-package org.apache.geode.management.internal.cli.commands;
+package org.apache.geode.management.internal.cli;
+
+import static org.assertj.core.api.Assertions.assertThat;
 
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.test.junit.categories.UnitTest;
 
+
 @Category(UnitTest.class)
-public class QueryCommandUnitTest {
+public class CliUtilTest {
 
   @Test
-  public void query() throws Exception {
-    QueryCommand queryCommand = new QueryCommand();
+  public void arrayToString() throws Exception {
+    assertThat(CliUtil.arrayToString(null)).isEqualTo("null");
+    String[] array1 = {"one", "two", "three"};
+    assertThat(CliUtil.arrayToString(array1)).isEqualTo("one, two, three");
+    String[] array2 = {"one", null, "three"};
+    assertThat(CliUtil.arrayToString(array2)).isEqualTo("one, null, three");
+    String[] array3 = {null};
+    assertThat(CliUtil.arrayToString(array3)).isEqualTo("null");
   }
 }
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
index afb9c5e..d320386 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import java.util.Collections;
+import java.util.Set;
 
 import org.junit.Before;
 import org.junit.Rule;
@@ -148,7 +149,7 @@ public class CreateRegionCommandTest {
   @Test
   public void defaultValues() throws Exception {
     ResultCollector resultCollector = mock(ResultCollector.class);
-    doReturn(resultCollector).when(command).executeFunction(any(), any(), any());
+    doReturn(resultCollector).when(command).executeFunction(any(), any(), any(Set.class));
     when(resultCollector.getResult()).thenReturn(Collections.emptyList());
     DistributedSystemMXBean dsMBean = mock(DistributedSystemMXBean.class);
     doReturn(dsMBean).when(command).getDSMBean(any());
@@ -159,7 +160,7 @@ public class CreateRegionCommandTest {
     parser.executeCommandWithInstance(command, "create region --name=A --type=REPLICATE");
     ArgumentCaptor<RegionFunctionArgs> argsCaptor =
         ArgumentCaptor.forClass(RegionFunctionArgs.class);
-    verify(command).executeFunction(any(), argsCaptor.capture(), any());
+    verify(command).executeFunction(any(), argsCaptor.capture(), any(Set.class));
     RegionFunctionArgs args = argsCaptor.getValue();
 
     assertThat(args.getRegionPath()).isEqualTo("/A");
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandSecurityTest.java
index dd78f0c..428cf3b 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandSecurityTest.java
@@ -41,10 +41,10 @@ import org.apache.geode.management.internal.security.ResourceConstants;
 import org.apache.geode.management.internal.security.TestFunctions.ReadFunction;
 import org.apache.geode.management.internal.security.TestFunctions.WriteFunction;
 import org.apache.geode.security.SimpleTestSecurityManager;
-import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
 
 @Category(DistributedTest.class)
 public class ExecuteFunctionCommandSecurityTest implements Serializable {
@@ -152,7 +152,7 @@ public class ExecuteFunctionCommandSecurityTest implements Serializable {
   private static void waitUntilRegionMBeansAreRegistered() {
     Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> {
       Set<DistributedMember> regionMembers = CliUtil.getRegionAssociatedMembers(REPLICATED_REGION,
-          (InternalCache) CacheFactory.getAnyInstance());
+          (InternalCache) CacheFactory.getAnyInstance(), true);
       assertThat(regionMembers).hasSize(2);
     });
   }
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java
index fe7b179..2e9bafe 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java
@@ -17,7 +17,6 @@ package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.assertFalse;
 import static org.apache.geode.test.dunit.Assert.assertNotEquals;
 import static org.apache.geode.test.dunit.Assert.assertNotNull;
 import static org.apache.geode.test.dunit.Assert.assertNotSame;
@@ -421,7 +420,7 @@ public class GemfireDataCommandsDUnitTest extends CliCommandTestBase {
       getLogWriter().info("Region in query : " + regionsInQuery);
       if (regionsInQuery.size() > 0) {
         Set<DistributedMember> members =
-            DataCommandsUtils.getQueryRegionsAssociatedMembers(regionsInQuery, cache, returnAll);
+            CliUtil.getQueryRegionsAssociatedMembers(regionsInQuery, cache, returnAll);
         getLogWriter().info("Members for Region in query : " + members);
         if (expectedMembers != -1) {
           assertNotNull(members);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandDUnitTest.java
index 986d1ae..5a0bb17 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandDUnitTest.java
@@ -14,7 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.getRegionAssociatedMembers;
 import static org.apache.geode.management.internal.cli.commands.RemoveCommand.REGION_NOT_FOUND;
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -35,6 +34,7 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.test.dunit.SerializableCallableIF;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
@@ -178,7 +178,7 @@ public class RemoveCommandDUnitTest implements Serializable {
   }
 
   private boolean regionMBeansAreInitialized() {
-    Set<DistributedMember> members = getRegionAssociatedMembers(REPLICATE_REGION_NAME,
+    Set<DistributedMember> members = CliUtil.getRegionAssociatedMembers(REPLICATE_REGION_NAME,
         (InternalCache) CacheFactory.getAnyInstance(), false);
 
     return CollectionUtils.isNotEmpty(members);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandJsonDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandJsonDUnitTest.java
index 1f2a757..4137820 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandJsonDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandJsonDUnitTest.java
@@ -14,7 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import static org.apache.geode.management.internal.cli.commands.DataCommandsUtils.getRegionAssociatedMembers;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.Serializable;
@@ -34,6 +33,7 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.dto.Key1;
 import org.apache.geode.management.internal.cli.dto.Value2;
 import org.apache.geode.test.dunit.SerializableCallableIF;
@@ -149,7 +149,7 @@ public class RemoveCommandJsonDUnitTest implements Serializable {
   }
 
   private boolean regionMBeansAreInitialized() {
-    Set<DistributedMember> members = getRegionAssociatedMembers(JSON_REGION_NAME,
+    Set<DistributedMember> members = CliUtil.getRegionAssociatedMembers(JSON_REGION_NAME,
         (InternalCache) CacheFactory.getAnyInstance(), false);
 
     return CollectionUtils.isNotEmpty(members);
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
index bb010e7..d73bfc5 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
@@ -444,7 +444,7 @@ public class LuceneIndexCommandsJUnitTest {
     }
 
     doReturn(mockResultCollector).when(commands).executeFunction(
-        isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any());
+        isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any(Set.class));
     doReturn(cliFunctionResults).when(mockResultCollector).getResult();
 
     doReturn(Collections.emptySet()).when(commands).getNormalMembers(any());
@@ -481,7 +481,7 @@ public class LuceneIndexCommandsJUnitTest {
     }
 
     doReturn(mockResultCollector).when(commands).executeFunction(
-        isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any());
+        isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any(Set.class));
     doReturn(cliFunctionResults).when(mockResultCollector).getResult();
 
     doReturn(members).when(commands).getNormalMembers(any());
@@ -513,7 +513,7 @@ public class LuceneIndexCommandsJUnitTest {
     }
 
     doReturn(mockResultCollector).when(commands).executeFunction(
-        isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any());
+        isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any(Set.class));
     doReturn(cliFunctionResults).when(mockResultCollector).getResult();
 
     doReturn(Collections.emptySet()).when(commands).getNormalMembers(any());
@@ -550,7 +550,7 @@ public class LuceneIndexCommandsJUnitTest {
     }
 
     doReturn(mockResultCollector).when(commands).executeFunction(
-        isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any());
+        isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any(Set.class));
     doReturn(cliFunctionResults).when(mockResultCollector).getResult();
 
     doReturn(Collections.emptySet()).when(commands).getNormalMembers(any());

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message