Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@
import org.apache.geode.internal.util.IOUtils;
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.cli.GfshParser;
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.result.model.InfoResultModel;
import org.apache.geode.management.internal.cli.result.model.ResultModel;
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.util.CommandStringBuilder;
Expand All @@ -61,7 +60,7 @@ public class StartLocatorCommand extends InternalGfshCommand {
@CliCommand(value = CliStrings.START_LOCATOR, help = CliStrings.START_LOCATOR__HELP)
@CliMetaData(shellOnly = true,
relatedTopic = {CliStrings.TOPIC_GEODE_LOCATOR, CliStrings.TOPIC_GEODE_LIFECYCLE})
public Result startLocator(
public ResultModel startLocator(
@CliOption(key = CliStrings.START_LOCATOR__MEMBER_NAME,
help = CliStrings.START_LOCATOR__MEMBER_NAME__HELP) String memberName,
@CliOption(key = CliStrings.START_LOCATOR__BIND_ADDRESS,
Expand Down Expand Up @@ -141,7 +140,7 @@ public Result startLocator(

}

Result doStartLocator(
ResultModel doStartLocator(
String memberName,
String bindAddress,
String classpath,
Expand Down Expand Up @@ -171,13 +170,13 @@ Result doStartLocator(
throws MalformedObjectNameException, IOException, InterruptedException,
ClassNotFoundException {
if (gemfirePropertiesFile != null && !gemfirePropertiesFile.exists()) {
return ResultBuilder.createUserErrorResult(
return ResultModel.createError(
CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY,
gemfirePropertiesFile.getAbsolutePath()));
}

if (gemfireSecurityPropertiesFile != null && !gemfireSecurityPropertiesFile.exists()) {
return ResultBuilder.createUserErrorResult(
return ResultModel.createError(
CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ",
gemfireSecurityPropertiesFile.getAbsolutePath()));
}
Expand Down Expand Up @@ -285,7 +284,7 @@ Result doStartLocator(
} else {
final int exitValue = locatorProcess.exitValue();

return ResultBuilder.createShellClientErrorResult(
return ResultModel.createError(
String.format(CliStrings.START_LOCATOR__PROCESS_TERMINATED_ABNORMALLY_ERROR_MESSAGE,
exitValue, locatorLauncher.getWorkingDirectory(), message.toString()));
}
Expand All @@ -305,21 +304,22 @@ Result doStartLocator(
(registeredLocatorSignalListener && locatorSignalListener.isSignaled()
&& ServerLauncher.ServerState.isStartingNotRespondingOrNull(locatorState));

InfoResultData infoResultData = ResultBuilder.createInfoResultData();
ResultModel result = new ResultModel();
InfoResultModel infoResult = result.addInfo();

if (loadSharedConfigurationFromDirectory) {
infoResultData.addLine("Warning: Option --load-cluster-config-from-dir is deprecated, use '"
infoResult.addLine("Warning: Option --load-cluster-config-from-dir is deprecated, use '"
+ CliStrings.IMPORT_SHARED_CONFIG
+ "' command instead to import any existing configuration.\n");
}

if (asyncStart) {
infoResultData.addLine(
infoResult.addLine(
String.format(CliStrings.ASYNC_PROCESS_LAUNCH_MESSAGE, CliStrings.LOCATOR_TERM_NAME));
return ResultBuilder.buildResult(infoResultData);
return result;
}

infoResultData.addLine(locatorState.toString());
infoResult.addLine(locatorState.toString());
String locatorHostName;
InetAddress bindAddr = locatorLauncher.getBindAddress();
if (bindAddr != null) {
Expand All @@ -341,16 +341,16 @@ Result doStartLocator(
// Else, ask the user to use the "connect" command to connect to the Locator.
if (shouldAutoConnect(connect)) {
boolean connected =
doAutoConnect(locatorHostName, locatorPort, configProperties, infoResultData);
doAutoConnect(locatorHostName, locatorPort, configProperties, infoResult);

// Report on the state of the Shared Configuration service if enabled...
if (enableSharedConfiguration && connected) {
infoResultData.addLine(ClusterConfigurationStatusRetriever.fromLocator(locatorHostName,
infoResult.addLine(ClusterConfigurationStatusRetriever.fromLocator(locatorHostName,
locatorPort, configProperties));
}
}

return ResultBuilder.buildResult(infoResultData);
return result;
}

// TODO should we connect implicitly when in non-interactive, headless mode (e.g. gfsh -e "start
Expand All @@ -362,7 +362,7 @@ private boolean shouldAutoConnect(final boolean connect) {
}

private boolean doAutoConnect(final String locatorHostname, final int locatorPort,
final Properties configurationProperties, final InfoResultData infoResultData) {
final Properties configurationProperties, final InfoResultModel infoResult) {
boolean connectSuccess = false;
boolean jmxManagerAuthEnabled = false;
boolean jmxManagerSslEnabled = false;
Expand All @@ -385,8 +385,8 @@ private boolean doAutoConnect(final String locatorHostname, final int locatorPor
String shellAndLogMessage = CliStrings.format(CliStrings.CONNECT__MSG__SUCCESS,
"JMX Manager " + memberEndpoint.toString(false));

infoResultData.addLine("\n");
infoResultData.addLine(shellAndLogMessage);
infoResult.addLine("\n");
infoResult.addLine(shellAndLogMessage);
getGfsh().logToFile(shellAndLogMessage, null);

connectSuccess = true;
Expand All @@ -411,20 +411,20 @@ private boolean doAutoConnect(final String locatorHostname, final int locatorPor

if (!connectSuccess) {
doOnConnectionFailure(locatorHostname, locatorPort, jmxManagerAuthEnabled,
jmxManagerSslEnabled, infoResultData);
jmxManagerSslEnabled, infoResult);
}

if (StringUtils.isNotBlank(responseFailureMessage)) {
infoResultData.addLine("\n");
infoResultData.addLine(responseFailureMessage);
infoResult.addLine("\n");
infoResult.addLine(responseFailureMessage);
}
return connectSuccess;
}

private void doOnConnectionFailure(final String locatorHostName, final int locatorPort,
final boolean jmxManagerAuthEnabled, final boolean jmxManagerSslEnabled,
final InfoResultData infoResultData) {
infoResultData.addLine("\n");
final InfoResultModel infoResult) {
infoResult.addLine("\n");
CommandStringBuilder commandUsage = new CommandStringBuilder(CliStrings.CONNECT)
.addOption(CliStrings.CONNECT__LOCATOR, locatorHostName + "[" + locatorPort + "]");

Expand All @@ -438,12 +438,12 @@ private void doOnConnectionFailure(final String locatorHostName, final int locat
message.append(jmxManagerAuthEnabled ? " and " : StringUtils.EMPTY)
.append("SSL configuration");
}
infoResultData.addLine(CliStrings.format(
infoResult.addLine(CliStrings.format(
CliStrings.START_LOCATOR__USE__0__TO__CONNECT_WITH_SECURITY, commandUsage.toString()));
if (jmxManagerAuthEnabled || jmxManagerSslEnabled) {
message.append(" required to connect to the Manager.");
infoResultData.addLine("\n");
infoResultData.addLine(message.toString());
infoResult.addLine("\n");
infoResult.addLine(message.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@
import org.apache.geode.internal.util.IOUtils;
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.cli.CliUtil;
import org.apache.geode.management.internal.cli.GfshParser;
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.result.model.ResultModel;
import org.apache.geode.management.internal.cli.shell.Gfsh;
import org.apache.geode.management.internal.security.ResourceConstants;

Expand All @@ -55,7 +54,7 @@ public class StartServerCommand extends InternalGfshCommand {
@CliCommand(value = CliStrings.START_SERVER, help = CliStrings.START_SERVER__HELP)
@CliMetaData(shellOnly = true,
relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE})
public Result startServer(
public ResultModel startServer(
@CliOption(key = CliStrings.START_SERVER__NAME,
help = CliStrings.START_SERVER__NAME__HELP) String memberName,
@CliOption(key = CliStrings.START_SERVER__ASSIGN_BUCKETS, unspecifiedDefaultValue = "false",
Expand Down Expand Up @@ -194,8 +193,8 @@ public Result startServer(
passwordToUse = getGfsh().readPassword(CliStrings.START_SERVER__PASSWORD + ": ");
}
if (StringUtils.isBlank(passwordToUse)) {
return ResultBuilder
.createConnectionErrorResult(CliStrings.START_SERVER__MSG__PASSWORD_MUST_BE_SPECIFIED);
return ResultModel
.createError(CliStrings.START_SERVER__MSG__PASSWORD_MUST_BE_SPECIFIED);
}
}

Expand All @@ -215,7 +214,7 @@ public Result startServer(
httpServicePort, httpServiceBindAddress, userName, passwordToUse, redirectOutput);
}

Result doStartServer(String memberName, Boolean assignBuckets, String bindAddress,
ResultModel doStartServer(String memberName, Boolean assignBuckets, String bindAddress,
String cacheXmlPathname, String classpath, Float criticalHeapPercentage,
Float criticalOffHeapPercentage, String workingDirectory, Boolean disableDefaultServer,
Boolean disableExitWhenOutOfMemory, Boolean enableTimeStatistics,
Expand All @@ -237,7 +236,7 @@ Result doStartServer(String memberName, Boolean assignBuckets, String bindAddres

if (StringUtils.isNotBlank(cacheXmlPathname)) {
if (!IOUtils.isExistingPathname(cacheXmlPathname)) {
return ResultBuilder.createUserErrorResult(
return ResultModel.createError(
CliStrings.format(CliStrings.CACHE_XML_NOT_FOUND_MESSAGE, cacheXmlPathname));
} else {
getGfsh().logWarning(
Expand All @@ -246,13 +245,13 @@ Result doStartServer(String memberName, Boolean assignBuckets, String bindAddres
}

if (gemfirePropertiesFile != null && !gemfirePropertiesFile.exists()) {
return ResultBuilder.createUserErrorResult(
return ResultModel.createError(
CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY,
gemfirePropertiesFile.getAbsolutePath()));
}

if (gemfireSecurityPropertiesFile != null && !gemfireSecurityPropertiesFile.exists()) {
return ResultBuilder.createUserErrorResult(
return ResultModel.createError(
CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ",
gemfireSecurityPropertiesFile.getAbsolutePath()));
}
Expand Down Expand Up @@ -402,7 +401,7 @@ Result doStartServer(String memberName, Boolean assignBuckets, String bindAddres
} else {
final int exitValue = serverProcess.exitValue();

return ResultBuilder.createShellClientErrorResult(
return ResultModel.createError(
String.format(CliStrings.START_SERVER__PROCESS_TERMINATED_ABNORMALLY_ERROR_MESSAGE,
exitValue, serverLauncher.getWorkingDirectory(), message.toString()));

Expand All @@ -422,9 +421,9 @@ Result doStartServer(String memberName, Boolean assignBuckets, String bindAddres

if (asyncStart) { // async start
Gfsh.print(String.format(CliStrings.ASYNC_PROCESS_LAUNCH_MESSAGE, SERVER_TERM_NAME));
return ResultBuilder.createInfoResult("");
return ResultModel.createInfo("");
} else {
return ResultBuilder.createInfoResult(serverState.toString());
return ResultModel.createInfo(serverState.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@
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.cli.commands.InternalGfshCommand;
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.result.model.InfoResultModel;
import org.apache.geode.management.internal.cli.result.model.ResultModel;
import org.apache.geode.management.internal.configuration.utils.ClusterConfigurationStatusRetriever;

public class StatusLocatorCommand extends InternalGfshCommand {
@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(
public ResultModel statusLocator(
@CliOption(key = CliStrings.STATUS_LOCATOR__MEMBER,
optionContext = ConverterHint.LOCATOR_MEMBER_IDNAME,
help = CliStrings.STATUS_LOCATOR__MEMBER__HELP) final String member,
Expand All @@ -62,11 +61,11 @@ public Result statusLocator(
LocatorLauncher.LocatorState.fromJson(locatorProxy.status());
return createStatusLocatorResult(state);
} else {
return ResultBuilder.createUserErrorResult(CliStrings.format(
return ResultModel.createError(CliStrings.format(
CliStrings.STATUS_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, member));
}
} else {
return ResultBuilder.createUserErrorResult(CliStrings.format(
return ResultModel.createError(CliStrings.format(
CliStrings.STATUS_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, LOCATOR_TERM_NAME));
}
} else {
Expand All @@ -78,18 +77,19 @@ public Result statusLocator(
final LocatorLauncher.LocatorState status = locatorLauncher.status();
if (status.getStatus().equals(AbstractLauncher.Status.NOT_RESPONDING)
|| status.getStatus().equals(AbstractLauncher.Status.STOPPED)) {
return ResultBuilder.createShellClientErrorResult(status.toString());
return ResultModel.createError(status.toString());
}
return createStatusLocatorResult(status);
}

}

protected Result createStatusLocatorResult(final LocatorLauncher.LocatorState state)
protected ResultModel createStatusLocatorResult(final LocatorLauncher.LocatorState state)
throws NumberFormatException, IOException, ClassNotFoundException {
InfoResultData infoResultData = ResultBuilder.createInfoResultData();
infoResultData.addLine(state.toString());
infoResultData.addLine(ClusterConfigurationStatusRetriever.fromLocator(state));
return ResultBuilder.buildResult(infoResultData);
ResultModel result = new ResultModel();
InfoResultModel info = result.addInfo();
info.addLine(state.toString());
info.addLine(ClusterConfigurationStatusRetriever.fromLocator(state));
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
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.cli.commands.InternalGfshCommand;
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.result.model.ResultModel;
import org.apache.geode.management.internal.cli.shell.Gfsh;

public class StopLocatorCommand extends InternalGfshCommand {
Expand All @@ -41,7 +40,7 @@ public class StopLocatorCommand extends InternalGfshCommand {
@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(
public ResultModel stopLocator(
@CliOption(key = CliStrings.STOP_LOCATOR__MEMBER,
optionContext = ConverterHint.LOCATOR_MEMBER_IDNAME,
help = CliStrings.STOP_LOCATOR__MEMBER__HELP) final String member,
Expand Down Expand Up @@ -70,11 +69,11 @@ public Result stopLocator(
locatorState = LocatorLauncher.LocatorState.fromJson(locatorProxy.status());
locatorProxy.shutDownMember();
} else {
return ResultBuilder.createUserErrorResult(CliStrings
return ResultModel.createError(CliStrings
.format(CliStrings.STOP_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, member));
}
} else {
return ResultBuilder.createUserErrorResult(CliStrings
return ResultModel.createError(CliStrings
.format(CliStrings.STOP_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, LOCATOR_TERM_NAME));
}
} else {
Expand Down Expand Up @@ -104,9 +103,9 @@ public Result stopLocator(
}
}

return ResultBuilder.createInfoResult(StringUtils.EMPTY);
return ResultModel.createInfo(StringUtils.EMPTY);
} else {
return ResultBuilder.createUserErrorResult(locatorState.toString());
return ResultModel.createError(locatorState.toString());
}
}
}