geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [2/7] geode git commit: Change GemFireCacheImpl to InternalCache
Date Fri, 05 May 2017 17:32:29 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
index b5fb9fe..6b63f09 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -14,9 +14,44 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+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.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+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 java.util.zip.DataFormatException;
+import java.util.zip.GZIPInputStream;
+
+import javax.management.ObjectName;
+
 import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Logger;
+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.CacheFactory;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
@@ -30,7 +65,9 @@ import org.apache.geode.distributed.internal.deadlock.Dependency;
 import org.apache.geode.distributed.internal.deadlock.DependencyGraph;
 import org.apache.geode.distributed.internal.deadlock.GemFireDeadlockDetector;
 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.internal.logging.log4j.LogLevel;
 import org.apache.geode.management.CacheServerMXBean;
 import org.apache.geode.management.DistributedRegionMXBean;
 import org.apache.geode.management.DistributedSystemMXBean;
@@ -70,49 +107,15 @@ import org.apache.geode.management.internal.cli.result.ResultData;
 import org.apache.geode.management.internal.cli.result.ResultDataException;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
-import org.apache.geode.internal.logging.log4j.LogLevel;
 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.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.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-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.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-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 java.util.zip.DataFormatException;
-import java.util.zip.GZIPInputStream;
-import javax.management.ObjectName;
 
 /**
  * @since GemFire 7.0
  */
 public class MiscellaneousCommands implements CommandMarker {
+
   public static final String NETSTAT_FILE_REQUIRED_EXTENSION = ".txt";
   public final static String DEFAULT_TIME_OUT = "10";
   private final static Logger logger = LogService.getLogger();
@@ -123,6 +126,9 @@ public class MiscellaneousCommands implements CommandMarker {
     return Gfsh.getCurrentInstance();
   }
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
 
   public void shutdownNode(final long timeout, final Set<DistributedMember> includeMembers)
       throws TimeoutException, InterruptedException, ExecutionException {
@@ -145,7 +151,6 @@ public class MiscellaneousCommands implements CommandMarker {
           }
           return "SUCCESS";
         }
-
       };
 
       Future<String> result = exec.submit(shutdownNodes);
@@ -163,10 +168,8 @@ public class MiscellaneousCommands implements CommandMarker {
     } finally {
       exec.shutdownNow();
     }
-
   }
 
-
   @CliCommand(value = CliStrings.SHUTDOWN, help = CliStrings.SHUTDOWN__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_LIFECYCLE},
       interceptor = "org.apache.geode.management.internal.cli.commands.MiscellaneousCommands$Interceptor")
@@ -185,7 +188,7 @@ public class MiscellaneousCommands implements CommandMarker {
       // convert to mili-seconds
       long timeout = userSpecifiedTimeout * 1000;
 
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
 
       int numDataNodes = CliUtil.getAllNormalMembers(cache).size();
 
@@ -199,9 +202,7 @@ public class MiscellaneousCommands implements CommandMarker {
         return ResultBuilder.createInfoResult(CliStrings.SHUTDOWN__MSG__NO_DATA_NODE_FOUND);
       }
 
-      GemFireCacheImpl gemFireCache = (GemFireCacheImpl) cache;
-      String managerName =
-          gemFireCache.getJmxManagerAdvisor().getDistributionManager().getId().getId();
+      String managerName = cache.getJmxManagerAdvisor().getDistributionManager().getId().getId();
 
       final DistributedMember manager = CliUtil.getDistributedMemberByNameOrId(managerName);
 
@@ -251,7 +252,6 @@ public class MiscellaneousCommands implements CommandMarker {
 
     // @TODO. List all the nodes which could be successfully shutdown
     return ResultBuilder.createInfoResult("Shutdown is triggered");
-
   }
 
   /**
@@ -269,10 +269,8 @@ public class MiscellaneousCommands implements CommandMarker {
 
     long timeElapsed = shutDownTimeEnd - shutDownTimeStart;
 
-    if (timeElapsed > timeout || Boolean.getBoolean("ThrowTimeoutException")) { // The second check
-      // for
-      // ThrowTimeoutException
-      // is a test hook
+    if (timeElapsed > timeout || Boolean.getBoolean("ThrowTimeoutException")) {
+      // The second check for ThrowTimeoutException is a test hook
       throw new TimeoutException();
     }
     return timeElapsed;
@@ -310,7 +308,7 @@ public class MiscellaneousCommands implements CommandMarker {
       @CliOption(key = CliStrings.GC__MEMBER, optionContext = ConverterHint.ALL_MEMBER_IDNAME,
           unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.GC__MEMBER__HELP) String memberId) {
-    Cache cache = CacheFactory.getAnyInstance();
+    InternalCache cache = getCache();
     Result result = null;
     CompositeResultData gcResultTable = ResultBuilder.createCompositeResultData();
     TabularResultData resultTable = gcResultTable.addSection().addTable("Table1");
@@ -324,25 +322,24 @@ public class MiscellaneousCommands implements CommandMarker {
             .createGemFireErrorResult(memberId + CliStrings.GC__MSG__MEMBER_NOT_FOUND);
       }
       dsMembers.add(member);
-      result = executeAndBuildResult(cache, resultTable, dsMembers);
+      result = executeAndBuildResult(resultTable, dsMembers);
     } else if (groups != null && groups.length > 0) {
       for (String group : groups) {
         dsMembers.addAll(cache.getDistributedSystem().getGroupMembers(group));
       }
-      result = executeAndBuildResult(cache, resultTable, dsMembers);
+      result = executeAndBuildResult(resultTable, dsMembers);
 
     } else {
       // gc on entire cluster
       // exclude locators
       dsMembers = CliUtil.getAllNormalMembers(cache);
-      result = executeAndBuildResult(cache, resultTable, dsMembers);
+      result = executeAndBuildResult(resultTable, dsMembers);
 
     }
     return result;
   }
 
-  Result executeAndBuildResult(Cache cache, TabularResultData resultTable,
-      Set<DistributedMember> dsMembers) {
+  Result executeAndBuildResult(TabularResultData resultTable, Set<DistributedMember> dsMembers) {
     try {
       List<?> resultList = null;
       Function garbageCollectionFunction = new GarbageCollectionFunction();
@@ -391,7 +388,6 @@ public class MiscellaneousCommands implements CommandMarker {
     table.accumulate(CliStrings.GC__MSG__TOTAL_TIME_IN_GC, timeTaken);
   }
 
-
   @CliCommand(value = CliStrings.NETSTAT, help = CliStrings.NETSTAT__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
@@ -568,7 +564,7 @@ public class MiscellaneousCommands implements CommandMarker {
         return ResultBuilder
             .createUserErrorResult(CliStrings.format(CliStrings.INVALID_FILE_EXTENSION, ".txt"));
       }
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
 
       Set<DistributedMember> allMembers = CliUtil.getAllMembers(cache);
       GemFireDeadlockDetector gfeDeadLockDetector = new GemFireDeadlockDetector(allMembers);
@@ -617,7 +613,7 @@ public class MiscellaneousCommands implements CommandMarker {
           help = CliStrings.SHOW_LOG_LINE_NUM_HELP, mandatory = false) int numberOfLines) {
     Result result = null;
     try {
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
       MemberMXBean bean = null;
@@ -651,7 +647,6 @@ public class MiscellaneousCommands implements CommandMarker {
               ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
                   .addLine(memberNameOrId + CliStrings.SHOW_LOG_MSG_MEMBER_NOT_FOUND);
           return (ResultBuilder.buildResult(errorResultData));
-
         }
 
         result = ResultBuilder.buildResult(resultData);
@@ -660,7 +655,6 @@ public class MiscellaneousCommands implements CommandMarker {
             ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
                 .addLine(memberNameOrId + CliStrings.SHOW_LOG_MSG_MEMBER_NOT_FOUND);
         return (ResultBuilder.buildResult(errorResultData));
-
       }
 
     } catch (Exception e) {
@@ -670,11 +664,8 @@ public class MiscellaneousCommands implements CommandMarker {
     return result;
   }
 
-  /****
+  /**
    * Current implementation supports writing it to a file and returning the location of the file
-   *
-   * @param memberNameOrId
-   * @return Stack Trace
    */
   @CliCommand(value = CliStrings.EXPORT_STACKTRACE, help = CliStrings.EXPORT_STACKTRACE__HELP)
   @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
@@ -706,9 +697,8 @@ public class MiscellaneousCommands implements CommandMarker {
             CliStrings.EXPORT_STACKTRACE__ERROR__FILE__PRESENT, outFile.getCanonicalPath()));
       }
 
-      Cache cache = CacheFactory.getAnyInstance();
-      GemFireCacheImpl gfeCacheImpl = (GemFireCacheImpl) cache;
-      InternalDistributedSystem ads = gfeCacheImpl.getSystem();
+      InternalCache cache = getCache();
+      InternalDistributedSystem ads = cache.getInternalDistributedSystem();
 
       InfoResultData resultData = ResultBuilder.createInfoResultData();
 
@@ -778,7 +768,6 @@ public class MiscellaneousCommands implements CommandMarker {
    * @throws IOException
    */
   private String writeStacksToFile(Map<String, byte[]> dumps, String fileName) throws IOException {
-
     String filePath = null;
     OutputStream os = null;
     PrintWriter ps = null;
@@ -897,17 +886,15 @@ public class MiscellaneousCommands implements CommandMarker {
     return result;
   }
 
-  /****
+  /**
    * Gets the system wide metrics
    *
-   * @param export_to_report_to
    * @return ResultData with required System wide statistics or ErrorResultData if DS MBean is not
    *         found to gather metrics
-   * @throws Exception
    */
   private ResultData getSystemWideMetrics(String export_to_report_to, String[] categoriesArr)
       throws Exception {
-    final Cache cache = CacheFactory.getAnyInstance();
+    final InternalCache cache = getCache();
     final ManagementService managmentService = ManagementService.getManagementService(cache);
     DistributedSystemMXBean dsMxBean = managmentService.getDistributedSystemMXBean();
     StringBuilder csvBuilder = null;
@@ -1001,14 +988,11 @@ public class MiscellaneousCommands implements CommandMarker {
           CliStrings.format(CliStrings.SHOW_METRICS__ERROR, "Distributed System MBean not found");
       return ResultBuilder.createErrorResultData().addLine(errorMessage);
     }
-
   }
 
-  /***
+  /**
    * Gets the Cluster wide metrics for a given member
    *
-   * @param distributedMember
-   * @param export_to_report_to
    * @return ResultData with required Member statistics or ErrorResultData if MemberMbean is not
    *         found to gather metrics
    * @throws ResultDataException if building result fails
@@ -1016,7 +1000,7 @@ public class MiscellaneousCommands implements CommandMarker {
   private ResultData getMemberMetrics(DistributedMember distributedMember,
       String export_to_report_to, String[] categoriesArr, int cacheServerPort)
       throws ResultDataException {
-    final Cache cache = CacheFactory.getAnyInstance();
+    final InternalCache cache = getCache();
     final SystemManagementService managementService =
         (SystemManagementService) ManagementService.getManagementService(cache);
 
@@ -1086,7 +1070,7 @@ public class MiscellaneousCommands implements CommandMarker {
         }
       }
 
-      /****
+      /*
        * Member Metrics
        */
       // member, jvm, region, serialization, communication, function, transaction, diskstore, lock,
@@ -1100,7 +1084,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "maximumHeapSize", memberMxBean.getMaximumHeapSize(),
             csvBuilder);
       }
-      /****
+      /*
        * JVM Metrics
        */
       if (categoriesMap.get("jvm").booleanValue()) {
@@ -1111,7 +1095,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "totalFileDescriptorOpen",
             memberMxBean.getTotalFileDescriptorOpen(), csvBuilder);
       }
-      /***
+      /*
        * Member wide region metrics
        */
       if (categoriesMap.get("region").booleanValue()) {
@@ -1170,10 +1154,9 @@ public class MiscellaneousCommands implements CommandMarker {
             memberMxBean.getCacheListenerCallsAvgLatency(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalLoadsCompleted",
             memberMxBean.getTotalLoadsCompleted(), csvBuilder);
-
       }
 
-      /******
+      /*
        * SERIALIZATION
        */
       if (categoriesMap.get("serialization").booleanValue()) {
@@ -1193,9 +1176,8 @@ public class MiscellaneousCommands implements CommandMarker {
             memberMxBean.getPDXDeserializationRate(), csvBuilder);
       }
 
-      /***
+      /*
        * Communication Metrics
-       *
        */
       if (categoriesMap.get("communication").booleanValue()) {
         writeToTableAndCsv(metricsTable, "communication", "bytesSentRate",
@@ -1209,12 +1191,10 @@ public class MiscellaneousCommands implements CommandMarker {
         String[] connectedGatewaySenders = memberMxBean.listConnectedGatewaySenders();
         writeToTableAndCsv(metricsTable, "", "connectedGatewaySenders", connectedGatewaySenders,
             csvBuilder);
-
       }
 
-      /***
+      /*
        * Member wide function metrics
-       *
        */
       if (categoriesMap.get("function").booleanValue()) {
         writeToTableAndCsv(metricsTable, "function", "numRunningFunctions",
@@ -1228,7 +1208,7 @@ public class MiscellaneousCommands implements CommandMarker {
         // memberMxBean.getFuncExecutionQueueSize(), csvBuilder);
       }
 
-      /***
+      /*
        * totalTransactionsCount currentTransactionalThreadIds transactionCommitsAvgLatency
        * transactionCommittedTotalCount transactionRolledBackTotalCount transactionCommitsRate
        */
@@ -1245,7 +1225,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "transactionCommitsRate",
             memberMxBean.getTransactionCommitsRate(), csvBuilder);
       }
-      /***
+      /*
        * Member wide disk metrics
        */
       if (categoriesMap.get("diskstore").booleanValue()) {
@@ -1263,7 +1243,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "totalBackupInProgress",
             memberMxBean.getTotalBackupInProgress(), csvBuilder);
       }
-      /***
+      /*
        * Member wide Lock
        */
       if (categoriesMap.get("lock").booleanValue()) {
@@ -1276,7 +1256,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "requestQueues", memberMxBean.getLockRequestQueues(),
             csvBuilder);
       }
-      /****
+      /*
        * Eviction
        */
       if (categoriesMap.get("eviction").booleanValue()) {
@@ -1285,7 +1265,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "lruDestroyRate", memberMxBean.getLruDestroyRate(),
             csvBuilder);
       }
-      /***
+      /*
        * Distribution
        */
       if (categoriesMap.get("distribution").booleanValue()) {
@@ -1297,7 +1277,7 @@ public class MiscellaneousCommands implements CommandMarker {
             memberMxBean.getInitialImageKeysReceived(), csvBuilder);
       }
 
-      /***
+      /*
        * OffHeap
        */
       if (categoriesMap.get("offheap").booleanValue()) {
@@ -1315,7 +1295,7 @@ public class MiscellaneousCommands implements CommandMarker {
             memberMxBean.getOffHeapCompactionTime(), csvBuilder);
       }
 
-      /***
+      /*
        * CacheServer stats
        */
       if (csMxBean != null) {
@@ -1345,7 +1325,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "putRequestRate", csMxBean.getPutRequestRate(),
             csvBuilder);
 
-        /*****
+        /*
          * Notification
          */
         writeToTableAndCsv(metricsTable, "notification", "numClientNotificationRequests",
@@ -1355,7 +1335,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "clientNotificationAvgLatency",
             csMxBean.getClientNotificationAvgLatency(), csvBuilder);
 
-        /***
+        /*
          * Query
          */
         writeToTableAndCsv(metricsTable, "query", "activeCQCount", csMxBean.getActiveCQCount(),
@@ -1369,7 +1349,6 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "index list", indexList, csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalIndexMaintenanceTime",
             csMxBean.getTotalIndexMaintenanceTime(), csvBuilder);
-
       }
 
       if (export_to_report_to != null && !export_to_report_to.isEmpty()) {
@@ -1386,17 +1365,16 @@ public class MiscellaneousCommands implements CommandMarker {
     }
   }
 
-  /****
+  /**
    * Gets the Cluster-wide metrics for a region
    *
-   * @param regionName
    * @return ResultData containing the table
    * @throws ResultDataException if building result fails
    */
   private ResultData getDistributedRegionMetrics(String regionName, String export_to_report_to,
       String[] categoriesArr) throws ResultDataException {
 
-    final Cache cache = CacheFactory.getAnyInstance();
+    final InternalCache cache = getCache();
     final ManagementService managementService = ManagementService.getManagementService(cache);
 
     DistributedRegionMXBean regionMxBean = managementService.getDistributedRegionMXBean(regionName);
@@ -1444,7 +1422,7 @@ public class MiscellaneousCommands implements CommandMarker {
           return ResultBuilder.createErrorResultData().addLine(sb.toString());
         }
       }
-      /***
+      /*
        * General System metrics
        */
       // cluster, region, partition , diskstore, callback, eviction
@@ -1471,7 +1449,6 @@ public class MiscellaneousCommands implements CommandMarker {
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "putAllRate", regionMxBean.getPutAllRate(),
             csvBuilder);
-
       }
 
       if (categoriesMap.get("partition").booleanValue()) {
@@ -1495,7 +1472,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "averageBucketSize", regionMxBean.getAvgBucketSize(),
             csvBuilder);
       }
-      /*****
+      /*
        * Disk store
        */
       if (categoriesMap.get("diskstore").booleanValue()) {
@@ -1511,7 +1488,7 @@ public class MiscellaneousCommands implements CommandMarker {
             csvBuilder);
 
       }
-      /*****
+      /*
        * LISTENER
        */
       if (categoriesMap.get("callback").booleanValue()) {
@@ -1521,7 +1498,7 @@ public class MiscellaneousCommands implements CommandMarker {
             regionMxBean.getCacheListenerCallsAvgLatency(), csvBuilder);
       }
 
-      /****
+      /*
        * Eviction
        */
       if (categoriesMap.get("eviction").booleanValue()) {
@@ -1546,12 +1523,9 @@ public class MiscellaneousCommands implements CommandMarker {
     }
   }
 
-  /***
+  /**
    * Gets the metrics of region on a given member
    *
-   * @param regionName
-   * @param distributedMember
-   * @param export_to_report_to
    * @return ResultData with required Region statistics or ErrorResultData if Region MBean is not
    *         found to gather metrics
    * @throws ResultDataException if building result fails
@@ -1560,7 +1534,7 @@ public class MiscellaneousCommands implements CommandMarker {
       DistributedMember distributedMember, String export_to_report_to, String[] categoriesArr)
       throws ResultDataException {
 
-    final Cache cache = CacheFactory.getAnyInstance();
+    final InternalCache cache = getCache();
     final SystemManagementService managementService =
         (SystemManagementService) ManagementService.getManagementService(cache);
 
@@ -1587,7 +1561,7 @@ public class MiscellaneousCommands implements CommandMarker {
         csvBuilder.append('\n');
       }
 
-      /****
+      /*
        * Region Metrics
        */
       Map<String, Boolean> categoriesMap = getRegionMetricsCategories();
@@ -1657,10 +1631,8 @@ public class MiscellaneousCommands implements CommandMarker {
             regionMxBean.getNumBucketsWithoutRedundancy(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalBucketSize", regionMxBean.getTotalBucketSize(),
             csvBuilder);
-        // writeToTableAndCsv(metricsTable, "", "averageBucketSize",
-        // regionMxBean.getAvgBucketSize(), csvBuilder);
       }
-      /*****
+      /*
        * Disk store
        */
       if (categoriesMap.get("diskstore").booleanValue()) {
@@ -1675,7 +1647,7 @@ public class MiscellaneousCommands implements CommandMarker {
         writeToTableAndCsv(metricsTable, "", "diskTaskWaiting", regionMxBean.getDiskTaskWaiting(),
             csvBuilder);
       }
-      /*****
+      /*
        * LISTENER
        */
       if (categoriesMap.get("callback").booleanValue()) {
@@ -1685,7 +1657,7 @@ public class MiscellaneousCommands implements CommandMarker {
             regionMxBean.getCacheListenerCallsAvgLatency(), csvBuilder);
       }
 
-      /****
+      /*
        * Eviction
        */
       if (categoriesMap.get("eviction").booleanValue()) {
@@ -1708,18 +1680,10 @@ public class MiscellaneousCommands implements CommandMarker {
       erd.addLine(errorMessage);
       return erd;
     }
-
   }
 
-
   /***
    * Writes an entry to a TabularResultData and writes a comma separated entry to a string builder
-   *
-   * @param metricsTable
-   * @param type
-   * @param metricName
-   * @param metricValue
-   * @param csvBuilder
    */
   private void writeToTableAndCsv(TabularResultData metricsTable, String type, String metricName,
       long metricValue, StringBuilder csvBuilder) {
@@ -1737,14 +1701,6 @@ public class MiscellaneousCommands implements CommandMarker {
     }
   }
 
-  /***
-   *
-   * @param metricsTable
-   * @param type
-   * @param metricName
-   * @param metricValue
-   * @param csvBuilder
-   */
   private void writeToTableAndCsv(TabularResultData metricsTable, String type, String metricName,
       double metricValue, StringBuilder csvBuilder) {
     metricsTable.accumulate(CliStrings.SHOW_METRICS__TYPE__HEADER, type);
@@ -1769,7 +1725,7 @@ public class MiscellaneousCommands implements CommandMarker {
     return categoriesSet;
   }
 
-  /****
+  /**
    * Defines and returns map of categories for System metrics.
    *
    * @return map with categories for system metrics and display flag set to true
@@ -1783,7 +1739,7 @@ public class MiscellaneousCommands implements CommandMarker {
     return categories;
   }
 
-  /****
+  /**
    * Defines and returns map of categories for Region Metrics
    *
    * @return map with categories for region metrics and display flag set to true
@@ -1802,7 +1758,7 @@ public class MiscellaneousCommands implements CommandMarker {
     return categories;
   }
 
-  /****
+  /**
    * Defines and returns map of categories for system-wide region metrics
    *
    * @return map with categories for system wide region metrics and display flag set to true
@@ -1813,7 +1769,7 @@ public class MiscellaneousCommands implements CommandMarker {
     return categories;
   }
 
-  /*****
+  /**
    * Defines and returns map of categories for member metrics
    *
    * @return map with categories for member metrics and display flag set to true
@@ -1835,11 +1791,9 @@ public class MiscellaneousCommands implements CommandMarker {
     return categories;
   }
 
-  /***
+  /**
    * Converts an array of strings to a String delimited by a new line character for display purposes
    *
-   * @param names
-   * @param startIndex
    * @return a String delimited by a new line character for display purposes
    */
   private String formatNames(String[] names, int startIndex) {
@@ -1867,14 +1821,8 @@ public class MiscellaneousCommands implements CommandMarker {
     }
   }
 
-  /***
+  /**
    * Writes to a TabularResultData and also appends a CSV string to a String builder
-   *
-   * @param metricsTable
-   * @param type
-   * @param metricName
-   * @param metricValue
-   * @param csvBuilder
    */
   private void writeToTableAndCsv(TabularResultData metricsTable, String type, String metricName,
       String metricValue, StringBuilder csvBuilder) {
@@ -1892,7 +1840,6 @@ public class MiscellaneousCommands implements CommandMarker {
     }
   }
 
-
   @CliCommand(value = CliStrings.CHANGE_LOGLEVEL, help = CliStrings.CHANGE_LOGLEVEL__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_LOGS},
       interceptor = "org.apache.geode.management.internal.cli.commands.MiscellaneousCommands$ChangeLogLevelInterceptor")
@@ -1911,7 +1858,7 @@ public class MiscellaneousCommands implements CommandMarker {
             .createUserErrorResult(CliStrings.CHANGE_LOGLEVEL__MSG__SPECIFY_GRP_OR_MEMBER);
       }
 
-      Cache cache = GemFireCacheImpl.getInstance();
+      InternalCache cache = GemFireCacheImpl.getInstance();
       LogWriter logger = cache.getLogger();
 
       Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
@@ -2008,7 +1955,6 @@ public class MiscellaneousCommands implements CommandMarker {
     }
   }
 
-
   @CliAvailabilityIndicator({CliStrings.SHUTDOWN, CliStrings.GC, CliStrings.SHOW_DEADLOCK,
       CliStrings.SHOW_METRICS, CliStrings.SHOW_LOG, CliStrings.EXPORT_STACKTRACE,
       CliStrings.NETSTAT, CliStrings.EXPORT_LOGS, CliStrings.CHANGE_LOGLEVEL})

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java
index 5cf5ff1..f8d27de 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java
@@ -18,9 +18,14 @@ import java.util.HashSet;
 import java.util.List;
 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.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.cli.Result.Status;
@@ -35,11 +40,6 @@ 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;
-
-
 public class StatusCommands extends AbstractCommandsSupport implements CommandMarker {
   static final FetchSharedConfigurationStatusFunction fetchSharedConfigStatusFunction =
       new FetchSharedConfigurationStatusFunction();
@@ -49,7 +49,7 @@ public class StatusCommands extends AbstractCommandsSupport implements CommandMa
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_LOCATOR)
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result statusSharedConfiguration() {
-    final GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    final InternalCache cache = GemFireCacheImpl.getInstance();
     final Set<DistributedMember> locators = new HashSet<DistributedMember>(
         cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration().keySet());
     if (locators.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AlterRuntimeConfigFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AlterRuntimeConfigFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AlterRuntimeConfigFunction.java
index 62b3226..1d3e5f5 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AlterRuntimeConfigFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AlterRuntimeConfigFunction.java
@@ -14,7 +14,10 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
-import org.apache.geode.cache.Cache;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.FunctionAdapter;
@@ -22,31 +25,26 @@ import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.ConfigSource;
 import org.apache.geode.internal.InternalEntity;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/****
- * 
- *
- */
 public class AlterRuntimeConfigFunction extends FunctionAdapter implements InternalEntity {
 
   private static final long serialVersionUID = 1L;
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @Override
   public void execute(FunctionContext context) {
     String memberId = "";
 
     try {
       Object arg = context.getArguments();
-      Cache trueCache = null;
-      GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
-      DistributionConfig config = cache.getSystem().getConfig();
+      InternalCache cache = getCache();
+      DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
       memberId = cache.getDistributedSystem().getDistributedMember().getId();
 
       Map<String, String> runtimeAttributes = (Map<String, String>) arg;

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction.java
index 816f76a..8cd67a0 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction.java
@@ -12,7 +12,6 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.management.internal.cli.functions;
 
 import java.io.Serializable;
@@ -23,29 +22,32 @@ import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.cache.CacheServerImpl;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.tier.sockets.AcceptorImpl;
 import org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier;
 import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy;
 import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 
-
-
 /**
+ * TODO: rename ContunuousQueryFunction
  * 
  * @since GemFire 8.0
  */
-
 public class ContunuousQueryFunction implements Function, InternalEntity {
-  public static final String ID = ContunuousQueryFunction.class.getName();
   private static final long serialVersionUID = 1L;
 
+  public static final String ID = ContunuousQueryFunction.class.getName();
+
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @Override
   public void execute(FunctionContext context) {
     try {
       String clientID = (String) context.getArguments();
-      GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
       if (cache.getCacheServers().size() > 0) {
         CacheServerImpl server = (CacheServerImpl) cache.getCacheServers().iterator().next();
         if (server != null) {
@@ -105,13 +107,11 @@ public class ContunuousQueryFunction implements Function, InternalEntity {
           .lastResult("Exception in ContunuousQueryFunction =" + e.getMessage());
     }
     context.getResultSender().lastResult(null);
-
   }
 
   @Override
   public String getId() {
     return ContunuousQueryFunction.ID;
-
   }
 
   @Override
@@ -129,14 +129,12 @@ public class ContunuousQueryFunction implements Function, InternalEntity {
     return false;
   }
 
-  public class ClientInfo implements Serializable {
+  public static class ClientInfo implements Serializable {
     private static final long serialVersionUID = 1L;
     public String isDurable;
     public String primaryServer;
     public String secondaryServer;
 
-
-
     public ClientInfo(String IsClientDurable, String primaryServerId, String secondaryServerId) {
       isDurable = IsClientDurable;
       primaryServer = primaryServerId;
@@ -148,8 +146,5 @@ public class ContunuousQueryFunction implements Function, InternalEntity {
       return "ClientInfo [isDurable=" + isDurable + ", primaryServer=" + primaryServer
           + ", secondaryServer=" + secondaryServer + "]";
     }
-
-
   }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateAsyncEventQueueFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateAsyncEventQueueFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateAsyncEventQueueFunction.java
index 8bd603b..aab19be 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateAsyncEventQueueFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateAsyncEventQueueFunction.java
@@ -14,16 +14,11 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
-/**
- * Function used by the 'create async-event-queue' gfsh command to create an asynchronous event
- * queue on a member.
- * 
- * @since GemFire 8.0
- */
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
+import joptsimple.internal.Strings;
 import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.SystemFailure;
@@ -34,25 +29,34 @@ import org.apache.geode.cache.asyncqueue.AsyncEventListener;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory;
 import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.cache.wan.GatewaySender.OrderPolicy;
 import org.apache.geode.cache.wan.GatewayEventFilter;
 import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter;
+import org.apache.geode.cache.wan.GatewaySender.OrderPolicy;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.internal.InternalDataSerializer;
 import org.apache.geode.internal.InternalEntity;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
-import joptsimple.internal.Strings;
 
+/**
+ * Function used by the 'create async-event-queue' gfsh command to create an asynchronous event
+ * queue on a member.
+ *
+ * @since GemFire 8.0
+ */
 public class CreateAsyncEventQueueFunction extends FunctionAdapter implements InternalEntity {
   private static final Logger logger = LogService.getLogger();
 
   private static final long serialVersionUID = 1L;
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @SuppressWarnings("deprecation")
   @Override
   public void execute(FunctionContext context) {
@@ -62,7 +66,7 @@ public class CreateAsyncEventQueueFunction extends FunctionAdapter implements In
     try {
       AsyncEventQueueFunctionArgs aeqArgs = (AsyncEventQueueFunctionArgs) context.getArguments();
 
-      GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDiskStoreFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDiskStoreFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDiskStoreFunction.java
index 944044b..3b4679c 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDiskStoreFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDiskStoreFunction.java
@@ -19,9 +19,9 @@ package org.apache.geode.management.internal.cli.functions;
  * 
  * @since GemFire 8.0
  */
+
 import org.apache.logging.log4j.Logger;
 
-import org.apache.geode.LogWriter;
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.CacheFactory;
@@ -31,7 +31,7 @@ import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.cache.DiskStoreAttributes;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
@@ -41,6 +41,10 @@ public class CreateDiskStoreFunction extends FunctionAdapter implements Internal
 
   private static final long serialVersionUID = 1L;
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @Override
   public void execute(FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
@@ -50,7 +54,7 @@ public class CreateDiskStoreFunction extends FunctionAdapter implements Internal
       final String diskStoreName = (String) args[0];
       final DiskStoreAttributes diskStoreAttrs = (DiskStoreAttributes) args[01];
 
-      GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DeployFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DeployFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DeployFunction.java
index 421f9d7..f1b1cd6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DeployFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DeployFunction.java
@@ -15,23 +15,21 @@
 package org.apache.geode.management.internal.cli.functions;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
-import org.apache.geode.internal.ClassPathLoader;
 import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.SystemFailure;
-import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.internal.InternalEntity;
+import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.internal.DeployedJar;
+import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.JarDeployer;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.logging.LogService;
 
 public class DeployFunction implements Function, InternalEntity {
@@ -41,6 +39,10 @@ public class DeployFunction implements Function, InternalEntity {
 
   private static final long serialVersionUID = 1L;
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @Override
   public void execute(FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
@@ -50,10 +52,10 @@ public class DeployFunction implements Function, InternalEntity {
       final Object[] args = (Object[]) context.getArguments();
       final String[] jarFilenames = (String[]) args[0];
       final byte[][] jarBytes = (byte[][]) args[1];
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
 
-      final JarDeployer jarDeployer = new JarDeployer(((GemFireCacheImpl) cache)
-          .getInternalDistributedSystem().getConfig().getDeployWorkingDir());
+      final JarDeployer jarDeployer =
+          new JarDeployer(cache.getInternalDistributedSystem().getConfig().getDeployWorkingDir());
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyDiskStoreFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyDiskStoreFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyDiskStoreFunction.java
index 84dde7f..c25a534 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyDiskStoreFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyDiskStoreFunction.java
@@ -24,7 +24,7 @@ import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.InternalEntity;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
@@ -34,12 +34,15 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
  * 
  * @since GemFire 8.0
  */
-
 public class DestroyDiskStoreFunction extends FunctionAdapter implements InternalEntity {
   private static final Logger logger = LogService.getLogger();
 
   private static final long serialVersionUID = 1L;
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @Override
   public void execute(FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
@@ -49,7 +52,7 @@ public class DestroyDiskStoreFunction extends FunctionAdapter implements Interna
       final Object[] args = (Object[]) context.getArguments();
       final String diskStoreName = (String) args[0];
 
-      GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
index fd5d6a4..663a08e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
@@ -15,7 +15,21 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.nio.file.Path;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Arrays;
+
 import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.Region;
@@ -25,27 +39,15 @@ import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.InternalRegionArguments;
 import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.management.internal.cli.commands.ExportLogsCommand;
 import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
 import org.apache.geode.management.internal.cli.util.LogExporter;
 import org.apache.geode.management.internal.cli.util.LogFilter;
-import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.nio.file.Path;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.Arrays;
 
 /**
  * this function extracts the logs using a LogExporter which creates a zip file, and then writes the
@@ -55,21 +57,21 @@ import java.util.Arrays;
  * The function only extracts .log and .gfs files under server's working directory
  */
 public class ExportLogsFunction implements Function, InternalEntity {
+  private static final Logger logger = LogService.getLogger();
 
   public static final String EXPORT_LOGS_REGION = "__exportLogsRegion";
 
-  private static final Logger LOGGER = LogService.getLogger();
   private static final long serialVersionUID = 1L;
   private static final int BUFFER_SIZE = 1024;
 
   @Override
   public void execute(final FunctionContext context) {
     try {
-      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      InternalCache cache = GemFireCacheImpl.getInstance();
       DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
 
       String memberId = cache.getDistributedSystem().getMemberId();
-      LOGGER.info("ExportLogsFunction started for member {}", memberId);
+      logger.info("ExportLogsFunction started for member {}", memberId);
 
       Region exportLogsRegion = createOrGetExistingExportLogsRegion(false, cache);
 
@@ -95,7 +97,7 @@ public class ExportLogsFunction implements Function, InternalEntity {
         return;
       }
 
-      LOGGER.info("Streaming zipped file: " + exportedZipFile.toString());
+      logger.info("Streaming zipped file: " + exportedZipFile.toString());
       try (FileInputStream inputStream = new FileInputStream(exportedZipFile.toFile())) {
         byte[] buffer = new byte[BUFFER_SIZE];
 
@@ -113,13 +115,13 @@ public class ExportLogsFunction implements Function, InternalEntity {
 
     } catch (Exception e) {
       e.printStackTrace();
-      LOGGER.error(e);
+      logger.error(e);
       context.getResultSender().sendException(e);
     }
   }
 
   public static Region createOrGetExistingExportLogsRegion(boolean isInitiatingMember,
-      GemFireCacheImpl cache) throws IOException, ClassNotFoundException {
+      InternalCache cache) throws IOException, ClassNotFoundException {
 
     Region exportLogsRegion = cache.getRegion(EXPORT_LOGS_REGION);
     if (exportLogsRegion == null) {
@@ -140,8 +142,7 @@ public class ExportLogsFunction implements Function, InternalEntity {
     return exportLogsRegion;
   }
 
-  public static void destroyExportLogsRegion(GemFireCacheImpl cache) {
-
+  public static void destroyExportLogsRegion(InternalCache cache) {
     Region exportLogsRegion = cache.getRegion(EXPORT_LOGS_REGION);
     if (exportLogsRegion == null) {
       return;

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java
index ff65471..57d209b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java
@@ -20,6 +20,7 @@ import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.InternalEntity;
 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.management.internal.configuration.domain.SharedConfigurationStatus;
 
@@ -31,7 +32,7 @@ public class FetchSharedConfigurationStatusFunction extends FunctionAdapter
   @Override
   public void execute(FunctionContext context) {
     InternalLocator locator = InternalLocator.getLocator();
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    InternalCache cache = GemFireCacheImpl.getInstance();
     DistributedMember member = cache.getDistributedSystem().getDistributedMember();
     SharedConfigurationStatus status = locator.getSharedConfigurationStatus().getStatus();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ListDeployedFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ListDeployedFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ListDeployedFunction.java
index 3d6a321..88a77be 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ListDeployedFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ListDeployedFunction.java
@@ -21,7 +21,6 @@ import org.apache.geode.internal.DeployedJar;
 import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.SystemFailure;
-import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.Function;
@@ -29,7 +28,7 @@ import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.JarDeployer;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.logging.LogService;
 
 public class ListDeployedFunction implements Function, InternalEntity {
@@ -39,13 +38,17 @@ public class ListDeployedFunction implements Function, InternalEntity {
 
   private static final long serialVersionUID = 1L;
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @Override
   public void execute(FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
     String memberId = "";
 
     try {
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
       final JarDeployer jarDeployer = ClassPathLoader.getLatest().getJarDeployer();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunction.java
index 441486e..ca66b6a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunction.java
@@ -19,8 +19,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.DistributedMember;
@@ -62,7 +60,7 @@ public class ShowMissingDiskStoresFunction extends FunctionAdapter implements In
           }
         }
         // Missing colocated regions
-        Set<PartitionedRegion> prs = ((GemFireCacheImpl) cache).getPartitionedRegions();
+        Set<PartitionedRegion> prs = cache.getPartitionedRegions();
         for (PartitionedRegion pr : prs) {
           List<String> missingChildRegions = pr.getMissingColocatedChildren();
           for (String child : missingChildRegions) {
@@ -96,4 +94,3 @@ public class ShowMissingDiskStoresFunction extends FunctionAdapter implements In
     return getClass().getName();
   }
 }
-

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunction.java
index 06af662..8d20dc0 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunction.java
@@ -14,36 +14,32 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
+import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Arrays;
+
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.InternalEntity;
 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.internal.cli.util.LogFilter;
 import org.apache.geode.management.internal.cli.util.LogSizer;
-import org.apache.logging.log4j.Logger;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.Arrays;
 
 public class SizeExportLogsFunction extends ExportLogsFunction implements Function, InternalEntity {
   private static final Logger LOGGER = LogService.getLogger();
   private static final long serialVersionUID = 1L;
 
-  protected Cache getCache() {
-    return CacheFactory.getAnyInstance();
-  }
-
   @Override
   public void execute(final FunctionContext context) {
     try {
-      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      InternalCache cache = GemFireCacheImpl.getInstance();
       DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
       Args args = (Args) context.getArguments();
       long diskAvailable = config.getLogFile().getUsableSpace();

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UndeployFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UndeployFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UndeployFunction.java
index 14d875e..64ed367 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UndeployFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UndeployFunction.java
@@ -22,7 +22,6 @@ import org.apache.geode.internal.ClassPathLoader;
 import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.SystemFailure;
-import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.Function;
@@ -31,7 +30,7 @@ import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.DeployedJar;
 import org.apache.geode.internal.JarDeployer;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.logging.LogService;
 
 public class UndeployFunction implements Function, InternalEntity {
@@ -41,6 +40,10 @@ public class UndeployFunction implements Function, InternalEntity {
 
   private static final long serialVersionUID = 1L;
 
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
   @Override
   public void execute(FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
@@ -49,7 +52,7 @@ public class UndeployFunction implements Function, InternalEntity {
     try {
       final Object[] args = (Object[]) context.getArguments();
       final String jarFilenameList = (String) args[0]; // Comma separated
-      Cache cache = CacheFactory.getAnyInstance();
+      InternalCache cache = getCache();
 
       final JarDeployer jarDeployer = ClassPathLoader.getLatest().getJarDeployer();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GetRegionNamesFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GetRegionNamesFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GetRegionNamesFunction.java
index 0fd8876..bd942c7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GetRegionNamesFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GetRegionNamesFunction.java
@@ -20,6 +20,7 @@ import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.LocalRegion;
 
 import java.util.Set;
@@ -27,7 +28,7 @@ import java.util.Set;
 public class GetRegionNamesFunction implements Function, InternalEntity {
   @Override
   public void execute(FunctionContext context) {
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    InternalCache cache = GemFireCacheImpl.getInstance();
 
     Set<String> regions =
         cache.getApplicationRegions().stream().map(LocalRegion::getName).collect(toSet());

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java
index 464a651..a00a79e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java
@@ -12,7 +12,6 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.management.internal.configuration.functions;
 
 import org.apache.geode.cache.execute.Function;
@@ -21,13 +20,14 @@ import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.cache.CacheConfig;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
 
 public class RecreateCacheFunction implements Function, InternalEntity {
   @Override
   public void execute(FunctionContext context) {
     CliFunctionResult result = null;
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    InternalCache cache = GemFireCacheImpl.getInstance();
     DistributedSystem ds = cache.getDistributedSystem();
     CacheConfig cacheConfig = cache.getCacheConfig();
     try {

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/messages/CompactRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/messages/CompactRequest.java b/geode-core/src/main/java/org/apache/geode/management/internal/messages/CompactRequest.java
index dfd5d88..2b22d27 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/messages/CompactRequest.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/messages/CompactRequest.java
@@ -33,27 +33,27 @@ import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.DM;
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.DistributionMessage;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.ReplyException;
 import org.apache.geode.internal.admin.remote.AdminMultipleReplyProcessor;
 import org.apache.geode.internal.admin.remote.AdminRequest;
 import org.apache.geode.internal.admin.remote.AdminResponse;
 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.logging.LogService;
 
 /**
  * An instruction to all members with cache that they should compact their disk stores.
- * 
- * 
+ * <p>
+ * NOTE: Extracted from org/apache/geode/internal/admin/remote/CompactRequest.java
+ *
  * @since GemFire 7.0
  */
-// NOTE: This is copied from org/apache/geode/internal/admin/remote/CompactRequest.java
-// and modified as per requirements. (original-author Dan Smith)
 public class CompactRequest extends AdminRequest {
   private static final Logger logger = LogService.getLogger();
 
   private String diskStoreName;
+
   private static String notExecutedMembers;
 
   public static Map<DistributedMember, PersistentID> send(DM dm, String diskStoreName,
@@ -103,7 +103,7 @@ public class CompactRequest extends AdminRequest {
 
   public static PersistentID compactDiskStore(String diskStoreName) {
     PersistentID persistentID = null;
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    InternalCache cache = GemFireCacheImpl.getInstance();
     if (cache != null && !cache.isClosed()) {
       DiskStoreImpl diskStore = (DiskStoreImpl) cache.findDiskStore(diskStoreName);
       if (diskStore != null && diskStore.forceCompaction()) {

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
index e93363a..0b64a44 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
@@ -25,6 +25,7 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
+
 import javax.management.JMX;
 import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
@@ -32,7 +33,20 @@ import javax.management.ObjectName;
 import javax.management.Query;
 import javax.management.QueryExp;
 
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.InitBinder;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.context.request.WebRequest;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+
 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.internal.logging.log4j.LogMarker;
@@ -51,18 +65,6 @@ import org.apache.geode.management.internal.web.controllers.support.LoginHandler
 import org.apache.geode.management.internal.web.util.UriUtils;
 import org.apache.geode.security.NotAuthorizedException;
 
-import org.apache.logging.log4j.Logger;
-import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.InitBinder;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.context.request.WebRequest;
-import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
-
 /**
  * The AbstractCommandsController class is the abstract base class encapsulating common
  * functionality across all Management Controller classes that expose REST API web service endpoints
@@ -89,22 +91,24 @@ public abstract class AbstractCommandsController {
 
   private Class accessControlKlass;
 
+  private InternalCache getCache() {
+    return GemFireCacheImpl.getInstance();
+  }
 
   // Convert a predefined exception to an HTTP Status code
   @ResponseStatus(value = HttpStatus.UNAUTHORIZED, reason = "Not authenticated") // 401
   @ExceptionHandler(org.apache.geode.security.AuthenticationFailedException.class)
   public void authenticate() {
-
+    // nothing
   }
 
   // Convert a predefined exception to an HTTP Status code
   @ResponseStatus(value = HttpStatus.FORBIDDEN, reason = "Access Denied") // 403
   @ExceptionHandler(java.lang.SecurityException.class)
   public void authorize() {
-
+    // nothing
   }
 
-
   /**
    * Asserts the argument is valid, as determined by the caller passing the result of an evaluated
    * expression to this assertion.
@@ -449,8 +453,8 @@ public abstract class AbstractCommandsController {
    */
   protected synchronized MemberMXBean getManagingMemberMXBean() {
     if (managingMemberMXBeanProxy == null) {
-      SystemManagementService service = (SystemManagementService) ManagementService
-          .getExistingManagementService(GemFireCacheImpl.getInstance());
+      SystemManagementService service =
+          (SystemManagementService) ManagementService.getExistingManagementService(getCache());
       MBeanServer mbs = getMBeanServer();
 
       final DistributedSystemMXBean distributedSystemMXBean = JMX.newMXBeanProxy(mbs,

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/pdx/internal/CheckTypeRegistryState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/pdx/internal/CheckTypeRegistryState.java b/geode-core/src/main/java/org/apache/geode/pdx/internal/CheckTypeRegistryState.java
index 8e628bf..d3e9f4f 100644
--- a/geode-core/src/main/java/org/apache/geode/pdx/internal/CheckTypeRegistryState.java
+++ b/geode-core/src/main/java/org/apache/geode/pdx/internal/CheckTypeRegistryState.java
@@ -28,10 +28,12 @@ import org.apache.geode.distributed.internal.ReplyException;
 import org.apache.geode.distributed.internal.ReplyMessage;
 import org.apache.geode.distributed.internal.ReplyProcessor21;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.pdx.PdxInitializationException;
 
 public class CheckTypeRegistryState extends HighPriorityDistributionMessage
     implements MessageWithReply {
+
   private int processorId;
 
   public CheckTypeRegistryState() {
@@ -68,7 +70,7 @@ public class CheckTypeRegistryState extends HighPriorityDistributionMessage
   protected void process(DistributionManager dm) {
     ReplyException e = null;
     try {
-      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      InternalCache cache = GemFireCacheImpl.getInstance();
       if (cache != null && !cache.isClosed()) {
         TypeRegistry pdxRegistry = cache.getPdxRegistry();
         if (pdxRegistry != null) {

http://git-wip-us.apache.org/repos/asf/geode/blob/bccdb56e/geode-core/src/main/java/org/apache/geode/pdx/internal/PdxInstanceImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/pdx/internal/PdxInstanceImpl.java b/geode-core/src/main/java/org/apache/geode/pdx/internal/PdxInstanceImpl.java
index f8acaad..d429601 100644
--- a/geode-core/src/main/java/org/apache/geode/pdx/internal/PdxInstanceImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/pdx/internal/PdxInstanceImpl.java
@@ -14,8 +14,6 @@
  */
 package org.apache.geode.pdx.internal;
 
-import static org.apache.logging.log4j.message.MapMessage.MapFormat.JSON;
-
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -30,8 +28,8 @@ import java.util.TreeSet;
 
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
-
 import org.apache.commons.lang.StringUtils;
+
 import org.apache.geode.InternalGemFireException;
 import org.apache.geode.distributed.internal.DMStats;
 import org.apache.geode.internal.ClassPathLoader;
@@ -39,6 +37,7 @@ import org.apache.geode.internal.DSCODE;
 import org.apache.geode.internal.InternalDataSerializer;
 import org.apache.geode.internal.Sendable;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.tcp.ByteBufferInputStream;
 import org.apache.geode.internal.tcp.ByteBufferInputStream.ByteSource;
 import org.apache.geode.internal.tcp.ByteBufferInputStream.ByteSourceFactory;
@@ -52,11 +51,9 @@ import org.apache.geode.pdx.WritablePdxInstance;
  * it must call {@link #getUnmodifiableReader()} and access the super class state using it. This
  * class could be changed to not extend PdxReaderImpl but to instead have an instance variable that
  * is a PdxReaderImpl but that would cause this class to use more memory.
- * 
+ * <p>
  * We do not use this normal java io serialization when serializing this class in GemFire because
  * Sendable takes precedence over Serializable.
- * 
- *
  */
 public class PdxInstanceImpl extends PdxReaderImpl
     implements PdxInstance, Sendable, ConvertableToBytes {
@@ -87,6 +84,7 @@ public class PdxInstanceImpl extends PdxReaderImpl
    * equality rule, where hash code can be same for non-equal objects.
    */
   private static final int UNUSED_HASH_CODE = 0;
+
   private transient volatile int cachedHashCode = UNUSED_HASH_CODE;
 
   private static final ThreadLocal<Boolean> pdxGetObjectInProgress = new ThreadLocal<Boolean>();
@@ -144,9 +142,9 @@ public class PdxInstanceImpl extends PdxReaderImpl
   private PdxWriterImpl convertToTypeWithNoDeletedFields(PdxReaderImpl ur) {
     PdxOutputStream os = new PdxOutputStream();
     PdxType pt = new PdxType(ur.getPdxType().getClassName(), !ur.getPdxType().getNoDomainClass());
-    GemFireCacheImpl gfc = GemFireCacheImpl
+    InternalCache cache = GemFireCacheImpl
         .getForPdx("PDX registry is unavailable because the Cache has been closed.");
-    TypeRegistry tr = gfc.getPdxRegistry();
+    TypeRegistry tr = cache.getPdxRegistry();
     PdxWriterImpl writer = new PdxWriterImpl(pt, tr, os);
     for (PdxField field : pt.getFields()) {
       if (!field.isDeleted()) {
@@ -328,15 +326,9 @@ public class PdxInstanceImpl extends PdxReaderImpl
       return true;
 
     if (obj == null) {
-      // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#0 o1=<" + this + "> o2=<" +
-      // obj + ">");
       return false;
     }
     if (!(obj instanceof PdxInstanceImpl)) {
-      // if (!result) {
-      // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#1 o1=<" + this + "> o2=<" +
-      // obj + ">");
-      // }
       return false;
     }
     final PdxInstanceImpl other = (PdxInstanceImpl) obj;
@@ -344,8 +336,6 @@ public class PdxInstanceImpl extends PdxReaderImpl
     PdxReaderImpl ur1 = getUnmodifiableReader();
 
     if (!ur1.getPdxType().getClassName().equals(ur2.getPdxType().getClassName())) {
-      // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#2 o1=<" + this + "> o2=<" +
-      // obj + ">");
       return false;
     }
 
@@ -359,7 +349,6 @@ public class PdxInstanceImpl extends PdxReaderImpl
       addDefaultFields(otherFields, myFields);
     }
 
-
     Iterator<PdxField> myFieldIterator = myFields.iterator();
     Iterator<PdxField> otherFieldIterator = otherFields.iterator();
     while (myFieldIterator.hasNext()) {
@@ -390,8 +379,6 @@ public class PdxInstanceImpl extends PdxReaderImpl
           ByteSource myBuffer = ur1.getRaw(myType);
           ByteSource otherBuffer = ur2.getRaw(otherType);
           if (!myBuffer.equals(otherBuffer)) {
-            // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#4 o1=<" + this + ">
-            // o2=<" + obj + ">");
             return false;
           }
         }
@@ -401,8 +388,6 @@ public class PdxInstanceImpl extends PdxReaderImpl
           Object[] myArray = ur1.readObjectArray(myType);
           Object[] otherArray = ur2.readObjectArray(otherType);
           if (!Arrays.deepEquals(myArray, otherArray)) {
-            // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#5 o1=<" + this + ">
-            // o2=<" + obj + ">");
             return false;
           }
         }
@@ -413,43 +398,29 @@ public class PdxInstanceImpl extends PdxReaderImpl
           Object otherObject = ur2.readObject(otherType);
           if (myObject != otherObject) {
             if (myObject == null) {
-              // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#6 o1=<" + this + ">
-              // o2=<" + obj + ">");
               return false;
             }
             if (otherObject == null) {
-              // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#7 o1=<" + this + ">
-              // o2=<" + obj + ">");
               return false;
             }
             if (myObject.getClass().isArray()) { // for bug 42976
               Class<?> myComponentType = myObject.getClass().getComponentType();
               Class<?> otherComponentType = otherObject.getClass().getComponentType();
               if (!myComponentType.equals(otherComponentType)) {
-                // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#8 o1=<" + this + ">
-                // o2=<" + obj + ">");
                 return false;
               }
               if (myComponentType.isPrimitive()) {
                 ByteSource myBuffer = getRaw(myType);
                 ByteSource otherBuffer = other.getRaw(otherType);
                 if (!myBuffer.equals(otherBuffer)) {
-                  // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#9 o1=<" + this +
-                  // "> o2=<" + obj + ">");
                   return false;
                 }
               } else {
                 if (!Arrays.deepEquals((Object[]) myObject, (Object[]) otherObject)) {
-                  // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#10 o1=<" + this +
-                  // "> o2=<" + obj + ">");
                   return false;
                 }
               }
             } else if (!myObject.equals(otherObject)) {
-              // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#11 fn=" +
-              // myType.getFieldName() + " myFieldClass=" + myObject.getClass() + "
-              // otherFieldCLass=" + otherObject.getClass() + " o1=<" + this + "> o2=<" + obj + ">"
-              // + "myObj=<" + myObject + "> otherObj=<" + otherObject + ">");
               return false;
             }
           }
@@ -463,7 +434,6 @@ public class PdxInstanceImpl extends PdxReaderImpl
     return true;
   }
 
-
   /**
    * Any fields that are in otherFields but not in myFields are added to myFields as defaults. When
    * adding fields they are inserted in the natural sort order. Note: myFields may be modified by
@@ -483,9 +453,7 @@ public class PdxInstanceImpl extends PdxReaderImpl
     StringBuilder result = new StringBuilder();
     PdxReaderImpl ur = getUnmodifiableReader();
     result.append("PDX[").append(ur.getPdxType().getTypeId()).append(",")
-        .append(ur.getPdxType().getClassName())
-        // .append(",limit=").append(this.dis.size())
-        .append("]{");
+        .append(ur.getPdxType().getClassName()).append("]{");
     boolean firstElement = true;
     for (PdxField fieldType : ur.getPdxType().getSortedIdentityFields()) {
       if (firstElement) {
@@ -494,8 +462,6 @@ public class PdxInstanceImpl extends PdxReaderImpl
         result.append(", ");
       } ;
       result.append(fieldType.getFieldName());
-      // result.append(':').append(fieldType.getTypeIdString()); // DEBUG
-      // result.append(':').append(getAbsolutePosition(fieldType)); // DEBUG
       result.append("=");
       try {
         // TODO check to see if getField returned an array and if it did use Arrays.deepToString
@@ -663,7 +629,6 @@ public class PdxInstanceImpl extends PdxReaderImpl
     return getUnmodifiableReader(fieldName).readRawField(fieldName);
   }
 
-
   public Object getDefaultValueIfFieldExistsInAnyPdxVersions(String fieldName, String className)
       throws FieldNotFoundInPdxVersion {
     PdxType pdxType =


Mime
View raw message