geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject [28/51] [abbrv] geode git commit: GEODE-2928: get rid of the isGfshVM static variable
Date Wed, 14 Jun 2017 22:07:15 GMT
GEODE-2928: get rid of the isGfshVM static variable

* consolidate the availability indicators
* remove the isGfshVM and isGfshVM() method
* enhance the MultiStepCommand to include info on shellOnly commands to enhance command validation
* remove the SUPPORT_MULTIPLE_GFSH static flag and properly remove the gfsh instance at the end of each test


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

Branch: refs/heads/feature/GEM-1483
Commit: f85d216341f4887e80d428f68dc8dfd2824dda5f
Parents: d1db2f0
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Fri May 19 08:58:30 2017 -0700
Committer: Jinmei Liao <jiliao@pivotal.io>
Committed: Mon Jun 12 13:54:39 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/GfeConsoleReaderFactory.java | 11 ++--
 .../geode/management/cli/CliMetaData.java       |  4 +-
 .../geode/management/internal/cli/CliUtil.java  |  9 ---
 .../internal/cli/commands/ClientCommands.java   | 10 ----
 .../commands/CommandAvailabilityIndicator.java  | 63 ++++++++++++++++++++
 .../internal/cli/commands/ConfigCommands.java   | 10 ----
 .../CreateAlterDestroyRegionCommands.java       | 10 ----
 .../internal/cli/commands/DataCommands.java     | 19 +-----
 .../internal/cli/commands/DeployCommands.java   | 10 ----
 .../cli/commands/DiskStoreCommands.java         | 14 -----
 .../cli/commands/DurableClientCommands.java     | 26 +++-----
 ...xportImportClusterConfigurationCommands.java | 10 ----
 .../internal/cli/commands/FunctionCommands.java | 10 ----
 .../internal/cli/commands/IndexCommands.java    |  8 ---
 .../cli/commands/LauncherLifecycleCommands.java |  9 ---
 .../internal/cli/commands/MemberCommands.java   | 29 +++------
 .../cli/commands/MiscellaneousCommands.java     | 11 ----
 .../internal/cli/commands/PDXCommands.java      | 14 -----
 .../internal/cli/commands/QueueCommands.java    | 11 ----
 .../internal/cli/commands/RegionCommands.java   | 10 ----
 .../internal/cli/commands/ShellCommands.java    |  7 ---
 .../internal/cli/commands/StatusCommands.java   | 22 ++-----
 .../internal/cli/commands/WanCommands.java      | 52 ++++++----------
 .../cli/functions/DataCommandFunction.java      |  4 +-
 .../cli/multistep/CLIMultiStepHelper.java       | 21 ++-----
 .../cli/multistep/MultiStepCommand.java         |  4 ++
 .../cli/remote/RemoteExecutionStrategy.java     | 26 +++++++-
 .../internal/cli/result/AbstractResultData.java | 63 +++++++++-----------
 .../management/internal/cli/shell/Gfsh.java     | 11 +---
 .../cli/shell/GfshExecutionStrategy.java        |  2 +-
 .../geode/management/DataCommandMBeanTest.java  | 59 ++++++++++++++++++
 .../management/internal/cli/HeadlessGfsh.java   | 11 +---
 .../cli/commands/CliCommandTestBase.java        |  4 --
 .../cli/commands/MemberCommandsDUnitTest.java   |  9 ---
 .../cli/commands/ShowDeadlockDUnitTest.java     | 13 ----
 .../dunit/rules/GfshShellConnectionRule.java    |  3 -
 .../internal/cli/LuceneIndexCommands.java       | 10 +++-
 37 files changed, 243 insertions(+), 376 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/internal/GfeConsoleReaderFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/GfeConsoleReaderFactory.java b/geode-core/src/main/java/org/apache/geode/internal/GfeConsoleReaderFactory.java
index 120d625..8c5dba2 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/GfeConsoleReaderFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/GfeConsoleReaderFactory.java
@@ -15,12 +15,12 @@
 
 package org.apache.geode.internal;
 
-import java.io.Console;
-
-import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.LogWrapper;
+import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.cli.util.GfshConsoleReader;
 
+import java.io.Console;
+
 /**
  * Factory for Console Reader Utility.
  * 
@@ -39,13 +39,12 @@ public class GfeConsoleReaderFactory {
   public static GfeConsoleReader createConsoleReader() {
     GfeConsoleReader consoleReader = null;
 
-    if (CliUtil.isGfshVM()) {
+    if (Gfsh.getCurrentInstance() != null) {
       LogWrapper.getInstance().info("GfeConsoleReaderFactory.createConsoleReader(): isGfshVM");
       consoleReader = new GfshConsoleReader();
       LogWrapper.getInstance().info("GfeConsoleReaderFactory.createConsoleReader(): consoleReader: "
           + consoleReader + "=" + consoleReader.isSupported());
-    }
-    if (consoleReader == null) {
+    } else {
       consoleReader = new GfeConsoleReader();
     }
     return consoleReader;

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java b/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
index 2e6dc39..226086f 100644
--- a/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
+++ b/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
@@ -38,8 +38,8 @@ public @interface CliMetaData {
   public static final String ANNOTATION_NULL_VALUE = "__NULL__";
 
   /**
-   * Indicates that the command will only run in the gfsh shell and will not need the management
-   * service
+   * Indicates that the command will only run in the gfsh shell Gfsh ExecutionStrategy will use this
+   * flag to determine whether to invoke remote call or not.
    **/
   boolean shellOnly() default false;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
index 038e069..b3bdf9a 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
@@ -73,17 +73,8 @@ import java.util.zip.Inflater;
  * @since GemFire 7.0
  */
 public class CliUtil {
-
-  public static final String GFSHVM_IDENTIFIER = "gfsh";
-
-  public static boolean isGfshVM = Boolean.getBoolean(GFSHVM_IDENTIFIER);
-
   public static final FileFilter JAR_FILE_FILTER = new CustomFileFilter(".jar");
 
-  public static boolean isGfshVM() {
-    return isGfshVM;
-  }
-
   public static String cliDependenciesExist(boolean includeGfshDependencies) {
     String jarProductName = null;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java
index e619342..fe27b60 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java
@@ -37,7 +37,6 @@ import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
 import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
@@ -340,13 +339,4 @@ public class ClientCommands implements GfshCommand {
       }
     }
   }
-
-  @CliAvailabilityIndicator({CliStrings.LIST_CLIENTS, CliStrings.DESCRIBE_CLIENT})
-  public boolean clientCommandsAvailable() {
-    boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) { // in gfsh check if connected
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CommandAvailabilityIndicator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CommandAvailabilityIndicator.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CommandAvailabilityIndicator.java
new file mode 100644
index 0000000..59d7206
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CommandAvailabilityIndicator.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal.cli.commands;
+
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.shell.Gfsh;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+
+public class CommandAvailabilityIndicator implements CommandMarker {
+
+  @CliAvailabilityIndicator({CliStrings.LIST_CLIENTS, CliStrings.DESCRIBE_CLIENT,
+      CliStrings.DESCRIBE_CONFIG, CliStrings.EXPORT_CONFIG, CliStrings.ALTER_RUNTIME_CONFIG,
+      CliStrings.ALTER_REGION, CliStrings.CREATE_REGION, CliStrings.DESTROY_REGION,
+      CliStrings.REBALANCE, CliStrings.GET, CliStrings.PUT, CliStrings.REMOVE,
+      CliStrings.LOCATE_ENTRY, CliStrings.QUERY, CliStrings.IMPORT_DATA, CliStrings.EXPORT_DATA,
+      CliStrings.DEPLOY, CliStrings.UNDEPLOY, CliStrings.LIST_DEPLOYED,
+      CliStrings.BACKUP_DISK_STORE, CliStrings.COMPACT_DISK_STORE, CliStrings.DESCRIBE_DISK_STORE,
+      CliStrings.LIST_DISK_STORE, CliStrings.REVOKE_MISSING_DISK_STORE,
+      CliStrings.SHOW_MISSING_DISK_STORE, CliStrings.CREATE_DISK_STORE,
+      CliStrings.DESTROY_DISK_STORE, CliStrings.LIST_DURABLE_CQS, CliStrings.CLOSE_DURABLE_CLIENTS,
+      CliStrings.CLOSE_DURABLE_CQS, CliStrings.COUNT_DURABLE_CQ_EVENTS,
+      CliStrings.EXPORT_SHARED_CONFIG, CliStrings.IMPORT_SHARED_CONFIG, CliStrings.EXECUTE_FUNCTION,
+      CliStrings.DESTROY_FUNCTION, CliStrings.LIST_FUNCTION, CliStrings.LIST_INDEX,
+      CliStrings.CREATE_INDEX, CliStrings.DESTROY_INDEX, CliStrings.CREATE_DEFINED_INDEXES,
+      CliStrings.CLEAR_DEFINED_INDEXES, CliStrings.DEFINE_INDEX, CliStrings.LIST_MEMBER,
+      CliStrings.DESCRIBE_MEMBER, CliStrings.SHUTDOWN, CliStrings.GC, CliStrings.SHOW_DEADLOCK,
+      CliStrings.SHOW_METRICS, CliStrings.SHOW_LOG, CliStrings.EXPORT_STACKTRACE,
+      CliStrings.NETSTAT, CliStrings.EXPORT_LOGS, CliStrings.CHANGE_LOGLEVEL,
+      CliStrings.CONFIGURE_PDX, CliStrings.CREATE_ASYNC_EVENT_QUEUE,
+      CliStrings.LIST_ASYNC_EVENT_QUEUES, CliStrings.LIST_REGION, CliStrings.DESCRIBE_REGION,
+      CliStrings.STATUS_SHARED_CONFIG, CliStrings.CREATE_GATEWAYSENDER,
+      CliStrings.START_GATEWAYSENDER, CliStrings.PAUSE_GATEWAYSENDER,
+      CliStrings.RESUME_GATEWAYSENDER, CliStrings.STOP_GATEWAYSENDER,
+      CliStrings.CREATE_GATEWAYRECEIVER, CliStrings.START_GATEWAYRECEIVER,
+      CliStrings.STOP_GATEWAYRECEIVER, CliStrings.LIST_GATEWAY, CliStrings.STATUS_GATEWAYSENDER,
+      CliStrings.STATUS_GATEWAYRECEIVER, CliStrings.LOAD_BALANCE_GATEWAYSENDER,
+      CliStrings.DESTROY_GATEWAYSENDER})
+  public boolean clientCommandsAvailable() {
+    Gfsh gfsh = Gfsh.getCurrentInstance();
+
+    // command should always be available on the server
+    if (gfsh == null) {
+      return true;
+    }
+
+    // if in gfshVM, only when gfsh is connected and ready
+    return gfsh.isConnectedAndReady();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
index bc9c05b..48a8d7a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
@@ -437,16 +437,6 @@ public class ConfigCommands implements GfshCommand {
     }
   }
 
-  @CliAvailabilityIndicator({CliStrings.DESCRIBE_CONFIG, CliStrings.EXPORT_CONFIG,
-      CliStrings.ALTER_RUNTIME_CONFIG})
-  public boolean configCommandsAvailable() {
-    boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) { // in gfsh check if connected
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
-
   /**
    * Interceptor used by gfsh to intercept execution of export config command at "shell".
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/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 270972b..b2f1d56 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
@@ -1122,14 +1122,4 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
     }
     return foundMembers;
   }
-
-  @CliAvailabilityIndicator({CliStrings.ALTER_REGION, CliStrings.CREATE_REGION,
-      CliStrings.DESTROY_REGION})
-  public boolean isRegionCommandAvailable() {
-    boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) { // in gfsh check if connected //TODO: make this better
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
index 887470d..d004b38 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
@@ -19,7 +19,6 @@ import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.CacheClosedException;
-import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.control.RebalanceFactory;
@@ -56,7 +55,6 @@ import org.apache.geode.management.internal.cli.result.CompositeResultData;
 import org.apache.geode.management.internal.cli.result.ErrorResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
@@ -1100,7 +1098,7 @@ public class DataCommands implements GfshCommand {
   }
 
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DATA, CliStrings.TOPIC_GEODE_REGION})
-  @MultiStepCommand
+  @MultiStepCommand(shellOnlyStep = {"ALL"})
   @CliCommand(value = {CliStrings.QUERY}, help = CliStrings.QUERY__HELP)
   public Object query(
       @CliOption(key = CliStrings.QUERY__QUERY, help = CliStrings.QUERY__QUERY__HELP,
@@ -1110,10 +1108,6 @@ public class DataCommands implements GfshCommand {
       @CliOption(key = CliStrings.QUERY__INTERACTIVE, help = CliStrings.QUERY__INTERACTIVE__HELP,
           unspecifiedDefaultValue = "true") final boolean interactive) {
 
-    if (!CliUtil.isGfshVM() && stepName.equals(CliStrings.QUERY__STEPNAME__DEFAULTVALUE)) {
-      return ResultBuilder.createInfoResult(CliStrings.QUERY__MSG__NOT_SUPPORTED_ON_MEMBERS);
-    }
-
     Object[] arguments = new Object[] {query, stepName, interactive};
     CLIStep exec = new SelectExecStep(arguments);
     CLIStep display = new DataCommandFunction.SelectDisplayStep(arguments);
@@ -1123,17 +1117,6 @@ public class DataCommands implements GfshCommand {
     return CLIMultiStepHelper.chooseStep(steps, stepName);
   }
 
-  @CliAvailabilityIndicator({CliStrings.REBALANCE, CliStrings.GET, CliStrings.PUT,
-      CliStrings.REMOVE, CliStrings.LOCATE_ENTRY, CliStrings.QUERY, CliStrings.IMPORT_DATA,
-      CliStrings.EXPORT_DATA})
-  public boolean dataCommandsAvailable() {
-    boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) { // in gfsh check if connected
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
-
   private static class MemberPRInfo {
     ArrayList<DistributedMember> dsMemberList;
     public String region;

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
index 8511de8..99216bf 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
@@ -40,7 +40,6 @@ import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.NotAuthorizedException;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
@@ -275,15 +274,6 @@ public class DeployCommands implements GfshCommand {
     }
   }
 
-  @CliAvailabilityIndicator({CliStrings.DEPLOY, CliStrings.UNDEPLOY, CliStrings.LIST_DEPLOYED})
-  public boolean isConnected() {
-    if (!CliUtil.isGfshVM()) {
-      return true;
-    }
-
-    return getGfsh() != null && getGfsh().isConnectedAndReady();
-  }
-
   /**
    * Interceptor used by gfsh to intercept execution of deploy command at "shell".
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
index 16124aa..ef2c3dd 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
@@ -1458,18 +1458,4 @@ public class DiskStoreCommands implements GfshCommand {
     erd.addLine(message);
     return ResultBuilder.buildResult(erd);
   }
-
-  @CliAvailabilityIndicator({CliStrings.BACKUP_DISK_STORE, CliStrings.COMPACT_DISK_STORE,
-      CliStrings.DESCRIBE_DISK_STORE, CliStrings.LIST_DISK_STORE,
-      CliStrings.REVOKE_MISSING_DISK_STORE, CliStrings.SHOW_MISSING_DISK_STORE,
-      CliStrings.CREATE_DISK_STORE, CliStrings.DESTROY_DISK_STORE})
-  public boolean diskStoreCommandsAvailable() {
-    // these disk store commands are always available in GemFire
-    return (!CliUtil.isGfshVM() || (getGfsh() != null && getGfsh().isConnectedAndReady()));
-  }
-
-  @CliAvailabilityIndicator({CliStrings.DESCRIBE_OFFLINE_DISK_STORE})
-  public boolean offlineDiskStoreCommandsAvailable() {
-    return true;
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java
index 6441f20..ef744d1 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java
@@ -14,13 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.management.cli.CliMetaData;
@@ -43,11 +36,16 @@ import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
 /**
  * The DurableClientCommands class encapsulates all GemFire shell (Gfsh) commands related to durable
  * clients and cqs defined in GemFire.
@@ -416,15 +414,5 @@ public class DurableClientCommands implements GfshCommand {
       }
     }
   }
-
-  @CliAvailabilityIndicator({CliStrings.LIST_DURABLE_CQS, CliStrings.CLOSE_DURABLE_CLIENTS,
-      CliStrings.CLOSE_DURABLE_CQS, CliStrings.COUNT_DURABLE_CQ_EVENTS})
-  public boolean durableCommandsAvailable() {
-    boolean isAvailable = true;
-    if (CliUtil.isGfshVM()) {
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
 }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
index 9d263d1..83eddee 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
@@ -45,7 +45,6 @@ import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
 import org.apache.logging.log4j.Logger;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
@@ -213,15 +212,6 @@ public class ExportImportClusterConfigurationCommands implements GfshCommand {
     return results.get(0);
   }
 
-  @CliAvailabilityIndicator({CliStrings.EXPORT_SHARED_CONFIG, CliStrings.IMPORT_SHARED_CONFIG})
-  public boolean sharedConfigCommandsAvailable() {
-    boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) { // in gfsh check if connected
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
-
   /**
    * Interceptor used by gfsh to intercept execution of export shared config command at "shell".
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
index 2774584..b0193af 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
@@ -584,14 +584,4 @@ public class FunctionCommands implements GfshCommand {
           "Exception while attempting to list functions: " + th.getMessage());
     }
   }
-
-  @CliAvailabilityIndicator({CliStrings.EXECUTE_FUNCTION, CliStrings.DESTROY_FUNCTION,
-      CliStrings.LIST_FUNCTION})
-  public boolean functionCommandsAvailable() {
-    boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) { // in gfsh check if connected
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
index 5a4a3d7..c61de37 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
@@ -47,7 +47,6 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
@@ -636,13 +635,6 @@ public class IndexCommands implements GfshCommand {
     return ResultBuilder.buildResult(infoResult);
   }
 
-  @CliAvailabilityIndicator({CliStrings.LIST_INDEX, CliStrings.CREATE_INDEX,
-      CliStrings.DESTROY_INDEX, CliStrings.CREATE_DEFINED_INDEXES, CliStrings.CLEAR_DEFINED_INDEXES,
-      CliStrings.DEFINE_INDEX})
-  public boolean indexCommandsAvailable() {
-    return !CliUtil.isGfshVM() || getGfsh() != null && getGfsh().isConnectedAndReady();
-  }
-
   protected static class IndexStatisticsDetailsAdapter {
 
     private final IndexStatisticsDetails indexStatisticsDetails;

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
index 45fbf1b..bc506cf 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
@@ -90,7 +90,6 @@ import org.apache.geode.management.internal.cli.util.ThreePhraseGenerator;
 import org.apache.geode.management.internal.configuration.utils.ClusterConfigurationStatusRetriever;
 import org.apache.geode.management.internal.security.ResourceConstants;
 import org.apache.geode.security.AuthenticationFailedException;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
@@ -1378,14 +1377,6 @@ public class LauncherLifecycleCommands implements GfshCommand {
     return resourceFile;
   }
 
-  @CliAvailabilityIndicator({CliStrings.START_LOCATOR, CliStrings.STOP_LOCATOR,
-      CliStrings.STATUS_LOCATOR, CliStrings.START_SERVER, CliStrings.STOP_SERVER,
-      CliStrings.STATUS_SERVER, CliStrings.START_MANAGER, CliStrings.START_PULSE,
-      CliStrings.START_VSD, CliStrings.START_DATABROWSER})
-  public boolean launcherCommandsAvailable() {
-    return true;
-  }
-
   protected static class LauncherSignalListener implements SignalListener {
 
     private volatile boolean signaled = false;

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MemberCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MemberCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MemberCommands.java
index 695718a..74264c3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MemberCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MemberCommands.java
@@ -14,17 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.FunctionInvocationTargetException;
@@ -48,6 +37,15 @@ import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
 
 /**
  * @since GemFire 7.0
@@ -196,13 +194,4 @@ public class MemberCommands implements GfshCommand {
     return result;
   }
 
-  @CliAvailabilityIndicator({CliStrings.LIST_MEMBER, CliStrings.DESCRIBE_MEMBER})
-  public boolean isListMemberAvailable() {
-    boolean isAvailable = true;
-    if (CliUtil.isGfshVM()) {
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/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 9754d7d..2c3d766 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
@@ -1938,17 +1938,6 @@ public class MiscellaneousCommands implements GfshCommand {
     }
   }
 
-  @CliAvailabilityIndicator({CliStrings.SHUTDOWN, CliStrings.GC, CliStrings.SHOW_DEADLOCK,
-      CliStrings.SHOW_METRICS, CliStrings.SHOW_LOG, CliStrings.EXPORT_STACKTRACE,
-      CliStrings.NETSTAT, CliStrings.EXPORT_LOGS, CliStrings.CHANGE_LOGLEVEL})
-  public boolean shutdownCommandAvailable() {
-    boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) { // in gfsh check if connected
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
-
   private Set<String> getSetDifference(Set<String> set1, Set<String> set2) {
     Set<String> setDifference = new HashSet<String>();
     for (String element : set1) {

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
index 9f1290d..9bfd47b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
@@ -32,7 +32,6 @@ import org.apache.geode.pdx.internal.EnumInfo;
 import org.apache.geode.pdx.internal.PdxType;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
@@ -152,14 +151,6 @@ public class PDXCommands implements GfshCommand {
     return result;
   }
 
-  @CliAvailabilityIndicator({CliStrings.CONFIGURE_PDX})
-  public boolean isRegionCommandAvailable() {
-    if (!CliUtil.isGfshVM()) {
-      return true;
-    }
-    return (getGfsh() != null && getGfsh().isConnectedAndReady());
-  }
-
   @CliCommand(value = CliStrings.PDX_RENAME, help = CliStrings.PDX_RENAME__HELP)
   @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
   @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
@@ -208,9 +199,4 @@ public class PDXCommands implements GfshCommand {
     }
 
   }
-
-  @CliAvailabilityIndicator({CliStrings.PDX_RENAME})
-  public boolean pdxRenameCommandsAvailable() {
-    return true;
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
index d3c2635..0f407e7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
@@ -35,7 +35,6 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
@@ -256,14 +255,4 @@ public class QueueCommands implements GfshCommand {
               new Object[] {th.getMessage()}));
     }
   }
-
-  @CliAvailabilityIndicator({CliStrings.CREATE_ASYNC_EVENT_QUEUE,
-      CliStrings.LIST_ASYNC_EVENT_QUEUES})
-  public boolean queueCommandsAvailable() {
-    boolean isAvailable = true;
-    if (CliUtil.isGfshVM()) {
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java
index 2009dcc..260230b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java
@@ -489,14 +489,4 @@ public class RegionCommands implements GfshCommand {
       }
     }
   }
-
-  @CliAvailabilityIndicator({CliStrings.LIST_REGION, CliStrings.DESCRIBE_REGION})
-  public boolean isRegionCommandAvailable() {
-    boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) { // in gfsh check if connected //TODO : make this better
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
index efd10d2..e37d1ba 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
@@ -55,7 +55,6 @@ import org.apache.geode.management.internal.web.shell.HttpOperationInvoker;
 import org.apache.geode.management.internal.web.shell.RestHttpOperationInvoker;
 import org.apache.geode.security.AuthenticationFailedException;
 import org.springframework.shell.core.ExitShellRequest;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
@@ -1037,10 +1036,4 @@ public class ShellCommands implements GfshCommand {
     }
     return result;
   }
-
-  @CliAvailabilityIndicator({CliStrings.CONNECT, CliStrings.DISCONNECT,
-      CliStrings.DESCRIBE_CONNECTION})
-  public boolean isAvailable() {
-    return true;
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java
index fffb964..0b0b78b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StatusCommands.java
@@ -14,14 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
@@ -39,6 +31,12 @@ import org.apache.geode.management.internal.configuration.domain.SharedConfigura
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliCommand;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 public class StatusCommands implements GfshCommand {
   static final FetchSharedConfigurationStatusFunction fetchSharedConfigStatusFunction =
@@ -81,12 +79,4 @@ public class StatusCommands implements GfshCommand {
     }
     return table;
   }
-
-  @CliAvailabilityIndicator({CliStrings.STATUS_SHARED_CONFIG})
-  public boolean isConnected() {
-    if (!CliUtil.isGfshVM()) {
-      return true;
-    }
-    return (getGfsh() != null && getGfsh().isConnectedAndReady());
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
index 28686ce..ad3d22c 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
@@ -14,27 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.management.ObjectName;
-
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
@@ -65,6 +44,24 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.management.ObjectName;
 
 public class WanCommands implements GfshCommand {
 
@@ -1129,19 +1126,6 @@ public class WanCommands implements GfshCommand {
     resultData.accumulate("Message", message);
   }
 
-  @CliAvailabilityIndicator({CliStrings.CREATE_GATEWAYSENDER, CliStrings.START_GATEWAYSENDER,
-      CliStrings.PAUSE_GATEWAYSENDER, CliStrings.RESUME_GATEWAYSENDER,
-      CliStrings.STOP_GATEWAYSENDER, CliStrings.CREATE_GATEWAYRECEIVER,
-      CliStrings.START_GATEWAYRECEIVER, CliStrings.STOP_GATEWAYRECEIVER, CliStrings.LIST_GATEWAY,
-      CliStrings.STATUS_GATEWAYSENDER, CliStrings.STATUS_GATEWAYRECEIVER,
-      CliStrings.LOAD_BALANCE_GATEWAYSENDER, CliStrings.DESTROY_GATEWAYSENDER})
-  public boolean isWanCommandsAvailable() {
-    boolean isAvailable = true; // always available on server
-    if (CliUtil.isGfshVM()) {
-      isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
-    }
-    return isAvailable;
-  }
 
   private Result handleCommandResultException(CommandResultException crex) {
     Result result = null;

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
index 20e2701..0efe074 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
@@ -47,7 +47,6 @@ import org.apache.geode.internal.cache.PartitionedRegion;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.commands.DataCommands;
 import org.apache.geode.management.internal.cli.domain.DataCommandRequest;
 import org.apache.geode.management.internal.cli.domain.DataCommandResult;
@@ -125,7 +124,6 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
   @Override
   public void execute(FunctionContext functionContext) {
     try {
-      InternalCache cache = getCache();
       DataCommandRequest request = (DataCommandRequest) functionContext.getArguments();
       if (logger.isDebugEnabled()) {
         logger.debug("Executing function : \n{}\n on member {}", request,
@@ -1041,7 +1039,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
   public static int getPageSize() {
     int pageSize = -1;
     Map<String, String> session;
-    if (CliUtil.isGfshVM()) {
+    if (Gfsh.getCurrentInstance() != null) {
       session = Gfsh.getCurrentInstance().getEnv();
     } else {
       session = CommandExecutionContext.getShellEnv();

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper.java
index d53261d..4eeb227 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper.java
@@ -17,11 +17,9 @@ package org.apache.geode.management.internal.cli.multistep;
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.CommandRequest;
 import org.apache.geode.management.internal.cli.GfshParseResult;
 import org.apache.geode.management.internal.cli.LogWrapper;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.json.GfJsonException;
 import org.apache.geode.management.internal.cli.json.GfJsonObject;
 import org.apache.geode.management.internal.cli.remote.CommandExecutionContext;
@@ -56,7 +54,8 @@ public class CLIMultiStepHelper {
   public static final String STEP_ARGS = "stepArgs";
   public static final int DEFAULT_PAGE_SIZE = 20;
 
-  public static Result execCLISteps(LogWrapper logWrapper, Gfsh shell, ParseResult parseResult) {
+  public static Result execCLISteps(MultiStepCommand msc, LogWrapper logWrapper, Gfsh shell,
+      ParseResult parseResult) {
     CLIStep[] steps = (CLIStep[]) ReflectionUtils.invokeMethod(parseResult.getMethod(),
         parseResult.getInstance(), parseResult.getArguments());
     if (steps != null) {
@@ -117,7 +116,7 @@ public class CLIMultiStepHelper {
             CommandRequest commandRequest = new CommandRequest(gfshParseResult, shell.getEnv());
             commandRequest
                 .setCustomInput(changeStepName(gfshParseResult.getUserInput(), nextStep.getName()));
-            commandRequest.getCustomParameters().put(CliStrings.QUERY__STEPNAME,
+            commandRequest.getCustomParameters().put(MultiStepCommand.STEP_PARAMETER_NAME,
                 nextStep.getName());
 
             String json = (String) shell.getOperationInvoker().processCommand(commandRequest);
@@ -127,11 +126,6 @@ public class CLIMultiStepHelper {
             throw new IllegalArgumentException("Command Configuration/Definition error.");
           }
         } else {
-          try {
-            throw new Exception();
-          } catch (Exception ex) {
-            ex.printStackTrace();
-          }
           throw new IllegalStateException(
               "Can't execute a remote command without connection. Use 'connect' first to connect.");
         }
@@ -208,7 +202,7 @@ public class CLIMultiStepHelper {
 
   public static GfJsonObject getStepArgs() {
     Map<String, String> args = null;
-    if (CliUtil.isGfshVM) {
+    if (Gfsh.getCurrentInstance() != null) {
       args = Gfsh.getCurrentInstance().getEnv();
     } else {
       args = CommandExecutionContext.getShellEnv();
@@ -227,13 +221,6 @@ public class CLIMultiStepHelper {
     return object;
   }
 
-  public static Result createSimpleStepResult(String nextStep) {
-    CompositeResultData result = ResultBuilder.createCompositeResultData();
-    SectionResultData section = result.addSection(STEP_SECTION);
-    section.addData(NEXT_STEP_NAME, nextStep);
-    return ResultBuilder.buildResult(result);
-  }
-
   public static Object chooseStep(CLIStep[] steps, String stepName) {
     if ("ALL".equals(stepName)) {
       return steps;

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/MultiStepCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/MultiStepCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/MultiStepCommand.java
index 6708726..75925f7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/MultiStepCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/MultiStepCommand.java
@@ -27,5 +27,9 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.METHOD)
 public @interface MultiStepCommand {
+  public static String STEP_PARAMETER_NAME = "step-name";
 
+  String[] shellOnlyStep();
+
+  String stepParameterName() default STEP_PARAMETER_NAME;
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java
index fa0f3b2..89cb9ad 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java
@@ -14,6 +14,7 @@
  */
 package org.apache.geode.management.internal.cli.remote;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.cli.CliMetaData;
@@ -22,6 +23,7 @@ import org.apache.geode.management.cli.Result.Status;
 import org.apache.geode.management.internal.cli.CliAroundInterceptor;
 import org.apache.geode.management.internal.cli.GfshParseResult;
 import org.apache.geode.management.internal.cli.LogWrapper;
+import org.apache.geode.management.internal.cli.multistep.MultiStepCommand;
 import org.apache.geode.management.internal.cli.result.FileResult;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.springframework.shell.event.ParseResult;
@@ -29,6 +31,7 @@ import org.springframework.util.Assert;
 import org.springframework.util.ReflectionUtils;
 
 import java.lang.reflect.Method;
+import java.util.Arrays;
 
 /**
  * 
@@ -54,7 +57,7 @@ public class RemoteExecutionStrategy {
 
       Method method = gfshParseResult.getMethod();
 
-      if (!isShellOnly(method)) {
+      if (!isShellOnly(method, gfshParseResult)) {
         Boolean fromShell = CommandExecutionContext.isShellRequest();
         boolean sentFromShell = fromShell != null && fromShell.booleanValue();
         String interceptorClass = getInterceptor(gfshParseResult.getMethod());
@@ -120,9 +123,26 @@ public class RemoteExecutionStrategy {
     return result;
   }
 
-  private boolean isShellOnly(Method method) {
+  private boolean isShellOnly(Method method, GfshParseResult result) {
     CliMetaData cliMetadata = method.getAnnotation(CliMetaData.class);
-    return cliMetadata != null && cliMetadata.shellOnly();
+    if (cliMetadata == null) {
+      return false;
+    }
+    if (cliMetadata.shellOnly()) {
+      return true;
+    }
+    MultiStepCommand stepCommand = method.getAnnotation(MultiStepCommand.class);
+    if (stepCommand == null) {
+      return false;
+    }
+    String step = result.getParamValue(MultiStepCommand.STEP_PARAMETER_NAME);
+    if (StringUtils.isBlank(step)) {
+      return false;
+    }
+    if (Arrays.asList(stepCommand.shellOnlyStep()).contains(step)) {
+      return true;
+    }
+    return false;
   }
 
   private String getInterceptor(Method method) {

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
index f453ec6..0d1d91b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
@@ -14,18 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.result;
 
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.text.MessageFormat;
-import java.util.Base64;
-import java.util.zip.DataFormatException;
-
 import org.apache.geode.management.cli.Result.Status;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.CliUtil.DeflaterInflaterData;
@@ -35,6 +23,15 @@ import org.apache.geode.management.internal.cli.json.GfJsonException;
 import org.apache.geode.management.internal.cli.json.GfJsonObject;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.Base64;
+import java.util.zip.DataFormatException;
+
 /**
  * 
  * 
@@ -234,7 +231,6 @@ public abstract class AbstractResultData implements ResultData {
       byte[] byteArray = Base64.getDecoder().decode(fileDataString);
       byte[] uncompressBytes = CliUtil.uncompressBytes(byteArray, fileDataLength).getData();
 
-      boolean isGfshVM = CliUtil.isGfshVM();
       File fileToDumpData = new File(fileName);
       if (!fileToDumpData.isAbsolute()) {
         if (directory == null || directory.isEmpty()) {
@@ -247,21 +243,19 @@ public abstract class AbstractResultData implements ResultData {
       if (parentDirectory != null) {
         parentDirectory.mkdirs();
       }
+      Gfsh gfsh = Gfsh.getCurrentInstance();
       if (fileToDumpData.exists()) {
         String fileExistsMessage =
             CliStrings.format(CliStrings.ABSTRACTRESULTDATA__MSG__FILE_WITH_NAME_0_EXISTS_IN_1,
                 new Object[] {fileName, fileToDumpData.getParent(), options});
-        if (isGfshVM) {
-          Gfsh gfsh = Gfsh.getCurrentInstance();
-          if (gfsh != null && !gfsh.isQuietMode() && !overwriteAllExisting) {
-            fileExistsMessage = fileExistsMessage + " Overwrite? " + options + " : ";
-            String interaction = gfsh.interact(fileExistsMessage);
-            if ("a".equalsIgnoreCase(interaction.trim())) {
-              overwriteAllExisting = true;
-            } else if (!"y".equalsIgnoreCase(interaction.trim())) {
-              // do not save file & continue
-              continue BYTEARRAY_LOOP;
-            }
+        if (gfsh != null && !gfsh.isQuietMode() && !overwriteAllExisting) {
+          fileExistsMessage = fileExistsMessage + " Overwrite? " + options + " : ";
+          String interaction = gfsh.interact(fileExistsMessage);
+          if ("a".equalsIgnoreCase(interaction.trim())) {
+            overwriteAllExisting = true;
+          } else if (!"y".equalsIgnoreCase(interaction.trim())) {
+            // do not save file & continue
+            continue BYTEARRAY_LOOP;
           }
         } else {
           throw new IOException(fileExistsMessage);
@@ -269,18 +263,17 @@ public abstract class AbstractResultData implements ResultData {
       } else if (!parentDirectory.exists()) {
         handleCondition(CliStrings.format(
             CliStrings.ABSTRACTRESULTDATA__MSG__PARENT_DIRECTORY_OF_0_DOES_NOT_EXIST,
-            fileToDumpData.getAbsolutePath()), isGfshVM);
+            fileToDumpData.getAbsolutePath()));
         return;
       } else if (!parentDirectory.canWrite()) {
         handleCondition(CliStrings.format(
             CliStrings.ABSTRACTRESULTDATA__MSG__PARENT_DIRECTORY_OF_0_IS_NOT_WRITABLE,
-            fileToDumpData.getAbsolutePath()), isGfshVM);
+            fileToDumpData.getAbsolutePath()));
         return;
       } else if (!parentDirectory.isDirectory()) {
         handleCondition(
             CliStrings.format(CliStrings.ABSTRACTRESULTDATA__MSG__PARENT_OF_0_IS_NOT_DIRECTORY,
-                fileToDumpData.getAbsolutePath()),
-            isGfshVM);
+                fileToDumpData.getAbsolutePath()));
         return;
       }
       if (fileType == FILE_TYPE_TEXT) {
@@ -298,7 +291,7 @@ public abstract class AbstractResultData implements ResultData {
       }
       // System.out.println("fileMessage :: "+fileMessage);
       if (fileMessage != null && !fileMessage.isEmpty()) {
-        if (isGfshVM) {
+        if (gfsh != null) {
           Gfsh.println(
               MessageFormat.format(fileMessage, new Object[] {fileToDumpData.getAbsolutePath()}));
         }
@@ -308,13 +301,11 @@ public abstract class AbstractResultData implements ResultData {
   }
 
   // TODO - Abhishek : prepare common utility for this & ANSI Styling
-  static void handleCondition(String message, boolean isGfshVM) throws IOException {
-    if (isGfshVM) {
-      Gfsh gfsh = Gfsh.getCurrentInstance();
-      // null check required in GfshVM too to avoid test issues
-      if (gfsh != null && !gfsh.isQuietMode()) {
-        gfsh.logWarning(message, null);
-      }
+  static void handleCondition(String message) throws IOException {
+    Gfsh gfsh = Gfsh.getCurrentInstance();
+    // null check required in GfshVM too to avoid test issues
+    if (gfsh != null && !gfsh.isQuietMode()) {
+      gfsh.logWarning(message, null);
     } else {
       throw new IOException(message);
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.java
index 74387d6..8ab7c93 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.java
@@ -131,7 +131,6 @@ public class Gfsh extends JLineShell {
   private static final String DEFAULT_SECONDARY_PROMPT = ">";
   private static final int DEFAULT_HEIGHT = 100;
   private static final Object INSTANCE_LOCK = new Object();
-  public static boolean SUPPORT_MUTLIPLESHELL = false;
 
   // private static final String ANIMATION_SLOT = "A"; //see 46072
   protected static PrintStream gfshout = System.out;
@@ -231,8 +230,7 @@ public class Gfsh extends JLineShell {
     try {
       ClassUtils.forName("sun.misc.Signal", new SunAPINotFoundException(
           "WARNING!!! Not running a Sun JVM.  Could not find the sun.misc.Signal class; Signal handling disabled."));
-      signalHandler = (CliUtil.isGfshVM() ? new GfshSignalHandler()
-          : new AbstractSignalNotificationHandler() {});
+      signalHandler = new GfshSignalHandler();
     } catch (SunAPINotFoundException e) {
       signalHandler = new AbstractSignalNotificationHandler() {};
       this.gfshFileLogger.warning(e.getMessage());
@@ -347,11 +345,7 @@ public class Gfsh extends JLineShell {
   }
 
   public static Gfsh getCurrentInstance() {
-    if (!SUPPORT_MUTLIPLESHELL) {
-      return instance;
-    } else {
-      return gfshThreadLocal.get();
-    }
+    return instance;
   }
 
   private static String extractKey(String input) {
@@ -517,6 +511,7 @@ public class Gfsh extends JLineShell {
     if (operationInvoker != null && operationInvoker.isConnected()) {
       operationInvoker.stop();
     }
+    instance = null;
   }
 
   public void waitForComplete() throws InterruptedException {

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
index 2b39bed..1cbdb15 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
@@ -79,7 +79,7 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
       // Check if it's a multi-step command
       MultiStepCommand cmd = method.getAnnotation(MultiStepCommand.class);
       if (cmd != null) {
-        return execCLISteps(logWrapper, shell, parseResult);
+        return execCLISteps(cmd, logWrapper, shell, parseResult);
       }
 
       // check if it's a shell only command

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/test/java/org/apache/geode/management/DataCommandMBeanTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/DataCommandMBeanTest.java b/geode-core/src/test/java/org/apache/geode/management/DataCommandMBeanTest.java
new file mode 100644
index 0000000..e5d6ce8
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/DataCommandMBeanTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(IntegrationTest.class)
+public class DataCommandMBeanTest {
+  private MemberMXBean bean;
+
+  @ClassRule
+  public static ServerStarterRule server =
+      new ServerStarterRule().withJMXManager().withRegion(RegionShortcut.REPLICATE, "testRegion");
+
+  @Rule
+  public MBeanServerConnectionRule mBeanConnector = new MBeanServerConnectionRule();
+
+  @Before
+  public void before() throws Exception {
+    mBeanConnector.connect(server.getJmxPort());
+    bean = mBeanConnector.getProxyMBean(MemberMXBean.class);
+  }
+
+  @Test
+  public void testQueryWithStepAll() throws Exception {
+    String result = bean.processCommand("query --query='SELECT * FROM /testRegion'");
+    assertThat(result).contains("Only Remote command can be executed");
+  }
+
+  @Test
+  public void testQueryWithStepExec() throws Exception {
+    String result =
+        bean.processCommand("query --query='SELECT * FROM /testRegion' --step-name=SELECT_EXEC");
+    assertThat(result).contains("Result     : true");
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
index 9ea22da..f636c89 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
@@ -84,7 +84,6 @@ public class HeadlessGfsh implements ResultHandler {
     });
 
     this.shell.start();
-    this.shell.setThreadLocalInstance();
 
     try {
       shellStarted.await();
@@ -195,10 +194,6 @@ public class HeadlessGfsh implements ResultHandler {
       this.handler = handler;
     }
 
-    public void setThreadLocalInstance() {
-      gfshThreadLocal.set(this);
-    }
-
     protected void handleExecutionResult(Object result) {
       if (!result.equals(ERROR_RESULT)) {
         super.handleExecutionResult(result);
@@ -222,6 +217,7 @@ public class HeadlessGfsh implements ResultHandler {
     }
 
     public void stop() {
+      super.stop();
       stopCalledThroughAPI = true;
     }
 
@@ -317,11 +313,6 @@ public class HeadlessGfsh implements ResultHandler {
    * HeadlessGfshConfig for tests. Taken from TestableGfsh
    */
   static class HeadlessGfshConfig extends GfshConfig {
-    {
-      // set vm as a gfsh vm
-      CliUtil.isGfshVM = true;
-    }
-
     private File parentDir;
     private String fileNamePrefix;
     private String name;

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
index bd5083c..d68bfae 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
@@ -26,12 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.CommandManager;
 import org.apache.geode.management.internal.cli.HeadlessGfsh;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.Host;
@@ -121,7 +119,6 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
   @Override
   public final void preTearDownCacheTestCase() throws Exception {
     preTearDownCliCommandTestBase();
-    CliUtil.isGfshVM = false;
     destroyDefaultSetup();
   }
 
@@ -300,7 +297,6 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
    */
   private HeadlessGfsh createShell() {
     try {
-      Gfsh.SUPPORT_MUTLIPLESHELL = true;
       String shellId = getClass().getSimpleName() + "_" + getName();
       HeadlessGfsh shell = new HeadlessGfsh(shellId, 30, this.gfshDir);
       // Added to avoid trimming of the columns

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java
index 22502c3..fb8341a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java
@@ -43,7 +43,6 @@ import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.cli.Result.Status;
-import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.remote.CommandProcessor;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
@@ -85,14 +84,6 @@ public class MemberCommandsDUnitTest extends JUnit4CacheTestCase {
       new ProvideSystemProperty(CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY, "true");
 
   @Override
-  public final void postSetUp() throws Exception {
-    // This test does not require an actual Gfsh connection to work, however when run as part of a
-    // suite, prior tests
-    // may mess up the environment causing this test to fail. Setting this prevents false failures.
-    CliUtil.isGfshVM = false;
-  }
-
-  @Override
   public final void postTearDownCacheTestCase() throws Exception {
     disconnectFromDS();
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
index e7ae38e..8b5c80e 100755
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
@@ -27,7 +27,6 @@ import org.apache.geode.distributed.internal.membership.InternalDistributedMembe
 import org.apache.geode.management.cli.CommandStatement;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.cli.Result.Status;
-import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.remote.CommandProcessor;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
@@ -55,9 +54,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
-
 /**
  * This DUnit tests uses same code as GemFireDeadlockDetectorDUnitTest and uses the command
  * processor for executing the "show deadlock" command
@@ -100,17 +96,8 @@ public class ShowDeadlockDUnitTest extends JUnit4CacheTestCase {
   }
 
   @Override
-  public final void postSetUp() throws Exception {
-    // This test does not require an actual Gfsh connection to work, however when run as part of a
-    // suite, prior tests
-    // may mess up the environment causing this test to fail. Setting this prevents false failures.
-    CliUtil.isGfshVM = false;
-  }
-
-  @Override
   public final void preTearDownCacheTestCase() throws Exception {
     invokeInEveryVM(() -> stuckThreads.forEach(Thread::interrupt));
-    CliUtil.isGfshVM = true;
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index bc709db..872553e 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.HeadlessGfsh;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.CommandResult;
@@ -128,7 +127,6 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
   }
 
   public void connect(int port, PortType type, String... options) throws Exception {
-    CliUtil.isGfshVM = true;
     if (gfsh == null) {
       this.gfsh = new HeadlessGfsh(getClass().getName(), 30,
           temporaryFolder.newFolder("gfsh_files").getAbsolutePath());
@@ -194,7 +192,6 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
     gfsh.executeCommand("exit");
     gfsh.terminate();
     gfsh = null;
-    CliUtil.isGfshVM = false;
   }
 
   public HeadlessGfsh getGfsh() {

http://git-wip-us.apache.org/repos/asf/geode/blob/f85d2163/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
index 5252bd1..00440e5 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
@@ -580,6 +580,14 @@ public class LuceneIndexCommands implements GfshCommand {
       LuceneCliStrings.LUCENE_CREATE_INDEX, LuceneCliStrings.LUCENE_DESCRIBE_INDEX,
       LuceneCliStrings.LUCENE_LIST_INDEX, LuceneCliStrings.LUCENE_DESTROY_INDEX})
   public boolean indexCommandsAvailable() {
-    return (!CliUtil.isGfshVM() || (getGfsh() != null && getGfsh().isConnectedAndReady()));
+    Gfsh gfsh = Gfsh.getCurrentInstance();
+
+    // command should always be available on the server
+    if (gfsh == null) {
+      return true;
+    }
+
+    // if in gfshVM, only when gfsh is connected and ready
+    return gfsh.isConnectedAndReady();
   }
 }


Mime
View raw message