Search in sources :

Example 11 with GemFireException

use of org.apache.geode.GemFireException in project geode by apache.

the class StartJVisualVMCommand method startJVisualVM.

@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)));
    }
}
Also used : GemFireException(org.apache.geode.GemFireException) InfoResultData(org.apache.geode.management.internal.cli.result.InfoResultData) CliCommand(org.springframework.shell.core.annotation.CliCommand) CliMetaData(org.apache.geode.management.cli.CliMetaData)

Example 12 with GemFireException

use of org.apache.geode.GemFireException in project geode by apache.

the class AgentLauncher method createAgentProcessRunnable.

private Runnable createAgentProcessRunnable(final Agent agent) {
    return new Runnable() {

        public void run() {
            try {
                agent.start();
                writeStatus(createStatus(AgentLauncher.this.basename, RUNNING, OSProcess.getId()));
            } catch (IOException e) {
                e.printStackTrace();
            } catch (GemFireException e) {
                e.printStackTrace();
                handleGemFireException(e);
            }
        }

        private void handleGemFireException(final GemFireException e) {
            String message = LocalizedStrings.AgentLauncher_SERVER_FAILED_TO_START_0.toLocalizedString(e.getMessage());
            if (e.getCause() != null) {
                if (e.getCause().getCause() != null) {
                    message += ", " + e.getCause().getCause().getMessage();
                }
            }
            setServerError(null, new Exception(message));
        }
    };
}
Also used : GemFireException(org.apache.geode.GemFireException) IOException(java.io.IOException) AdminException(org.apache.geode.admin.AdminException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) GemFireException(org.apache.geode.GemFireException)

Aggregations

GemFireException (org.apache.geode.GemFireException)12 ExecutionException (java.util.concurrent.ExecutionException)3 Future (java.util.concurrent.Future)3 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)3 CliMetaData (org.apache.geode.management.cli.CliMetaData)3 CliCommand (org.springframework.shell.core.annotation.CliCommand)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 InternalGemFireError (org.apache.geode.InternalGemFireError)2 ServerConnectivityException (org.apache.geode.cache.client.ServerConnectivityException)2 RebalanceResults (org.apache.geode.cache.control.RebalanceResults)2 InfoResultData (org.apache.geode.management.internal.cli.result.InfoResultData)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Iterator (java.util.Iterator)1 List (java.util.List)1 GemFireIOException (org.apache.geode.GemFireIOException)1