geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [27/27] geode git commit: Convert to use FunctionContext.getCache()
Date Fri, 04 Aug 2017 23:25:55 GMT
Convert to use FunctionContext.getCache()


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

Branch: refs/heads/feature/GEODE-3299
Commit: 634cbb34e5fbacb0fca4de116df10a640603e27e
Parents: 3fd6330
Author: Kirk Lund <klund@apache.org>
Authored: Mon Jul 24 12:44:37 2017 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Fri Aug 4 15:33:55 2017 -0700

----------------------------------------------------------------------
 .../geode/cache/execute/FunctionContext.java    |  17 +-
 .../CreateAlterDestroyRegionCommands.java       |  20 +-
 .../commands/CreateGatewayReceiverCommand.java  |   4 +-
 .../commands/CreateGatewaySenderCommand.java    |   2 +-
 .../commands/DestroyGatewaySenderCommand.java   |   2 +-
 .../cli/commands/ExportLogsInterceptor.java     |   8 +-
 .../cli/commands/MiscellaneousCommands.java     |   2 +-
 .../functions/AlterRuntimeConfigFunction.java   |  32 +-
 .../functions/AsyncEventQueueFunctionArgs.java  |  48 +--
 .../cli/functions/ChangeLogLevelFunction.java   |  42 +-
 .../cli/functions/CliFunctionResult.java        |  41 +-
 .../functions/CloseDurableClientFunction.java   |  22 +-
 .../cli/functions/CloseDurableCqFunction.java   |  24 +-
 .../cli/functions/ContinuousQueryFunction.java  |  43 ++-
 .../CreateAsyncEventQueueFunction.java          |  27 +-
 .../functions/CreateDefinedIndexesFunction.java |  35 +-
 .../cli/functions/CreateDiskStoreFunction.java  |  38 +-
 .../cli/functions/CreateIndexFunction.java      |  35 +-
 .../internal/cli/functions/DeployFunction.java  |  27 +-
 .../functions/DescribeDiskStoreFunction.java    | 150 +++-----
 .../cli/functions/DestroyDiskStoreFunction.java |  24 +-
 .../cli/functions/DestroyIndexFunction.java     |  26 +-
 .../cli/functions/ExportConfigFunction.java     |  22 +-
 .../cli/functions/ExportDataFunction.java       |  29 +-
 .../cli/functions/ExportLogsFunction.java       |  72 ++--
 .../FetchRegionAttributesFunction.java          |  60 +--
 .../FetchSharedConfigurationStatusFunction.java |  19 +-
 .../functions/GarbageCollectionFunction.java    |  19 +-
 .../GatewayReceiverCreateFunction.java          |  55 ++-
 .../functions/GatewayReceiverFunctionArgs.java  |  13 +-
 .../functions/GatewaySenderCreateFunction.java  |  49 +--
 .../functions/GatewaySenderDestroyFunction.java |  25 +-
 .../GatewaySenderDestroyFunctionArgs.java       |   6 +-
 .../functions/GatewaySenderFunctionArgs.java    |  18 +-
 .../GetMemberConfigInformationFunction.java     |  99 ++---
 .../functions/GetMemberInformationFunction.java | 100 ++---
 .../functions/GetRegionDescriptionFunction.java |  21 +-
 .../cli/functions/GetRegionsFunction.java       |  11 +-
 .../cli/functions/GetStackTracesFunction.java   |  17 +-
 .../GetSubscriptionQueueSizeFunction.java       |  21 +-
 .../cli/functions/ImportDataFunction.java       |  30 +-
 .../functions/ListAsyncEventQueuesFunction.java |  24 +-
 .../cli/functions/ListDeployedFunction.java     |  33 +-
 .../cli/functions/ListDiskStoresFunction.java   |  40 +-
 .../functions/ListDurableCqNamesFunction.java   |  26 +-
 .../cli/functions/ListFunctionFunction.java     |  25 +-
 .../cli/functions/ListIndexFunction.java        |  25 +-
 .../cli/functions/MemberRegionFunction.java     |  83 ----
 .../cli/functions/MembersForRegionFunction.java |  31 +-
 .../internal/cli/functions/NetstatFunction.java | 115 +++---
 .../cli/functions/RebalanceFunction.java        |  55 ++-
 .../cli/functions/RegionAlterFunction.java      |  80 ++--
 .../cli/functions/RegionCreateFunction.java     | 129 ++++---
 .../cli/functions/RegionDestroyFunction.java    |  26 +-
 .../cli/functions/RegionFunctionArgs.java       | 385 ++++++++-----------
 .../ShowMissingDiskStoresFunction.java          |  24 +-
 .../cli/functions/ShutDownFunction.java         |  51 +--
 .../cli/functions/SizeExportLogsFunction.java   |  21 +-
 .../cli/functions/UndeployFunction.java         |  39 +-
 .../cli/functions/UnregisterFunction.java       |  23 +-
 .../cli/functions/UserFunctionExecution.java    |  17 +-
 .../internal/cli/util/TimeParser.java           |  47 +++
 .../DescribeDiskStoreFunctionJUnitTest.java     | 141 +++----
 .../ListDiskStoresFunctionJUnitTest.java        |  52 +--
 .../functions/ListIndexFunctionJUnitTest.java   |  31 +-
 .../codeAnalysis/sanctionedSerializables.txt    |  11 +-
 66 files changed, 1178 insertions(+), 1711 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/cache/execute/FunctionContext.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/execute/FunctionContext.java b/geode-core/src/main/java/org/apache/geode/cache/execute/FunctionContext.java
index 0b4e7f9..00c877b 100755
--- a/geode-core/src/main/java/org/apache/geode/cache/execute/FunctionContext.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/execute/FunctionContext.java
@@ -19,20 +19,21 @@ import org.apache.geode.cache.Cache;
 /**
  * Defines the execution context of a {@link Function}. It is required by the
  * {@link Function#execute(FunctionContext)} to execute a {@link Function} on a particular member.
+ *
  * <p>
  * A context can be data dependent or data independent. For data dependent functions refer to
  * {@link RegionFunctionContext}
- * </p>
+ *
  * <p>
  * This interface is implemented by GemFire. Instances of it will be passed in to
  * {@link Function#execute(FunctionContext)}.
- * 
- * @param T1 object type of Arguments
+ *
+ * <p>
+ * T1 object type of Arguments
  *
  * @since GemFire 6.0
  *
  * @see RegionFunctionContext
- *
  */
 public interface FunctionContext<T1> {
   /**
@@ -64,7 +65,6 @@ public interface FunctionContext<T1> {
    * @return ResultSender
    * @since GemFire 6.0
    */
-
   public <T2> ResultSender<T2> getResultSender();
 
   /**
@@ -78,5 +78,12 @@ public interface FunctionContext<T1> {
    */
   public boolean isPossibleDuplicate();
 
+  /**
+   * Returns a reference to the Cache.
+   *
+   * @return a reference to the Cache
+   *
+   * @since Geode 1.2
+   */
   public Cache getCache();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/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 2c61b73..4d6e0c7 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
@@ -259,6 +259,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
         String cacheWriterClass =
             cacheWriter != null ? cacheWriter : regionAttributesResult.getCacheWriterClass();
 
+        // use constructor with RegionAttributes (NOTE: evictionMax and compressor are null)
         regionFunctionArgs = new RegionFunctionArgs(regionPath, useAttributesFrom, skipIfExists,
             keyConstraint, valueConstraint, statisticsEnabled, entryIdle, entryTTL, regionIdle,
             regionTTL, diskStore, diskSynchronous, enableAsyncConflation,
@@ -266,7 +267,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
             asyncEventQueueIds, gatewaySenderIds, concurrencyChecksEnabled, cloningEnabled,
             concurrencyLevel, prColocatedWith, prLocalMaxMemory, prRecoveryDelay, prRedundantCopies,
             prStartupRecoveryDelay, prTotalMaxMemory, prTotalNumBuckets, offHeap, mcastEnabled,
-            regionAttributes, partitionResolver);
+            partitionResolver, regionAttributes);
 
         if (regionAttributes.getPartitionAttributes() == null
             && regionFunctionArgs.hasPartitionAttributes()) {
@@ -277,6 +278,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
                   useAttributesFrom));
         }
       } else {
+        // use constructor with RegionShortcut (NOTE: evictionMax is null)
         regionFunctionArgs = new RegionFunctionArgs(regionPath, regionShortcut, useAttributesFrom,
             skipIfExists, keyConstraint, valueConstraint, statisticsEnabled, entryIdle, entryTTL,
             regionIdle, regionTTL, diskStore, diskSynchronous, enableAsyncConflation,
@@ -318,7 +320,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
         return ResultBuilder.createUserErrorResult(CliStrings.NO_CACHING_MEMBERS_FOUND_MESSAGE);
       }
 
-      ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(RegionCreateFunction.INSTANCE,
+      ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(new RegionCreateFunction(),
           regionFunctionArgs, membersToCreateRegionOn);
       @SuppressWarnings("unchecked")
       List<CliFunctionResult> regionCreateResults =
@@ -559,7 +561,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
     return result;
   }
 
-  private static boolean regionExists(InternalCache cache, String regionPath) {
+  private boolean regionExists(InternalCache cache, String regionPath) {
     boolean regionFound = false;
     if (regionPath != null && !Region.SEPARATOR.equals(regionPath)) {
       ManagementService managementService = ManagementService.getExistingManagementService(cache);
@@ -866,8 +868,8 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
     return false;
   }
 
-  private static <K, V> FetchRegionAttributesFunctionResult<K, V> getRegionAttributes(
-      InternalCache cache, String regionPath) {
+  private <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,
@@ -878,7 +880,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
     // First check whether the region exists on a this manager, if yes then no
     // need to use FetchRegionAttributesFunction to fetch RegionAttributes
     try {
-      attributes = FetchRegionAttributesFunction.getRegionAttributes(regionPath);
+      attributes = FetchRegionAttributesFunction.getRegionAttributes(cache, regionPath);
     } catch (IllegalArgumentException e) {
       /* region doesn't exist on the manager */
     }
@@ -890,7 +892,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
       if (regionAssociatedMembers != null && !regionAssociatedMembers.isEmpty()) {
         DistributedMember distributedMember = regionAssociatedMembers.iterator().next();
         ResultCollector<?, ?> resultCollector = CliUtil
-            .executeFunction(FetchRegionAttributesFunction.INSTANCE, regionPath, distributedMember);
+            .executeFunction(new FetchRegionAttributesFunction(), regionPath, distributedMember);
         List<?> resultsList = (List<?>) resultCollector.getResult();
 
         if (resultsList != null && !resultsList.isEmpty()) {
@@ -920,7 +922,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
     return attributes;
   }
 
-  private static boolean isClusterWideSameConfig(InternalCache cache, String regionPath) {
+  private boolean isClusterWideSameConfig(InternalCache cache, String regionPath) {
     ManagementService managementService = ManagementService.getExistingManagementService(cache);
 
     DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
@@ -1002,7 +1004,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
       CliFunctionResult destroyRegionResult;
 
       ResultCollector<?, ?> resultCollector =
-          CliUtil.executeFunction(RegionDestroyFunction.INSTANCE, regionPath, regionMembersList);
+          CliUtil.executeFunction(new RegionDestroyFunction(), regionPath, regionMembersList);
       List<CliFunctionResult> resultsList = (List<CliFunctionResult>) resultCollector.getResult();
       String message =
           CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED, regionPath, "");

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
index a07aee1..c9a9a95 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
@@ -91,8 +91,8 @@ public class CreateGatewayReceiverCommand implements GfshCommand {
       }
 
       ResultCollector<?, ?> resultCollector =
-          CliUtil.executeFunction(GatewayReceiverCreateFunction.INSTANCE,
-              gatewayReceiverFunctionArgs, membersToCreateGatewayReceiverOn);
+          CliUtil.executeFunction(new GatewayReceiverCreateFunction(), gatewayReceiverFunctionArgs,
+              membersToCreateGatewayReceiverOn);
       @SuppressWarnings("unchecked")
       List<CliFunctionResult> gatewayReceiverCreateResults =
           (List<CliFunctionResult>) resultCollector.getResult();

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewaySenderCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewaySenderCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewaySenderCommand.java
index 5b4073d..6fbca66 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewaySenderCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewaySenderCommand.java
@@ -126,7 +126,7 @@ public class CreateGatewaySenderCommand implements GfshCommand {
       }
 
       ResultCollector<?, ?> resultCollector =
-          CliUtil.executeFunction(GatewaySenderCreateFunction.INSTANCE, gatewaySenderFunctionArgs,
+          CliUtil.executeFunction(new GatewaySenderCreateFunction(), gatewaySenderFunctionArgs,
               membersToCreateGatewaySenderOn);
       @SuppressWarnings("unchecked")
       List<CliFunctionResult> gatewaySenderCreateResults =

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyGatewaySenderCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyGatewaySenderCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyGatewaySenderCommand.java
index 97b4a95..44e5c5d 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyGatewaySenderCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyGatewaySenderCommand.java
@@ -66,7 +66,7 @@ public class DestroyGatewaySenderCommand implements GfshCommand {
       }
 
       ResultCollector<?, ?> resultCollector =
-          CliUtil.executeFunction(GatewaySenderDestroyFunction.INSTANCE,
+          CliUtil.executeFunction(new GatewaySenderDestroyFunction(),
               gatewaySenderDestroyFunctionArgs, membersToDestroyGatewaySenderOn);
       @SuppressWarnings("unchecked")
       List<CliFunctionResult> gatewaySenderDestroyResults =

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptor.java
index 5f21848..c5ac227 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptor.java
@@ -21,9 +21,9 @@ import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.AbstractCliAroundInterceptor;
 import org.apache.geode.management.internal.cli.GfshParseResult;
-import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
-import org.apache.logging.log4j.Level;
+import org.apache.geode.management.internal.cli.util.TimeParser;
+
 import org.apache.logging.log4j.Logger;
 
 import java.io.File;
@@ -61,8 +61,8 @@ public class ExportLogsInterceptor extends AbstractCliAroundInterceptor {
     String end = arguments.get("end-time");
     if (start != null && end != null) {
       // need to make sure end is later than start
-      LocalDateTime startTime = ExportLogsFunction.parseTime(start);
-      LocalDateTime endTime = ExportLogsFunction.parseTime(end);
+      LocalDateTime startTime = TimeParser.parseTime(start);
+      LocalDateTime endTime = TimeParser.parseTime(end);
       if (startTime.isAfter(endTime)) {
         return ResultBuilder.createUserErrorResult("start-time has to be earlier than end-time.");
       }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/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 1415bc6..f7e65b4 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
@@ -456,7 +456,7 @@ public class MiscellaneousCommands implements GfshCommand {
       if (!hostMemberMap.isEmpty()) {
         Set<DistributedMember> membersToExecuteOn = new HashSet<>(hostMemberMap.values());
         ResultCollector<?, ?> netstatResult =
-            CliUtil.executeFunction(NetstatFunction.INSTANCE, nfa, membersToExecuteOn);
+            CliUtil.executeFunction(new NetstatFunction(), nfa, membersToExecuteOn);
         List<?> resultList = (List<?>) netstatResult.getResult();
         for (Object aResultList : resultList) {
           NetstatFunctionResult netstatFunctionResult = (NetstatFunctionResult) aResultList;

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/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 53d3ab7..2505516 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,9 +14,14 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.cache.CacheClosedException;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.execute.FunctionAdapter;
+import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.ConfigSource;
@@ -25,29 +30,18 @@ import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.logging.log4j.Logger;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-public class AlterRuntimeConfigFunction extends FunctionAdapter implements InternalEntity {
 
+public class AlterRuntimeConfigFunction implements Function, InternalEntity {
   private static final long serialVersionUID = 1L;
-
   private static Logger logger = LogService.getLogger();
 
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   @Override
-  public void execute(FunctionContext context) {
+  public void execute(final FunctionContext context) {
     String memberId = "";
 
     try {
       Object arg = context.getArguments();
-      InternalCache cache = getCache();
+      InternalCache cache = (InternalCache) context.getCache();
       DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
       memberId = cache.getDistributedSystem().getDistributedMember().getId();
 
@@ -82,15 +76,11 @@ public class AlterRuntimeConfigFunction extends FunctionAdapter implements Inter
       context.getResultSender().lastResult(result);
 
     } catch (Exception e) {
-      logger.error("Exception happened on : " + memberId, e);
+      logger.error("Exception happened on : {}", memberId, e);
       CliFunctionResult cliFuncResult =
           new CliFunctionResult(memberId, e, CliUtil.stackTraceAsString(e));
       context.getResultSender().lastResult(cliFuncResult);
     }
   }
 
-  @Override
-  public String getId() {
-    return AlterRuntimeConfigFunction.class.getName();
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AsyncEventQueueFunctionArgs.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AsyncEventQueueFunctionArgs.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AsyncEventQueueFunctionArgs.java
index 2e297bf..aaeb9ed 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AsyncEventQueueFunctionArgs.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/AsyncEventQueueFunctionArgs.java
@@ -21,31 +21,32 @@ import java.util.Properties;
  * This class stores the arguments provided for create async event queue command.
  */
 public class AsyncEventQueueFunctionArgs implements Serializable {
-
   private static final long serialVersionUID = -6524494645663740872L;
 
-  private String asyncEventQueueId;
-  private boolean isParallel;
-  private boolean enableBatchConflation;
-  private int batchSize;
-  private int batchTimeInterval;
-  private boolean persistent;
-  private String diskStoreName;
-  private boolean diskSynchronous;
-  private int maxQueueMemory;
-  private int dispatcherThreads;
-  private String orderPolicy;
-  private String[] gatewayEventFilters;
-  private String gatewaySubstitutionFilter;
-  private String listenerClassName;
-  private Properties listenerProperties;
-  private boolean forwardExpirationDestroy;
-
-  public AsyncEventQueueFunctionArgs(String asyncEventQueueId, boolean isParallel,
-      boolean enableBatchConflation, int batchSize, int batchTimeInterval, boolean persistent,
-      String diskStoreName, boolean diskSynchronous, int maxQueueMemory, int dispatcherThreads,
-      String orderPolicy, String[] gatewayEventFilters, String gatewaySubstitutionFilter,
-      String listenerClassName, Properties listenerProperties, boolean forwardExpirationDestroy) {
+  private final String asyncEventQueueId;
+  private final boolean isParallel;
+  private final boolean enableBatchConflation;
+  private final int batchSize;
+  private final int batchTimeInterval;
+  private final boolean persistent;
+  private final String diskStoreName;
+  private final boolean diskSynchronous;
+  private final int maxQueueMemory;
+  private final int dispatcherThreads;
+  private final String orderPolicy;
+  private final String[] gatewayEventFilters;
+  private final String gatewaySubstitutionFilter;
+  private final String listenerClassName;
+  private final Properties listenerProperties;
+  private final boolean forwardExpirationDestroy;
+
+  public AsyncEventQueueFunctionArgs(final String asyncEventQueueId, final boolean isParallel,
+      final boolean enableBatchConflation, final int batchSize, final int batchTimeInterval,
+      final boolean persistent, final String diskStoreName, final boolean diskSynchronous,
+      final int maxQueueMemory, final int dispatcherThreads, final String orderPolicy,
+      final String[] gatewayEventFilters, final String gatewaySubstitutionFilter,
+      final String listenerClassName, final Properties listenerProperties,
+      final boolean forwardExpirationDestroy) {
     this.asyncEventQueueId = asyncEventQueueId;
     this.isParallel = isParallel;
     this.enableBatchConflation = enableBatchConflation;
@@ -127,4 +128,5 @@ public class AsyncEventQueueFunctionArgs implements Serializable {
   public boolean isForwardExpirationDestroy() {
     return forwardExpirationDestroy;
   }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java
index 91aabe4..fe9a515 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java
@@ -14,47 +14,42 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.cache.Cache;
-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.internal.DistributionConfig;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.internal.logging.log4j.LogMarker;
 import org.apache.geode.internal.logging.log4j.LogWriterLogger;
-import org.apache.geode.internal.logging.log4j.LogLevel;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-
-import java.util.HashMap;
-import java.util.Map;
-
 
 /**
- * 
  * Class for change log level function
  * 
- * since 8.0
- * 
+ * @since GemFire 8.0
  */
-
 public class ChangeLogLevelFunction implements Function, InternalEntity {
-  private static final Logger logger = LogService.getLogger();
-
-  public static final String ID = ChangeLogLevelFunction.class.getName();
   private static final long serialVersionUID = 1L;
+  private static final Logger logger = LogService.getLogger();
 
   @Override
-  public void execute(FunctionContext context) {
-    Cache cache = CacheFactory.getAnyInstance();
-    Map<String, String> result = new HashMap<String, String>();
+  public void execute(final FunctionContext context) {
+    Cache cache = context.getCache();
+    Map<String, String> result = new HashMap<>();
+
     try {
       LogWriterLogger logwriterLogger = (LogWriterLogger) cache.getLogger();
       Object[] args = (Object[]) context.getArguments();
-      final String logLevel = (String) args[0];
+      String logLevel = (String) args[0];
       Level log4jLevel = LogLevel.getLevel(logLevel);
       logwriterLogger.setLevel(log4jLevel);
       System.setProperty(DistributionConfig.GEMFIRE_PREFIX + LOG_LEVEL, logLevel);
@@ -63,6 +58,7 @@ public class ChangeLogLevelFunction implements Function, InternalEntity {
       result.put(cache.getDistributedSystem().getDistributedMember().getId(),
           "New log level is " + log4jLevel);
       context.getResultSender().lastResult(result);
+
     } catch (Exception ex) {
       // LOG:CONFIG:
       logger.info(LogMarker.CONFIG, "GFSH Changing log level exception {}", ex.getMessage(), ex);
@@ -73,12 +69,6 @@ public class ChangeLogLevelFunction implements Function, InternalEntity {
   }
 
   @Override
-  public String getId() {
-    return ChangeLogLevelFunction.ID;
-
-  }
-
-  @Override
   public boolean hasResult() {
     return true;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CliFunctionResult.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CliFunctionResult.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CliFunctionResult.java
index 401c1a8..914f092 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CliFunctionResult.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CliFunctionResult.java
@@ -14,11 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
-import org.apache.geode.DataSerializer;
-import org.apache.geode.internal.DataSerializableFixedID;
-import org.apache.geode.internal.Version;
-import org.apache.geode.management.internal.configuration.domain.XmlEntity;
-
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -28,7 +23,14 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.geode.DataSerializer;
+import org.apache.geode.internal.DataSerializableFixedID;
+import org.apache.geode.internal.Version;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+
+// TODO: make CliFunctionResult immutable
 public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSerializableFixedID {
+
   private String memberIdOrName;
   private Serializable[] serializables = new String[0];
   private Throwable throwable;
@@ -36,7 +38,9 @@ public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSer
   private XmlEntity xmlEntity;
   private byte[] byteData = new byte[0];
 
-  public CliFunctionResult() {}
+  public CliFunctionResult() {
+    // nothing
+  }
 
   public CliFunctionResult(final String memberIdOrName) {
     this.memberIdOrName = memberIdOrName;
@@ -65,7 +69,6 @@ public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSer
     this.successful = true;
   }
 
-
   public CliFunctionResult(final String memberIdOrName, final XmlEntity xmlEntity,
       final Serializable[] serializables) {
     this.memberIdOrName = memberIdOrName;
@@ -131,7 +134,7 @@ public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSer
   }
 
   @Override
-  public void toData(DataOutput out) throws IOException {
+  public void toData(final DataOutput out) throws IOException {
     DataSerializer.writeString(this.memberIdOrName, out);
     DataSerializer.writePrimitiveBoolean(this.successful, out);
     DataSerializer.writeObject(this.xmlEntity, out);
@@ -140,14 +143,14 @@ public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSer
     DataSerializer.writeByteArray(this.byteData, out);
   }
 
-  public void toDataPre_GFE_8_0_0_0(DataOutput out) throws IOException {
+  public void toDataPre_GFE_8_0_0_0(final DataOutput out) throws IOException {
     DataSerializer.writeString(this.memberIdOrName, out);
     DataSerializer.writeObjectArray(this.serializables, out);
     DataSerializer.writeObject(this.throwable, out);
   }
 
   @Override
-  public void fromData(DataInput in) throws IOException, ClassNotFoundException {
+  public void fromData(final DataInput in) throws IOException, ClassNotFoundException {
     this.memberIdOrName = DataSerializer.readString(in);
     this.successful = DataSerializer.readPrimitiveBoolean(in);
     this.xmlEntity = DataSerializer.readObject(in);
@@ -156,7 +159,8 @@ public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSer
     this.byteData = DataSerializer.readByteArray(in);
   }
 
-  public void fromDataPre_GFE_8_0_0_0(DataInput in) throws IOException, ClassNotFoundException {
+  public void fromDataPre_GFE_8_0_0_0(final DataInput in)
+      throws IOException, ClassNotFoundException {
     this.memberIdOrName = DataSerializer.readString(in);
     this.throwable = DataSerializer.readObject(in);
     this.serializables = (Serializable[]) DataSerializer.readObjectArray(in);
@@ -170,12 +174,8 @@ public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSer
     return this.xmlEntity;
   }
 
-  public byte[] getByteData() {
-    return this.byteData;
-  }
-
   @Override
-  public int compareTo(CliFunctionResult o) {
+  public int compareTo(final CliFunctionResult o) {
     if (this.memberIdOrName == null && o.memberIdOrName == null) {
       return 0;
     }
@@ -190,14 +190,14 @@ public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSer
 
   @Override
   public int hashCode() {
-    final int prime = 31;
+    int prime = 31;
     int result = 1;
     result = prime * result + ((this.memberIdOrName == null) ? 0 : this.memberIdOrName.hashCode());
     return result;
   }
 
   @Override
-  public boolean equals(Object obj) {
+  public boolean equals(final Object obj) {
     if (this == obj)
       return true;
     if (obj == null)
@@ -227,8 +227,8 @@ public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSer
    * @param results The results to clean.
    * @return The cleaned results.
    */
-  public static List<CliFunctionResult> cleanResults(List<?> results) {
-    List<CliFunctionResult> returnResults = new ArrayList<CliFunctionResult>(results.size());
+  public static List<CliFunctionResult> cleanResults(final List<?> results) {
+    List<CliFunctionResult> returnResults = new ArrayList<>(results.size());
     for (Object result : results) {
       if (result instanceof CliFunctionResult) {
         returnResults.add((CliFunctionResult) result);
@@ -243,4 +243,5 @@ public class CliFunctionResult implements Comparable<CliFunctionResult>, DataSer
   public Version[] getSerializationVersions() {
     return new Version[] {Version.GFE_80};
   }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableClientFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableClientFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableClientFunction.java
index 73761c4..3decf83 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableClientFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableClientFunction.java
@@ -15,9 +15,8 @@
 package org.apache.geode.management.internal.cli.functions;
 
 import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.execute.FunctionAdapter;
+import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier;
 import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy;
@@ -25,19 +24,17 @@ import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.domain.MemberResult;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 
-/***
+/**
  * Function to close a durable client
- *
  */
-public class CloseDurableClientFunction extends FunctionAdapter implements InternalEntity {
-
+public class CloseDurableClientFunction implements Function, InternalEntity {
   private static final long serialVersionUID = 1L;
 
   @Override
-  public void execute(FunctionContext context) {
+  public void execute(final FunctionContext context) {
     String durableClientId = (String) context.getArguments();
-    final Cache cache = CliUtil.getCacheIfExists();
-    final String memberNameOrId =
+    Cache cache = context.getCache();
+    String memberNameOrId =
         CliUtil.getMemberNameOrId(cache.getDistributedSystem().getDistributedMember());
     MemberResult memberResult = new MemberResult(memberNameOrId);
 
@@ -62,16 +59,13 @@ public class CloseDurableClientFunction extends FunctionAdapter implements Inter
       } else {
         memberResult.setErrorMessage(CliStrings.NO_CLIENT_FOUND);
       }
+
     } catch (Exception e) {
       memberResult.setExceptionMessage(e.getMessage());
+
     } finally {
       context.getResultSender().lastResult(memberResult);
     }
   }
 
-  @Override
-  public String getId() {
-    return CloseDurableClientFunction.class.getName();
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableCqFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableCqFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableCqFunction.java
index e526409..c9d7728 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableCqFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CloseDurableCqFunction.java
@@ -15,29 +15,25 @@
 package org.apache.geode.management.internal.cli.functions;
 
 import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.execute.FunctionAdapter;
+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.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.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.domain.MemberResult;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 
-/***
+/**
  * Function to close a durable cq
- *
  */
-public class CloseDurableCqFunction extends FunctionAdapter implements InternalEntity {
-
+public class CloseDurableCqFunction implements Function, InternalEntity {
   private static final long serialVersionUID = 1L;
 
   @Override
-  public void execute(FunctionContext context) {
-
-    final Cache cache = CliUtil.getCacheIfExists();
-    final String memberNameOrId =
+  public void execute(final FunctionContext context) {
+    Cache cache = context.getCache();
+    String memberNameOrId =
         CliUtil.getMemberNameOrId(cache.getDistributedSystem().getDistributedMember());
     CacheClientNotifier cacheClientNotifier = CacheClientNotifier.getInstance();
     String[] args = (String[]) context.getArguments();
@@ -45,6 +41,7 @@ public class CloseDurableCqFunction extends FunctionAdapter implements InternalE
     String cqName = args[1];
 
     MemberResult memberResult = new MemberResult(memberNameOrId);
+
     try {
       if (cacheClientNotifier != null) {
         CacheClientProxy cacheClientProxy = cacheClientNotifier.getClientProxy(durableClientId);
@@ -64,16 +61,13 @@ public class CloseDurableCqFunction extends FunctionAdapter implements InternalE
       } else {
         memberResult.setErrorMessage(CliStrings.NO_CLIENT_FOUND);
       }
+
     } catch (Exception e) {
       memberResult.setExceptionMessage(e.getMessage());
+
     } finally {
       context.getResultSender().lastResult(memberResult);
     }
   }
 
-  @Override
-  public String getId() {
-    return CloseDurableCqFunction.class.getName();
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction.java
index 1f06a41..15ba98b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction.java
@@ -17,12 +17,12 @@ package org.apache.geode.management.internal.cli.functions;
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.Iterator;
-import org.apache.geode.cache.CacheFactory;
+
+import org.apache.geode.cache.Cache;
 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.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;
@@ -35,31 +35,29 @@ import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 public class ContinuousQueryFunction implements Function, InternalEntity {
   private static final long serialVersionUID = 1L;
 
-  public static final String ID = ContinuousQueryFunction.class.getName();
-
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   @Override
-  public void execute(FunctionContext context) {
+  public void execute(final FunctionContext context) {
     try {
       String clientID = (String) context.getArguments();
-      InternalCache cache = getCache();
+      Cache cache = context.getCache();
+
       if (cache.getCacheServers().size() > 0) {
         CacheServerImpl server = (CacheServerImpl) cache.getCacheServers().iterator().next();
+
         if (server != null) {
           AcceptorImpl acceptorImpl = server.getAcceptor();
+
           if (acceptorImpl != null) {
             CacheClientNotifier cacheClientNotifier = acceptorImpl.getCacheClientNotifier();
+
             if (cacheClientNotifier != null) {
               Collection<CacheClientProxy> cacheClientProxySet =
                   cacheClientNotifier.getClientProxies();
               ClientInfo clientInfo = null;
               boolean foundClientinCCP = false;
+
               Iterator<CacheClientProxy> it = cacheClientProxySet.iterator();
               while (it.hasNext()) {
-
                 CacheClientProxy ccp = it.next();
                 if (ccp != null) {
                   String clientIdFromProxy = ccp.getProxyID().getDSMembership();
@@ -100,16 +98,13 @@ public class ContinuousQueryFunction implements Function, InternalEntity {
           }
         }
       }
+
     } catch (Exception e) {
       context.getResultSender()
           .lastResult("Exception in ContinuousQueryFunction =" + e.getMessage());
     }
-    context.getResultSender().lastResult(null);
-  }
 
-  @Override
-  public String getId() {
-    return ContinuousQueryFunction.ID;
+    context.getResultSender().lastResult(null);
   }
 
   @Override
@@ -127,14 +122,19 @@ public class ContinuousQueryFunction implements Function, InternalEntity {
     return false;
   }
 
+  /**
+   * Info details about cache client.
+   */
   public 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;
+    public final String isDurable;
+    public final String primaryServer;
+    public final String secondaryServer;
+
+    public ClientInfo(final String isClientDurable, final String primaryServerId,
+        final String secondaryServerId) {
+      isDurable = isClientDurable;
       primaryServer = primaryServerId;
       secondaryServer = secondaryServerId;
     }
@@ -145,4 +145,5 @@ public class ContinuousQueryFunction implements Function, InternalEntity {
           + ", secondaryServer=" + secondaryServer + "]";
     }
   }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/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 5696696..9f35538 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
@@ -23,11 +23,10 @@ import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.CacheClosedException;
-import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Declarable;
 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.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.wan.GatewayEventFilter;
 import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter;
@@ -48,25 +47,19 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
  *
  * @since GemFire 8.0
  */
-public class CreateAsyncEventQueueFunction extends FunctionAdapter implements InternalEntity {
+public class CreateAsyncEventQueueFunction implements Function, 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) {
+  public void execute(final FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
     String memberId = "";
 
     try {
       AsyncEventQueueFunctionArgs aeqArgs = (AsyncEventQueueFunctionArgs) context.getArguments();
 
-      InternalCache cache = getCache();
+      InternalCache cache = (InternalCache) context.getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
@@ -147,17 +140,19 @@ public class CreateAsyncEventQueueFunction extends FunctionAdapter implements In
     }
   }
 
-  private Class<?> forName(String className, String neededFor) {
+  private Class<?> forName(final String className, final String neededFor) {
     if (Strings.isNullOrEmpty(className)) {
       return null;
     }
 
     try {
       return ClassPathLoader.getLatest().forName(className);
+
     } catch (ClassNotFoundException e) {
       throw new RuntimeException(CliStrings.format(
           CliStrings.CREATE_ASYNC_EVENT_QUEUE__MSG__COULD_NOT_FIND_CLASS_0_SPECIFIED_FOR_1,
           className, neededFor), e);
+
     } catch (ClassCastException e) {
       throw new RuntimeException(CliStrings.format(
           CliStrings.CREATE_ASYNC_EVENT_QUEUE__MSG__CLASS_0_SPECIFIED_FOR_1_IS_NOT_OF_EXPECTED_TYPE,
@@ -165,13 +160,15 @@ public class CreateAsyncEventQueueFunction extends FunctionAdapter implements In
     }
   }
 
-  private static Object newInstance(Class<?> klass, String neededFor) {
+  private static Object newInstance(final Class<?> klass, final String neededFor) {
     try {
       return klass.newInstance();
+
     } catch (InstantiationException e) {
       throw new RuntimeException(CliStrings.format(
           CliStrings.CREATE_ASYNC_EVENT_QUEUE__MSG__COULD_NOT_INSTANTIATE_CLASS_0_SPECIFIED_FOR_1,
           klass, neededFor), e);
+
     } catch (IllegalAccessException e) {
       throw new RuntimeException(CliStrings.format(
           CliStrings.CREATE_ASYNC_EVENT_QUEUE__MSG__COULD_NOT_ACCESS_CLASS_0_SPECIFIED_FOR_1, klass,
@@ -179,8 +176,4 @@ public class CreateAsyncEventQueueFunction extends FunctionAdapter implements In
     }
   }
 
-  @Override
-  public String getId() {
-    return CreateDiskStoreFunction.class.getName();
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDefinedIndexesFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDefinedIndexesFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDefinedIndexesFunction.java
index 742840c..18eb0b9 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDefinedIndexesFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDefinedIndexesFunction.java
@@ -14,35 +14,30 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
-import java.util.Arrays;
-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.Function;
 import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.cache.query.Index;
 import org.apache.geode.cache.query.MultiIndexCreationException;
 import org.apache.geode.cache.query.QueryService;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.management.internal.cli.domain.IndexInfo;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 
-public class CreateDefinedIndexesFunction extends FunctionAdapter implements InternalEntity {
-
+public class CreateDefinedIndexesFunction implements Function, InternalEntity {
   private static final long serialVersionUID = 1L;
 
   @Override
-  public void execute(FunctionContext context) {
+  public void execute(final FunctionContext context) {
     String memberId = null;
-    List<Index> indexes = null;
-    Cache cache = null;
+
     try {
-      cache = CacheFactory.getAnyInstance();
+      Cache cache = context.getCache();
       memberId = cache.getDistributedSystem().getDistributedMember().getId();
       QueryService queryService = cache.getQueryService();
+
       Set<IndexInfo> indexDefinitions = (Set<IndexInfo>) context.getArguments();
       for (IndexInfo indexDefinition : indexDefinitions) {
         String indexName = indexDefinition.getIndexName();
@@ -56,16 +51,20 @@ public class CreateDefinedIndexesFunction extends FunctionAdapter implements Int
           queryService.defineIndex(indexName, indexedExpression, regionPath);
         }
       }
-      indexes = queryService.createDefinedIndexes();
+
+      queryService.createDefinedIndexes();
+
       context.getResultSender().lastResult(new CliFunctionResult(memberId));
+
     } catch (MultiIndexCreationException e) {
-      StringBuffer sb = new StringBuffer();
+      StringBuilder sb = new StringBuilder();
       sb.append("Index creation failed for indexes: ").append("\n");
       for (Map.Entry<String, Exception> failedIndex : e.getExceptionsMap().entrySet()) {
         sb.append(failedIndex.getKey()).append(" : ").append(failedIndex.getValue().getMessage())
             .append("\n");
       }
       context.getResultSender().lastResult(new CliFunctionResult(memberId, e, sb.toString()));
+
     } catch (Exception e) {
       String exceptionMessage = CliStrings.format(CliStrings.EXCEPTION_CLASS_AND_MESSAGE,
           e.getClass().getName(), e.getMessage());
@@ -73,14 +72,4 @@ public class CreateDefinedIndexesFunction extends FunctionAdapter implements Int
     }
   }
 
-  public void createCommandObject(IndexInfo info) {
-    Cache cache = CacheFactory.getAnyInstance();
-    QueryService queryService = cache.getQueryService();
-  }
-
-  @Override
-  public String getId() {
-    return CreateDefinedIndexesFunction.class.getName();
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/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 3b4679c..6ccd67d 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
@@ -14,19 +14,12 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
-/**
- * Function used by the 'create disk-store' gfsh command to create a disk store on each member.
- * 
- * @since GemFire 8.0
- */
-
 import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.CacheClosedException;
-import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.DiskStoreFactory;
-import org.apache.geode.cache.execute.FunctionAdapter;
+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;
@@ -36,25 +29,26 @@ import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 
-public class CreateDiskStoreFunction extends FunctionAdapter implements InternalEntity {
-  private static final Logger logger = LogService.getLogger();
-
+/**
+ * Function used by the 'create disk-store' gfsh command to create a disk store on each member.
+ *
+ * @since GemFire 8.0
+ */
+public class CreateDiskStoreFunction implements Function, InternalEntity {
   private static final long serialVersionUID = 1L;
-
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
+  private static final Logger logger = LogService.getLogger();
 
   @Override
-  public void execute(FunctionContext context) {
+  public void execute(final FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
     String memberId = "";
+
     try {
-      final Object[] args = (Object[]) context.getArguments();
-      final String diskStoreName = (String) args[0];
-      final DiskStoreAttributes diskStoreAttrs = (DiskStoreAttributes) args[01];
+      Object[] args = (Object[]) context.getArguments();
+      String diskStoreName = (String) args[0];
+      DiskStoreAttributes diskStoreAttrs = (DiskStoreAttributes) args[01];
 
-      InternalCache cache = getCache();
+      InternalCache cache = (InternalCache) context.getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
@@ -84,8 +78,4 @@ public class CreateDiskStoreFunction extends FunctionAdapter implements Internal
     }
   }
 
-  @Override
-  public String getId() {
-    return CreateDiskStoreFunction.class.getName();
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateIndexFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateIndexFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateIndexFunction.java
index 8a65f7a..1c332ee 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateIndexFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateIndexFunction.java
@@ -15,8 +15,7 @@
 package org.apache.geode.management.internal.cli.functions;
 
 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.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.query.IndexExistsException;
 import org.apache.geode.cache.query.IndexInvalidException;
@@ -29,28 +28,28 @@ import org.apache.geode.management.internal.cli.domain.IndexInfo;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 
-/***
+/**
  * Function to create index in a member, based on different arguments passed to it
- *
  */
-public class CreateIndexFunction extends FunctionAdapter implements InternalEntity {
-
-
+public class CreateIndexFunction implements Function, InternalEntity {
   private static final long serialVersionUID = 1L;
 
   @Override
-  public void execute(FunctionContext context) {
-    final IndexInfo indexInfo = (IndexInfo) context.getArguments();
+  public void execute(final FunctionContext context) {
+    IndexInfo indexInfo = (IndexInfo) context.getArguments();
     String memberId = null;
+
     try {
-      Cache cache = CacheFactory.getAnyInstance();
+      Cache cache = context.getCache();
       memberId = cache.getDistributedSystem().getDistributedMember().getId();
       QueryService queryService = cache.getQueryService();
       String indexName = indexInfo.getIndexName();
       String indexedExpression = indexInfo.getIndexedExpression();
       String fromClause = indexInfo.getRegionPath();
+
       // Check to see if the region path contains an alias e.g "/region1 r1"
       // Then the first string will be the regionPath
+
       String[] regionPathTokens = fromClause.trim().split(" ");
       String regionPath = regionPathTokens[0];
 
@@ -70,20 +69,25 @@ public class CreateIndexFunction extends FunctionAdapter implements InternalEnti
 
       regionPath = getValidRegionName(cache, regionPath);
       setResultInSender(context, indexInfo, memberId, cache, regionPath);
+
     } catch (IndexExistsException e) {
       String message =
           CliStrings.format(CliStrings.CREATE_INDEX__INDEX__EXISTS, indexInfo.getIndexName());
       context.getResultSender().lastResult(new CliFunctionResult(memberId, false, message));
+
     } catch (IndexNameConflictException e) {
       String message =
           CliStrings.format(CliStrings.CREATE_INDEX__NAME__CONFLICT, indexInfo.getIndexName());
       context.getResultSender().lastResult(new CliFunctionResult(memberId, false, message));
+
     } catch (RegionNotFoundException e) {
       String message = CliStrings.format(CliStrings.CREATE_INDEX__INVALID__REGIONPATH,
           indexInfo.getRegionPath());
       context.getResultSender().lastResult(new CliFunctionResult(memberId, false, message));
+
     } catch (IndexInvalidException e) {
       context.getResultSender().lastResult(new CliFunctionResult(memberId, e, e.getMessage()));
+
     } catch (Exception e) {
       String exceptionMessage = CliStrings.format(CliStrings.EXCEPTION_CLASS_AND_MESSAGE,
           e.getClass().getName(), e.getMessage());
@@ -91,12 +95,13 @@ public class CreateIndexFunction extends FunctionAdapter implements InternalEnti
     }
   }
 
-  private void setResultInSender(FunctionContext context, IndexInfo indexInfo, String memberId,
-      Cache cache, String regionPath) {
+  private void setResultInSender(final FunctionContext context, final IndexInfo indexInfo,
+      final String memberId, final Cache cache, final String regionPath) {
     if (regionPath == null) {
       String message = CliStrings.format(CliStrings.CREATE_INDEX__INVALID__REGIONPATH,
           indexInfo.getRegionPath());
       context.getResultSender().lastResult(new CliFunctionResult(memberId, false, message));
+
     } else {
       XmlEntity xmlEntity =
           new XmlEntity(CacheXml.REGION, "name", cache.getRegion(regionPath).getName());
@@ -104,7 +109,7 @@ public class CreateIndexFunction extends FunctionAdapter implements InternalEnti
     }
   }
 
-  private String getValidRegionName(Cache cache, String regionPath) {
+  private String getValidRegionName(final Cache cache, String regionPath) {
     while (regionPath != null && cache.getRegion(regionPath) == null) {
       int dotPosition;
       if (regionPath.contains(".") && ((dotPosition = regionPath.lastIndexOf('.')) != -1)) {
@@ -116,8 +121,4 @@ public class CreateIndexFunction extends FunctionAdapter implements InternalEnti
     return regionPath;
   }
 
-  @Override
-  public String getId() {
-    return CreateIndexFunction.class.getName();
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/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 401a368..e283ace 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
@@ -21,38 +21,29 @@ import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.SystemFailure;
 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.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.InternalCache;
 import org.apache.geode.internal.logging.LogService;
 
 public class DeployFunction implements Function, InternalEntity {
-  private static final Logger logger = LogService.getLogger();
-
-  public static final String ID = DeployFunction.class.getName();
-
   private static final long serialVersionUID = 1L;
-
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
+  private static final Logger logger = LogService.getLogger();
 
   @Override
-  public void execute(FunctionContext context) {
+  public void execute(final FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
     String memberId = "";
 
     try {
-      final Object[] args = (Object[]) context.getArguments();
-      final String[] jarFilenames = (String[]) args[0];
-      final byte[][] jarBytes = (byte[][]) args[1];
-      InternalCache cache = getCache();
+      Object[] args = (Object[]) context.getArguments();
+      String[] jarFilenames = (String[]) args[0];
+      byte[][] jarBytes = (byte[][]) args[1];
+      InternalCache cache = (InternalCache) context.getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
@@ -96,11 +87,6 @@ public class DeployFunction implements Function, InternalEntity {
   }
 
   @Override
-  public String getId() {
-    return ID;
-  }
-
-  @Override
   public boolean hasResult() {
     return true;
   }
@@ -114,4 +100,5 @@ public class DeployFunction implements Function, InternalEntity {
   public boolean isHA() {
     return false;
   }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java
index 68cc2e0..3b26ed9 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java
@@ -12,18 +12,18 @@
  * 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.File;
+
 import org.apache.commons.lang.StringUtils;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.DataPolicy;
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.cache.DiskStore;
 import org.apache.geode.cache.EvictionAction;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
-import org.apache.geode.cache.execute.FunctionAdapter;
+import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.cache.wan.GatewaySender;
@@ -35,12 +35,6 @@ import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.util.ArrayUtils;
 import org.apache.geode.management.internal.cli.domain.DiskStoreDetails;
 import org.apache.geode.management.internal.cli.util.DiskStoreNotFoundException;
-import org.apache.logging.log4j.Logger;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
 
 /**
  * The DescribeDiskStoreFunction class is an implementation of a GemFire Function used to collect
@@ -53,82 +47,54 @@ import java.util.Set;
  * @see org.apache.geode.cache.execute.FunctionContext
  * @see org.apache.geode.internal.InternalEntity
  * @see org.apache.geode.management.internal.cli.domain.DiskStoreDetails
+ *
  * @since GemFire 7.0
  */
-public class DescribeDiskStoreFunction extends FunctionAdapter implements InternalEntity {
-
+public class DescribeDiskStoreFunction implements Function, InternalEntity {
   private static final Logger logger = LogService.getLogger();
 
-  private static final Set<DataPolicy> PERSISTENT_DATA_POLICIES = new HashSet<>(2);
-
-  static {
-    PERSISTENT_DATA_POLICIES.add(DataPolicy.PERSISTENT_PARTITION);
-    PERSISTENT_DATA_POLICIES.add(DataPolicy.PERSISTENT_REPLICATE);
-  }
-
-  protected static void assertState(final boolean condition, final String message,
-      final Object... args) {
-    if (!condition) {
-      throw new IllegalStateException(String.format(message, args));
-    }
-  }
-
-  protected Cache getCache() {
-    return CacheFactory.getAnyInstance();
-  }
-
-  public String getId() {
-    return getClass().getName();
-  }
-
-  @SuppressWarnings("unused")
-  public void init(final Properties props) {}
-
   public void execute(final FunctionContext context) {
-    Cache cache = getCache();
+    InternalCache cache = (InternalCache) context.getCache();
 
     try {
-      if (cache instanceof InternalCache) {
-        InternalCache gemfireCache = (InternalCache) cache;
-
-        DistributedMember member = gemfireCache.getMyId();
-
-        String diskStoreName = (String) context.getArguments();
-        String memberId = member.getId();
-        String memberName = member.getName();
-
-        DiskStore diskStore = gemfireCache.findDiskStore(diskStoreName);
-
-        if (diskStore != null) {
-          DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStore.getDiskStoreUUID(),
-              diskStore.getName(), memberId, memberName);
-
-          diskStoreDetails.setAllowForceCompaction(diskStore.getAllowForceCompaction());
-          diskStoreDetails.setAutoCompact(diskStore.getAutoCompact());
-          diskStoreDetails.setCompactionThreshold(diskStore.getCompactionThreshold());
-          diskStoreDetails.setMaxOplogSize(diskStore.getMaxOplogSize());
-          diskStoreDetails.setQueueSize(diskStore.getQueueSize());
-          diskStoreDetails.setTimeInterval(diskStore.getTimeInterval());
-          diskStoreDetails.setWriteBufferSize(diskStore.getWriteBufferSize());
-          diskStoreDetails.setDiskUsageWarningPercentage(diskStore.getDiskUsageWarningPercentage());
-          diskStoreDetails
-              .setDiskUsageCriticalPercentage(diskStore.getDiskUsageCriticalPercentage());
-
-          setDiskDirDetails(diskStore, diskStoreDetails);
-          setRegionDetails(gemfireCache, diskStore, diskStoreDetails);
-          setCacheServerDetails(gemfireCache, diskStore, diskStoreDetails);
-          setGatewayDetails(gemfireCache, diskStore, diskStoreDetails);
-          setPdxSerializationDetails(gemfireCache, diskStore, diskStoreDetails);
-          setAsyncEventQueueDetails(gemfireCache, diskStore, diskStoreDetails);
-
-          context.getResultSender().lastResult(diskStoreDetails);
-        } else {
-          context.getResultSender()
-              .sendException(new DiskStoreNotFoundException(
-                  String.format("A disk store with name (%1$s) was not found on member (%2$s).",
-                      diskStoreName, memberName)));
-        }
+      DistributedMember member = cache.getMyId();
+
+      String diskStoreName = (String) context.getArguments();
+      String memberId = member.getId();
+      String memberName = member.getName();
+
+      DiskStore diskStore = cache.findDiskStore(diskStoreName);
+
+      if (diskStore != null) {
+        DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStore.getDiskStoreUUID(),
+            diskStore.getName(), memberId, memberName);
+
+        diskStoreDetails.setAllowForceCompaction(diskStore.getAllowForceCompaction());
+        diskStoreDetails.setAutoCompact(diskStore.getAutoCompact());
+        diskStoreDetails.setCompactionThreshold(diskStore.getCompactionThreshold());
+        diskStoreDetails.setMaxOplogSize(diskStore.getMaxOplogSize());
+        diskStoreDetails.setQueueSize(diskStore.getQueueSize());
+        diskStoreDetails.setTimeInterval(diskStore.getTimeInterval());
+        diskStoreDetails.setWriteBufferSize(diskStore.getWriteBufferSize());
+        diskStoreDetails.setDiskUsageWarningPercentage(diskStore.getDiskUsageWarningPercentage());
+        diskStoreDetails.setDiskUsageCriticalPercentage(diskStore.getDiskUsageCriticalPercentage());
+
+        setDiskDirDetails(diskStore, diskStoreDetails);
+        setRegionDetails(cache, diskStore, diskStoreDetails);
+        setCacheServerDetails(cache, diskStore, diskStoreDetails);
+        setGatewayDetails(cache, diskStore, diskStoreDetails);
+        setPdxSerializationDetails(cache, diskStore, diskStoreDetails);
+        setAsyncEventQueueDetails(cache, diskStore, diskStoreDetails);
+
+        context.getResultSender().lastResult(diskStoreDetails);
+
+      } else {
+        context.getResultSender()
+            .sendException(new DiskStoreNotFoundException(
+                String.format("A disk store with name (%1$s) was not found on member (%2$s).",
+                    diskStoreName, memberName)));
       }
+
     } catch (Exception e) {
       logger.error("Error occurred while executing 'describe disk-store': {}!", e.getMessage(), e);
       context.getResultSender().sendException(e);
@@ -165,12 +131,12 @@ public class DescribeDiskStoreFunction extends FunctionAdapter implements Intern
     return region.getAttributes().getDataPolicy().withPersistence();
   }
 
-  protected boolean isUsingDiskStore(final Region region, final DiskStore diskStore) {
+  boolean isUsingDiskStore(final Region region, final DiskStore diskStore) {
     return ((isPersistent(region) || isOverflowToDisk(region))
         && ObjectUtils.equals(getDiskStoreName(region), diskStore.getName()));
   }
 
-  protected void setRegionDetails(final InternalCache cache, final DiskStore diskStore,
+  void setRegionDetails(final InternalCache cache, final DiskStore diskStore,
       final DiskStoreDetails diskStoreDetails) {
     for (Region<?, ?> region : cache.rootRegions()) {
       setRegionDetails(region, diskStore, diskStoreDetails);
@@ -199,11 +165,11 @@ public class DescribeDiskStoreFunction extends FunctionAdapter implements Intern
             DiskStoreDetails.DEFAULT_DISK_STORE_NAME));
   }
 
-  protected boolean isUsingDiskStore(final CacheServer cacheServer, final DiskStore diskStore) {
+  boolean isUsingDiskStore(final CacheServer cacheServer, final DiskStore diskStore) {
     return ObjectUtils.equals(getDiskStoreName(cacheServer), diskStore.getName());
   }
 
-  protected void setCacheServerDetails(final InternalCache cache, final DiskStore diskStore,
+  void setCacheServerDetails(final InternalCache cache, final DiskStore diskStore,
       final DiskStoreDetails diskStoreDetails) {
     for (CacheServer cacheServer : cache.getCacheServers()) {
       if (isUsingDiskStore(cacheServer, diskStore)) {
@@ -225,11 +191,11 @@ public class DescribeDiskStoreFunction extends FunctionAdapter implements Intern
     return gateway.isPersistenceEnabled();
   }
 
-  protected boolean isUsingDiskStore(final GatewaySender gateway, final DiskStore diskStore) {
+  boolean isUsingDiskStore(final GatewaySender gateway, final DiskStore diskStore) {
     return ObjectUtils.equals(getDiskStoreName(gateway), diskStore.getName());
   }
 
-  protected void setGatewayDetails(final InternalCache cache, final DiskStore diskStore,
+  private void setGatewayDetails(final InternalCache cache, final DiskStore diskStore,
       final DiskStoreDetails diskStoreDetails) {
     for (GatewaySender gatewaySender : cache.getGatewaySenders()) {
       if (isUsingDiskStore(gatewaySender, diskStore)) {
@@ -241,7 +207,7 @@ public class DescribeDiskStoreFunction extends FunctionAdapter implements Intern
     }
   }
 
-  protected void setPdxSerializationDetails(final InternalCache cache, final DiskStore diskStore,
+  void setPdxSerializationDetails(final InternalCache cache, final DiskStore diskStore,
       final DiskStoreDetails diskStoreDetails) {
     if (cache.getPdxPersistent()) {
       String diskStoreName = StringUtils.defaultIfBlank(cache.getPdxDiskStore(),
@@ -256,12 +222,12 @@ public class DescribeDiskStoreFunction extends FunctionAdapter implements Intern
         DiskStoreDetails.DEFAULT_DISK_STORE_NAME);
   }
 
-  protected boolean isUsingDiskStore(final AsyncEventQueue queue, final DiskStore diskStore) {
+  boolean isUsingDiskStore(final AsyncEventQueue queue, final DiskStore diskStore) {
     return (queue.isPersistent()
         && ObjectUtils.equals(getDiskStoreName(queue), diskStore.getName()));
   }
 
-  protected void setAsyncEventQueueDetails(final InternalCache cache, final DiskStore diskStore,
+  void setAsyncEventQueueDetails(final InternalCache cache, final DiskStore diskStore,
       final DiskStoreDetails diskStoreDetails) {
     for (AsyncEventQueue queue : cache.getAsyncEventQueues()) {
       if (isUsingDiskStore(queue, diskStore)) {
@@ -270,4 +236,12 @@ public class DescribeDiskStoreFunction extends FunctionAdapter implements Intern
     }
   }
 
+  // TODO: delete assertState
+  protected static void assertState(final boolean condition, final String message,
+      final Object... args) {
+    if (!condition) {
+      throw new IllegalStateException(String.format(message, args));
+    }
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/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 c25a534..baaf973 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
@@ -18,9 +18,8 @@ import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.CacheClosedException;
-import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.DiskStore;
-import org.apache.geode.cache.execute.FunctionAdapter;
+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;
@@ -34,25 +33,20 @@ 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();
-
+public class DestroyDiskStoreFunction implements Function, InternalEntity {
   private static final long serialVersionUID = 1L;
-
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
+  private static final Logger logger = LogService.getLogger();
 
   @Override
-  public void execute(FunctionContext context) {
+  public void execute(final FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
     String memberId = "";
 
     try {
-      final Object[] args = (Object[]) context.getArguments();
-      final String diskStoreName = (String) args[0];
+      Object[] args = (Object[]) context.getArguments();
+      String diskStoreName = (String) args[0];
 
-      InternalCache cache = getCache();
+      InternalCache cache = (InternalCache) context.getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
@@ -95,8 +89,4 @@ public class DestroyDiskStoreFunction extends FunctionAdapter implements Interna
     }
   }
 
-  @Override
-  public String getId() {
-    return CreateDiskStoreFunction.class.getName();
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyIndexFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyIndexFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyIndexFunction.java
index 24322bc..915cb60 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyIndexFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DestroyIndexFunction.java
@@ -18,9 +18,8 @@ import java.util.List;
 
 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.FunctionAdapter;
+import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.query.Index;
 import org.apache.geode.cache.query.QueryService;
@@ -30,19 +29,16 @@ import org.apache.geode.management.internal.cli.domain.IndexInfo;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 
-
-
-public class DestroyIndexFunction extends FunctionAdapter implements InternalEntity {
-
+public class DestroyIndexFunction implements Function, InternalEntity {
   private static final long serialVersionUID = 1L;
 
   @Override
-  public void execute(FunctionContext context) {
+  public void execute(final FunctionContext context) {
     IndexInfo indexInfo = (IndexInfo) context.getArguments();
     String memberId = null;
 
     try {
-      Cache cache = CacheFactory.getAnyInstance();
+      Cache cache = context.getCache();
       memberId = cache.getDistributedSystem().getDistributedMember().getId();
       QueryService queryService = cache.getQueryService();
       String indexName = indexInfo.getIndexName();
@@ -87,20 +83,19 @@ public class DestroyIndexFunction extends FunctionAdapter implements InternalEnt
           }
         }
       }
+
     } catch (CacheClosedException e) {
       context.getResultSender().lastResult(new CliFunctionResult(memberId, e, e.getMessage()));
+
     } catch (Exception e) {
       context.getResultSender().lastResult(new CliFunctionResult(memberId, e, e.getMessage()));
     }
   }
 
-  /***
-   * 
-   * @param name
-   * @param queryService
+  /**
    * @return true if the index was found and removed/false if the index was not found.
    */
-  private boolean removeIndexByName(String name, QueryService queryService) {
+  private boolean removeIndexByName(final String name, final QueryService queryService) {
     List<Index> indexes = (List<Index>) queryService.getIndexes();
     boolean removed = false;
 
@@ -115,9 +110,4 @@ public class DestroyIndexFunction extends FunctionAdapter implements InternalEnt
     return removed;
   }
 
-  @Override
-  public String getId() {
-    return DestroyIndexFunction.class.getName();
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/634cbb34/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportConfigFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportConfigFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportConfigFunction.java
index 49e27b0..1086ec1 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportConfigFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportConfigFunction.java
@@ -23,7 +23,6 @@ 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;
@@ -35,19 +34,16 @@ import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
 import org.apache.geode.internal.logging.LogService;
 
 public class ExportConfigFunction implements Function, InternalEntity {
-  private static final Logger logger = LogService.getLogger();
-
-  public static final String ID = ExportConfigFunction.class.getName();
-
   private static final long serialVersionUID = 1L;
+  private static final Logger logger = LogService.getLogger();
 
   @Override
-  public void execute(FunctionContext context) {
+  public void execute(final FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
     String memberId = "";
 
     try {
-      Cache cache = CacheFactory.getAnyInstance();
+      Cache cache = context.getCache();
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
       memberId = member.getId();
@@ -66,26 +62,30 @@ public class ExportConfigFunction implements Function, InternalEntity {
       DistributionConfigImpl config =
           (DistributionConfigImpl) ((InternalDistributedSystem) cache.getDistributedSystem())
               .getConfig();
-      StringBuffer propStringBuf = new StringBuffer();
+      StringBuilder propStringBuf = new StringBuilder();
       String lineSeparator = System.getProperty("line.separator");
+
       for (Map.Entry entry : config.getConfigPropsFromSource(ConfigSource.runtime()).entrySet()) {
         if (entry.getValue() != null && !entry.getValue().equals("")) {
           propStringBuf.append(entry.getKey()).append("=").append(entry.getValue())
               .append(lineSeparator);
         }
       }
+
       for (Map.Entry entry : config.getConfigPropsFromSource(ConfigSource.api()).entrySet()) {
         if (entry.getValue() != null && !entry.getValue().equals("")) {
           propStringBuf.append(entry.getKey()).append("=").append(entry.getValue())
               .append(lineSeparator);
         }
       }
+
       for (Map.Entry entry : config.getConfigPropsDefinedUsingFiles().entrySet()) {
         if (entry.getValue() != null && !entry.getValue().equals("")) {
           propStringBuf.append(entry.getKey()).append("=").append(entry.getValue())
               .append(lineSeparator);
         }
       }
+
       // fix for bug 46653
       for (Map.Entry entry : config.getConfigPropsFromSource(ConfigSource.launcher()).entrySet()) {
         if (entry.getValue() != null && !entry.getValue().equals("")) {
@@ -116,11 +116,6 @@ public class ExportConfigFunction implements Function, InternalEntity {
   }
 
   @Override
-  public String getId() {
-    return ID;
-  }
-
-  @Override
   public boolean hasResult() {
     return true;
   }
@@ -134,4 +129,5 @@ public class ExportConfigFunction implements Function, InternalEntity {
   public boolean isHA() {
     return false;
   }
+
 }


Mime
View raw message