use of org.apache.geode.management.internal.cli.shell.OperationInvoker in project geode by apache.
the class ShellCommands method describeConnection.
@CliCommand(value = { CliStrings.DESCRIBE_CONNECTION }, help = CliStrings.DESCRIBE_CONNECTION__HELP)
@CliMetaData(shellOnly = true, relatedTopic = { CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GEODE_JMX })
public Result describeConnection() {
Result result = null;
try {
TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
Gfsh gfshInstance = getGfsh();
if (gfshInstance.isConnectedAndReady()) {
OperationInvoker operationInvoker = gfshInstance.getOperationInvoker();
// tabularResultData.accumulate("Monitored GemFire DS", operationInvoker.toString());
tabularResultData.accumulate("Connection Endpoints", operationInvoker.toString());
} else {
tabularResultData.accumulate("Connection Endpoints", "Not connected");
}
result = ResultBuilder.buildResult(tabularResultData);
} catch (Exception e) {
ErrorResultData errorResultData = ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
result = ResultBuilder.buildResult(errorResultData);
}
return result;
}
use of org.apache.geode.management.internal.cli.shell.OperationInvoker in project geode by apache.
the class ShellCommands method disconnect.
@CliCommand(value = { CliStrings.DISCONNECT }, help = CliStrings.DISCONNECT__HELP)
@CliMetaData(shellOnly = true, relatedTopic = { CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_MANAGER })
public Result disconnect() {
Result result = null;
if (getGfsh() != null && !getGfsh().isConnectedAndReady()) {
result = ResultBuilder.createInfoResult("Not connected.");
} else {
InfoResultData infoResultData = ResultBuilder.createInfoResultData();
try {
Gfsh gfshInstance = getGfsh();
if (gfshInstance.isConnectedAndReady()) {
OperationInvoker operationInvoker = gfshInstance.getOperationInvoker();
Gfsh.println("Disconnecting from: " + operationInvoker);
operationInvoker.stop();
infoResultData.addLine(CliStrings.format(CliStrings.DISCONNECT__MSG__DISCONNECTED, operationInvoker.toString()));
LogWrapper.getInstance().info(CliStrings.format(CliStrings.DISCONNECT__MSG__DISCONNECTED, operationInvoker.toString()));
gfshInstance.setPromptPath(org.apache.geode.management.internal.cli.converters.RegionPathConverter.DEFAULT_APP_CONTEXT_PATH);
} else {
infoResultData.addLine(CliStrings.DISCONNECT__MSG__NOTCONNECTED);
}
result = ResultBuilder.buildResult(infoResultData);
} catch (Exception e) {
result = ResultBuilder.createConnectionErrorResult(CliStrings.format(CliStrings.DISCONNECT__MSG__ERROR, e.getMessage()));
}
}
return result;
}
use of org.apache.geode.management.internal.cli.shell.OperationInvoker in project geode by apache.
the class StartPulseCommand method startPulse.
@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)));
}
}
Aggregations