protected ResultModel createStatusLocatorResult(final LocatorLauncher.LocatorState state) throws NumberFormatException, IOException, ClassNotFoundException { ResultModel result = new ResultModel(); InfoResultModel info = result.addInfo(); info.addLine(state.toString()); info.addLine(ClusterConfigurationStatusRetriever.fromLocator(state)); return result; } }
private void doOnConnectionFailure(final String locatorHostName, final int locatorPort, final boolean jmxManagerAuthEnabled, final boolean jmxManagerSslEnabled, final InfoResultModel infoResult) { infoResult.addLine("\n"); CommandStringBuilder commandUsage = new CommandStringBuilder(CliStrings.CONNECT) .addOption(CliStrings.CONNECT__LOCATOR, locatorHostName + "[" + locatorPort + "]"); StringBuilder message = new StringBuilder(); if (jmxManagerAuthEnabled) { commandUsage.addOption(CliStrings.CONNECT__USERNAME).addOption(CliStrings.CONNECT__PASSWORD); message.append("Authentication"); } if (jmxManagerSslEnabled) { message.append(jmxManagerAuthEnabled ? " and " : StringUtils.EMPTY) .append("SSL configuration"); } 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."); infoResult.addLine("\n"); infoResult.addLine(message.toString()); } }
@Override public ResultModel postExecution(GfshParseResult parseResult, ResultModel resultModel, Path tempFile) { try { for (Map.Entry<String, FileResultModel> entry : resultModel.getFiles().entrySet()) { entry.getValue().saveFile(); resultModel.addInfo().addLine("Metrics saved to: " + entry.getKey()); } } catch (IOException e) { resultModel.addInfo().addLine("Unable to save file: " + e.getMessage()); resultModel.setStatus(Result.Status.ERROR); } return resultModel; } }
info.addLine(dir.getAbsolutePath() + " can not be created."); setStatus(Result.Status.ERROR); return; info.addLine(dir.getAbsolutePath() + " is not a directory."); setStatus(Result.Status.ERROR); return; info.addLine("Can not write to " + dir.getAbsolutePath()); setStatus(Result.Status.ERROR); return; info.addLine(fileResult.saveFile(dir));
@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 ResultModel startJVisualVM( @CliOption(key = CliStrings.START_JCONSOLE__J, optionContext = GfshParser.J_OPTION_CONTEXT, help = CliStrings.START_JCONSOLE__J__HELP) final String[] jvmArgs) throws IOException { String jvisualvmProcessOutput = getProcessOutput(jvmArgs); ResultModel result = new ResultModel(); InfoResultModel infoResultModel = result.addInfo(); if (StringUtils.isNotBlank(jvisualvmProcessOutput)) { infoResultModel.addLine(System.lineSeparator()); infoResultModel.addLine(jvisualvmProcessOutput); } return result; }
@Override public ResultModel postExecution(GfshParseResult parseResult, ResultModel resultModel, Path tempFile) { if (resultModel.getFiles().size() != 1) { resultModel.addInfo("No filename found to save"); resultModel.setStatus(Result.Status.ERROR); return resultModel; } try { for (Map.Entry<String, FileResultModel> entry : resultModel.getFiles().entrySet()) { entry.getValue().saveFile(); resultModel.addInfo().addLine( MessageFormat.format(CliStrings.SHOW_DEADLOCK__DEPENDENCIES__REVIEW, entry.getKey())); } } catch (IOException e) { resultModel.addInfo().addLine("Unable to save file: " + e.getMessage()); resultModel.setStatus(Result.Status.ERROR); } return resultModel; } }
/** * Helper method to create an {@code InfoResultModel} named "info". */ public static ResultModel createInfo(String message) { ResultModel result = new ResultModel(); result.addInfo(INFO_SECTION).addLine(message); result.setStatus(Result.Status.OK); return result; }
if (xmlSection == null) { InfoResultModel info = result.addInfo("info"); info.addLine(String.format("xml content is empty. %s is not created.", xmlFile)); } else { File file = new File(xmlFile).getAbsoluteFile(); Charset.defaultCharset()); xmlSection.removeLine(0); xmlSection.addLine("xml content exported to " + file.getAbsolutePath());
@Override public ResultModel postExecution(GfshParseResult parseResult, ResultModel model, Path tempFile) throws Exception { File outputFile = getOutputFile(parseResult); if (outputFile == null) { return model; } Map<String, String> sectionResultData = model.getDataSection(DataCommandResult.DATA_INFO_SECTION).getContent(); String limit = sectionResultData.get("Limit"); String resultString = sectionResultData.get("Result"); String rows = sectionResultData.get("Rows"); if ("false".equalsIgnoreCase(resultString)) { return model; } writeResultTableToFile(outputFile, new ModelCommandResult(model)); ResultModel newModel = new ResultModel(); DataResultModel data = newModel.addData(DataCommandResult.DATA_INFO_SECTION); data.addData("Result", resultString); if (StringUtils.isNotBlank(limit)) { data.addData("Limit", limit); } data.addData("Rows", rows); newModel.addInfo().addLine("Query results output to " + outputFile.getAbsolutePath()); return newModel; }
infoResult.addLine(CliStrings.DEFINE_INDEX__SUCCESS__MSG); infoResult.addLine(CliStrings.format(CliStrings.DEFINE_INDEX__NAME__MSG, indexName)); infoResult .addLine(CliStrings.format(CliStrings.DEFINE_INDEX__EXPRESSION__MSG, indexedExpression)); infoResult.addLine(CliStrings.format(CliStrings.DEFINE_INDEX__REGIONPATH__MSG, regionPath));
infoResult.addLine(message.toString());
@CliCommand(value = {CliStrings.LIST_MEMBER}, help = CliStrings.LIST_MEMBER__HELP) @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_SERVER) @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER, operation = ResourcePermission.Operation.READ) public ResultModel listMember(@CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.LIST_MEMBER__GROUP__HELP) String[] groups) { ResultModel crm = new ResultModel(); Set<DistributedMember> memberSet = new TreeSet<>(); memberSet.addAll(this.findMembersIncludingLocators(groups, null)); if (memberSet.isEmpty()) { crm.addInfo().addLine(CliStrings.LIST_MEMBER__MSG__NO_MEMBER_FOUND); return crm; } TabularResultModel resultData = crm.addTable(MEMBERS_SECTION); final DistributedMember coordinatorMember = getCoordinator(); for (DistributedMember member : memberSet) { resultData.accumulate("Name", member.getName()); if (member == coordinatorMember) { resultData.accumulate("Id", member.getId() + " [Coordinator]"); } else { resultData.accumulate("Id", member.getId()); } } return crm; }
regionsUsingSection.setHeader("Regions Using Data Source:"); if (regionsUsing.isEmpty()) { regionsUsingSection.addLine("no regions are using " + dataSourceName); } else { regionsUsingSection.setContent(regionsUsing);
@Test public void legacyErrorComparison() { // Create the legacy results ErrorResultData legacyError = ResultBuilder.createErrorResultData(); legacyError.addLine("This is a bad line"); legacyError.addLine("This is another bad line"); Result legacyResult = ResultBuilder.buildResult(legacyError); String legacyString = CommandResponseBuilder.createCommandResponseJson("server1", (CommandResult) legacyResult); CommandResult legacyErrorResult = ResultBuilder.fromJson(legacyString); // Create the new model results ResultModel newCrm = ResultModel.createError("This is a bad line"); newCrm.getInfoSections().get(0).addLine("This is another bad line"); String newModelString = CommandResponseBuilder.createCommandResponseJson("server1", newCrm); CommandResult newErrorModelResult = ResultBuilder.fromJson(newModelString); assertThat(legacyErrorResult.getMessageFromContent()) .isEqualTo(newErrorModelResult.getErrorMessage()); assertThat(readCommandOutput(newErrorModelResult)) .isEqualTo(readCommandOutput(legacyErrorResult)); }
result.addInfo().addLine("Please restart the servers to apply any changed configuration"); result.setConfigObject(aeqConfiguration);
infoData.addLine(CliStrings.format(CliStrings.EXPORT_CONFIG__MSG__EXCEPTION, result.getMemberIdOrName(), result.getThrowable())); } else if (result.isSuccessful()) {