geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kh...@apache.org
Subject [geode] branch develop updated: GEODE_3299: Refactor Gfsh functions to acquire Cache from FunctionContex
Date Mon, 09 Oct 2017 21:17:38 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/develop by this push:
     new 59738f8  GEODE_3299: Refactor Gfsh functions to acquire Cache from FunctionContex
59738f8 is described below

commit 59738f8a34ebe2a59e7b4b6a3d583056ed76810f
Author: Ken Howe <khowe@pivotal.io>
AuthorDate: Fri Oct 6 10:09:30 2017 -0700

    GEODE_3299: Refactor Gfsh functions to acquire Cache from FunctionContex
    
    To simplify reviews, the changes required for this refactoring will
    be broken up into separate commitss.
    
    This commit is the first set of refactored Functions to get the Cache
    reference from the the FunctionContext parameter.
---
 .../internal/cli/functions/AlterRuntimeConfigFunction.java        | 7 +------
 .../management/internal/cli/functions/ChangeLogLevelFunction.java | 3 +--
 .../internal/cli/functions/ContinuousQueryFunction.java           | 7 +------
 .../internal/cli/functions/CreateAsyncEventQueueFunction.java     | 7 +------
 .../internal/cli/functions/CreateDefinedIndexesFunction.java      | 8 +-------
 .../internal/cli/functions/CreateDiskStoreFunction.java           | 7 +------
 .../management/internal/cli/functions/CreateIndexFunction.java    | 3 +--
 .../geode/management/internal/cli/functions/DeployFunction.java   | 8 +-------
 .../internal/cli/functions/DestroyDiskStoreFunction.java          | 7 +------
 .../management/internal/cli/functions/DestroyIndexFunction.java   | 3 +--
 .../management/internal/cli/functions/ExportConfigFunction.java   | 3 +--
 11 files changed, 11 insertions(+), 52 deletions(-)

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..ae0b756 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
@@ -15,7 +15,6 @@
 package org.apache.geode.management.internal.cli.functions;
 
 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.FunctionContext;
 import org.apache.geode.distributed.internal.DistributionConfig;
@@ -37,17 +36,13 @@ public class AlterRuntimeConfigFunction extends FunctionAdapter implements
Inter
 
   private static Logger logger = LogService.getLogger();
 
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   @Override
   public void execute(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();
 
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..87c806b 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
@@ -17,7 +17,6 @@ package org.apache.geode.management.internal.cli.functions;
 import static org.apache.geode.distributed.ConfigurationProperties.*;
 
 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;
@@ -49,7 +48,7 @@ public class ChangeLogLevelFunction implements Function, InternalEntity
{
 
   @Override
   public void execute(FunctionContext context) {
-    Cache cache = CacheFactory.getAnyInstance();
+    Cache cache = context.getCache();
     Map<String, String> result = new HashMap<String, String>();
     try {
       LogWriterLogger logwriterLogger = (LogWriterLogger) cache.getLogger();
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..f6ced99 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,7 +17,6 @@ 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.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.internal.InternalEntity;
@@ -37,15 +36,11 @@ public class ContinuousQueryFunction implements Function, InternalEntity
{
 
   public static final String ID = ContinuousQueryFunction.class.getName();
 
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   @Override
   public void execute(FunctionContext context) {
     try {
       String clientID = (String) context.getArguments();
-      InternalCache cache = getCache();
+      InternalCache cache = (InternalCache) context.getCache();
       if (cache.getCacheServers().size() > 0) {
         CacheServerImpl server = (CacheServerImpl) cache.getCacheServers().iterator().next();
         if (server != null) {
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..437e276 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,7 +23,6 @@ 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;
@@ -53,10 +52,6 @@ public class CreateAsyncEventQueueFunction extends FunctionAdapter implements
In
 
   private static final long serialVersionUID = 1L;
 
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   @SuppressWarnings("deprecation")
   @Override
   public void execute(FunctionContext context) {
@@ -66,7 +61,7 @@ public class CreateAsyncEventQueueFunction extends FunctionAdapter implements
In
     try {
       AsyncEventQueueFunctionArgs aeqArgs = (AsyncEventQueueFunctionArgs) context.getArguments();
 
-      InternalCache cache = getCache();
+      InternalCache cache = (InternalCache) context.getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
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 47cdb27..c54ee21 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
@@ -19,7 +19,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.query.Index;
@@ -39,7 +38,7 @@ public class CreateDefinedIndexesFunction extends FunctionAdapter implements
Int
     List<Index> indexes = null;
     Cache cache;
     try {
-      cache = CacheFactory.getAnyInstance();
+      cache = context.getCache();
       memberId = cache.getDistributedSystem().getDistributedMember().getId();
       QueryService queryService = cache.getQueryService();
       Set<IndexInfo> indexDefinitions = (Set<IndexInfo>) context.getArguments();
@@ -72,11 +71,6 @@ 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();
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..bbf4bf1 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
@@ -24,7 +24,6 @@ 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.FunctionContext;
@@ -41,10 +40,6 @@ public class CreateDiskStoreFunction extends FunctionAdapter implements
Internal
 
   private static final long serialVersionUID = 1L;
 
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   @Override
   public void execute(FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
@@ -54,7 +49,7 @@ public class CreateDiskStoreFunction extends FunctionAdapter implements
Internal
       final String diskStoreName = (String) args[0];
       final DiskStoreAttributes diskStoreAttrs = (DiskStoreAttributes) args[01];
 
-      InternalCache cache = getCache();
+      InternalCache cache = (InternalCache) context.getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
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..0e2695b 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,7 +15,6 @@
 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.FunctionContext;
 import org.apache.geode.cache.query.IndexExistsException;
@@ -43,7 +42,7 @@ public class CreateIndexFunction extends FunctionAdapter implements InternalEnti
     final 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();
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..c9ef06a 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,14 +21,12 @@ 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;
 
@@ -39,10 +37,6 @@ public class DeployFunction implements Function, InternalEntity {
 
   private static final long serialVersionUID = 1L;
 
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   @Override
   public void execute(FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
@@ -52,7 +46,7 @@ public class DeployFunction implements Function, InternalEntity {
       final Object[] args = (Object[]) context.getArguments();
       final String[] jarFilenames = (String[]) args[0];
       final byte[][] jarBytes = (byte[][]) args[1];
-      InternalCache cache = getCache();
+      InternalCache cache = (InternalCache) context.getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
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..ad98ed1 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,7 +18,6 @@ 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.FunctionContext;
@@ -39,10 +38,6 @@ public class DestroyDiskStoreFunction extends FunctionAdapter implements
Interna
 
   private static final long serialVersionUID = 1L;
 
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   @Override
   public void execute(FunctionContext context) {
     // Declared here so that it's available when returning a Throwable
@@ -52,7 +47,7 @@ public class DestroyDiskStoreFunction extends FunctionAdapter implements
Interna
       final Object[] args = (Object[]) context.getArguments();
       final String diskStoreName = (String) args[0];
 
-      InternalCache cache = getCache();
+      InternalCache cache = (InternalCache) context.getCache();
 
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
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..d76c2fb 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,7 +18,6 @@ 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.FunctionContext;
@@ -42,7 +41,7 @@ public class DestroyIndexFunction extends FunctionAdapter implements InternalEnt
     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();
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..61278a5 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;
@@ -47,7 +46,7 @@ public class ExportConfigFunction implements Function, InternalEntity {
     String memberId = "";
 
     try {
-      Cache cache = CacheFactory.getAnyInstance();
+      Cache cache = context.getCache();
       DistributedMember member = cache.getDistributedSystem().getDistributedMember();
 
       memberId = member.getId();

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

Mime
View raw message