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)));
}
}
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));
}
};
}
Aggregations