/** * Logs the configuration check report information. */ public synchronized void logConfigReport() { ConfigStatus reportStatus = mConfigCheckReport.getConfigStatus(); if (reportStatus.equals(ConfigStatus.PASSED)) { LOG.info(CONSISTENT_CONFIGURATION_INFO); } else if (reportStatus.equals(ConfigStatus.WARN)) { LOG.warn("{}\nWarnings: {}", INCONSISTENT_CONFIGURATION_INFO, mConfigCheckReport.getConfigWarns().values().stream() .map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", "))); } else { LOG.error("{}\nErrors: {}\nWarnings: {}", INCONSISTENT_CONFIGURATION_INFO, mConfigCheckReport.getConfigErrors().values().stream() .map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", ")), mConfigCheckReport.getConfigWarns().values().stream() .map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", "))); } }
/** * Runs doctor configuration command. * * @return 0 on success, 1 otherwise */ public int run() throws IOException { ConfigCheckReport report = mMetaMasterClient.getConfigReport(); ConfigStatus configStatus = report.getConfigStatus(); if (configStatus == ConfigStatus.PASSED) { // No errors or warnings to show mPrintStream.println("No server-side configuration errors or warnings."); return 0; } Map<Scope, List<InconsistentProperty>> errors = report.getConfigErrors(); if (errors.size() != 0) { mPrintStream.println("Server-side configuration errors " + "(those properties are required to be identical): "); printInconsistentProperties(errors); } Map<Scope, List<InconsistentProperty>> warnings = report.getConfigWarns(); if (warnings.size() != 0) { mPrintStream.println("\nServer-side configuration warnings " + "(those properties are recommended to be identical): "); printInconsistentProperties(warnings); } return 0; }
/** * Checks if the server-side configuration report is as expected. * * @param expectedErrorNum the expected error number * @param expectedWarnNum the expected warning number * @param expectedStatus the expected config check status */ private void checkResults(int expectedErrorNum, int expectedWarnNum, ConfigStatus expectedStatus) { mConfigChecker.regenerateReport(); ConfigCheckReport report = mConfigChecker.getConfigCheckReport(); assertEquals(expectedErrorNum, report.getConfigErrors().size()); assertEquals(expectedWarnNum, report.getConfigWarns().size()); assertEquals(expectedStatus, report.getConfigStatus()); } }
response.setConfigCheckStatus(report.getConfigStatus()) .setConfigCheckErrors(report.getConfigErrors()) .setConfigCheckWarns(report.getConfigWarns()).setConfigCheckErrorNum( report.getConfigErrors().values().stream().mapToInt(List::size).sum()) .setConfigCheckWarnNum( report.getConfigWarns().values().stream().mapToInt(List::size).sum());
/** * Logs the configuration check report information. */ public synchronized void logConfigReport() { ConfigStatus reportStatus = mConfigCheckReport.getConfigStatus(); if (reportStatus.equals(ConfigStatus.PASSED)) { LOG.info(CONSISTENT_CONFIGURATION_INFO); } else if (reportStatus.equals(ConfigStatus.WARN)) { LOG.warn("{}\nWarnings: {}", INCONSISTENT_CONFIGURATION_INFO, mConfigCheckReport.getConfigWarns().values().stream() .map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", "))); } else { LOG.error("{}\nErrors: {}\nWarnings: {}", INCONSISTENT_CONFIGURATION_INFO, mConfigCheckReport.getConfigErrors().values().stream() .map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", ")), mConfigCheckReport.getConfigWarns().values().stream() .map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", "))); } }
request.setAttribute("configCheckStatus", report.getConfigStatus()); request.setAttribute("configCheckErrors", report.getConfigErrors()); request.setAttribute("configCheckWarns", report.getConfigWarns()); request.setAttribute("configCheckErrorNum", report.getConfigErrors().values().stream().mapToInt(List::size).sum()); request.setAttribute("configCheckWarnNum", report.getConfigWarns().values().stream().mapToInt(List::size).sum());