use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class ShellCommands method executeClearHistory.
Result executeClearHistory() {
try {
Gfsh gfsh = Gfsh.getCurrentInstance();
gfsh.clearHistory();
} catch (Exception e) {
LogWrapper.getInstance().info(CliUtil.stackTraceAsString(e));
return ResultBuilder.createGemFireErrorResult("Exception occurred while clearing history " + e.getMessage());
}
return ResultBuilder.createInfoResult(CliStrings.HISTORY__MSG__CLEARED_HISTORY);
}
use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class RegionPathConverter method getAllRegionPaths.
public Set<String> getAllRegionPaths() {
Set<String> regionPathSet = Collections.emptySet();
Gfsh gfsh = Gfsh.getCurrentInstance();
if (gfsh != null && gfsh.isConnectedAndReady()) {
String[] regionPaths = gfsh.getOperationInvoker().getDistributedSystemMXBean().listAllRegionPaths();
if (regionPaths != null && regionPaths.length > 0) {
regionPathSet = new TreeSet<String>();
for (String regionPath : regionPaths) {
if (regionPath != null) {
// Not needed after 46387/46502 are addressed
regionPathSet.add(regionPath);
}
}
}
}
return regionPathSet;
}
use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class LocatorDiscoveryConfigConverter method getLocatorIdAndNames.
private Set<String> getLocatorIdAndNames() {
final Set<String> locatorIdsAndNames = new TreeSet<String>();
final Gfsh gfsh = Gfsh.getCurrentInstance();
if (gfsh != null && gfsh.isConnectedAndReady()) {
final String[] locatorIds = gfsh.getOperationInvoker().getDistributedSystemMXBean().listLocators();
if (locatorIds != null && locatorIds.length != 0) {
locatorIdsAndNames.addAll(Arrays.asList(locatorIds));
}
}
return locatorIdsAndNames;
}
use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class MemberGroupConverter method getMemberGroups.
public Set<String> getMemberGroups() {
final Gfsh gfsh = Gfsh.getCurrentInstance();
final Set<String> memberGroups = new TreeSet<String>();
if (gfsh != null && gfsh.isConnectedAndReady()) {
final String[] memberGroupsArray = gfsh.getOperationInvoker().getDistributedSystemMXBean().listGroups();
memberGroups.addAll(Arrays.asList(memberGroupsArray));
}
return memberGroups;
}
use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class Launcher method parseCommandLineCommand.
private int parseCommandLineCommand(final String... args) {
Gfsh gfsh = null;
try {
gfsh = Gfsh.getInstance(false, args, new GfshConfig());
this.startupTimeLogHelper.logStartupTime();
} catch (ClassNotFoundException cnfex) {
log(cnfex, gfsh);
} catch (IOException ioex) {
log(ioex, gfsh);
} catch (IllegalStateException isex) {
System.err.println("ERROR : " + isex.getMessage());
}
ExitShellRequest exitRequest = ExitShellRequest.NORMAL_EXIT;
if (gfsh != null) {
final String commandLineCommand = combineStrings(args);
if (commandLineCommand.startsWith(HELP)) {
if (commandLineCommand.equals(HELP)) {
printUsage(gfsh, System.out);
} else {
// help is also available for commands which are not available under
// allowedCommandLineCommands
gfsh.executeCommand(commandLineCommand);
}
} else {
boolean commandIsAllowed = false;
for (String allowedCommandLineCommand : this.allowedCommandLineCommands) {
if (commandLineCommand.startsWith(allowedCommandLineCommand)) {
commandIsAllowed = true;
break;
}
}
if (!commandIsAllowed) {
System.err.println(CliStrings.format(MSG_INVALID_COMMAND_OR_OPTION, CliUtil.arrayToString(args)));
exitRequest = ExitShellRequest.FATAL_EXIT;
} else {
if (!gfsh.executeScriptLine(commandLineCommand)) {
if (gfsh.getLastExecutionStatus() != 0)
exitRequest = ExitShellRequest.FATAL_EXIT;
} else if (gfsh.getLastExecutionStatus() != 0) {
exitRequest = ExitShellRequest.FATAL_EXIT;
}
}
}
}
return exitRequest.getExitCode();
}
Aggregations