geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [3/7] geode git commit: Change GemFireCacheImpl to InternalCache
Date Fri, 05 May 2017 17:32:30 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/beans/RegionMBeanBridge.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/RegionMBeanBridge.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/RegionMBeanBridge.java
index b67b07d..8cfd4f2 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/RegionMBeanBridge.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/RegionMBeanBridge.java
@@ -45,8 +45,7 @@ import org.apache.geode.management.internal.beans.stats.StatsRate;
 /**
  * This class acts as a bridge between a Region and RegionMBean This also listens for statistics
  * changes and update its value accordingly
- * 
- * 
+ *
  * @param <K>
  * @param <V>
  */
@@ -100,10 +99,7 @@ public class RegionMBeanBridge<K, V> {
 
   private StatsRate averageReadsRate;
 
-
-
   public static <K, V> RegionMBeanBridge<K, V> getInstance(Region<K, V> region) {
-
     if (region.getAttributes().getPartitionAttributes() != null) {
       RegionMBeanBridge<K, V> bridge = PartitionedRegionBridge.getInstance(region);
       PartitionedRegion parRegion = ((PartitionedRegion) region);
@@ -119,9 +115,7 @@ public class RegionMBeanBridge<K, V> {
         }
 
         bridge.addDiskRegionBridge(diskRegionBridge);
-
       }
-
       return bridge;
 
     } else {
@@ -139,11 +133,9 @@ public class RegionMBeanBridge<K, V> {
         }
       }
       return bridge;
-
     }
   }
 
-
   protected void addDiskRegionBridge(DiskRegionBridge diskRegionBridge) {
     this.diskRegionBridge = diskRegionBridge;
   }
@@ -167,8 +159,6 @@ public class RegionMBeanBridge<K, V> {
 
     this.persistentEnabled = region.getAttributes().getDataPolicy().withPersistence();
 
-
-
     this.regionStats = ((LocalRegion) region).getRegionPerfStats();
     if (regionStats != null) {
       regionMonitor.addStatisticsToMonitor(regionStats.getStats()); // fixes 46692
@@ -183,7 +173,6 @@ public class RegionMBeanBridge<K, V> {
         if (ea != null && ea.getAlgorithm().isLRUMemory()) {
           this.lruMemoryStats = stats;
         }
-
       }
     }
 
@@ -194,8 +183,6 @@ public class RegionMBeanBridge<K, V> {
     this.member = GemFireCacheImpl.getInstance().getDistributedSystem().getMemberId();
   }
 
-
-
   public String getRegionType() {
     return region.getAttributes().getDataPolicy().toString();
   }
@@ -216,7 +203,6 @@ public class RegionMBeanBridge<K, V> {
     return membershipAttributesData;
   }
 
-
   public RegionAttributesData listRegionAttributes() {
     return regionAttributesData;
   }
@@ -238,11 +224,6 @@ public class RegionMBeanBridge<K, V> {
     return subregionPaths.toArray(new String[subregionPaths.size()]);
   }
 
-  /** Statistic related Methods **/
-
-
-
-  // Dummy constructor for testing purpose only
   public RegionMBeanBridge(CachePerfStats cachePerfStats) {
     this.regionStats = cachePerfStats;
 
@@ -255,8 +236,6 @@ public class RegionMBeanBridge<K, V> {
   // Dummy constructor for testing purpose only
   public RegionMBeanBridge() {}
 
-
-
   public void stopMonitor() {
     regionMonitor.stopListener();
     if (diskRegionBridge != null) {
@@ -264,9 +243,7 @@ public class RegionMBeanBridge<K, V> {
     }
   }
 
-
   private void configureRegionMetrics() {
-
     putAllRate = new StatsRate(StatsKey.PUT_ALLS, StatType.INT_TYPE, regionMonitor);
     getRequestRate = new StatsRate(StatsKey.GETS, StatType.INT_TYPE, regionMonitor);
 
@@ -282,7 +259,6 @@ public class RegionMBeanBridge<K, V> {
     writerCallsAvgLatency = new StatsAverageLatency(StatsKey.CACHE_WRITER_CALLS_COMPLETED,
         StatType.INT_TYPE, StatsKey.CACHE_WRITER_CALL_TIME, regionMonitor);
 
-
     lruDestroyRate = new StatsRate(StatsKey.LRU_DESTROYS, StatType.LONG_TYPE, regionMonitor);
 
     lruEvictionRate = new StatsRate(StatsKey.LRU_EVICTIONS, StatType.LONG_TYPE, regionMonitor);
@@ -290,7 +266,6 @@ public class RegionMBeanBridge<K, V> {
     String[] writesRates = new String[] {StatsKey.PUT_ALLS, StatsKey.PUTS, StatsKey.CREATES};
     averageWritesRate = new StatsRate(writesRates, StatType.INT_TYPE, regionMonitor);
     averageReadsRate = new StatsRate(StatsKey.GETS, StatType.INT_TYPE, regionMonitor);
-
   }
 
   private Number getRegionStatistic(String statName) {
@@ -321,7 +296,6 @@ public class RegionMBeanBridge<K, V> {
     return putAllRate.getRate();
   }
 
-
   public float getPutsRate() {
     return putRequestRate.getRate();
   }
@@ -339,7 +313,6 @@ public class RegionMBeanBridge<K, V> {
       return region.getStatistics().getHitCount();
     }
     return ManagementConstants.NOT_AVAILABLE_LONG;
-
   }
 
   public float getHitRatio() {
@@ -370,7 +343,6 @@ public class RegionMBeanBridge<K, V> {
     return ManagementConstants.NOT_AVAILABLE_LONG;
   }
 
-
   public float getLruDestroyRate() {
     return lruDestroyRate.getRate();
   }
@@ -394,7 +366,6 @@ public class RegionMBeanBridge<K, V> {
     return ManagementConstants.NOT_AVAILABLE_LONG;
   }
 
-
   public boolean isGatewayEnabled() {
     return isGatewayEnabled;
   }
@@ -407,7 +378,6 @@ public class RegionMBeanBridge<K, V> {
     return member;
   }
 
-
   /**
    * Only applicable for PRs
    * 
@@ -520,7 +490,6 @@ public class RegionMBeanBridge<K, V> {
     return null;
   }
 
-
   public long getDiskReadsAverageLatency() {
     if (this.diskRegionBridge != null) {
       return diskRegionBridge.getDiskReadsAverageLatency();

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
----------------------------------------------------------------------
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 d125e53..bd6d810 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
@@ -14,30 +14,6 @@
  */
 package org.apache.geode.management.internal.cli;
 
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheClosedException;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.execute.Execution;
-import org.apache.geode.cache.execute.Function;
-import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.cache.execute.AbstractExecution;
-import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.management.DistributedSystemMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.cli.Result;
-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.CommandResultException;
-import org.apache.geode.management.internal.cli.result.ResultBuilder;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
-
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileFilter;
@@ -66,15 +42,40 @@ import java.util.zip.DataFormatException;
 import java.util.zip.Deflater;
 import java.util.zip.Inflater;
 
+import org.apache.geode.cache.CacheClosedException;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.execute.Execution;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionService;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.ClassPathLoader;
+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.lang.StringUtils;
+import org.apache.geode.internal.util.IOUtils;
+import org.apache.geode.management.DistributedSystemMXBean;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.management.cli.Result;
+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.CommandResultException;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.shell.Gfsh;
+
 /**
  * This class contains utility methods used by classes used to build the Command Line Interface
  * (CLI).
  *
- *
  * @since GemFire 7.0
  */
 public class CliUtil {
+
   public static final String GFSHVM_IDENTIFIER = "gfsh";
+
   public static boolean isGfshVM = Boolean.getBoolean(GFSHVM_IDENTIFIER);
 
   public static final FileFilter JAR_FILE_FILTER = new CustomFileFilter(".jar");
@@ -123,10 +124,10 @@ public class CliUtil {
     return null;
   }
 
-  public static Cache getCacheIfExists() {
-    Cache cache;
+  public static InternalCache getCacheIfExists() {
+    InternalCache cache;
     try {
-      cache = CacheFactory.getAnyInstance();
+      cache = getInternalCache();
     } catch (CacheClosedException e) {
       // ignore & return null
       cache = null;
@@ -146,8 +147,8 @@ public class CliUtil {
         throw new FileNotFoundException("Could not find " + file.getCanonicalPath());
       }
 
-      if (file.isDirectory()) { // TODO - Abhishek: (1) No recursive search yet. (2) Do we need to
-                                // check/limit size of the files too?
+      if (file.isDirectory()) {
+        // TODO: (1) No recursive search yet. (2) Do we need to check/limit size of the files too?
         File[] childrenFiles = file.listFiles(JAR_FILE_FILTER);
         for (int j = 0; j < childrenFiles.length; j++) {
           // 1. add name of the file as bytes at even index
@@ -221,15 +222,17 @@ public class CliUtil {
     }
   }
 
-
-
   public static boolean isValidFileName(String filePath, String extension) {
     boolean isValid = true;
     return isValid;
   }
 
+  private static InternalCache getInternalCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   public static Set<String> getAllRegionNames() {
-    Cache cache = CacheFactory.getAnyInstance();
+    InternalCache cache = getInternalCache();
     Set<String> regionNames = new HashSet<String>();
     Set<Region<?, ?>> rootRegions = cache.rootRegions();
 
@@ -278,8 +281,6 @@ public class CliUtil {
     return sb.toString();
   }
 
-
-
   public static Set<DistributedMember> findMembersOrThrow(final String groups, final String members)
       throws CommandResultException {
 
@@ -307,7 +308,7 @@ public class CliUtil {
    */
   public static Set<DistributedMember> findMembersIncludingLocators(String[] groups,
       String[] members) {
-    Cache cache = CacheFactory.getAnyInstance();
+    InternalCache cache = getInternalCache();
     Set<DistributedMember> allMembers = getAllMembers(cache);
 
     return findMembers(allMembers, groups, members);
@@ -318,7 +319,7 @@ public class CliUtil {
    * locators.
    */
   public static Set<DistributedMember> findMembers(String[] groups, String[] members) {
-    Cache cache = CacheFactory.getAnyInstance();
+    InternalCache cache = getInternalCache();
     Set<DistributedMember> allNormalMembers = getAllNormalMembers(cache);
 
     return findMembers(allNormalMembers, groups, members);
@@ -367,7 +368,7 @@ public class CliUtil {
     DistributedMember memberFound = null;
 
     if (memberNameOrId != null) {
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getInternalCache();
       Set<DistributedMember> memberSet = CliUtil.getAllMembers(cache);
       for (DistributedMember member : memberSet) {
         if (memberNameOrId.equalsIgnoreCase(member.getId())
@@ -442,7 +443,6 @@ public class CliUtil {
     @Override
     public boolean accept(File pathname) {
       String name = pathname.getName();
-
       return name.endsWith(extensionWithDot);
     }
   }
@@ -493,10 +493,6 @@ public class CliUtil {
     private final int dataLength;
     private final byte[] data;
 
-    /**
-     * @param dataLength
-     * @param data
-     */
     public DeflaterInflaterData(int dataLength, byte[] data) {
       this.dataLength = dataLength;
       this.data = data;
@@ -565,20 +561,24 @@ public class CliUtil {
 
   /**
    * Returns a set of all the members of the distributed system excluding locators.
+   * 
+   * @param cache
    */
   @SuppressWarnings("unchecked")
-  public static Set<DistributedMember> getAllNormalMembers(Cache cache) {
-    return new HashSet<DistributedMember>(((InternalDistributedSystem) cache.getDistributedSystem())
+  public static Set<DistributedMember> getAllNormalMembers(InternalCache cache) {
+    return new HashSet<DistributedMember>(cache.getInternalDistributedSystem()
         .getDistributionManager().getNormalDistributionManagerIds());
   }
 
   /**
    * Returns a set of all the members of the distributed system including locators.
+   * 
+   * @param cache
    */
   @SuppressWarnings("unchecked")
-  public static Set<DistributedMember> getAllMembers(Cache cache) {
-    return new HashSet<DistributedMember>(((InternalDistributedSystem) cache.getDistributedSystem())
-        .getDistributionManager().getDistributionManagerIds());
+  public static Set<DistributedMember> getAllMembers(InternalCache cache) {
+    return new HashSet<DistributedMember>(
+        cache.getInternalDistributedSystem().getDistributionManager().getDistributionManagerIds());
   }
 
   @SuppressWarnings("unchecked")
@@ -590,11 +590,12 @@ public class CliUtil {
   /**
    * Returns a set of all the members of the distributed system for the given groups.
    */
-  public static Set<DistributedMember> getDistributedMembersByGroup(Cache cache, String[] groups) {
+  public static Set<DistributedMember> getDistributedMembersByGroup(InternalCache cache,
+      String[] groups) {
     Set<DistributedMember> groupMembers = new HashSet<DistributedMember>();
     for (String group : groups) {
-      groupMembers.addAll(((InternalDistributedSystem) cache.getDistributedSystem())
-          .getDistributionManager().getGroupMembers(group));
+      groupMembers.addAll(
+          cache.getInternalDistributedSystem().getDistributionManager().getGroupMembers(group));
     }
     return groupMembers;
   }
@@ -652,13 +653,13 @@ public class CliUtil {
    * find.
    *
    * @param region region path for which members that have this region are required
-   * @param cache Cache instance to use to find members
+   * @param cache cache instance to use to find members
    * @param returnAll whether to return all members or only the first member we find. Returns all
    *        when <code>true</code>
    * @return a Set of DistributedMember for members that have the specified <code>region</code>.
    */
   public static Set<DistributedMember> getRegionAssociatedMembers(final String region,
-      final Cache cache, boolean returnAll) {
+      final InternalCache cache, boolean returnAll) {
     if (region == null || region.isEmpty()) {
       return null;
     }
@@ -742,20 +743,16 @@ public class CliUtil {
   /**
    * Resolves file system path relative to Gfsh. If the pathname is not specified, then pathname is
    * returned.
-   * <p/>
    *
    * @param pathname a String value specifying the file system pathname to resolve.
    * @return a String specifying a path relative to Gfsh.
    */
-  // Moved form LauncherLifeCycleCommands
   public static String resolvePathname(final String pathname) {
     return (StringUtils.isBlank(pathname) ? pathname
         : IOUtils.tryGetCanonicalPathElseGetAbsolutePath(new File(pathname)));
   }
 
-
   public static void runLessCommandAsExternalViewer(Result commandResult, boolean isError) {
-
     StringBuilder sb = new StringBuilder();
     String NEW_LINE = System.getProperty("line.separator");
 
@@ -784,7 +781,6 @@ public class CliUtil {
       if (file != null)
         file.delete();
     }
-
   }
 
   public static String getClientIdFromCacheClientProxy(CacheClientProxy p) {
@@ -797,7 +793,7 @@ public class CliUtil {
     return buffer.toString();
   }
 
-  public static Set<DistributedMember> getMembersForeRegionViaFunction(Cache cache,
+  public static Set<DistributedMember> getMembersForeRegionViaFunction(InternalCache cache,
       String regionPath, boolean returnAll) {
     try {
       Set<DistributedMember> regionMembers = new HashSet<DistributedMember>();

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java
index f077180..ae44e24 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java
@@ -12,10 +12,15 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.management.internal.cli.commands;
 
-import org.apache.geode.cache.Cache;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.shell.core.CommandMarker;
+
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
@@ -23,6 +28,7 @@ import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.management.cli.CliMetaData;
@@ -30,12 +36,6 @@ import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.cli.util.MemberNotFoundException;
-import org.springframework.shell.core.CommandMarker;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Set;
 
 /**
  * The AbstractCommandsSupport class is an abstract base class encapsulating common functionality
@@ -126,8 +126,8 @@ public abstract class AbstractCommandsSupport implements CommandMarker {
     return (getGfsh() != null);
   }
 
-  protected Cache getCache() {
-    return CacheFactory.getAnyInstance();
+  protected InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
   }
 
   protected static Gfsh getGfsh() {
@@ -135,7 +135,7 @@ public abstract class AbstractCommandsSupport implements CommandMarker {
   }
 
   @SuppressWarnings("deprecated")
-  protected DistributedMember getMember(final Cache cache, final String memberName) {
+  protected DistributedMember getMember(final InternalCache cache, final String memberName) {
     for (final DistributedMember member : getMembers(cache)) {
       if (memberName.equalsIgnoreCase(member.getName())
           || memberName.equalsIgnoreCase(member.getId())) {
@@ -149,15 +149,14 @@ public abstract class AbstractCommandsSupport implements CommandMarker {
 
   /**
    * Gets all members in the GemFire distributed system/cache.
-   * </p>
-   * 
+   *
    * @param cache the GemFire cache.
    * @return all members in the GemFire distributed system/cache.
-   * @see org.apache.geode.management.internal.cli.CliUtil#getAllMembers(org.apache.geode.cache.Cache)
+   * @see org.apache.geode.management.internal.cli.CliUtil#getAllMembers(org.apache.geode.internal.cache.InternalCache)
    * @deprecated use CliUtil.getAllMembers(org.apache.geode.cache.Cache) instead
    */
   @Deprecated
-  protected Set<DistributedMember> getMembers(final Cache cache) {
+  protected Set<DistributedMember> getMembers(final InternalCache cache) {
     Set<DistributedMember> members = new HashSet<DistributedMember>(cache.getMembers());
     members.add(cache.getDistributedSystem().getDistributedMember());
     return members;

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
index c4455ad..3b1fb09 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
@@ -14,9 +14,29 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.regex.Pattern;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.LogWriter;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.ExpirationAttributes;
 import org.apache.geode.cache.PartitionResolver;
@@ -30,7 +50,7 @@ import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.security.IntegratedSecurityService;
@@ -63,31 +83,12 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Pattern;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
 
 /**
  * @since GemFire 7.0
  */
 public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
+
   public static final Set<RegionShortcut> PERSISTENT_OVERFLOW_SHORTCUTS =
       new TreeSet<RegionShortcut>();
 
@@ -108,6 +109,9 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.LOCAL_PERSISTENT_OVERFLOW);
   }
 
+  /**
+   * TODO: method createRegion is too complex to analyze
+   */
   @CliCommand(value = CliStrings.CREATE_REGION, help = CliStrings.CREATE_REGION__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
   @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
@@ -229,7 +233,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
 
     try {
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
 
       if (regionShortcut != null && useAttributesFrom != null) {
         throw new IllegalArgumentException(
@@ -285,7 +289,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
         String cacheLoaderClass =
             cacheLoader != null ? cacheLoader : regionAttributesResult.getCacheLoaderClass();
         String cacheWriterClass =
-            cacheWriter != null ? cacheWriter : regionAttributesResult.getCacheWriterClass();;
+            cacheWriter != null ? cacheWriter : regionAttributesResult.getCacheWriterClass();
 
         regionFunctionArgs = new RegionFunctionArgs(regionPath, useAttributesFrom, skipIfExists,
             keyConstraint, valueConstraint, statisticsEnabled, entryIdle, entryTTL, regionIdle,
@@ -375,7 +379,6 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     } catch (RuntimeException e) {
       LogWrapper.getInstance().info(e.getMessage(), e);
       result = ResultBuilder.createGemFireErrorResult(e.getMessage());
-
     }
     if (xmlEntity.get() != null) {
       persistClusterConfiguration(result,
@@ -385,11 +388,9 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     return result;
   }
 
-
-  public boolean verifyDistributedRegionMbean(Cache cache, String regionName) {
-    GemFireCacheImpl gemfireCache = (GemFireCacheImpl) cache;
+  public boolean verifyDistributedRegionMbean(InternalCache cache, String regionName) {
     int federationInterval =
-        gemfireCache.getInternalDistributedSystem().getConfig().getJmxManagerUpdateRate();
+        cache.getInternalDistributedSystem().getConfig().getJmxManagerUpdateRate();
     long timeEnd = System.currentTimeMillis() + federationInterval + 50;
 
     for (; System.currentTimeMillis() <= timeEnd;) {
@@ -479,7 +480,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     this.securityService.authorizeRegionManage(regionPath);
 
     try {
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
 
       if (groups != null) {
         validateGroups(cache, groups);
@@ -616,7 +617,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     return result;
   }
 
-  private static boolean regionExists(Cache cache, String regionPath) {
+  private static boolean regionExists(InternalCache cache, String regionPath) {
     boolean regionFound = false;
     if (regionPath != null && !Region.SEPARATOR.equals(regionPath)) {
       ManagementService managementService = ManagementService.getExistingManagementService(cache);
@@ -633,7 +634,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     return regionFound;
   }
 
-  private void validateRegionPathAndParent(Cache cache, String regionPath) {
+  private void validateRegionPathAndParent(InternalCache cache, String regionPath) {
     if (regionPath == null || "".equals(regionPath)) {
       throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH);
     }
@@ -649,8 +650,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     }
   }
 
-
-  private void validateGroups(Cache cache, String[] groups) {
+  private void validateGroups(InternalCache cache, String[] groups) {
     if (groups != null && groups.length != 0) {
       Set<String> existingGroups = new HashSet<String>();
       Set<DistributedMember> members = CliUtil.getAllNormalMembers(cache);
@@ -669,7 +669,8 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     }
   }
 
-  private void validateRegionFunctionArgs(Cache cache, RegionFunctionArgs regionFunctionArgs) {
+  private void validateRegionFunctionArgs(InternalCache cache,
+      RegionFunctionArgs regionFunctionArgs) {
     if (regionFunctionArgs.getRegionPath() == null) {
       throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH);
     }
@@ -751,16 +752,6 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
                 new Object[] {prRedundantCopies}));
         }
       }
-      // Validation for the following is not known yet
-      // if (partitionArgs.isSetPRTotalNumBuckets()) {
-      // int prTotalNumBuckets = partitionArgs.getPrTotalNumBuckets();
-      // }
-      // if (partitionArgs.isSetPRStartupRecoveryDelay()) {
-      // long prStartupRecoveryDelay = partitionArgs.getPrStartupRecoveryDelay();
-      // }
-      // if (partitionArgs.isSetPRRecoveryDelay()) {
-      // long prRecoveryDelay = partitionArgs.getPrRecoveryDelay();
-      // }
     }
 
     String keyConstraint = regionFunctionArgs.getKeyConstraint();
@@ -918,7 +909,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     }
   }
 
-  private boolean diskStoreExists(Cache cache, String diskStoreName) {
+  private boolean diskStoreExists(InternalCache cache, String diskStoreName) {
     ManagementService managementService = ManagementService.getExistingManagementService(cache);
     DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
     Map<String, String[]> diskstore = dsMXBean.listMemberDiskstore();
@@ -935,9 +926,9 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     return false;
   }
 
-  private static <K, V> FetchRegionAttributesFunctionResult<K, V> getRegionAttributes(Cache cache,
-      String regionPath) {
-    if (!isClusterwideSameConfig(cache, regionPath)) {
+  private static <K, V> FetchRegionAttributesFunctionResult<K, V> getRegionAttributes(
+      InternalCache cache, String regionPath) {
+    if (!isClusterWideSameConfig(cache, regionPath)) {
       throw new IllegalStateException(CliStrings.format(
           CliStrings.CREATE_REGION__MSG__USE_ATTRIBUTES_FORM_REGIONS_EXISTS_BUT_DIFFERENT_SCOPE_OR_DATAPOLICY_USE_DESCRIBE_REGION_FOR_0,
           regionPath));
@@ -990,7 +981,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     return attributes;
   }
 
-  private static boolean isClusterwideSameConfig(Cache cache, String regionPath) {
+  private static boolean isClusterWideSameConfig(InternalCache cache, String regionPath) {
     ManagementService managementService = ManagementService.getExistingManagementService(cache);
 
     DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
@@ -1053,7 +1044,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
     try {
       String message = "";
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
       ManagementService managementService = ManagementService.getExistingManagementService(cache);
       String regionPathToUse = regionPath;
 
@@ -1076,7 +1067,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
           CliUtil.executeFunction(RegionDestroyFunction.INSTANCE, regionPath, regionMembersList);
       List<CliFunctionResult> resultsList = (List<CliFunctionResult>) resultCollector.getResult();
       message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED,
-          new Object[] {regionPath, /* subRegionMessage */""});
+          new Object[] {regionPath, ""});
 
       // Only if there is an error is this set to false
       boolean isRegionDestroyed = true;
@@ -1121,7 +1112,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     return result;
   }
 
-  private Set<DistributedMember> findMembersForRegion(Cache cache,
+  private Set<DistributedMember> findMembersForRegion(InternalCache cache,
       ManagementService managementService, String regionPath) {
     Set<DistributedMember> membersList = new HashSet<>();
     Set<String> regionMemberIds = new HashSet<>();
@@ -1181,7 +1172,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
     return membersList;
   }
 
-  private Set<DistributedMember> getMembersByIds(Cache cache, Set<String> memberIds) {
+  private Set<DistributedMember> getMembersByIds(InternalCache cache, Set<String> memberIds) {
     Set<DistributedMember> foundMembers = Collections.emptySet();
     if (memberIds != null && !memberIds.isEmpty()) {
       foundMembers = new HashSet<DistributedMember>();
@@ -1203,7 +1194,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport {
       CliStrings.DESTROY_REGION})
   public boolean isRegionCommandAvailable() {
     boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) { // in gfsh check if connected //TODO - Abhishek: make this better
+    if (CliUtil.isGfshVM()) { // in gfsh check if connected //TODO: make this better
       isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
     }
     return isAvailable;

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
index 29d68bd..46ee2b0 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
@@ -14,8 +14,28 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.shiro.subject.Subject;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.LogWriter;
-import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.DataPolicy;
@@ -30,7 +50,7 @@ import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.cache.partition.PartitionRebalanceInfo;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.security.IntegratedSecurityService;
 import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.management.DistributedRegionMXBean;
@@ -59,35 +79,16 @@ import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.apache.shiro.subject.Subject;
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
 /**
- * 
  * @since GemFire 7.0
  */
 public class DataCommands implements CommandMarker {
 
   final int resultItemCount = 9;
+
   private final ExportDataFunction exportDataFunction = new ExportDataFunction();
+
   private final ImportDataFunction importDataFunction = new ImportDataFunction();
 
   private SecurityService securityService = IntegratedSecurityService.getSecurityService();
@@ -96,6 +97,10 @@ public class DataCommands implements CommandMarker {
     return Gfsh.getCurrentInstance();
   }
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @CliCommand(value = CliStrings.REBALANCE, help = CliStrings.REBALANCE__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DATA, CliStrings.TOPIC_GEODE_REGION})
   @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
@@ -135,15 +140,13 @@ public class DataCommands implements CommandMarker {
     }
     LogWrapper.getInstance().info("Rebalance returning result >>>" + result);
     return result;
-
-
   }
 
   private class ExecuteRebalanceWithTimeout implements Callable<Result> {
     String[] includeRegions = null;
     String[] excludeRegions = null;
     boolean simulate;
-    Cache cache = CacheFactory.getAnyInstance();;
+    InternalCache cache = getCache();
 
     @Override
     public Result call() throws Exception {
@@ -163,8 +166,6 @@ public class DataCommands implements CommandMarker {
       Result result = null;
       try {
         RebalanceOperation op = null;
-        new HashSet<String>();
-        new HashSet<String>();
 
         if (includeRegions != null && includeRegions.length > 0) {
           CompositeResultData rebalanceResulteData = ResultBuilder.createCompositeResultData();
@@ -253,7 +254,6 @@ public class DataCommands implements CommandMarker {
 
                 result = ResultBuilder.buildResult(toCompositeResultData(rebalanceResulteData,
                     (ArrayList) rstList, index, simulate, cache));
-
               }
 
             } else {
@@ -279,12 +279,11 @@ public class DataCommands implements CommandMarker {
                 // Wait until the rebalance is complete and then get the results
                 result = ResultBuilder.buildResult(buildResultForRebalance(rebalanceResulteData,
                     op.getResults(), index, simulate, cache));
-
               }
             }
             index++;
           }
-          LogWrapper.getInstance().info("Rebalance returning result" + result);
+          LogWrapper.getInstance().info("Rebalance returning result " + result);
           return result;
         } else {
           result = executeRebalanceOnDS(cache, String.valueOf(simulate), excludeRegions);
@@ -307,7 +306,6 @@ public class DataCommands implements CommandMarker {
 
     }
     return rstList;
-
   }
 
   boolean checkResultList(CompositeResultData rebalanceResulteData, List resultList,
@@ -349,10 +347,9 @@ public class DataCommands implements CommandMarker {
     }
 
     return toContinueForOtherMembers;
-
   }
 
-  Result executeRebalanceOnDS(Cache cache, String simulate, String[] excludeRegionsList) {
+  Result executeRebalanceOnDS(InternalCache cache, String simulate, String[] excludeRegionsList) {
     Result result = null;
     int index = 1;
     CompositeResultData rebalanceResulteData = ResultBuilder.createCompositeResultData();
@@ -369,7 +366,6 @@ public class DataCommands implements CommandMarker {
           .createInfoResult(CliStrings.REBALANCE__MSG__NO_REBALANCING_REGIONS_ON_DS);
     }
 
-
     Iterator<MemberPRInfo> iterator = listMemberRegion.iterator();
     boolean flagToContinueWithRebalance = false;
 
@@ -471,7 +467,7 @@ public class DataCommands implements CommandMarker {
     return result;
   }
 
-  public boolean checkMemberPresence(DistributedMember dsMember, Cache cache) {
+  public boolean checkMemberPresence(DistributedMember dsMember, InternalCache cache) {
     // check if member's presence just before executing function
     // this is to avoid running a function on departed members #47248
     Set<DistributedMember> dsMemberList = CliUtil.getAllNormalMembers(cache);
@@ -488,7 +484,7 @@ public class DataCommands implements CommandMarker {
   }
 
   protected CompositeResultData toCompositeResultData(CompositeResultData rebalanceResulteData,
-      ArrayList<String> rstlist, int index, boolean simulate, Cache cache) {
+      ArrayList<String> rstlist, int index, boolean simulate, InternalCache cache) {
 
     // add only if there are any valid regions in results
     if (rstlist.size() > resultItemCount && rstlist.get(resultItemCount) != null
@@ -565,7 +561,7 @@ public class DataCommands implements CommandMarker {
   }
 
   CompositeResultData buildResultForRebalance(CompositeResultData rebalanceResulteData,
-      RebalanceResults results, int index, boolean simulate, Cache cache) {
+      RebalanceResults results, int index, boolean simulate, InternalCache cache) {
     Set<PartitionRebalanceInfo> regions = results.getPartitionRebalanceDetails();
     Iterator iterator = regions.iterator();
 
@@ -655,13 +651,11 @@ public class DataCommands implements CommandMarker {
       cache.getLogger().info(headerText + resultStr);
     }
     return rebalanceResulteData;
-
   }
 
-  public DistributedMember getAssociatedMembers(String region, final Cache cache) {
-
-    DistributedRegionMXBean bean = ManagementService
-        .getManagementService(GemFireCacheImpl.getInstance()).getDistributedRegionMXBean(region);
+  public DistributedMember getAssociatedMembers(String region, final InternalCache cache) {
+    DistributedRegionMXBean bean =
+        ManagementService.getManagementService(cache).getDistributedRegionMXBean(region);
 
     DistributedMember member = null;
 
@@ -688,10 +682,9 @@ public class DataCommands implements CommandMarker {
       }
     }
     return member;
-
   }
 
-  List<MemberPRInfo> getMemberRegionList(Cache cache, List<String> listExcludedRegion) {
+  List<MemberPRInfo> getMemberRegionList(InternalCache cache, List<String> listExcludedRegion) {
     List<MemberPRInfo> listMemberPRInfo = new ArrayList<MemberPRInfo>();
     String[] listDSRegions =
         ManagementService.getManagementService(cache).getDistributedSystemMXBean().listRegions();
@@ -729,15 +722,12 @@ public class DataCommands implements CommandMarker {
 
       if (!regionName.startsWith("/")) {
         regionName = Region.SEPARATOR + regionName;
-
       }
-      // remove this prefix / once Rishi fixes this
+      // remove this prefix /
       DistributedRegionMXBean bean =
-          ManagementService.getManagementService(GemFireCacheImpl.getInstance())
-              .getDistributedRegionMXBean(regionName);
+          ManagementService.getManagementService(cache).getDistributedRegionMXBean(regionName);
 
       if (bean != null) {
-        // TODO: Ajay to call a method once Rishi provides
         if (bean.getRegionType().equals(DataPolicy.PARTITION.toString())
             || bean.getRegionType().equals(DataPolicy.PERSISTENT_PARTITION.toString())) {
 
@@ -755,13 +745,11 @@ public class DataCommands implements CommandMarker {
                   listMember.dsMemberList.add(dsmember);
                 } else {
                   listMemberPRInfo.add(memberAndItsPRRegions);
-
                 }
                 break;
               }
             }
           }
-
         }
       }
     }
@@ -769,8 +757,6 @@ public class DataCommands implements CommandMarker {
     return listMemberPRInfo;
   }
 
-
-
   @CliCommand(value = CliStrings.EXPORT_DATA, help = CliStrings.EXPORT_DATA__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DATA, CliStrings.TOPIC_GEODE_REGION})
   public Result exportData(
@@ -786,7 +772,6 @@ public class DataCommands implements CommandMarker {
           help = CliStrings.EXPORT_DATA__MEMBER__HELP) String memberNameOrId) {
 
     this.securityService.authorizeRegionRead(regionName);
-    final Cache cache = CacheFactory.getAnyInstance();
     final DistributedMember targetMember = CliUtil.getDistributedMemberByNameOrId(memberNameOrId);
     Result result = null;
 
@@ -850,7 +835,6 @@ public class DataCommands implements CommandMarker {
     Result result = null;
 
     try {
-      final Cache cache = CacheFactory.getAnyInstance();
       final DistributedMember targetMember = CliUtil.getDistributedMemberByNameOrId(memberNameOrId);
 
       if (!filePath.endsWith(CliStrings.GEODE_DATA_FILE_EXTENSION)) {
@@ -909,7 +893,7 @@ public class DataCommands implements CommandMarker {
           unspecifiedDefaultValue = "false") boolean putIfAbsent) {
 
     this.securityService.authorizeRegionWrite(regionPath);
-    Cache cache = CacheFactory.getAnyInstance();
+    InternalCache cache = getCache();
     DataCommandResult dataResult = null;
     if (regionPath == null || regionPath.isEmpty()) {
       return makePresentationResult(DataCommandResult.createPutResult(key, null, null,
@@ -928,8 +912,7 @@ public class DataCommands implements CommandMarker {
     Region region = cache.getRegion(regionPath);
     DataCommandFunction putfn = new DataCommandFunction();
     if (region == null) {
-      Set<DistributedMember> memberList =
-          getRegionAssociatedMembers(regionPath, CacheFactory.getAnyInstance(), false);
+      Set<DistributedMember> memberList = getRegionAssociatedMembers(regionPath, getCache(), false);
       if (memberList != null && memberList.size() > 0) {
         DataCommandRequest request = new DataCommandRequest();
         request.setCommand(CliStrings.PUT);
@@ -978,7 +961,7 @@ public class DataCommands implements CommandMarker {
           help = CliStrings.GET__LOAD__HELP) Boolean loadOnCacheMiss) {
     this.securityService.authorizeRegionRead(regionPath, key);
 
-    Cache cache = CacheFactory.getAnyInstance();
+    InternalCache cache = getCache();
     DataCommandResult dataResult = null;
 
     if (regionPath == null || regionPath.isEmpty()) {
@@ -994,8 +977,7 @@ public class DataCommands implements CommandMarker {
     Region region = cache.getRegion(regionPath);
     DataCommandFunction getfn = new DataCommandFunction();
     if (region == null) {
-      Set<DistributedMember> memberList =
-          getRegionAssociatedMembers(regionPath, CacheFactory.getAnyInstance(), false);
+      Set<DistributedMember> memberList = getRegionAssociatedMembers(regionPath, getCache(), false);
       if (memberList != null && memberList.size() > 0) {
         DataCommandRequest request = new DataCommandRequest();
         request.setCommand(CliStrings.GET);
@@ -1054,8 +1036,7 @@ public class DataCommands implements CommandMarker {
           null, null, CliStrings.LOCATE_ENTRY__MSG__KEY_EMPTY, false));
 
     DataCommandFunction locateEntry = new DataCommandFunction();
-    Set<DistributedMember> memberList =
-        getRegionAssociatedMembers(regionPath, CacheFactory.getAnyInstance(), true);
+    Set<DistributedMember> memberList = getRegionAssociatedMembers(regionPath, getCache(), true);
     if (memberList != null && memberList.size() > 0) {
       DataCommandRequest request = new DataCommandRequest();
       request.setCommand(CliStrings.LOCATE_ENTRY);
@@ -1088,7 +1069,7 @@ public class DataCommands implements CommandMarker {
           specifiedDefaultValue = "true", unspecifiedDefaultValue = "false") boolean removeAllKeys,
       @CliOption(key = {CliStrings.REMOVE__KEYCLASS},
           help = CliStrings.REMOVE__KEYCLASS__HELP) String keyClass) {
-    Cache cache = CacheFactory.getAnyInstance();
+    InternalCache cache = getCache();
     DataCommandResult dataResult = null;
 
     if (regionPath == null || regionPath.isEmpty()) {
@@ -1111,8 +1092,7 @@ public class DataCommands implements CommandMarker {
     Region region = cache.getRegion(regionPath);
     DataCommandFunction removefn = new DataCommandFunction();
     if (region == null) {
-      Set<DistributedMember> memberList =
-          getRegionAssociatedMembers(regionPath, CacheFactory.getAnyInstance(), false);
+      Set<DistributedMember> memberList = getRegionAssociatedMembers(regionPath, getCache(), false);
       if (memberList != null && memberList.size() > 0) {
         DataCommandRequest request = new DataCommandRequest();
         request.setCommand(CliStrings.REMOVE);
@@ -1188,7 +1168,6 @@ public class DataCommands implements CommandMarker {
         return true;
       }
       return false;
-
     }
   }
 
@@ -1236,11 +1215,10 @@ public class DataCommands implements CommandMarker {
       }
       return result;
     }
-
   }
 
   public static Set<DistributedMember> getQueryRegionsAssociatedMembers(Set<String> regions,
-      final Cache cache, boolean returnAll) {
+      final InternalCache cache, boolean returnAll) {
     LogWriter logger = cache.getLogger();
     Set<DistributedMember> members = null;
     Set<DistributedMember> newMembers = null;
@@ -1286,8 +1264,8 @@ public class DataCommands implements CommandMarker {
   }
 
   @SuppressWarnings("rawtypes")
-  public static Set<DistributedMember> getRegionAssociatedMembers(String region, final Cache cache,
-      boolean returnAll) {
+  public static Set<DistributedMember> getRegionAssociatedMembers(String region,
+      final InternalCache cache, boolean returnAll) {
 
     DistributedMember member = null;
 
@@ -1336,7 +1314,7 @@ public class DataCommands implements CommandMarker {
     return matchedMembers;
   }
 
-  // TODO - Abhishek revisit after adding support in Gfsh.java?
+  // TODO:k revisit after adding support in Gfsh.java?
   public static Object[] replaceGfshEnvVar(String query, Map<String, String> gfshEnvVarMap) {
     boolean done = false;
     int startIndex = 0;

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
index a96d3c2..bea7e77 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
@@ -14,13 +14,35 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+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.concurrent.atomic.AtomicReference;
+
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.GemFireIOException;
 import org.apache.geode.SystemFailure;
 import org.apache.geode.admin.BackupStatus;
 import org.apache.geode.admin.internal.AdminDistributedSystemImpl;
-import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheExistsException;
-import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.FunctionInvocationTargetException;
@@ -32,7 +54,7 @@ import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.cache.DiskStoreAttributes;
 import org.apache.geode.internal.cache.DiskStoreImpl;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
 import org.apache.geode.internal.cache.partitioned.ColocatedRegionDetails;
 import org.apache.geode.internal.cache.persistence.PersistentMemberPattern;
@@ -73,35 +95,10 @@ import org.apache.geode.management.internal.messages.CompactRequest;
 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.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-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.concurrent.atomic.AtomicReference;
-
 
 /**
  * The DiskStoreCommands class encapsulates all GemFire Disk Store commands in Gfsh.
- * </p>
- * 
+ *
  * @see org.apache.geode.management.internal.cli.commands.AbstractCommandsSupport
  * @since GemFire 7.0
  */
@@ -109,12 +106,12 @@ import java.util.concurrent.atomic.AtomicReference;
 public class DiskStoreCommands extends AbstractCommandsSupport {
 
   @Override
-  protected Set<DistributedMember> getMembers(final Cache cache) {
+  protected Set<DistributedMember> getMembers(final InternalCache cache) {
     // TODO determine what this does (as it is untested and unmockable!)
     return CliUtil.getAllMembers(cache);
   }
 
-  protected Set<DistributedMember> getNormalMembers(final Cache cache) {
+  protected Set<DistributedMember> getNormalMembers(final InternalCache cache) {
     // TODO determine what this does (as it is untested and unmockable!)
     return CliUtil.getAllNormalMembers(cache);
   }
@@ -132,7 +129,7 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
 
     Result result = null;
     try {
-      GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
       DM dm = cache.getDistributionManager();
       BackupStatus backupStatus = null;
 
@@ -149,9 +146,7 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
       Set<DistributedMember> backedupMembers = backedupMemberDiskstoreMap.keySet();
       CompositeResultData crd = ResultBuilder.createCompositeResultData();
 
-
       if (!backedupMembers.isEmpty()) {
-
         SectionResultData backedupDiskStoresSection = crd.addSection();
         backedupDiskStoresSection.setHeader(CliStrings.BACKUP_DISK_STORE_MSG_BACKED_UP_DISK_STORES);
         TabularResultData backedupDiskStoresTable = backedupDiskStoresSection.addTable();
@@ -218,7 +213,6 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
     backedupDiskStoreTable.accumulate(CliStrings.BACKUP_DISK_STORE_MSG_HOST, host);
   }
 
-
   @CliCommand(value = CliStrings.LIST_DISK_STORE, help = CliStrings.LIST_DISK_STORE__HELP)
   @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
@@ -353,7 +347,7 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
       diskStoreAttributes.diskDirs = directories;
       diskStoreAttributes.diskDirSizes = sizes;
 
-      diskStoreAttributes.setDiskUsageWarningPercentage(diskUsageWarningPercentage);;
+      diskStoreAttributes.setDiskUsageWarningPercentage(diskUsageWarningPercentage);
       diskStoreAttributes.setDiskUsageCriticalPercentage(diskUsageCriticalPercentage);
 
       TabularResultData tabularData = ResultBuilder.createTabularResultData();
@@ -412,7 +406,6 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
     }
   }
 
-
   @CliCommand(value = CliStrings.COMPACT_DISK_STORE, help = CliStrings.COMPACT_DISK_STORE__HELP)
   @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
   @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
@@ -432,8 +425,7 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
             CliStrings.format(CliStrings.COMPACT_DISK_STORE__DISKSTORE_0_DOESNOT_EXIST,
                 new Object[] {diskStoreName}));
       } else {
-        InternalDistributedSystem ds =
-            (InternalDistributedSystem) getCache().getDistributedSystem();
+        InternalDistributedSystem ds = getCache().getInternalDistributedSystem();
 
         Map<DistributedMember, PersistentID> overallCompactInfo =
             new HashMap<DistributedMember, PersistentID>();
@@ -538,7 +530,7 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
   }
 
   private boolean diskStoreExists(String diskStoreName) {
-    Cache cache = getCache();
+    InternalCache cache = getCache();
     ManagementService managementService = ManagementService.getExistingManagementService(cache);
     DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
     Map<String, String[]> diskstore = dsMXBean.listMemberDiskstore();
@@ -695,7 +687,6 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
     return result;
   }
 
-
   @CliCommand(value = CliStrings.UPGRADE_OFFLINE_DISK_STORE,
       help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__HELP)
   @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
@@ -713,7 +704,6 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
           help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__J__HELP) String[] jvmProps)
       throws InterruptedException {
 
-
     Result result = null;
     LogWrapper logWrapper = LogWrapper.getInstance();
 
@@ -794,8 +784,6 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
         throw new GemFireIOException(errorMessage);
       }
 
-      // do we have to waitFor??
-      // upgraderProcess.waitFor();
       upgraderProcess.destroy();
       result = ResultBuilder.createInfoResult(output.toString());
     } catch (IOException e) {
@@ -840,8 +828,6 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
     return result;
   }
 
-
-
   private String validatedDirectories(String[] diskDirs) {
     String invalidDirectories = null;
     StringBuilder builder = null;
@@ -1009,8 +995,8 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
       mandatory = true, help = CliStrings.REVOKE_MISSING_DISK_STORE__ID__HELP) String id) {
 
     try {
-      DistributedSystemMXBean dsMXBean = ManagementService
-          .getManagementService(CacheFactory.getAnyInstance()).getDistributedSystemMXBean();
+      DistributedSystemMXBean dsMXBean =
+          ManagementService.getManagementService(getCache()).getDistributedSystemMXBean();
       if (dsMXBean.revokeMissingDiskStores(id)) {
         return ResultBuilder.createInfoResult("Missing disk store successfully revoked");
       }
@@ -1297,10 +1283,8 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
       return ResultBuilder.createGemFireErrorResult(CliStrings
           .format(CliStrings.VALIDATE_DISK_STORE__MSG__ERROR, diskStoreName, ex.getMessage()));
     }
-
   }
 
-
   @CliCommand(value = CliStrings.ALTER_DISK_STORE, help = CliStrings.ALTER_DISK_STORE__HELP)
   @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
   public Result alterOfflineDiskStore(
@@ -1456,7 +1440,6 @@ public class DiskStoreCommands extends AbstractCommandsSupport {
         }
       }
 
-
       if (!accumulatedData) {
         return ResultBuilder.createInfoResult("No matching disk stores found.");
       }

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
----------------------------------------------------------------------
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 7afb0db..dfd20a9 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
@@ -14,15 +14,29 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toSet;
+import static java.util.stream.Collectors.*;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.logging.log4j.Logger;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.cli.CliMetaData;
@@ -44,24 +58,9 @@ import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.apache.logging.log4j.Logger;
-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.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
-/****
+/**
  * Commands for the cluster configuration
- *
  */
 @SuppressWarnings("unused")
 public class ExportImportClusterConfigurationCommands extends AbstractCommandsSupport {
@@ -117,7 +116,6 @@ public class ExportImportClusterConfigurationCommands extends AbstractCommandsSu
     return result;
   }
 
-
   @CliCommand(value = {CliStrings.IMPORT_SHARED_CONFIG},
       help = CliStrings.IMPORT_SHARED_CONFIG__HELP)
   @CliMetaData(
@@ -136,7 +134,7 @@ public class ExportImportClusterConfigurationCommands extends AbstractCommandsSu
       return ResultBuilder.buildResult(errorData);
     }
 
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    InternalCache cache = getCache();
 
     Set<DistributedMember> servers = CliUtil.getAllNormalMembers(cache);
 
@@ -149,7 +147,6 @@ public class ExportImportClusterConfigurationCommands extends AbstractCommandsSu
               + regionsWithData.stream().collect(joining(",")));
     }
 
-
     byte[][] shellBytesData = CommandExecutionContext.getBytesFromShell();
     String zipFileName = CliUtil.bytesToNames(shellBytesData)[0];
     byte[] zipBytes = CliUtil.bytesToData(shellBytesData)[0];
@@ -261,7 +258,6 @@ public class ExportImportClusterConfigurationCommands extends AbstractCommandsSu
     }
   }
 
-
   public static class ImportInterceptor extends AbstractCliAroundInterceptor {
 
     public Result preExecution(GfshParseResult parseResult) {

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
----------------------------------------------------------------------
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 647fff2..20ec1f5 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
@@ -12,14 +12,30 @@
  * 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.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Logger;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.ConverterHint;
@@ -34,21 +50,6 @@ import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission;
-import org.apache.logging.log4j.Logger;
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 public class ExportLogsCommand implements CommandMarker {
 
@@ -61,6 +62,10 @@ public class ExportLogsCommand implements CommandMarker {
 
   private static final Pattern DISK_SPACE_LIMIT_PATTERN = Pattern.compile("(\\d+)([mgtMGT]?)");
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @CliCommand(value = CliStrings.EXPORT_LOGS, help = CliStrings.EXPORT_LOGS__HELP)
   @CliMetaData(shellOnly = false, isFileDownloadOverHttp = true,
       interceptor = "org.apache.geode.management.internal.cli.commands.ExportLogsInterceptor",
@@ -103,7 +108,7 @@ public class ExportLogsCommand implements CommandMarker {
     // specifiedDefaultValue = CliStrings.EXPORT_LOGS__FILESIZELIMIT__SPECIFIED_DEFAULT,
     // help = CliStrings.EXPORT_LOGS__FILESIZELIMIT__HELP) String fileSizeLimit) {
     Result result = null;
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    InternalCache cache = getCache();
     try {
       Set<DistributedMember> targetMembers =
           CliUtil.findMembersIncludingLocators(groups, memberIds);
@@ -194,13 +199,6 @@ public class ExportLogsCommand implements CommandMarker {
       ZipUtils.zipDirectory(exportedLogsDir, exportedLogsZipFile);
       FileUtils.deleteDirectory(tempDir.toFile());
 
-      // try {
-      // isFileSizeCheckEnabledAndWithinLimit(parseFileSizeLimit(fileSizeLimit),
-      // exportedLogsZipFile.toFile());
-      // } catch (IllegalArgumentException e) {
-      // return ResultBuilder.createUserErrorResult("TOO BIG: fileSizeLimit = " + fileSizeLimit);
-      // }
-
       result = ResultBuilder.createInfoResult(exportedLogsZipFile.toString());
     } catch (Exception ex) {
       logger.error(ex.getMessage(), ex);

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
index e21a334..d19f91b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
@@ -14,8 +14,21 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+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 org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.SystemFailure;
-import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
@@ -25,7 +38,7 @@ 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.ClassPathLoader;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+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.CliMetaData;
@@ -51,32 +64,23 @@ import org.apache.geode.management.internal.cli.shell.Gfsh;
 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.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-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;
 
 /**
- * 
  * @since GemFire 7.0
  */
 @SuppressWarnings("unused")
 public class FunctionCommands implements CommandMarker {
+
   private final ListFunctionFunction listFunctionFunction = new ListFunctionFunction();
 
   private Gfsh getGfsh() {
     return Gfsh.getCurrentInstance();
   }
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @CliCommand(value = CliStrings.EXECUTE_FUNCTION, help = CliStrings.EXECUTE_FUNCTION__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_FUNCTION})
   @ResourceOperation(resource = Resource.DATA, operation = Operation.WRITE)
@@ -176,8 +180,7 @@ public class FunctionCommands implements CommandMarker {
         return result;
       }
 
-      Cache cache = CacheFactory.getAnyInstance();
-
+      InternalCache cache = getCache();
 
       if (resultCollector != null) {
         resultCollectorInstance =
@@ -208,11 +211,10 @@ public class FunctionCommands implements CommandMarker {
       } else if (onRegion != null && onRegion.length() > 0) {
         if (cache.getRegion(onRegion) == null) {
           // find a member where region is present
-          DistributedRegionMXBean bean =
-              ManagementService.getManagementService(GemFireCacheImpl.getInstance())
-                  .getDistributedRegionMXBean(onRegion);
+          DistributedRegionMXBean bean = ManagementService.getManagementService(getCache())
+              .getDistributedRegionMXBean(onRegion);
           if (bean == null) {
-            bean = ManagementService.getManagementService(GemFireCacheImpl.getInstance())
+            bean = ManagementService.getManagementService(getCache())
                 .getDistributedRegionMXBean(Region.SEPARATOR + onRegion);
 
             if (bean == null) {
@@ -350,7 +352,7 @@ public class FunctionCommands implements CommandMarker {
     return result;
   }
 
-  DistributedMember getMember(Cache cache, String memberNameOrId) {
+  DistributedMember getMember(InternalCache cache, String memberNameOrId) {
     DistributedMember member = null;
     Set<DistributedMember> dsMembers = CliUtil.getAllMembers(cache);
     Iterator<DistributedMember> it = dsMembers.iterator();
@@ -365,8 +367,8 @@ public class FunctionCommands implements CommandMarker {
   }
 
   void executeAndGetResults(String functionId, String filterString, String resultCollector,
-      String[] arguments, Cache cache, DistributedMember member, TabularResultData resultTable,
-      String onRegion) {
+      String[] arguments, InternalCache cache, DistributedMember member,
+      TabularResultData resultTable, String onRegion) {
     StringBuilder resultMessege = new StringBuilder();
     try {
       Function function = new UserFunctionExecution();
@@ -448,7 +450,7 @@ public class FunctionCommands implements CommandMarker {
           help = CliStrings.DESTROY_FUNCTION__ONMEMBER__HELP) String memberId) {
     Result result = null;
     try {
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
       Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
       if (groups != null && memberId != null) {
         return ResultBuilder
@@ -479,7 +481,6 @@ public class FunctionCommands implements CommandMarker {
       result = ResultBuilder.buildResult(errorResultData);
       return result;
     }
-
   }
 
   /**
@@ -510,7 +511,7 @@ public class FunctionCommands implements CommandMarker {
     }
   }
 
-  Result executeFunction(Cache cache, Set<DistributedMember> DsMembers, String functionId) {
+  Result executeFunction(InternalCache cache, Set<DistributedMember> DsMembers, String functionId) {
     // unregister on a set of of members
     Function unregisterFunction = new UnregisterFunction();
     FunctionService.registerFunction(unregisterFunction);
@@ -565,7 +566,7 @@ public class FunctionCommands implements CommandMarker {
     TabularResultData tabularData = ResultBuilder.createTabularResultData();
     boolean accumulatedData = false;
 
-    Cache cache = CacheFactory.getAnyInstance();
+    InternalCache cache = getCache();
 
     Set<DistributedMember> targetMembers;
     try {

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
index 080d520..1a7e2df 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
@@ -22,6 +22,7 @@ import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.FunctionInvocationTargetException;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.security.IntegratedSecurityService;
@@ -85,7 +86,7 @@ public class IndexCommands extends AbstractCommandsSupport {
   private SecurityService securityService = IntegratedSecurityService.getSecurityService();
 
   @Override
-  protected Set<DistributedMember> getMembers(final Cache cache) {
+  protected Set<DistributedMember> getMembers(final InternalCache cache) {
     // TODO determine what this does (as it is untested and unmockable!)
     return CliUtil.getAllMembers(cache);
   }


Mime
View raw message