geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstew...@apache.org
Subject [4/6] geode git commit: GEODE-2966: RefactorLauncherLifecycleCommands
Date Thu, 01 Jun 2017 16:41:04 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/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 a2ace7d..4c668b6 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
@@ -39,104 +39,76 @@ import static org.apache.geode.distributed.ConfigurationProperties.REDIS_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
 import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
+import static org.apache.geode.management.internal.cli.i18n.CliStrings.LOCATOR_TERM_NAME;
 import static org.apache.geode.management.internal.cli.i18n.CliStrings.START_SERVER__PASSWORD;
+import static org.apache.geode.management.internal.cli.shell.MXBeanProvider.getDistributedSystemMXBean;
+import static org.apache.geode.management.internal.cli.util.HostUtils.getLocatorId;
 
 import org.apache.commons.lang.ArrayUtils;
-import org.apache.geode.GemFireException;
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.AbstractLauncher;
-import org.apache.geode.distributed.AbstractLauncher.ServiceState;
-import org.apache.geode.distributed.AbstractLauncher.Status;
 import org.apache.geode.distributed.LocatorLauncher;
 import org.apache.geode.distributed.LocatorLauncher.LocatorState;
 import org.apache.geode.distributed.ServerLauncher;
 import org.apache.geode.distributed.ServerLauncher.ServerState;
 import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.tcpserver.TcpClient;
-import org.apache.geode.internal.DistributionLocator;
 import org.apache.geode.internal.GemFireVersion;
 import org.apache.geode.internal.OSProcess;
-import org.apache.geode.internal.cache.persistence.PersistentMemberPattern;
 import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.lang.ObjectUtils;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.lang.SystemUtils;
-import org.apache.geode.internal.net.SocketCreator;
 import org.apache.geode.internal.process.ClusterConfigurationNotAvailableException;
 import org.apache.geode.internal.process.ProcessLauncherContext;
 import org.apache.geode.internal.process.ProcessStreamReader;
 import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
 import org.apache.geode.internal.process.ProcessStreamReader.ReadingMode;
 import org.apache.geode.internal.process.ProcessType;
-import org.apache.geode.internal.process.ProcessUtils;
 import org.apache.geode.internal.process.signal.SignalEvent;
 import org.apache.geode.internal.process.signal.SignalListener;
 import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.internal.util.StopWatch;
 import org.apache.geode.management.DistributedSystemMXBean;
-import org.apache.geode.management.MemberMXBean;
 import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.ConverterHint;
 import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.ManagementConstants;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.GfshParser;
 import org.apache.geode.management.internal.cli.LogWrapper;
-import org.apache.geode.management.internal.cli.converters.ConnectionEndpointConverter;
 import org.apache.geode.management.internal.cli.domain.ConnectToLocatorResult;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.InfoResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.cli.shell.JmxOperationInvoker;
-import org.apache.geode.management.internal.cli.shell.OperationInvoker;
 import org.apache.geode.management.internal.cli.util.CauseFinder;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.management.internal.cli.util.ConnectionEndpoint;
-import org.apache.geode.management.internal.cli.util.JConsoleNotFoundException;
+import org.apache.geode.management.internal.cli.util.HostUtils;
 import org.apache.geode.management.internal.cli.util.ThreePhraseGenerator;
-import org.apache.geode.management.internal.cli.util.VisualVmNotFoundException;
-import org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus;
-import org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusRequest;
-import org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse;
+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;
 
-import java.awt.Desktop;
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.InetAddress;
-import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.EmptyStackException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
-import java.util.Stack;
-import java.util.TreeSet;
 import java.util.concurrent.TimeUnit;
 import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryExp;
 import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLHandshakeException;
 
@@ -148,14 +120,12 @@ import javax.net.ssl.SSLHandshakeException;
  *
  * @see org.apache.geode.distributed.LocatorLauncher
  * @see org.apache.geode.distributed.ServerLauncher
- * @see org.apache.geode.management.internal.cli.commands.AbstractCommandsSupport
+ * @see GfshCommand
  * @see org.apache.geode.management.internal.cli.shell.Gfsh
  * @since GemFire 7.0
  */
 @SuppressWarnings("unused")
-public class LauncherLifecycleCommands extends AbstractCommandsSupport {
-
-  private static final String LOCATOR_TERM_NAME = "Locator";
+public class LauncherLifecycleCommands implements GfshCommand {
   private static final String SERVER_TERM_NAME = "Server";
 
   private static final long PROCESS_STREAM_READER_JOIN_TIMEOUT_MILLIS = 30 * 1000;
@@ -164,14 +134,11 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
   private static final long WAITING_FOR_PID_FILE_TO_CONTAIN_PID_TIMEOUT_MILLIS = 2 * 1000;
 
   protected static final int CMS_INITIAL_OCCUPANCY_FRACTION = 60;
-  protected static final int DEFAULT_PROCESS_OUTPUT_WAIT_TIME_MILLISECONDS = 5000;
   protected static final int INVALID_PID = -1;
   protected static final int MINIMUM_HEAP_FREE_RATIO = 10;
-  protected static final int NUM_ATTEMPTS_FOR_SHARED_CONFIGURATION_STATUS = 3;
 
   protected static final String GEODE_HOME = System.getenv("GEODE_HOME");
   protected static final String JAVA_HOME = System.getProperty("java.home");
-  protected static final String LOCALHOST = "localhost";
 
   // MUST CHANGE THIS TO REGEX SINCE VERSION CHANGES IN JAR NAME
   protected static final String GEODE_JAR_PATHNAME =
@@ -354,7 +321,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
                 new File(locatorLauncher.getWorkingDirectory()))),
             null);
 
-        locatorState = locatorStatus(workingDirectory, memberName);
+        locatorState = LocatorState.fromDirectory(workingDirectory, memberName);
         do {
           if (locatorProcess.isAlive()) {
             Gfsh.print(".");
@@ -363,11 +330,11 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
               TimeUnit.MILLISECONDS.timedWait(this, 500);
             }
 
-            locatorState = locatorStatus(workingDirectory, memberName);
+            locatorState = LocatorState.fromDirectory(workingDirectory, memberName);
 
             String currentLocatorStatusMessage = locatorState.getStatusMessage();
 
-            if (isStartingOrNotResponding(locatorState.getStatus())
+            if (locatorState.isStartingOrNotResponding()
                 && !(StringUtils.isBlank(currentLocatorStatusMessage)
                     || currentLocatorStatusMessage.equalsIgnoreCase(previousLocatorStatusMessage)
                     || currentLocatorStatusMessage.trim().toLowerCase().equals("null"))) {
@@ -383,7 +350,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
                     exitValue, locatorLauncher.getWorkingDirectory(), message.toString()));
           }
         } while (!(registeredLocatorSignalListener && locatorSignalListener.isSignaled())
-            && isStartingOrNotResponding(locatorState.getStatus()));
+            && locatorState.isStartingOrNotResponding());
       } finally {
         stderrReader.stopAsync(PROCESS_STREAM_READER_ASYNC_STOP_TIMEOUT_MILLIS); // stop will close
                                                                                  // ErrorStream
@@ -392,8 +359,9 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
 
       Gfsh.println();
 
-      final boolean asyncStart = (registeredLocatorSignalListener
-          && locatorSignalListener.isSignaled() && isStartingNotRespondingOrNull(locatorState));
+      final boolean asyncStart =
+          (registeredLocatorSignalListener && locatorSignalListener.isSignaled()
+              && ServerState.isStartingNotRespondingOrNull(locatorState));
 
       InfoResultData infoResultData = ResultBuilder.createInfoResultData();
 
@@ -408,8 +376,8 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
         if (bindAddr != null) {
           locatorHostName = bindAddr.getCanonicalHostName();
         } else {
-          locatorHostName =
-              StringUtils.defaultIfBlank(locatorLauncher.getHostnameForClients(), getLocalHost());
+          locatorHostName = StringUtils.defaultIfBlank(locatorLauncher.getHostnameForClients(),
+              HostUtils.getLocalHost());
         }
 
         int locatorPort = Integer.parseInt(locatorState.getPort());
@@ -424,8 +392,8 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
 
         // Report on the state of the Shared Configuration service if enabled...
         if (enableSharedConfiguration) {
-          infoResultData
-              .addLine(getSharedConfigurationStatusFromLocator(locatorHostName, locatorPort));
+          infoResultData.addLine(
+              ClusterConfigurationStatusRetriever.fromLocator(locatorHostName, locatorPort));
         }
       }
 
@@ -657,227 +625,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
     return configurationProperties;
   }
 
-  private String getSharedConfigurationStatusFromLocatorState(LocatorState locatorState)
-      throws ClassNotFoundException, IOException {
-    return getSharedConfigurationStatusFromLocator(locatorState.getHost(),
-        Integer.parseInt(locatorState.getPort()));
-  }
-
-  private String getSharedConfigurationStatusFromLocator(String locatorHostName, int locatorPort)
-      throws ClassNotFoundException, IOException {
-    final StringBuilder buffer = new StringBuilder();
-
-    try {
-      final InetAddress networkAddress = InetAddress.getByName(locatorHostName);
-      InetSocketAddress inetSockAddr = new InetSocketAddress(networkAddress, locatorPort);
-
-      TcpClient client = new TcpClient();
-      SharedConfigurationStatusResponse statusResponse = (SharedConfigurationStatusResponse) client
-          .requestToServer(inetSockAddr, new SharedConfigurationStatusRequest(), 10000, true);
-
-      for (int i = 0; i < NUM_ATTEMPTS_FOR_SHARED_CONFIGURATION_STATUS; i++) {
-        if (statusResponse.getStatus().equals(SharedConfigurationStatus.STARTED)
-            || statusResponse.getStatus().equals(SharedConfigurationStatus.NOT_STARTED)) {
-          statusResponse = (SharedConfigurationStatusResponse) client.requestToServer(inetSockAddr,
-              new SharedConfigurationStatusRequest(), 10000, true);
-          try {
-            Thread.sleep(5000);
-          } catch (InterruptedException e) {
-            // Swallow the exception
-          }
-        } else {
-          break;
-        }
-      }
-
-      switch (statusResponse.getStatus()) {
-        case RUNNING:
-          buffer.append("\nCluster configuration service is up and running.");
-          break;
-        case STOPPED:
-          buffer.append(
-              "\nCluster configuration service failed to start , please check the log file for errors.");
-          break;
-        case WAITING:
-          buffer.append(
-              "\nCluster configuration service is waiting for other locators with newer shared configuration data.");
-          Set<PersistentMemberPattern> pmpSet = statusResponse.getOtherLocatorInformation();
-          if (!pmpSet.isEmpty()) {
-            buffer.append("\nThis locator might have stale cluster configuration data.");
-            buffer.append(
-                "\nFollowing locators contain potentially newer cluster configuration data");
-
-            for (PersistentMemberPattern pmp : pmpSet) {
-              buffer.append("\nHost : ").append(pmp.getHost());
-              buffer.append("\nDirectory : ").append(pmp.getDirectory());
-            }
-          } else {
-            buffer.append("\nPlease check the log file for errors");
-          }
-          break;
-        case UNDETERMINED:
-          buffer.append(
-              "\nUnable to determine the status of shared configuration service, please check the log file");
-          break;
-        case NOT_STARTED:
-          buffer.append("\nCluster configuration service has not been started yet");
-          break;
-        case STARTED:
-          buffer
-              .append("\nCluster configuration service has been started, but its not running yet");
-          break;
-      }
-    } catch (Exception e) {
-      // TODO fix this once Trac Bug #50513 gets fixed
-      // NOTE this ClassCastException occurs if the a plain text TCP/IP connection is used to
-      // connect to a Locator
-      // configured with SSL.
-      getGfsh().logToFile(String.format(
-          "Failed to get the status of the Shared Configuration Service running on Locator (%1$s[%2$d])!",
-          locatorHostName, locatorPort), e);
-    }
-
-    return buffer.toString();
-  }
-
-  @CliCommand(value = CliStrings.STATUS_LOCATOR, help = CliStrings.STATUS_LOCATOR__HELP)
-  @CliMetaData(shellOnly = true,
-      relatedTopic = {CliStrings.TOPIC_GEODE_LOCATOR, CliStrings.TOPIC_GEODE_LIFECYCLE})
-  public Result statusLocator(
-      @CliOption(key = CliStrings.STATUS_LOCATOR__MEMBER,
-          optionContext = ConverterHint.LOCATOR_MEMBER_IDNAME,
-          help = CliStrings.STATUS_LOCATOR__MEMBER__HELP) final String member,
-      @CliOption(key = CliStrings.STATUS_LOCATOR__HOST,
-          help = CliStrings.STATUS_LOCATOR__HOST__HELP) final String locatorHost,
-      @CliOption(key = CliStrings.STATUS_LOCATOR__PORT,
-          help = CliStrings.STATUS_LOCATOR__PORT__HELP) final Integer locatorPort,
-      @CliOption(key = CliStrings.STATUS_LOCATOR__PID,
-          help = CliStrings.STATUS_LOCATOR__PID__HELP) final Integer pid,
-      @CliOption(key = CliStrings.STATUS_LOCATOR__DIR,
-          help = CliStrings.STATUS_LOCATOR__DIR__HELP) final String workingDirectory) {
-    try {
-      if (StringUtils.isNotBlank(member)) {
-        if (isConnectedAndReady()) {
-          final MemberMXBean locatorProxy = getMemberMXBean(member);
-
-          if (locatorProxy != null) {
-            LocatorState state = LocatorState.fromJson(locatorProxy.status());
-            return createStatusLocatorResult(state);
-          } else {
-            return ResultBuilder.createUserErrorResult(CliStrings.format(
-                CliStrings.STATUS_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, member));
-          }
-        } else {
-          return ResultBuilder.createUserErrorResult(CliStrings.format(
-              CliStrings.STATUS_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, LOCATOR_TERM_NAME));
-        }
-      } else {
-        final LocatorLauncher locatorLauncher =
-            new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.STATUS)
-                .setBindAddress(locatorHost).setDebug(isDebugging()).setPid(pid)
-                .setPort(locatorPort).setWorkingDirectory(workingDirectory).build();
-
-        final LocatorState state = locatorLauncher.status();
-        return createStatusLocatorResult(state);
-      }
-    } catch (IllegalArgumentException | IllegalStateException e) {
-      return ResultBuilder.createUserErrorResult(e.getMessage());
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable t) {
-      SystemFailure.checkFailure();
-      return ResultBuilder.createShellClientErrorResult(String.format(
-          CliStrings.STATUS_LOCATOR__GENERAL_ERROR_MESSAGE, getLocatorId(locatorHost, locatorPort),
-          StringUtils.defaultIfBlank(workingDirectory, SystemUtils.CURRENT_DIRECTORY),
-          toString(t, getGfsh().getDebug())));
-    }
-  }
-
-  @CliCommand(value = CliStrings.STOP_LOCATOR, help = CliStrings.STOP_LOCATOR__HELP)
-  @CliMetaData(shellOnly = true,
-      relatedTopic = {CliStrings.TOPIC_GEODE_LOCATOR, CliStrings.TOPIC_GEODE_LIFECYCLE})
-  public Result stopLocator(
-      @CliOption(key = CliStrings.STOP_LOCATOR__MEMBER,
-          optionContext = ConverterHint.LOCATOR_MEMBER_IDNAME,
-          help = CliStrings.STOP_LOCATOR__MEMBER__HELP) final String member,
-      @CliOption(key = CliStrings.STOP_LOCATOR__PID,
-          help = CliStrings.STOP_LOCATOR__PID__HELP) final Integer pid,
-      @CliOption(key = CliStrings.STOP_LOCATOR__DIR,
-          help = CliStrings.STOP_LOCATOR__DIR__HELP) final String workingDirectory) {
-    LocatorState locatorState;
-
-    try {
-      if (StringUtils.isNotBlank(member)) {
-        if (isConnectedAndReady()) {
-          final MemberMXBean locatorProxy = getMemberMXBean(member);
-
-          if (locatorProxy != null) {
-            if (!locatorProxy.isLocator()) {
-              throw new IllegalStateException(
-                  CliStrings.format(CliStrings.STOP_LOCATOR__NOT_LOCATOR_ERROR_MESSAGE, member));
-            }
-
-            if (locatorProxy.isServer()) {
-              throw new IllegalStateException(CliStrings
-                  .format(CliStrings.STOP_LOCATOR__LOCATOR_IS_CACHE_SERVER_ERROR_MESSAGE, member));
-            }
-
-            locatorState = LocatorState.fromJson(locatorProxy.status());
-            locatorProxy.shutDownMember();
-          } else {
-            return ResultBuilder.createUserErrorResult(CliStrings.format(
-                CliStrings.STOP_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, member));
-          }
-        } else {
-          return ResultBuilder.createUserErrorResult(CliStrings.format(
-              CliStrings.STOP_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, LOCATOR_TERM_NAME));
-        }
-      } else {
-        final LocatorLauncher locatorLauncher =
-            new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.STOP)
-                .setDebug(isDebugging()).setPid(pid).setWorkingDirectory(workingDirectory).build();
-
-        locatorState = locatorLauncher.status();
-        locatorLauncher.stop();
-      }
-
-      if (Status.ONLINE.equals(locatorState.getStatus())) {
-        getGfsh().logInfo(
-            String.format(CliStrings.STOP_LOCATOR__STOPPING_LOCATOR_MESSAGE,
-                locatorState.getWorkingDirectory(), locatorState.getServiceLocation(),
-                locatorState.getMemberName(), locatorState.getPid(), locatorState.getLogFile()),
-            null);
-
-        StopWatch stopWatch = new StopWatch(true);
-        while (isVmWithProcessIdRunning(locatorState.getPid())) {
-          Gfsh.print(".");
-          if (stopWatch.elapsedTimeMillis() > WAITING_FOR_STOP_TO_MAKE_PID_GO_AWAY_TIMEOUT_MILLIS) {
-            break;
-          }
-          synchronized (this) {
-            TimeUnit.MILLISECONDS.timedWait(this, 500);
-          }
-        }
-
-        return ResultBuilder.createInfoResult(StringUtils.EMPTY);
-      } else {
-        return ResultBuilder.createUserErrorResult(locatorState.toString());
-      }
-    } catch (IllegalArgumentException | IllegalStateException e) {
-      return ResultBuilder.createUserErrorResult(e.getMessage());
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable t) {
-      SystemFailure.checkFailure();
-      return ResultBuilder.createShellClientErrorResult(String.format(
-          CliStrings.STOP_LOCATOR__GENERAL_ERROR_MESSAGE, toString(t, getGfsh().getDebug())));
-    } finally {
-      Gfsh.redirectInternalJavaLoggers();
-    }
-  }
-
   // TODO re-evaluate whether a MalformedObjectNameException should be thrown here; just because we
   // were not able to find
   // the "current" Locators in order to conveniently add the new member to the GemFire cluster does
@@ -895,14 +642,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
     }
   }
 
-  protected Result createStatusLocatorResult(final LocatorState state)
-      throws NumberFormatException, IOException, ClassNotFoundException {
-    InfoResultData infoResultData = ResultBuilder.createInfoResultData();
-    infoResultData.addLine(state.toString());
-    infoResultData.addLine(getSharedConfigurationStatusFromLocatorState(state));
-    return ResultBuilder.buildResult(infoResultData);
-  }
-
   protected void addGemFirePropertyFile(final List<String> commandLine,
       final String gemfirePropertiesPathname) {
     if (StringUtils.isNotBlank(gemfirePropertiesPathname)) {
@@ -976,46 +715,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
     }
   }
 
-  protected LocatorState locatorStatus(final File locatorPidFile, final int oldPid,
-      final String memberName) {
-    final int newPid = readPid(locatorPidFile);
-
-    if (newPid != INVALID_PID && newPid != oldPid) {
-      LocatorState locatorState = new LocatorLauncher.Builder().setPid(newPid).build().status();
-
-      if (ObjectUtils.equals(locatorState.getMemberName(), memberName)) {
-        return locatorState;
-      }
-    }
-
-    return new LocatorState(new LocatorLauncher.Builder().build(), Status.NOT_RESPONDING);
-  }
-
-  protected LocatorState locatorStatus(final String workingDirectory, final String memberName) {
-    LocatorState locatorState =
-        new LocatorLauncher.Builder().setWorkingDirectory(workingDirectory).build().status();
-
-    if (ObjectUtils.equals(locatorState.getMemberName(), memberName)) {
-      return locatorState;
-    }
-
-    return new LocatorState(new LocatorLauncher.Builder().build(), Status.NOT_RESPONDING);
-  }
-
-  protected String readErrorStream(final Process process) throws IOException {
-    BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
-    StringBuilder message = new StringBuilder();
-
-    for (String line = reader.readLine(); line != null; line = reader.readLine()) {
-      message.append(line);
-      message.append(StringUtils.LINE_SEPARATOR);
-    }
-
-    IOUtils.close(reader);
-
-    return message.toString();
-  }
-
   protected int readPid(final File pidFile) {
     assert pidFile != null : "The file from which to read the process ID (pid) cannot be null!";
 
@@ -1033,33 +732,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
     return INVALID_PID;
   }
 
-  protected ServerState serverStatus(final File serverPidFile, final int oldPid,
-      final String memberName) {
-    final int newPid = readPid(serverPidFile);
-
-    if (newPid != INVALID_PID && newPid != oldPid) {
-      ServerState serverState = new ServerLauncher.Builder().setPid(newPid)
-          .setDisableDefaultServer(true).build().status();
-
-      if (ObjectUtils.equals(serverState.getMemberName(), memberName)) {
-        return serverState;
-      }
-    }
-
-    return new ServerState(new ServerLauncher.Builder().build(), Status.NOT_RESPONDING);
-  }
-
-  protected ServerState serverStatus(final String workingDirectory, final String memberName) {
-    ServerState serverState = new ServerLauncher.Builder().setWorkingDirectory(workingDirectory)
-        .setDisableDefaultServer(true).build().status();
-
-    if (ObjectUtils.equals(serverState.getMemberName(), memberName)) {
-      return serverState;
-    }
-
-    return new ServerState(new ServerLauncher.Builder().build(), Status.NOT_RESPONDING);
-  }
-
   @Deprecated
   protected String getClasspath(final String userClasspath) {
     String classpath = getSystemClasspath();
@@ -1152,107 +824,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
     return new File(new File(JAVA_HOME, "bin"), "java").getPath();
   }
 
-  // TODO refactor the following method into a common base class or utility class
-  protected String getLocalHost() {
-    try {
-      return SocketCreator.getLocalHost().getCanonicalHostName();
-    } catch (UnknownHostException ignore) {
-      return LOCALHOST;
-    }
-  }
-
-  protected String getLocatorId(final String host, final Integer port) {
-    final String locatorHost = (host != null ? host : getLocalHost());
-    final String locatorPort =
-        StringUtils.defaultString(port, String.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT));
-    return locatorHost.concat("[").concat(locatorPort).concat("]");
-  }
-
-  /**
-   * Gets a proxy to the DistributedSystemMXBean from the GemFire Manager's MBeanServer, or null if
-   * unable to find the DistributedSystemMXBean.
-   * </p>
-   *
-   * @return a proxy to the DistributedSystemMXBean from the GemFire Manager's MBeanServer, or null
-   *         if unable to find the DistributedSystemMXBean.
-   */
-  protected DistributedSystemMXBean getDistributedSystemMXBean()
-      throws IOException, MalformedObjectNameException {
-    assertState(isConnectedAndReady(),
-        "Gfsh must be connected in order to get proxy to a GemFire DistributedSystemMXBean.");
-    return getGfsh().getOperationInvoker().getDistributedSystemMXBean();
-  }
-
-  /**
-   * Gets a proxy to the MemberMXBean for the GemFire member specified by member name or ID from the
-   * GemFire Manager's MBeanServer.
-   * </p>
-   *
-   * @param member a String indicating the GemFire member's name or ID.
-   * @return a proxy to the MemberMXBean having the specified GemFire member's name or ID from the
-   *         GemFire Manager's MBeanServer, or null if no GemFire member could be found with the
-   *         specified member name or ID.
-   * @see #getMemberMXBean(String, String)
-   */
-  protected MemberMXBean getMemberMXBean(final String member) throws IOException {
-    return getMemberMXBean(null, member);
-  }
-
-  protected MemberMXBean getMemberMXBean(final String serviceName, final String member)
-      throws IOException {
-    assertState(isConnectedAndReady(),
-        "Gfsh must be connected in order to get proxy to a GemFire Member MBean.");
-
-    MemberMXBean memberBean = null;
-
-    try {
-      String objectNamePattern = ManagementConstants.OBJECTNAME__PREFIX;
-
-      objectNamePattern += (StringUtils.isBlank(serviceName) ? StringUtils.EMPTY
-          : "service=" + serviceName + StringUtils.COMMA_DELIMITER);
-      objectNamePattern += "type=Member,*";
-
-      // NOTE throws a MalformedObjectNameException, however, this should not happen since the
-      // ObjectName is constructed
-      // here in a conforming pattern
-      final ObjectName objectName = ObjectName.getInstance(objectNamePattern);
-
-      final QueryExp query = Query.or(Query.eq(Query.attr("Name"), Query.value(member)),
-          Query.eq(Query.attr("Id"), Query.value(member)));
-
-      final Set<ObjectName> memberObjectNames =
-          getGfsh().getOperationInvoker().queryNames(objectName, query);
-
-      if (!memberObjectNames.isEmpty()) {
-        memberBean = getGfsh().getOperationInvoker()
-            .getMBeanProxy(memberObjectNames.iterator().next(), MemberMXBean.class);
-      }
-    } catch (MalformedObjectNameException e) {
-      getGfsh().logSevere(e.getMessage(), e);
-    }
-
-    return memberBean;
-  }
-
-  protected String getServerId(final String host, final Integer port) {
-    String serverHost = (host != null ? host : getLocalHost());
-    String serverPort = StringUtils.defaultString(port, String.valueOf(CacheServer.DEFAULT_PORT));
-    return serverHost.concat("[").concat(serverPort).concat("]");
-  }
-
-  protected boolean isStartingNotRespondingOrNull(final ServiceState serviceState) {
-    return (serviceState == null || isStartingOrNotResponding(serviceState.getStatus()));
-  }
-
-  protected boolean isStartingOrNotResponding(final Status processStatus) {
-    return (Status.NOT_RESPONDING.equals(processStatus) || Status.STARTING.equals(processStatus));
-  }
-
-  protected boolean isVmWithProcessIdRunning(final Integer pid) {
-    // note: this will use JNA if available or return false
-    return ProcessUtils.isProcessAlive(pid);
-  }
-
   @CliCommand(value = CliStrings.START_SERVER, help = CliStrings.START_SERVER__HELP)
   @CliMetaData(shellOnly = true,
       relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE})
@@ -1540,7 +1111,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
                 new File(serverLauncher.getWorkingDirectory()))),
             null);
 
-        serverState = serverStatus(workingDirectory, memberName);
+        serverState = ServerState.fromDirectory(workingDirectory, memberName);
         do {
           if (serverProcess.isAlive()) {
             Gfsh.print(".");
@@ -1549,11 +1120,11 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
               TimeUnit.MILLISECONDS.timedWait(this, 500);
             }
 
-            serverState = serverStatus(workingDirectory, memberName);
+            serverState = ServerState.fromDirectory(workingDirectory, memberName);
 
             String currentServerStatusMessage = serverState.getStatusMessage();
 
-            if (isStartingOrNotResponding(serverState.getStatus())
+            if (serverState.isStartingOrNotResponding()
                 && !(StringUtils.isBlank(currentServerStatusMessage)
                     || currentServerStatusMessage.equalsIgnoreCase(previousServerStatusMessage)
                     || currentServerStatusMessage.trim().toLowerCase().equals("null"))) {
@@ -1570,7 +1141,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
 
           }
         } while (!(registeredServerSignalListener && serverSignalListener.isSignaled())
-            && isStartingOrNotResponding(serverState.getStatus()));
+            && serverState.isStartingOrNotResponding());
       } finally {
         stderrReader.stopAsync(PROCESS_STREAM_READER_ASYNC_STOP_TIMEOUT_MILLIS); // stop will close
                                                                                  // ErrorStream
@@ -1579,7 +1150,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
 
       Gfsh.println();
 
-      final boolean asyncStart = isStartingNotRespondingOrNull(serverState);
+      final boolean asyncStart = ServerState.isStartingNotRespondingOrNull(serverState);
 
       if (asyncStart) { // async start
         Gfsh.print(String.format(CliStrings.ASYNC_PROCESS_LAUNCH_MESSAGE, SERVER_TERM_NAME));
@@ -1768,467 +1339,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
     return delimitedLocators;
   }
 
-  @CliCommand(value = CliStrings.STATUS_SERVER, help = CliStrings.STATUS_SERVER__HELP)
-  @CliMetaData(shellOnly = true,
-      relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE})
-  public Result statusServer(
-      @CliOption(key = CliStrings.STATUS_SERVER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME,
-          help = CliStrings.STATUS_SERVER__MEMBER__HELP) final String member,
-      @CliOption(key = CliStrings.STATUS_SERVER__PID,
-          help = CliStrings.STATUS_SERVER__PID__HELP) final Integer pid,
-      @CliOption(key = CliStrings.STATUS_SERVER__DIR,
-          help = CliStrings.STATUS_SERVER__DIR__HELP) final String workingDirectory) {
-    try {
-      if (StringUtils.isNotBlank(member)) {
-        if (isConnectedAndReady()) {
-          final MemberMXBean serverProxy = getMemberMXBean(member);
-
-          if (serverProxy != null) {
-            return ResultBuilder
-                .createInfoResult(ServerState.fromJson(serverProxy.status()).toString());
-          } else {
-            return ResultBuilder.createUserErrorResult(CliStrings.format(
-                CliStrings.STATUS_SERVER__NO_SERVER_FOUND_FOR_MEMBER_ERROR_MESSAGE, member));
-          }
-        } else {
-          return ResultBuilder.createUserErrorResult(CliStrings
-              .format(CliStrings.STATUS_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Cache Server"));
-        }
-      } else {
-        final ServerLauncher serverLauncher = new ServerLauncher.Builder()
-            .setCommand(ServerLauncher.Command.STATUS).setDebug(isDebugging())
-            // NOTE since we do not know whether the "CacheServer" was enabled or not on the GemFire
-            // server when it was started, set the disableDefaultServer property in the
-            // ServerLauncher.Builder to default status
-            // to the MemberMBean
-            // TODO fix this hack! (how, the 'start server' loop needs it)
-            .setDisableDefaultServer(true).setPid(pid).setWorkingDirectory(workingDirectory)
-            .build();
-
-        final ServerState status = serverLauncher.status();
-
-        return ResultBuilder.createInfoResult(status.toString());
-      }
-    } catch (IllegalArgumentException | IllegalStateException e) {
-      return ResultBuilder.createUserErrorResult(e.getMessage());
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable t) {
-      SystemFailure.checkFailure();
-      return ResultBuilder.createShellClientErrorResult(String.format(
-          CliStrings.STATUS_SERVER__GENERAL_ERROR_MESSAGE, toString(t, getGfsh().getDebug())));
-    }
-  }
-
-  @CliCommand(value = CliStrings.STOP_SERVER, help = CliStrings.STOP_SERVER__HELP)
-  @CliMetaData(shellOnly = true,
-      relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE})
-  public Result stopServer(
-      @CliOption(key = CliStrings.STOP_SERVER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME,
-          help = CliStrings.STOP_SERVER__MEMBER__HELP) final String member,
-      @CliOption(key = CliStrings.STOP_SERVER__PID,
-          help = CliStrings.STOP_SERVER__PID__HELP) final Integer pid,
-      @CliOption(key = CliStrings.STOP_SERVER__DIR,
-          help = CliStrings.STOP_SERVER__DIR__HELP) final String workingDirectory) {
-    ServerState serverState;
-
-    try {
-      if (StringUtils.isNotBlank(member)) {
-        if (isConnectedAndReady()) {
-          final MemberMXBean serverProxy = getMemberMXBean(member);
-
-          if (serverProxy != null) {
-            if (!serverProxy.isServer()) {
-              throw new IllegalStateException(CliStrings
-                  .format(CliStrings.STOP_SERVER__MEMBER_IS_NOT_SERVER_ERROR_MESSAGE, member));
-            }
-
-            serverState = ServerState.fromJson(serverProxy.status());
-            serverProxy.shutDownMember();
-          } else {
-            return ResultBuilder.createUserErrorResult(CliStrings
-                .format(CliStrings.STOP_SERVER__NO_SERVER_FOUND_FOR_MEMBER_ERROR_MESSAGE, member));
-          }
-        } else {
-          return ResultBuilder.createUserErrorResult(CliStrings
-              .format(CliStrings.STOP_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Cache Server"));
-        }
-      } else {
-        final ServerLauncher serverLauncher =
-            new ServerLauncher.Builder().setCommand(ServerLauncher.Command.STOP)
-                .setDebug(isDebugging()).setPid(pid).setWorkingDirectory(workingDirectory).build();
-
-        serverState = serverLauncher.status();
-        serverLauncher.stop();
-      }
-
-      if (Status.ONLINE.equals(serverState.getStatus())) {
-        getGfsh().logInfo(
-            String.format(CliStrings.STOP_SERVER__STOPPING_SERVER_MESSAGE,
-                serverState.getWorkingDirectory(), serverState.getServiceLocation(),
-                serverState.getMemberName(), serverState.getPid(), serverState.getLogFile()),
-            null);
-
-        StopWatch stopWatch = new StopWatch(true);
-        while (isVmWithProcessIdRunning(serverState.getPid())) {
-          Gfsh.print(".");
-          if (stopWatch.elapsedTimeMillis() > WAITING_FOR_STOP_TO_MAKE_PID_GO_AWAY_TIMEOUT_MILLIS) {
-            break;
-          }
-          synchronized (this) {
-            TimeUnit.MILLISECONDS.timedWait(this, 500);
-          }
-        }
-
-        return ResultBuilder.createInfoResult(StringUtils.EMPTY);
-      } else {
-        return ResultBuilder.createUserErrorResult(serverState.toString());
-      }
-    } catch (IllegalArgumentException | IllegalStateException e) {
-      return ResultBuilder.createUserErrorResult(e.getMessage());
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable t) {
-      SystemFailure.checkFailure();
-      return ResultBuilder.createShellClientErrorResult(String.format(
-          CliStrings.STOP_SERVER__GENERAL_ERROR_MESSAGE, toString(t, getGfsh().getDebug())));
-    } finally {
-      Gfsh.redirectInternalJavaLoggers();
-    }
-  }
-
-  // @CliCommand(value=CliStrings.START_MANAGER, help=CliStrings.START_MANAGER__HELP)
-  // @CliMetaData(shellOnly=true, relatedTopic = {CliStrings.TOPIC_GEODE_MANAGER,
-  // CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_LIFECYCLE})
-  public Result startManager(
-      @CliOption(key = CliStrings.START_MANAGER__MEMBERNAME,
-          help = CliStrings.START_MANAGER__MEMBERNAME__HELP) String memberName,
-      @CliOption(key = CliStrings.START_MANAGER__DIR,
-          help = CliStrings.START_MANAGER__DIR__HELP) String dir,
-      @CliOption(key = CliStrings.START_MANAGER__PORT, unspecifiedDefaultValue = "1099",
-          help = CliStrings.START_MANAGER__PORT__HELP) int cacheServerPort,
-      @CliOption(key = CliStrings.START_MANAGER__BIND_ADDRESS,
-          unspecifiedDefaultValue = "localhost",
-          help = CliStrings.START_MANAGER__BIND_ADDRESS__HELP) String cacheServerHost,
-      @CliOption(key = CliStrings.START_MANAGER__CLASSPATH,
-          help = CliStrings.START_MANAGER__CLASSPATH__HELP) String classpath,
-      @CliOption(key = CliStrings.START_MANAGER__MAXHEAP,
-          help = CliStrings.START_MANAGER__MAXHEAP__HELP) String maxHeap,
-      @CliOption(key = CliStrings.START_MANAGER__INITIALHEAP,
-          help = CliStrings.START_MANAGER__INITIALHEAP__HELP) String initialHeap,
-      @CliOption(key = CliStrings.START_MANAGER__J,
-          help = CliStrings.START_MANAGER__J__HELP) Map<String, String> systepProps,
-      @CliOption(key = CliStrings.START_MANAGER__GEODEPROPS,
-          help = CliStrings.START_MANAGER__GEODEPROPS__HELP) Map<String, String> gemfireProps) {
-    return ResultBuilder.createInfoResult("Not-implemented");
-  }
-
-  @CliCommand(value = CliStrings.START_JCONSOLE, help = CliStrings.START_JCONSOLE__HELP)
-  @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_MANAGER,
-      CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_M_AND_M})
-  public Result startJConsole(
-      @CliOption(key = CliStrings.START_JCONSOLE__INTERVAL, unspecifiedDefaultValue = "4",
-          help = CliStrings.START_JCONSOLE__INTERVAL__HELP) final int interval,
-      @CliOption(key = CliStrings.START_JCONSOLE__NOTILE, specifiedDefaultValue = "true",
-          unspecifiedDefaultValue = "false",
-          help = CliStrings.START_JCONSOLE__NOTILE__HELP) final boolean notile,
-      @CliOption(key = CliStrings.START_JCONSOLE__PLUGINPATH,
-          help = CliStrings.START_JCONSOLE__PLUGINPATH__HELP) final String pluginpath,
-      @CliOption(key = CliStrings.START_JCONSOLE__VERSION, specifiedDefaultValue = "true",
-          unspecifiedDefaultValue = "false",
-          help = CliStrings.START_JCONSOLE__VERSION__HELP) final boolean version,
-      @CliOption(key = CliStrings.START_JCONSOLE__J, optionContext = GfshParser.J_OPTION_CONTEXT,
-          help = CliStrings.START_JCONSOLE__J__HELP) final String[] jvmArgs) {
-    try {
-      String[] jconsoleCommandLine =
-          createJConsoleCommandLine(null, interval, notile, pluginpath, version, jvmArgs);
-
-      if (isDebugging()) {
-        getGfsh().printAsInfo(
-            String.format("JConsole command-line ($1%s)", Arrays.toString(jconsoleCommandLine)));
-      }
-
-      Process jconsoleProcess = Runtime.getRuntime().exec(jconsoleCommandLine);
-
-      StringBuilder message = new StringBuilder();
-
-      if (version) {
-        jconsoleProcess.waitFor();
-
-        BufferedReader reader =
-            new BufferedReader(new InputStreamReader(jconsoleProcess.getErrorStream()));
-
-        for (String line = reader.readLine(); line != null; line = reader.readLine()) {
-          message.append(line);
-          message.append(StringUtils.LINE_SEPARATOR);
-        }
-
-        IOUtils.close(reader);
-      } else {
-        getGfsh().printAsInfo(CliStrings.START_JCONSOLE__RUN);
-
-        String jconsoleProcessOutput = waitAndCaptureProcessStandardErrorStream(jconsoleProcess);
-
-        if (StringUtils.isNotBlank(jconsoleProcessOutput)) {
-          message.append(StringUtils.LINE_SEPARATOR);
-          message.append(jconsoleProcessOutput);
-        }
-      }
-
-      return ResultBuilder.createInfoResult(message.toString());
-    } catch (GemFireException | IllegalStateException | IllegalArgumentException e) {
-      return ResultBuilder.createShellClientErrorResult(e.getMessage());
-    } catch (IOException e) {
-      return ResultBuilder
-          .createShellClientErrorResult(CliStrings.START_JCONSOLE__IO_EXCEPTION_MESSAGE);
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable t) {
-      SystemFailure.checkFailure();
-      return ResultBuilder.createShellClientErrorResult(
-          String.format(CliStrings.START_JCONSOLE__CATCH_ALL_ERROR_MESSAGE, toString(t, false)));
-    }
-  }
-
-  protected String[] createJConsoleCommandLine(final String member, final int interval,
-      final boolean notile, final String pluginpath, final boolean version,
-      final String[] jvmArgs) {
-    List<String> commandLine = new ArrayList<>();
-
-    commandLine.add(getJConsolePathname());
-
-    if (version) {
-      commandLine.add("-version");
-    } else {
-      commandLine.add("-interval=" + interval);
-
-      if (notile) {
-        commandLine.add("-notile");
-      }
-
-      if (StringUtils.isNotBlank(pluginpath)) {
-        commandLine.add("-pluginpath " + pluginpath);
-      }
-
-      if (jvmArgs != null) {
-        for (final String arg : jvmArgs) {
-          commandLine.add("-J" + arg);
-        }
-      }
-
-      String jmxServiceUrl = getJmxServiceUrlAsString(member);
-
-      if (StringUtils.isNotBlank(jmxServiceUrl)) {
-        commandLine.add(jmxServiceUrl);
-      }
-    }
-
-    return commandLine.toArray(new String[commandLine.size()]);
-  }
-
-  protected String getJConsolePathname() {
-    return getJdkToolPathname("jconsole" + getExecutableSuffix(),
-        new JConsoleNotFoundException(CliStrings.START_JCONSOLE__NOT_FOUND_ERROR_MESSAGE));
-  }
-
-  protected String getJdkToolPathname(final String jdkToolExecutableName,
-      final GemFireException throwable) {
-    assertNotNull(jdkToolExecutableName, "The JDK tool executable name cannot be null!");
-    assertNotNull(throwable, "The GemFireException cannot be null!");
-
-    Stack<String> pathnames = new Stack<>();
-
-    pathnames.push(jdkToolExecutableName);
-    pathnames
-        .push(IOUtils.appendToPath(System.getenv("JAVA_HOME"), "..", "bin", jdkToolExecutableName));
-    pathnames.push(IOUtils.appendToPath(System.getenv("JAVA_HOME"), "bin", jdkToolExecutableName));
-    pathnames.push(IOUtils.appendToPath(JAVA_HOME, "..", "bin", jdkToolExecutableName));
-    pathnames.push(IOUtils.appendToPath(JAVA_HOME, "bin", jdkToolExecutableName));
-
-    return getJdkToolPathname(pathnames, throwable);
-  }
-
-  protected String getJdkToolPathname(final Stack<String> pathnames,
-      final GemFireException throwable) {
-    assertNotNull(pathnames, "The JDK tool executable pathnames cannot be null!");
-    assertNotNull(throwable, "The GemFireException cannot be null!");
-
-    try {
-      // assume 'java.home' JVM System property refers to the JDK installation directory. note,
-      // however, that the
-      // 'java.home' JVM System property usually refers to the JRE used to launch this application
-      return IOUtils.verifyPathnameExists(pathnames.pop());
-    } catch (EmptyStackException ignore) {
-      throw throwable;
-    } catch (FileNotFoundException ignore) {
-      return getJdkToolPathname(pathnames, throwable);
-    }
-  }
-
-  protected static String getExecutableSuffix() {
-    return SystemUtils.isWindows() ? ".exe" : StringUtils.EMPTY;
-  }
-
-  protected String getJmxServiceUrlAsString(final String member) {
-    if (StringUtils.isNotBlank(member)) {
-      ConnectionEndpointConverter converter = new ConnectionEndpointConverter();
-
-      try {
-        ConnectionEndpoint connectionEndpoint =
-            converter.convertFromText(member, ConnectionEndpoint.class, null);
-        String hostAndPort = connectionEndpoint.getHost() + ":" + connectionEndpoint.getPort();
-        return String.format("service:jmx:rmi://%s/jndi/rmi://%s/jmxrmi", hostAndPort, hostAndPort);
-      } catch (Exception e) {
-        throw new IllegalArgumentException(
-            CliStrings.START_JCONSOLE__CONNECT_BY_MEMBER_NAME_ID_ERROR_MESSAGE);
-      }
-    } else {
-      if (isConnectedAndReady()
-          && (getGfsh().getOperationInvoker() instanceof JmxOperationInvoker)) {
-        JmxOperationInvoker jmxOperationInvoker =
-            (JmxOperationInvoker) getGfsh().getOperationInvoker();
-
-        return ObjectUtils.toString(jmxOperationInvoker.getJmxServiceUrl());
-      }
-    }
-
-    return null;
-  }
-
-  @CliCommand(value = CliStrings.START_JVISUALVM, help = CliStrings.START_JVISUALVM__HELP)
-  @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_MANAGER,
-      CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_M_AND_M})
-  public Result startJVisualVM(
-      @CliOption(key = CliStrings.START_JCONSOLE__J, optionContext = GfshParser.J_OPTION_CONTEXT,
-          help = CliStrings.START_JCONSOLE__J__HELP) final String[] jvmArgs) {
-    try {
-      String[] jvisualvmCommandLine = createJVisualVMCommandLine(jvmArgs);
-
-      if (isDebugging()) {
-        getGfsh().printAsInfo(
-            String.format("JVisualVM command-line (%1$s)", Arrays.toString(jvisualvmCommandLine)));
-      }
-
-      Process jvisualvmProcess = Runtime.getRuntime().exec(jvisualvmCommandLine);
-
-      getGfsh().printAsInfo(CliStrings.START_JVISUALVM__RUN);
-
-      String jvisualvmProcessOutput = waitAndCaptureProcessStandardErrorStream(jvisualvmProcess);
-
-      InfoResultData infoResultData = ResultBuilder.createInfoResultData();
-
-      if (StringUtils.isNotBlank(jvisualvmProcessOutput)) {
-        infoResultData.addLine(StringUtils.LINE_SEPARATOR);
-        infoResultData.addLine(jvisualvmProcessOutput);
-      }
-
-      return ResultBuilder.buildResult(infoResultData);
-    } catch (GemFireException | IllegalStateException | IllegalArgumentException e) {
-      return ResultBuilder.createShellClientErrorResult(e.getMessage());
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable t) {
-      SystemFailure.checkFailure();
-      return ResultBuilder.createShellClientErrorResult(
-          String.format(CliStrings.START_JVISUALVM__ERROR_MESSAGE, toString(t, false)));
-    }
-  }
-
-  protected String[] createJVisualVMCommandLine(final String[] jvmArgs) {
-    List<String> commandLine = new ArrayList<>();
-
-    commandLine.add(getJVisualVMPathname());
-
-    if (jvmArgs != null) {
-      for (final String arg : jvmArgs) {
-        commandLine.add("-J" + arg);
-      }
-    }
-
-    return commandLine.toArray(new String[commandLine.size()]);
-  }
-
-  protected String getJVisualVMPathname() {
-    if (SystemUtils.isMacOSX()) {
-      try {
-        return IOUtils.verifyPathnameExists(
-            "/System/Library/Java/Support/VisualVM.bundle/Contents/Home/bin/jvisualvm");
-      } catch (FileNotFoundException e) {
-        throw new VisualVmNotFoundException(CliStrings.START_JVISUALVM__NOT_FOUND_ERROR_MESSAGE, e);
-      }
-    } else { // Linux, Solaris, Windows, etc...
-      try {
-        return getJdkToolPathname("jvisualvm" + getExecutableSuffix(),
-            new VisualVmNotFoundException(CliStrings.START_JVISUALVM__NOT_FOUND_ERROR_MESSAGE));
-      } catch (VisualVmNotFoundException e) {
-        if (!SystemUtils.isJavaVersionAtLeast("1.6")) {
-          throw new VisualVmNotFoundException(
-              CliStrings.START_JVISUALVM__EXPECTED_JDK_VERSION_ERROR_MESSAGE);
-        }
-
-        throw e;
-      }
-    }
-  }
-
-  @CliCommand(value = CliStrings.START_PULSE, help = CliStrings.START_PULSE__HELP)
-  @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_MANAGER,
-      CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_M_AND_M})
-  public Result startPulse(@CliOption(key = CliStrings.START_PULSE__URL,
-      unspecifiedDefaultValue = "http://localhost:7070/pulse",
-      help = CliStrings.START_PULSE__URL__HELP) final String url) {
-    try {
-      if (StringUtils.isNotBlank(url)) {
-        browse(URI.create(url));
-        return ResultBuilder.createInfoResult(CliStrings.START_PULSE__RUN);
-      } else {
-        if (isConnectedAndReady()) {
-          OperationInvoker operationInvoker = getGfsh().getOperationInvoker();
-
-          ObjectName managerObjectName = (ObjectName) operationInvoker.getAttribute(
-              ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN, "ManagerObjectName");
-
-          String pulseURL =
-              (String) operationInvoker.getAttribute(managerObjectName.toString(), "PulseURL");
-
-          if (StringUtils.isNotBlank(pulseURL)) {
-            browse(URI.create(pulseURL));
-            return ResultBuilder
-                .createInfoResult(CliStrings.START_PULSE__RUN + " with URL: " + pulseURL);
-          } else {
-            String pulseMessage = (String) operationInvoker
-                .getAttribute(managerObjectName.toString(), "StatusMessage");
-            return (StringUtils.isNotBlank(pulseMessage)
-                ? ResultBuilder.createGemFireErrorResult(pulseMessage)
-                : ResultBuilder.createGemFireErrorResult(CliStrings.START_PULSE__URL__NOTFOUND));
-          }
-        } else {
-          return ResultBuilder.createUserErrorResult(CliStrings
-              .format(CliStrings.GFSH_MUST_BE_CONNECTED_FOR_LAUNCHING_0, "GemFire Pulse"));
-        }
-      }
-    } catch (Exception e) {
-      return ResultBuilder.createShellClientErrorResult(e.getMessage());
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable t) {
-      SystemFailure.checkFailure();
-      return ResultBuilder.createShellClientErrorResult(
-          String.format(CliStrings.START_PULSE__ERROR, toString(t, false)));
-    }
-  }
-
-  private void browse(URI uri) throws IOException {
-    assertState(Desktop.isDesktopSupported(),
-        String.format(CliStrings.DESKSTOP_APP_RUN_ERROR_MESSAGE, System.getProperty("os.name")));
-    Desktop.getDesktop().browse(uri);
-  }
-
   @Deprecated
   protected File readIntoTempFile(final String classpathResourceLocation) throws IOException {
     String resourceName = classpathResourceLocation
@@ -2260,239 +1370,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
     return resourceFile;
   }
 
-  @CliCommand(value = CliStrings.START_VSD, help = CliStrings.START_VSD__HELP)
-  @CliMetaData(shellOnly = true,
-      relatedTopic = {CliStrings.TOPIC_GEODE_M_AND_M, CliStrings.TOPIC_GEODE_STATISTICS})
-  public Result startVsd(@CliOption(key = CliStrings.START_VSD__FILE,
-      help = CliStrings.START_VSD__FILE__HELP) final String[] statisticsArchiveFilePathnames) {
-    try {
-      String geodeHome = System.getenv("GEODE_HOME");
-
-      assertState(StringUtils.isNotBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE);
-
-      assertState(IOUtils.isExistingPathname(getPathToVsd()),
-          String.format(CliStrings.START_VSD__NOT_FOUND_ERROR_MESSAGE, geodeHome));
-
-      String[] vsdCommandLine = createdVsdCommandLine(statisticsArchiveFilePathnames);
-
-      if (isDebugging()) {
-        getGfsh().printAsInfo(
-            String.format("GemFire VSD command-line (%1$s)", Arrays.toString(vsdCommandLine)));
-      }
-
-      Process vsdProcess = Runtime.getRuntime().exec(vsdCommandLine);
-
-      getGfsh().printAsInfo(CliStrings.START_VSD__RUN);
-
-      String vsdProcessOutput = waitAndCaptureProcessStandardErrorStream(vsdProcess);
-
-      InfoResultData infoResultData = ResultBuilder.createInfoResultData();
-
-      if (StringUtils.isNotBlank(vsdProcessOutput)) {
-        infoResultData.addLine(StringUtils.LINE_SEPARATOR);
-        infoResultData.addLine(vsdProcessOutput);
-      }
-
-      return ResultBuilder.buildResult(infoResultData);
-    } catch (GemFireException | IllegalStateException | IllegalArgumentException
-        | FileNotFoundException e) {
-      return ResultBuilder.createShellClientErrorResult(e.getMessage());
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable t) {
-      SystemFailure.checkFailure();
-      return ResultBuilder.createShellClientErrorResult(
-          String.format(CliStrings.START_VSD__ERROR_MESSAGE, toString(t, false)));
-    }
-  }
-
-  protected String[] createdVsdCommandLine(final String[] statisticsArchiveFilePathnames)
-      throws FileNotFoundException {
-    List<String> commandLine = new ArrayList<>();
-
-    commandLine.add(getPathToVsd());
-    commandLine.addAll(processStatisticsArchiveFiles(statisticsArchiveFilePathnames));
-
-    return commandLine.toArray(new String[commandLine.size()]);
-  }
-
-  protected String getPathToVsd() {
-    String vsdPathname =
-        IOUtils.appendToPath(System.getenv("GEODE_HOME"), "tools", "vsd", "bin", "vsd");
-
-    if (SystemUtils.isWindows()) {
-      vsdPathname += ".bat";
-    }
-
-    return vsdPathname;
-  }
-
-  protected Set<String> processStatisticsArchiveFiles(final String[] statisticsArchiveFilePathnames)
-      throws FileNotFoundException {
-    Set<String> statisticsArchiveFiles = new TreeSet<>();
-
-    if (statisticsArchiveFilePathnames != null) {
-      for (String pathname : statisticsArchiveFilePathnames) {
-        File path = new File(pathname);
-
-        if (path.exists()) {
-          if (path.isFile()) {
-            if (StatisticsArchiveFileFilter.INSTANCE.accept(path)) {
-              statisticsArchiveFiles.add(pathname);
-            } else {
-              throw new IllegalArgumentException(
-                  "A Statistics Archive File must end with a .gfs file extension.");
-            }
-          } else { // the File (path) is a directory
-            processStatisticsArchiveFiles(path, statisticsArchiveFiles);
-          }
-        } else {
-          throw new FileNotFoundException(String.format(
-              "The pathname (%1$s) does not exist.  Please check the path and try again.",
-              path.getAbsolutePath()));
-        }
-      }
-    }
-
-    return statisticsArchiveFiles;
-  }
-
-  @SuppressWarnings("null")
-  protected void processStatisticsArchiveFiles(final File path,
-      final Set<String> statisticsArchiveFiles) {
-    if (path != null && path.isDirectory()) {
-      for (File file : path.listFiles(StatisticsArchiveFileAndDirectoryFilter.INSTANCE)) {
-        if (file.isDirectory()) {
-          processStatisticsArchiveFiles(file, statisticsArchiveFiles);
-        } else if (StatisticsArchiveFileFilter.INSTANCE.accept(file)) {
-          statisticsArchiveFiles.add(file.getAbsolutePath());
-        }
-      }
-    }
-  }
-
-  // NOTE as of 8.0, this command is no more!
-  // @CliCommand(value=CliStrings.START_DATABROWSER, help=CliStrings.START_DATABROWSER__HELP)
-  @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_M_AND_M})
-  public Result startDataBrowser() {
-    try {
-      String geodeHome = System.getenv("GEODE_HOME");
-
-      assertState(StringUtils.isNotBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE);
-
-      if (isConnectedAndReady()
-          && (getGfsh().getOperationInvoker() instanceof JmxOperationInvoker)) {
-        String dataBrowserPath = getPathToDataBrowser();
-
-        assertState(IOUtils.isExistingPathname(dataBrowserPath),
-            String.format(CliStrings.START_DATABROWSER__NOT_FOUND_ERROR_MESSAGE, geodeHome));
-
-        JmxOperationInvoker operationInvoker =
-            (JmxOperationInvoker) getGfsh().getOperationInvoker();
-
-        String dataBrowserCommandLine = String.format("%1$s %2$s %3$d", getPathToDataBrowser(),
-            operationInvoker.getManagerHost(), operationInvoker.getManagerPort());
-
-        if (isDebugging()) {
-          getGfsh().printAsInfo(
-              String.format("GemFire DataBrowser command-line (%1$s)", dataBrowserCommandLine));
-        }
-
-        Process dataBrowserProcess = Runtime.getRuntime().exec(dataBrowserCommandLine);
-
-        getGfsh().printAsInfo(CliStrings.START_DATABROWSER__RUN);
-
-        String dataBrowserProcessOutput =
-            waitAndCaptureProcessStandardOutputStream(dataBrowserProcess);
-
-        InfoResultData infoResultData = ResultBuilder.createInfoResultData();
-
-        if (StringUtils.isNotBlank(dataBrowserProcessOutput)) {
-          infoResultData.addLine(StringUtils.LINE_SEPARATOR);
-          infoResultData.addLine(dataBrowserProcessOutput);
-        }
-
-        return ResultBuilder.buildResult(infoResultData);
-      } else {
-        return ResultBuilder.createUserErrorResult(CliStrings.format(
-            CliStrings.GFSH_MUST_BE_CONNECTED_VIA_JMX_FOR_LAUNCHING_0, "GemFire DataBrowser"));
-      }
-    } catch (IllegalArgumentException | IllegalStateException e) {
-      return ResultBuilder.createUserErrorResult(e.getMessage());
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable t) {
-      SystemFailure.checkFailure();
-      return ResultBuilder.createShellClientErrorResult(t.getMessage());
-    }
-  }
-
-  protected String getPathToDataBrowser() {
-    String dataBrowserPathName =
-        IOUtils.appendToPath(GEODE_HOME, "tools", "DataBrowser", "bin", "databrowser");
-
-    if (SystemUtils.isWindows()) {
-      dataBrowserPathName += ".bat";
-    }
-
-    return dataBrowserPathName;
-  }
-
-  protected String waitAndCaptureProcessStandardOutputStream(final Process process) {
-    return waitAndCaptureProcessStandardOutputStream(process,
-        DEFAULT_PROCESS_OUTPUT_WAIT_TIME_MILLISECONDS);
-  }
-
-  protected String waitAndCaptureProcessStandardOutputStream(final Process process,
-      final long waitTimeMilliseconds) {
-    return waitAndCaptureProcessStream(process, process.getInputStream(), waitTimeMilliseconds);
-  }
-
-  protected String waitAndCaptureProcessStandardErrorStream(final Process process) {
-    return waitAndCaptureProcessStandardErrorStream(process,
-        DEFAULT_PROCESS_OUTPUT_WAIT_TIME_MILLISECONDS);
-  }
-
-  protected String waitAndCaptureProcessStandardErrorStream(final Process process,
-      final long waitTimeMilliseconds) {
-    return waitAndCaptureProcessStream(process, process.getErrorStream(), waitTimeMilliseconds);
-  }
-
-  private String waitAndCaptureProcessStream(final Process process,
-      final InputStream processInputStream, long waitTimeMilliseconds) {
-    final StringBuffer buffer = new StringBuffer();
-
-    InputListener inputListener = new InputListener() {
-      @Override
-      public void notifyInputLine(final String line) {
-        buffer.append(line);
-        buffer.append(StringUtils.LINE_SEPARATOR);
-      }
-    };
-
-    ProcessStreamReader reader = new ProcessStreamReader.Builder(process)
-        .inputStream(processInputStream).inputListener(inputListener).build();
-
-    try {
-      reader.start();
-
-      final long endTime = (System.currentTimeMillis() + waitTimeMilliseconds);
-
-      while (System.currentTimeMillis() < endTime) {
-        try {
-          reader.join(waitTimeMilliseconds);
-        } catch (InterruptedException ignore) {
-        }
-      }
-    } finally {
-      reader.stop();
-    }
-
-    return buffer.toString();
-  }
-
   @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,
@@ -2516,27 +1393,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
     }
   }
 
-  protected static class StatisticsArchiveFileFilter implements FileFilter {
-
-    protected static final StatisticsArchiveFileFilter INSTANCE = new StatisticsArchiveFileFilter();
-
-    public boolean accept(final File pathname) {
-      return (pathname.isFile() && pathname.getAbsolutePath().endsWith(".gfs"));
-    }
-  }
-
-  protected static class StatisticsArchiveFileAndDirectoryFilter
-      extends StatisticsArchiveFileFilter {
-
-    protected static final StatisticsArchiveFileAndDirectoryFilter INSTANCE =
-        new StatisticsArchiveFileAndDirectoryFilter();
-
-    @Override
-    public boolean accept(final File pathname) {
-      return (pathname.isDirectory() || super.accept(pathname));
-    }
-  }
-
   protected String resolveWorkingDir(String userSpecifiedDir, String memberName) {
     File workingDir =
         (userSpecifiedDir == null) ? new File(memberName) : new File(userSpecifiedDir);

http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/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 415dd69..695718a 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
@@ -52,11 +52,7 @@ import org.apache.geode.security.ResourcePermission.Resource;
 /**
  * @since GemFire 7.0
  */
-public class MemberCommands implements CommandMarker {
-
-  private Gfsh getGfsh() {
-    return Gfsh.getCurrentInstance();
-  }
+public class MemberCommands implements GfshCommand {
 
   private static final GetMemberInformationFunction getMemberInformation =
       new GetMemberInformationFunction();
@@ -104,10 +100,6 @@ public class MemberCommands implements CommandMarker {
     return result;
   }
 
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   @CliCommand(value = {CliStrings.DESCRIBE_MEMBER}, help = CliStrings.DESCRIBE_MEMBER__HELP)
   @CliMetaData(shellOnly = false, relatedTopic = CliStrings.TOPIC_GEODE_SERVER)
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)

http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/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 a23afd0..9754d7d 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -14,45 +14,8 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.zip.DataFormatException;
-import java.util.zip.GZIPInputStream;
-
-import javax.management.ObjectName;
-
 import org.apache.commons.lang.StringUtils;
-import org.apache.logging.log4j.Logger;
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
 import org.apache.geode.LogWriter;
-import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionException;
@@ -106,15 +69,47 @@ import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.result.ResultData;
 import org.apache.geode.management.internal.cli.result.ResultDataException;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.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;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.zip.DataFormatException;
+import java.util.zip.GZIPInputStream;
+import javax.management.ObjectName;
 
 /**
  * @since GemFire 7.0
  */
-public class MiscellaneousCommands implements CommandMarker {
+public class MiscellaneousCommands implements GfshCommand {
 
   public static final String NETSTAT_FILE_REQUIRED_EXTENSION = ".txt";
   public final static String DEFAULT_TIME_OUT = "10";
@@ -122,14 +117,6 @@ public class MiscellaneousCommands implements CommandMarker {
 
   private final GetStackTracesFunction getStackTracesFunction = new GetStackTracesFunction();
 
-  private Gfsh getGfsh() {
-    return Gfsh.getCurrentInstance();
-  }
-
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
   public void shutdownNode(final long timeout, final Set<DistributedMember> includeMembers)
       throws TimeoutException, InterruptedException, ExecutionException {
     ExecutorService exec = Executors.newSingleThreadExecutor();

http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/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 0ce8ec2..9f1290d 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
@@ -44,7 +44,7 @@ import java.io.StringWriter;
 import java.util.Arrays;
 import java.util.Collection;
 
-public class PDXCommands extends AbstractCommandsSupport {
+public class PDXCommands implements GfshCommand {
 
 
   @CliCommand(value = CliStrings.CONFIGURE_PDX, help = CliStrings.CONFIGURE_PDX__HELP)

http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/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 f4dee75..d3c2635 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
@@ -51,7 +51,7 @@ import java.util.concurrent.atomic.AtomicReference;
  * 
  * @since GemFire 8.0
  */
-public class QueueCommands extends AbstractCommandsSupport {
+public class QueueCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.CREATE_ASYNC_EVENT_QUEUE,
       help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__HELP)

http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/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 6f5b047..2009dcc 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
@@ -14,20 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-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.CacheFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.FunctionInvocationTargetException;
 import org.apache.geode.cache.execute.ResultCollector;
@@ -50,11 +36,21 @@ import org.apache.geode.management.internal.cli.result.CompositeResultData;
 import org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData;
 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.cli.util.RegionAttributesNames;
 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.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
 
 /**
  * Class containing implementation of commands based on region:
@@ -65,12 +61,7 @@ import org.apache.geode.security.ResourcePermission.Resource;
  * 
  * @since GemFire 7.0
  */
-public class RegionCommands implements CommandMarker {
-
-  private Gfsh getGfsh() {
-    return Gfsh.getCurrentInstance();
-  }
-
+public class RegionCommands implements GfshCommand {
   private static final GetRegionsFunction getRegionsFunction = new GetRegionsFunction();
   private static final GetRegionDescriptionFunction getRegionDescription =
       new GetRegionDescriptionFunction();
@@ -508,7 +499,4 @@ public class RegionCommands implements CommandMarker {
     return isAvailable;
   }
 
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/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 ad344ff..efd10d2 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
@@ -54,7 +54,6 @@ import org.apache.geode.management.internal.web.http.support.SimpleHttpRequester
 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.CommandMarker;
 import org.springframework.shell.core.ExitShellRequest;
 import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
@@ -90,7 +89,7 @@ import javax.net.ssl.TrustManagerFactory;
  *
  * @since GemFire 7.0
  */
-public class ShellCommands implements CommandMarker {
+public class ShellCommands implements GfshCommand {
 
   // millis that connect --locator will wait for a response from the locator.
   private final static int CONNECT_LOCATOR_TIMEOUT_MS = 60000; // see bug 45971
@@ -241,10 +240,6 @@ public class ShellCommands implements CommandMarker {
     return infoResultData;
   }
 
-  private Gfsh getGfsh() {
-    return Gfsh.getCurrentInstance();
-  }
-
   @CliCommand(value = {CliStrings.EXIT, "quit"}, help = CliStrings.EXIT__HELP)
   @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH})
   public ExitShellRequest exit() throws IOException {

http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/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 29627f3..fffb964 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
@@ -40,7 +40,7 @@ import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
 
-public class StatusCommands extends AbstractCommandsSupport implements CommandMarker {
+public class StatusCommands implements GfshCommand {
   static final FetchSharedConfigurationStatusFunction fetchSharedConfigStatusFunction =
       new FetchSharedConfigurationStatusFunction();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/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 57080ba..28686ce 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
@@ -66,7 +66,7 @@ import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
 
-public class WanCommands extends AbstractCommandsSupport {
+public class WanCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.CREATE_GATEWAYSENDER, help = CliStrings.CREATE_GATEWAYSENDER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)

http://git-wip-us.apache.org/repos/asf/geode/blob/cfdd5737/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartJConsoleCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartJConsoleCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartJConsoleCommand.java
new file mode 100644
index 0000000..e27d78b
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartJConsoleCommand.java
@@ -0,0 +1,175 @@
+/*
+ * 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.lifecycle;
+
+import static org.apache.geode.internal.process.ProcessStreamReader.waitAndCaptureProcessStandardErrorStream;
+
+import org.apache.geode.GemFireException;
+import org.apache.geode.SystemFailure;
+import org.apache.geode.internal.lang.ObjectUtils;
+import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.internal.util.IOUtils;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.GfshParser;
+import org.apache.geode.management.internal.cli.commands.GfshCommand;
+import org.apache.geode.management.internal.cli.converters.ConnectionEndpointConverter;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.shell.JmxOperationInvoker;
+import org.apache.geode.management.internal.cli.util.ConnectionEndpoint;
+import org.apache.geode.management.internal.cli.util.JdkTool;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class StartJConsoleCommand implements GfshCommand {
+
+  @CliCommand(value = CliStrings.START_JCONSOLE, help = CliStrings.START_JCONSOLE__HELP)
+  @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_MANAGER,
+      CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_M_AND_M})
+  public Result startJConsole(
+      @CliOption(key = CliStrings.START_JCONSOLE__INTERVAL, unspecifiedDefaultValue = "4",
+          help = CliStrings.START_JCONSOLE__INTERVAL__HELP) final int interval,
+      @CliOption(key = CliStrings.START_JCONSOLE__NOTILE, specifiedDefaultValue = "true",
+          unspecifiedDefaultValue = "false",
+          help = CliStrings.START_JCONSOLE__NOTILE__HELP) final boolean notile,
+      @CliOption(key = CliStrings.START_JCONSOLE__PLUGINPATH,
+          help = CliStrings.START_JCONSOLE__PLUGINPATH__HELP) final String pluginpath,
+      @CliOption(key = CliStrings.START_JCONSOLE__VERSION, specifiedDefaultValue = "true",
+          unspecifiedDefaultValue = "false",
+          help = CliStrings.START_JCONSOLE__VERSION__HELP) final boolean version,
+      @CliOption(key = CliStrings.START_JCONSOLE__J, optionContext = GfshParser.J_OPTION_CONTEXT,
+          help = CliStrings.START_JCONSOLE__J__HELP) final List<String> jvmArgs) {
+    try {
+      String[] jconsoleCommandLine =
+          createJConsoleCommandLine(null, interval, notile, pluginpath, version, jvmArgs);
+
+      if (isDebugging()) {
+        getGfsh().printAsInfo(
+            String.format("JConsole command-line ($1%s)", Arrays.toString(jconsoleCommandLine)));
+      }
+
+      Process jconsoleProcess = Runtime.getRuntime().exec(jconsoleCommandLine);
+
+      StringBuilder message = new StringBuilder();
+
+      if (version) {
+        jconsoleProcess.waitFor();
+
+        BufferedReader reader =
+            new BufferedReader(new InputStreamReader(jconsoleProcess.getErrorStream()));
+
+        for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+          message.append(line);
+          message.append(StringUtils.LINE_SEPARATOR);
+        }
+
+        IOUtils.close(reader);
+      } else {
+        getGfsh().printAsInfo(CliStrings.START_JCONSOLE__RUN);
+
+        String jconsoleProcessOutput = waitAndCaptureProcessStandardErrorStream(jconsoleProcess);
+
+        if (StringUtils.isNotBlank(jconsoleProcessOutput)) {
+          message.append(StringUtils.LINE_SEPARATOR);
+          message.append(jconsoleProcessOutput);
+        }
+      }
+
+      return ResultBuilder.createInfoResult(message.toString());
+    } catch (GemFireException | IllegalStateException | IllegalArgumentException e) {
+      return ResultBuilder.createShellClientErrorResult(e.getMessage());
+    } catch (IOException e) {
+      return ResultBuilder
+          .createShellClientErrorResult(CliStrings.START_JCONSOLE__IO_EXCEPTION_MESSAGE);
+    } catch (VirtualMachineError e) {
+      SystemFailure.initiateFailure(e);
+      throw e;
+    } catch (Throwable t) {
+      SystemFailure.checkFailure();
+      return ResultBuilder.createShellClientErrorResult(
+          String.format(CliStrings.START_JCONSOLE__CATCH_ALL_ERROR_MESSAGE, toString(t, false)));
+    }
+  }
+
+  protected String[] createJConsoleCommandLine(final String member, final int interval,
+      final boolean notile, final String pluginpath, final boolean version,
+      final List<String> jvmArgs) {
+    List<String> commandLine = new ArrayList<>();
+
+    commandLine.add(JdkTool.getJConsolePathname());
+
+    if (version) {
+      commandLine.add("-version");
+    } else {
+      commandLine.add("-interval=" + interval);
+
+      if (notile) {
+        commandLine.add("-notile");
+      }
+
+      if (StringUtils.isNotBlank(pluginpath)) {
+        commandLine.add("-pluginpath " + pluginpath);
+      }
+
+      if (jvmArgs != null) {
+        for (final String arg : jvmArgs) {
+          commandLine.add("-J" + arg);
+        }
+      }
+
+      String jmxServiceUrl = getJmxServiceUrlAsString(member);
+
+      if (StringUtils.isNotBlank(jmxServiceUrl)) {
+        commandLine.add(jmxServiceUrl);
+      }
+    }
+
+    return commandLine.toArray(new String[commandLine.size()]);
+  }
+
+  protected String getJmxServiceUrlAsString(final String member) {
+    if (StringUtils.isNotBlank(member)) {
+      ConnectionEndpointConverter converter = new ConnectionEndpointConverter();
+
+      try {
+        ConnectionEndpoint connectionEndpoint =
+            converter.convertFromText(member, ConnectionEndpoint.class, null);
+        String hostAndPort = connectionEndpoint.getHost() + ":" + connectionEndpoint.getPort();
+        return String.format("service:jmx:rmi://%s/jndi/rmi://%s/jmxrmi", hostAndPort, hostAndPort);
+      } catch (Exception e) {
+        throw new IllegalArgumentException(
+            CliStrings.START_JCONSOLE__CONNECT_BY_MEMBER_NAME_ID_ERROR_MESSAGE);
+      }
+    } else {
+      if (isConnectedAndReady()
+          && (getGfsh().getOperationInvoker() instanceof JmxOperationInvoker)) {
+        JmxOperationInvoker jmxOperationInvoker =
+            (JmxOperationInvoker) getGfsh().getOperationInvoker();
+
+        return ObjectUtils.toString(jmxOperationInvoker.getJmxServiceUrl());
+      }
+    }
+
+    return null;
+  }
+}


Mime
View raw message