geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [24/51] [abbrv] geode git commit: GEODE-393: Providing cache for FunctionContext
Date Mon, 10 Jul 2017 18:00:47 GMT
GEODE-393: Providing cache for FunctionContext

Added the ability to pass a Cache to a function context as well as tests to check for this.

This closes #589
This closes #74


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

Branch: refs/heads/feature/GEODE-3109
Commit: d82a548f6575e7d691c83bc0558aca981689d601
Parents: 4227786
Author: David Anuta <david.r.anuta@gmail.com>
Authored: Fri Jun 16 16:05:24 2017 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Thu Jun 29 14:04:36 2017 -0700

----------------------------------------------------------------------
 .../geode/cache/execute/FunctionContext.java    |  4 ++
 .../geode/internal/cache/DistributedRegion.java |  6 +--
 .../geode/internal/cache/LocalRegion.java       |  2 +-
 .../cache/MemberFunctionStreamingMessage.java   |  7 +--
 .../geode/internal/cache/PartitionedRegion.java | 17 +++----
 .../cache/PartitionedRegionDataStore.java       |  2 +-
 .../cache/execute/FunctionContextImpl.java      | 20 +++++---
 .../cache/execute/MemberFunctionExecutor.java   |  7 ++-
 .../execute/MultiRegionFunctionContextImpl.java |  8 ++--
 .../execute/MultiRegionFunctionExecutor.java    |  5 +-
 .../execute/RegionFunctionContextImpl.java      | 10 ++--
 .../tier/sockets/command/ExecuteFunction.java   | 12 ++---
 .../tier/sockets/command/ExecuteFunction65.java | 12 +++--
 .../tier/sockets/command/ExecuteFunction66.java | 12 +++--
 .../cli/functions/ExportLogsFunction.java       |  2 +-
 .../ShowMissingDiskStoresFunction.java          |  6 +--
 .../cli/functions/SizeExportLogsFunction.java   |  2 +-
 .../geode/internal/DeployedJarJUnitTest.java    | 10 ++--
 .../cache/execute/FunctionServiceBase.java      | 14 ++++++
 ...unctionServiceMultipleOnMemberDUnitTest.java |  4 +-
 .../FunctionServiceSingleOnMemberDUnitTest.java | 12 ++---
 .../ExportLogsFunctionIntegrationTest.java      |  9 ++--
 .../ShowMissingDiskStoresFunctionJUnitTest.java | 49 +++-----------------
 .../functions/SizeExportLogsFunctionTest.java   | 12 +++--
 .../cli/util/LogExporterIntegrationTest.java    |  6 +--
 25 files changed, 128 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/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 74f05c5..0b4e7f9 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
@@ -14,6 +14,8 @@
  */
 package org.apache.geode.cache.execute;
 
+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.
@@ -75,4 +77,6 @@ public interface FunctionContext<T1> {
    * @see Function#isHA()
    */
   public boolean isPossibleDuplicate();
+
+  public Cache getCache();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
index 21f911d..eb18134 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
@@ -3618,8 +3618,8 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
       final Object args, int prid, final Set filter, boolean isReExecute) throws IOException {
     final DM dm = getDistributionManager();
     ResultSender resultSender = new DistributedRegionFunctionResultSender(dm, msg, function);
-    final RegionFunctionContextImpl context = new RegionFunctionContextImpl(function.getId(), this,
-        args, filter, null, null, resultSender, isReExecute);
+    final RegionFunctionContextImpl context = new RegionFunctionContextImpl(cache, function.getId(),
+        this, args, filter, null, null, resultSender, isReExecute);
     FunctionStats stats = FunctionStats.getFunctionStats(function.getId(), dm.getSystem());
     try {
       long start = stats.startTime();
@@ -3656,7 +3656,7 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
     final DM dm = getDistributionManager();
     final DistributedRegionFunctionResultSender resultSender =
         new DistributedRegionFunctionResultSender(dm, localRC, function, sender);
-    final RegionFunctionContextImpl context = new RegionFunctionContextImpl(function.getId(),
+    final RegionFunctionContextImpl context = new RegionFunctionContextImpl(cache, function.getId(),
         DistributedRegion.this, args, filter, null, null, resultSender, execution.isReExecute());
     execution.executeFunctionOnLocalNode(function, context, resultSender, dm, isTX());
     return localRC;

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index 02625ee..3b3047f 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -10719,7 +10719,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
 
     final DistributedRegionFunctionResultSender resultSender =
         new DistributedRegionFunctionResultSender(dm, resultCollector, function, sender);
-    final RegionFunctionContextImpl context = new RegionFunctionContextImpl(function.getId(),
+    final RegionFunctionContextImpl context = new RegionFunctionContextImpl(cache, function.getId(),
         LocalRegion.this, args, filter, null, null, resultSender, execution.isReExecute());
     execution.executeFunctionOnLocalNode(function, context, resultSender, dm, isTX());
     return resultCollector;

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/MemberFunctionStreamingMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/MemberFunctionStreamingMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/MemberFunctionStreamingMessage.java
index 617001f..a62f50e 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/MemberFunctionStreamingMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/MemberFunctionStreamingMessage.java
@@ -157,12 +157,13 @@ public class MemberFunctionStreamingMessage extends DistributionMessage
     FunctionStats stats =
         FunctionStats.getFunctionStats(this.functionObject.getId(), dm.getSystem());
     TXStateProxy tx = null;
+    InternalCache cache = GemFireCacheImpl.getInstance();
+
     try {
       tx = prepForTransaction();
       ResultSender resultSender = new MemberFunctionResultSender(dm, this, this.functionObject);
       Set<Region> regions = new HashSet<Region>();
       if (this.regionPathSet != null) {
-        InternalCache cache = GemFireCacheImpl.getInstance();
         for (String regionPath : this.regionPathSet) {
           if (checkCacheClosing(dm) || checkDSClosing(dm)) {
             thr =
@@ -173,8 +174,8 @@ public class MemberFunctionStreamingMessage extends DistributionMessage
           regions.add(cache.getRegion(regionPath));
         }
       }
-      FunctionContextImpl context = new MultiRegionFunctionContextImpl(this.functionObject.getId(),
-          this.args, resultSender, regions, isReExecute);
+      FunctionContextImpl context = new MultiRegionFunctionContextImpl(cache,
+          this.functionObject.getId(), this.args, resultSender, regions, isReExecute);
 
       long start = stats.startTime();
       stats.startFunctionExecution(this.functionObject.hasResult());

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
index cf3ca76..c3aec13 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
@@ -3472,11 +3472,12 @@ public class PartitionedRegion extends LocalRegion
             execution.isForwardExceptions(), function, localBucketSet);
 
     if (localKeys != null) {
-      final RegionFunctionContextImpl prContext = new RegionFunctionContextImpl(function.getId(),
-          PartitionedRegion.this, execution.getArgumentsForMember(getMyId().getId()),
-          localKeys, ColocationHelper
-              .constructAndGetAllColocatedLocalDataSet(PartitionedRegion.this, localBucketSet),
-          localBucketSet, resultSender, execution.isReExecute());
+      final RegionFunctionContextImpl prContext =
+          new RegionFunctionContextImpl(cache, function.getId(), PartitionedRegion.this,
+              execution.getArgumentsForMember(getMyId().getId()),
+              localKeys, ColocationHelper
+                  .constructAndGetAllColocatedLocalDataSet(PartitionedRegion.this, localBucketSet),
+              localBucketSet, resultSender, execution.isReExecute());
       if (logger.isDebugEnabled()) {
         logger.debug("FunctionService: Executing on local node with keys.{}", localKeys);
       }
@@ -3611,7 +3612,7 @@ public class PartitionedRegion extends LocalRegion
               execution.getServerResultSender(), true, false, execution.isForwardExceptions(),
               function, buckets);
       final FunctionContext context =
-          new RegionFunctionContextImpl(function.getId(), PartitionedRegion.this,
+          new RegionFunctionContextImpl(cache, function.getId(), PartitionedRegion.this,
               execution.getArgumentsForMember(localVm.getId()), routingKeys, ColocationHelper
                   .constructAndGetAllColocatedLocalDataSet(PartitionedRegion.this, buckets),
               buckets, resultSender, execution.isReExecute());
@@ -3742,7 +3743,7 @@ public class PartitionedRegion extends LocalRegion
     // execute locally and collect the result
     if (isSelf && this.dataStore != null) {
       final RegionFunctionContextImpl prContext =
-          new RegionFunctionContextImpl(function.getId(), PartitionedRegion.this,
+          new RegionFunctionContextImpl(cache, function.getId(), PartitionedRegion.this,
               execution.getArgumentsForMember(getMyId().getId()), null, ColocationHelper
                   .constructAndGetAllColocatedLocalDataSet(PartitionedRegion.this, localBucketSet),
               localBucketSet, resultSender, execution.isReExecute());
@@ -3838,7 +3839,7 @@ public class PartitionedRegion extends LocalRegion
     // execute locally and collect the result
     if (isSelf && this.dataStore != null) {
       final RegionFunctionContextImpl prContext =
-          new RegionFunctionContextImpl(function.getId(), PartitionedRegion.this,
+          new RegionFunctionContextImpl(cache, function.getId(), PartitionedRegion.this,
               execution.getArgumentsForMember(getMyId().getId()), null, ColocationHelper
                   .constructAndGetAllColocatedLocalDataSet(PartitionedRegion.this, localBucketSet),
               localBucketSet, resultSender, execution.isReExecute());

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
index 7cef0a5..2589626 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
@@ -2893,7 +2893,7 @@ public class PartitionedRegionDataStore implements HasCachePerfStats {
         this.partitionedRegion, time, msg, function, bucketSet);
 
     final RegionFunctionContextImpl prContext =
-        new RegionFunctionContextImpl(function.getId(),
+        new RegionFunctionContextImpl(getPartitionedRegion().getCache(), function.getId(),
             this.partitionedRegion, object, localKeys, ColocationHelper
                 .constructAndGetAllColocatedLocalDataSet(this.partitionedRegion, bucketSet),
             bucketSet, resultSender, isReExecute);

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/execute/FunctionContextImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/FunctionContextImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/FunctionContextImpl.java
index 39190f3..5fb52fc 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/FunctionContextImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/FunctionContextImpl.java
@@ -14,6 +14,7 @@
  */
 package org.apache.geode.internal.cache.execute;
 
+import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
@@ -37,20 +38,20 @@ public class FunctionContextImpl implements FunctionContext {
 
   private String functionId = null;
 
+  private Cache cache = null;
+
   private ResultSender resultSender = null;
 
   private final boolean isPossDup;
 
-  public FunctionContextImpl(final String functionId, final Object args,
+  public FunctionContextImpl(final Cache cache, final String functionId, final Object args,
       ResultSender resultSender) {
-    this.functionId = functionId;
-    this.args = args;
-    this.resultSender = resultSender;
-    this.isPossDup = false;
+    this(cache, functionId, args, resultSender, false);
   }
 
-  public FunctionContextImpl(final String functionId, final Object args, ResultSender resultSender,
-      boolean isPossibleDuplicate) {
+  public FunctionContextImpl(final Cache cache, final String functionId, final Object args,
+      ResultSender resultSender, boolean isPossibleDuplicate) {
+    this.cache = cache;
     this.functionId = functionId;
     this.args = args;
     this.resultSender = resultSender;
@@ -97,4 +98,9 @@ public class FunctionContextImpl implements FunctionContext {
     return this.isPossDup;
   }
 
+  @Override
+  public Cache getCache() {
+    return cache;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionExecutor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionExecutor.java
index ab6794b..54c37ee 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionExecutor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionExecutor.java
@@ -122,18 +122,21 @@ public class MemberFunctionExecutor extends AbstractExecution {
     if (dest.size() == 1 && dest.contains(localVM)) {
       localOnly = true;
     }
+
+
     final MemberFunctionResultSender resultSender =
         new MemberFunctionResultSender(dm, localRC, function, localOnly, remoteOnly, sender);
     if (dest.contains(localVM)) {
       // if member is local VM
       dest.remove(localVM);
-      final FunctionContext context = new FunctionContextImpl(function.getId(),
-          getArgumentsForMember(localVM.getId()), resultSender);
+
       boolean isTx = false;
       InternalCache cache = GemFireCacheImpl.getInstance();
       if (cache != null) {
         isTx = cache.getTxManager().getTXState() == null ? false : true;
       }
+      final FunctionContext context = new FunctionContextImpl(cache, function.getId(),
+          getArgumentsForMember(localVM.getId()), resultSender);
       executeFunctionOnLocalNode(function, context, resultSender, dm, isTx);
     }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionContextImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionContextImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionContextImpl.java
index f38f2e9..cfb802c 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionContextImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionContextImpl.java
@@ -16,6 +16,7 @@ package org.apache.geode.internal.cache.execute;
 
 import java.util.Set;
 
+import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.ResultSender;
 
@@ -33,9 +34,10 @@ public class MultiRegionFunctionContextImpl extends FunctionContextImpl
 
   private final boolean isPossibleDuplicate;
 
-  public MultiRegionFunctionContextImpl(final String functionId, final Object args,
-      ResultSender resultSender, Set<Region> regions, boolean isPossibleDuplicate) {
-    super(functionId, args, resultSender);
+  public MultiRegionFunctionContextImpl(final Cache cache, final String functionId,
+      final Object args, ResultSender resultSender, Set<Region> regions,
+      boolean isPossibleDuplicate) {
+    super(cache, functionId, args, resultSender);
     this.regions = regions;
     this.isPossibleDuplicate = isPossibleDuplicate;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionExecutor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionExecutor.java
index 27542f5..adc126f 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionExecutor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MultiRegionFunctionExecutor.java
@@ -244,8 +244,9 @@ public class MultiRegionFunctionExecutor extends AbstractExecution {
           regions.add(cache1.getRegion(regionPath));
         }
       }
-      final FunctionContextImpl context = new MultiRegionFunctionContextImpl(function.getId(),
-          getArgumentsForMember(localVM.getId()), resultSender, regions, this.isReExecute);
+      final FunctionContextImpl context =
+          new MultiRegionFunctionContextImpl(cache, function.getId(),
+              getArgumentsForMember(localVM.getId()), resultSender, regions, this.isReExecute);
       boolean isTx = cache.getTxManager().getTXState() == null ? false : true;
       executeFunctionOnLocalNode(function, context, resultSender, dm, isTx);
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/execute/RegionFunctionContextImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/RegionFunctionContextImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/RegionFunctionContextImpl.java
index abb3d00..4f90745 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/RegionFunctionContextImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/RegionFunctionContextImpl.java
@@ -20,6 +20,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.FunctionService;
@@ -50,10 +51,11 @@ public class RegionFunctionContextImpl extends FunctionContextImpl
 
   private final boolean isPossibleDuplicate;
 
-  public RegionFunctionContextImpl(final String functionId, final Region dataSet, final Object args,
-      final Set<?> routingObjects, final Map<String, LocalDataSet> colocatedLocalDataMap,
-      Set<Integer> localBucketSet, ResultSender<?> resultSender, boolean isPossibleDuplicate) {
-    super(functionId, args, resultSender);
+  public RegionFunctionContextImpl(final Cache cache, final String functionId, final Region dataSet,
+      final Object args, final Set<?> routingObjects,
+      final Map<String, LocalDataSet> colocatedLocalDataMap, Set<Integer> localBucketSet,
+      ResultSender<?> resultSender, boolean isPossibleDuplicate) {
+    super(cache, functionId, args, resultSender);
     this.dataSet = dataSet;
     this.filter = routingObjects;
     this.colocatedLocalDataMap = colocatedLocalDataMap;

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction.java
index 2bfbdb5..08f0264 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction.java
@@ -135,16 +135,16 @@ public class ExecuteFunction extends BaseCommand {
       ResultSender resultSender = new ServerToClientFunctionResultSender(m,
           MessageType.EXECUTE_FUNCTION_RESULT, serverConnection, functionObject, executeContext);
 
-      InternalDistributedMember localVM = (InternalDistributedMember) serverConnection.getCache()
-          .getDistributedSystem().getDistributedMember();
-
       FunctionContext context = null;
+      InternalCache cache = serverConnection.getCache();
+      InternalDistributedMember localVM =
+          (InternalDistributedMember) cache.getDistributedSystem().getDistributedMember();
 
       if (memberMappedArg != null) {
-        context = new FunctionContextImpl(functionObject.getId(),
+        context = new FunctionContextImpl(cache, functionObject.getId(),
             memberMappedArg.getArgumentsForMember(localVM.getId()), resultSender);
       } else {
-        context = new FunctionContextImpl(functionObject.getId(), args, resultSender);
+        context = new FunctionContextImpl(cache, functionObject.getId(), args, resultSender);
       }
       HandShake handShake = (HandShake) serverConnection.getHandshake();
       int earlierClientReadTimeout = handShake.getClientReadTimeout();
@@ -156,7 +156,7 @@ public class ExecuteFunction extends BaseCommand {
           logger.debug("Executing Function on Server: " + serverConnection.toString()
               + "with context :" + context.toString());
         }
-        InternalCache cache = serverConnection.getCache();
+
         HeapMemoryMonitor hmm =
             ((InternalResourceManager) cache.getResourceManager()).getHeapMonitor();
         if (functionObject.optimizeForWrite() && cache != null && hmm.getState().isCritical()

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65.java
index 167aa3b..53db561 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65.java
@@ -165,15 +165,17 @@ public class ExecuteFunction65 extends BaseCommand {
       ResultSender resultSender = new ServerToClientFunctionResultSender65(m,
           MessageType.EXECUTE_FUNCTION_RESULT, serverConnection, functionObject, executeContext);
 
-      InternalDistributedMember localVM = (InternalDistributedMember) serverConnection.getCache()
-          .getDistributedSystem().getDistributedMember();
       FunctionContext context = null;
+      InternalCache cache = serverConnection.getCache();
+      InternalDistributedMember localVM =
+          (InternalDistributedMember) cache.getDistributedSystem().getDistributedMember();
 
       if (memberMappedArg != null) {
-        context = new FunctionContextImpl(functionObject.getId(),
+        context = new FunctionContextImpl(cache, functionObject.getId(),
             memberMappedArg.getArgumentsForMember(localVM.getId()), resultSender, isReexecute);
       } else {
-        context = new FunctionContextImpl(functionObject.getId(), args, resultSender, isReexecute);
+        context =
+            new FunctionContextImpl(cache, functionObject.getId(), args, resultSender, isReexecute);
       }
       HandShake handShake = (HandShake) serverConnection.getHandshake();
       int earlierClientReadTimeout = handShake.getClientReadTimeout();
@@ -185,7 +187,7 @@ public class ExecuteFunction65 extends BaseCommand {
           logger.debug("Executing Function on Server: {} with context: {}", serverConnection,
               context);
         }
-        InternalCache cache = serverConnection.getCache();
+
         HeapMemoryMonitor hmm =
             ((InternalResourceManager) cache.getResourceManager()).getHeapMonitor();
         if (functionObject.optimizeForWrite() && cache != null && hmm.getState().isCritical()

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66.java
index e212b50..a3b061f 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66.java
@@ -206,15 +206,17 @@ public class ExecuteFunction66 extends BaseCommand {
       ServerToClientFunctionResultSender resultSender = new ServerToClientFunctionResultSender65(m,
           MessageType.EXECUTE_FUNCTION_RESULT, serverConnection, functionObject, executeContext);
 
-      InternalDistributedMember localVM = (InternalDistributedMember) serverConnection.getCache()
-          .getDistributedSystem().getDistributedMember();
       FunctionContext context = null;
+      InternalCache cache = serverConnection.getCache();
+      InternalDistributedMember localVM =
+          (InternalDistributedMember) cache.getDistributedSystem().getDistributedMember();
 
       if (memberMappedArg != null) {
-        context = new FunctionContextImpl(functionObject.getId(),
+        context = new FunctionContextImpl(cache, functionObject.getId(),
             memberMappedArg.getArgumentsForMember(localVM.getId()), resultSender, isReexecute);
       } else {
-        context = new FunctionContextImpl(functionObject.getId(), args, resultSender, isReexecute);
+        context =
+            new FunctionContextImpl(cache, functionObject.getId(), args, resultSender, isReexecute);
       }
       HandShake handShake = (HandShake) serverConnection.getHandshake();
       int earlierClientReadTimeout = handShake.getClientReadTimeout();
@@ -224,7 +226,7 @@ public class ExecuteFunction66 extends BaseCommand {
           logger.debug("Executing Function on Server: {} with context: {}", serverConnection,
               context);
         }
-        InternalCache cache = serverConnection.getCache();
+
         HeapMemoryMonitor hmm =
             ((InternalResourceManager) cache.getResourceManager()).getHeapMonitor();
         if (functionObject.optimizeForWrite() && cache != null && hmm.getState().isCritical()

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/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 86b506e..b2a7e7e 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
@@ -67,7 +67,7 @@ public class ExportLogsFunction implements Function, InternalEntity {
   @Override
   public void execute(final FunctionContext context) {
     try {
-      InternalCache cache = GemFireCacheImpl.getInstance();
+      InternalCache cache = (InternalCache) context.getCache();
       DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
 
       String memberId = cache.getDistributedSystem().getMemberId();

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/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 ca66b6a..2a1b746 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
@@ -33,10 +33,6 @@ import org.apache.geode.internal.cache.persistence.PersistentMemberPattern;
 
 public class ShowMissingDiskStoresFunction extends FunctionAdapter implements InternalEntity {
 
-  protected InternalCache getCache() {
-    return GemFireCacheImpl.getInstance();
-  }
-
   @Override
   public void execute(FunctionContext context) {
     final Set<PersistentMemberPattern> memberMissingIDs = new HashSet<PersistentMemberPattern>();
@@ -46,7 +42,7 @@ public class ShowMissingDiskStoresFunction extends FunctionAdapter implements In
       throw new RuntimeException();
     }
     try {
-      final InternalCache cache = getCache();
+      final InternalCache cache = (InternalCache) context.getCache();
 
       if (cache != null && !cache.isClosed()) {
         final DistributedMember member = cache.getMyId();

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/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 9d1eff5..fbb60a0 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
@@ -39,7 +39,7 @@ public class SizeExportLogsFunction extends ExportLogsFunction implements Functi
   @Override
   public void execute(final FunctionContext context) {
     try {
-      InternalCache cache = GemFireCacheImpl.getInstance();
+      InternalCache cache = (InternalCache) context.getCache();
       DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
       Args args = (Args) context.getArguments();
       long diskAvailable = getDiskAvailable(config);

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/test/java/org/apache/geode/internal/DeployedJarJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/DeployedJarJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/DeployedJarJUnitTest.java
index 5e7c40f..178dbae 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/DeployedJarJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/DeployedJarJUnitTest.java
@@ -140,7 +140,8 @@ public class DeployedJarJUnitTest {
     Function function = FunctionService.getFunction("JarClassLoaderJUnitFunction");
     assertThat(function).isNotNull();
     TestResultSender resultSender = new TestResultSender();
-    FunctionContext functionContext = new FunctionContextImpl(function.getId(), null, resultSender);
+    FunctionContext functionContext =
+        new FunctionContextImpl(null, function.getId(), null, resultSender);
     function.execute(functionContext);
     assertThat(resultSender.getResults()).isEqualTo("GOODv1");
 
@@ -153,7 +154,7 @@ public class DeployedJarJUnitTest {
     function = FunctionService.getFunction("JarClassLoaderJUnitFunction");
     assertThat(function).isNotNull();
     resultSender = new TestResultSender();
-    functionContext = new FunctionContextImpl(function.getId(), null, resultSender);
+    functionContext = new FunctionContextImpl(null, function.getId(), null, resultSender);
     function.execute(functionContext);
     assertThat(resultSender.getResults()).isEqualTo("GOODv2");
 
@@ -220,7 +221,7 @@ public class DeployedJarJUnitTest {
     Function function = FunctionService.getFunction("JarClassLoaderJUnitFunctionNoXml");
     assertThat(function).isNotNull();
     TestResultSender resultSender = new TestResultSender();
-    function.execute(new FunctionContextImpl(function.getId(), null, resultSender));
+    function.execute(new FunctionContextImpl(null, function.getId(), null, resultSender));
     assertThat((String) resultSender.getResults()).isEqualTo("NOPARMSv1");
   }
 
@@ -280,7 +281,8 @@ public class DeployedJarJUnitTest {
     Function function = FunctionService.getFunction("JarClassLoaderJUnitFunction");
     assertThat(function).isNotNull();
     TestResultSender resultSender = new TestResultSender();
-    FunctionContext functionContext = new FunctionContextImpl(function.getId(), null, resultSender);
+    FunctionContext functionContext =
+        new FunctionContextImpl(null, function.getId(), null, resultSender);
     function.execute(functionContext);
     assertThat((String) resultSender.getResults()).isEqualTo("PARENT:USES");
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceBase.java b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceBase.java
index 8efeae0..55d9a8d 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceBase.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceBase.java
@@ -24,6 +24,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
@@ -72,6 +73,19 @@ public abstract class FunctionServiceBase extends JUnit4CacheTestCase {
   public abstract int numberOfExecutions();
 
   @Test
+  public void functionContextGetCacheIsNotNullAndOpen() {
+    ResultCollector rc = getExecution().execute((context) -> {
+      Cache cache = context.getCache();
+      assertNotNull(cache);
+      assertFalse(cache.isClosed());
+      context.getResultSender().lastResult("done");
+    });
+    List<String> results = (List<String>) rc.getResult();
+    assertEquals(numberOfExecutions(), results.size());
+    results.stream().forEach(element -> assertEquals("done", element));
+  }
+
+  @Test
   public void defaultCollectorReturnsSingleResult() {
     ResultCollector rc = getExecution().execute((context) -> {
       context.getResultSender().lastResult("done");

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceMultipleOnMemberDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceMultipleOnMemberDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceMultipleOnMemberDUnitTest.java
index e594f11..af504f4 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceMultipleOnMemberDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceMultipleOnMemberDUnitTest.java
@@ -41,8 +41,8 @@ public class FunctionServiceMultipleOnMemberDUnitTest extends FunctionServiceBas
     Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
-    members.add(vm0.invoke(() -> getSystem().getDistributedMember()));
-    members.add(vm1.invoke(() -> getSystem().getDistributedMember()));
+    members.add(vm0.invoke(() -> getCache().getDistributedSystem().getDistributedMember()));
+    members.add(vm1.invoke(() -> getCache().getDistributedSystem().getDistributedMember()));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceSingleOnMemberDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceSingleOnMemberDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceSingleOnMemberDUnitTest.java
index 77f35a4..f5a841a 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceSingleOnMemberDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionServiceSingleOnMemberDUnitTest.java
@@ -14,25 +14,25 @@
  */
 package org.apache.geode.internal.cache.execute;
 
+import org.junit.Before;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.test.junit.categories.DistributedTest;
 
-import org.junit.Before;
-import org.junit.experimental.categories.Category;
-
 /**
  * Test of the behavior of a custom ResultCollector when handling exceptions
  */
 @Category(DistributedTest.class)
 public class FunctionServiceSingleOnMemberDUnitTest extends FunctionServiceBase {
 
-  private InternalDistributedMember memberId;
+  private DistributedMember memberId;
 
   @Before
   public void createDistributedSystem() {
-    memberId = getSystem().getDistributedMember();
+    memberId = getCache().getDistributedSystem().getDistributedMember();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
index e47cefb..d986418 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
@@ -58,18 +58,19 @@ public class ExportLogsFunctionIntegrationTest {
     File notALogFile = new File(serverWorkingDir, "foo.txt");
     FileUtils.writeStringToFile(notALogFile, "some text");
 
-    verifyExportLogsFunctionDoesNotBlowUp();
+    verifyExportLogsFunctionDoesNotBlowUp(serverStarterRule.getCache());
 
-    Cache cache = GemFireCacheImpl.getInstance();
+    Cache cache = serverStarterRule.getCache();
     assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isEmpty();
   }
 
-  public static void verifyExportLogsFunctionDoesNotBlowUp() throws Throwable {
+  public static void verifyExportLogsFunctionDoesNotBlowUp(Cache cache) throws Throwable {
     ExportLogsFunction.Args args =
         new ExportLogsFunction.Args(null, null, "info", false, false, false);
 
     CapturingResultSender resultSender = new CapturingResultSender();
-    FunctionContext context = new FunctionContextImpl("functionId", args, resultSender);
+
+    FunctionContext context = new FunctionContextImpl(cache, "functionId", args, resultSender);
 
     new ExportLogsFunction().execute(context);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java
index 0bd0ee9..7e6688a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ShowMissingDiskStoresFunctionJUnitTest.java
@@ -64,7 +64,6 @@ import org.apache.geode.test.junit.categories.UnitTest;
 public class ShowMissingDiskStoresFunctionJUnitTest {
 
   private GemFireCacheImpl cache;
-  private GemFireCacheImpl oldCacheInstance;
   private InternalDistributedSystem system;
   private PartitionedRegion pr1;
   private PartitionedRegion pr2;
@@ -77,6 +76,7 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
   private FunctionContext context;
   private TestResultSender resultSender;
   private PersistentMemberManager memberManager;
+  private ShowMissingDiskStoresFunction smdsFunc;
 
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
@@ -91,40 +91,14 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
     pa = mock(PartitionAttributes.class);
     prc = mock(PartitionRegionConfig.class);
     cache = Fakes.cache();
-    oldCacheInstance = GemFireCacheImpl.setInstanceForTests(cache);
     resultSender = new TestResultSender();
-    context = new FunctionContextImpl("testFunction", null, resultSender);
+    context = new FunctionContextImpl(cache, "testFunction", null, resultSender);
     memberManager = mock(PersistentMemberManager.class);
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    GemFireCacheImpl.setInstanceForTests(oldCacheInstance);
-  }
-
-  private class TestSMDSFFunc1 extends ShowMissingDiskStoresFunction {
-    @Override
-    protected InternalCache getCache() {
-      return null;
-    }
-  }
-
-  private class TestSMDSFFunc2 extends ShowMissingDiskStoresFunction {
-    @Override
-    protected InternalCache getCache() {
-      return cache;
-    }
-  }
-
-  @Test
-  public void testGetCache() {
-    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
-    assertTrue(smdsFunc.getCache() instanceof Cache);
+    smdsFunc = new ShowMissingDiskStoresFunction();
   }
 
   @Test
   public void testExecute() {
-    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
     List<?> results = null;
 
     when(cache.getPersistentMemberManager()).thenReturn(memberManager);
@@ -143,7 +117,6 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
   public void testExecuteWithNullContextThrowsRuntimeException() {
     expectedException.expect(RuntimeException.class);
 
-    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
     smdsFunc.execute(null);
     fail("Missing expected RuntimeException");
   }
@@ -154,10 +127,10 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
    */
   @Test
   public void testExecuteWithNullCacheInstanceHasEmptyResults() throws Throwable {
-    TestSMDSFFunc1 testSMDSFunc = new TestSMDSFFunc1();
+    context = new FunctionContextImpl(null, "testFunction", null, resultSender);
     List<?> results = null;
 
-    testSMDSFunc.execute(context);
+    smdsFunc.execute(context);
     results = resultSender.getResults();
     assertNotNull(results);
     assertEquals(1, results.size());
@@ -166,13 +139,12 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
 
   @Test
   public void testExecuteWithNullGFCIResultValueIsNull() throws Throwable {
-    TestSMDSFFunc2 testSMDSFunc = new TestSMDSFFunc2();
     List<?> results = null;
 
     when(cache.getPersistentMemberManager()).thenReturn(memberManager);
     GemFireCacheImpl.setInstanceForTests(null);
 
-    testSMDSFunc.execute(context);
+    smdsFunc.execute(context);
     results = resultSender.getResults();
     assertNotNull(results);
     assertEquals(1, results.size());
@@ -181,19 +153,17 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
 
   @Test
   public void testExecuteWhenGFCIClosedResultValueIsNull() throws Throwable {
-    TestSMDSFFunc2 testSMDSFunc = new TestSMDSFFunc2();
     List<?> results = null;
 
     when(cache.getPersistentMemberManager()).thenReturn(memberManager);
     when(((GemFireCacheImpl) cache).isClosed()).thenReturn(true);
-    testSMDSFunc.execute(context);
+    smdsFunc.execute(context);
     results = resultSender.getResults();
     assertNotNull(results);
   }
 
   @Test
   public void testExecuteReturnsMissingDiskStores() throws Throwable {
-    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
     List<?> results = null;
 
     when(cache.getPersistentMemberManager()).thenReturn(memberManager);
@@ -232,7 +202,6 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
 
   @Test
   public void testExecuteReturnsMissingColocatedRegions() throws Throwable {
-    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
     List<?> results = null;
 
     when(cache.getPersistentMemberManager()).thenReturn(memberManager);
@@ -267,7 +236,6 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
 
   @Test
   public void testExecuteReturnsMissingStoresAndRegions() throws Throwable {
-    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
     List<?> results = null;
 
     when(cache.getPersistentMemberManager()).thenReturn(memberManager);
@@ -335,8 +303,6 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
   public void testExecuteCatchesExceptions() throws Exception {
     expectedException.expect(RuntimeException.class);
 
-    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
-
     when(cache.getPersistentMemberManager()).thenThrow(new RuntimeException());
 
     smdsFunc.execute(context);
@@ -346,7 +312,6 @@ public class ShowMissingDiskStoresFunctionJUnitTest {
 
   @Test
   public void testGetId() {
-    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
     assertEquals(ShowMissingDiskStoresFunction.class.getName(), smdsFunc.getId());
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java
index 96fa733..510a4e7 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java
@@ -81,7 +81,8 @@ public class SizeExportLogsFunctionTest {
     config.setProperty(STATISTIC_ARCHIVE_FILE, statFile.getAbsolutePath());
 
     server.withProperties(config).startServer();
-    FunctionContext context = new FunctionContextImpl("functionId", nonFilteringArgs, resultSender);
+    FunctionContext context =
+        new FunctionContextImpl(server.getCache(), "functionId", nonFilteringArgs, resultSender);
 
     // log and stat files sizes are not constant with a real cache running, so check for the sizer
     // estimate within a range
@@ -98,7 +99,8 @@ public class SizeExportLogsFunctionTest {
 
     server.withProperties(config).startServer();
 
-    FunctionContext context = new FunctionContextImpl("functionId", nonFilteringArgs, resultSender);
+    FunctionContext context =
+        new FunctionContextImpl(server.getCache(), "functionId", nonFilteringArgs, resultSender);
     new SizeExportLogsFunction().execute(context);
     getAndVerifySizeEstimate(resultSender, 0L);
   }
@@ -107,7 +109,8 @@ public class SizeExportLogsFunctionTest {
   public void withFunctionError_shouldThrow() throws Throwable {
     server.withProperties(config).startServer();
 
-    FunctionContext context = new FunctionContextImpl("functionId", null, resultSender);
+    FunctionContext context =
+        new FunctionContextImpl(server.getCache(), "functionId", null, resultSender);
     new SizeExportLogsFunction().execute(context);
     assertThatThrownBy(resultSender::getResults).isInstanceOf(NullPointerException.class);
   }
@@ -116,7 +119,8 @@ public class SizeExportLogsFunctionTest {
   public void sizeGreaterThanDiskAvailable_sendsErrorResult() throws Throwable {
     server.withProperties(config).startServer();
 
-    FunctionContext context = new FunctionContextImpl("functionId", nonFilteringArgs, resultSender);
+    FunctionContext context =
+        new FunctionContextImpl(server.getCache(), "functionId", nonFilteringArgs, resultSender);
     SizeExportLogsFunction testFunction = new SizeExportLogsFunction();
     SizeExportLogsFunction spyFunction = spy(testFunction);
     long fakeDiskAvailable = 1024;

http://git-wip-us.apache.org/repos/asf/geode/blob/d82a548f/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
index c694523..a8b498d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
@@ -113,7 +113,7 @@ public class LogExporterIntegrationTest {
     properties.setProperty(LOG_FILE, logsFile.toString());
     server.withProperties(properties).startServer();
 
-    ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp();
+    ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp(server.getCache());
   }
 
   @Test
@@ -124,7 +124,7 @@ public class LogExporterIntegrationTest {
     properties.setProperty(STATISTIC_ARCHIVE_FILE, "stats.gfs");
     server.withProperties(properties).startServer();
 
-    ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp();
+    ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp(server.getCache());
   }
 
   @Test
@@ -134,7 +134,7 @@ public class LogExporterIntegrationTest {
     properties.setProperty(STATISTIC_ARCHIVE_FILE, statsFile.toString());
     server.withProperties(properties).startServer();
 
-    ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp();
+    ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp(server.getCache());
   }
 
   @Test


Mime
View raw message