use of org.apache.ignite.internal.commandline.CommandHandler.DELIM in project ignite by apache.
the class BaselineCommand method baselinePrint0.
/**
* Print baseline topology.
*
* @param res Task result with baseline topology.
*/
private void baselinePrint0(VisorBaselineTaskResult res, Logger logger) {
logger.info("Cluster state: " + (res.isActive() ? "active" : "inactive"));
logger.info("Current topology version: " + res.getTopologyVersion());
VisorBaselineAutoAdjustSettings autoAdjustSettings = res.getAutoAdjustSettings();
if (autoAdjustSettings != null) {
logger.info("Baseline auto adjustment " + (TRUE.equals(autoAdjustSettings.getEnabled()) ? "enabled" : "disabled") + ": softTimeout=" + autoAdjustSettings.getSoftTimeout());
}
if (autoAdjustSettings.enabled) {
if (res.isBaselineAdjustInProgress())
logger.info("Baseline auto-adjust is in progress");
else if (res.getRemainingTimeToBaselineAdjust() < 0)
logger.info("Baseline auto-adjust are not scheduled");
else
logger.info("Baseline auto-adjust will happen in '" + res.getRemainingTimeToBaselineAdjust() + "' ms");
}
logger.info("");
Map<String, VisorBaselineNode> baseline = res.getBaseline();
Map<String, VisorBaselineNode> srvs = res.getServers();
// if task runs on a node with VisorBaselineNode of old version (V1) we'll get order=null for all nodes.
Function<VisorBaselineNode, String> extractFormattedAddrs = node -> {
Stream<String> sortedByIpHosts = Optional.ofNullable(node).map(addrs -> node.getAddrs()).orElse(Collections.emptyList()).stream().sorted(Comparator.comparing(resolvedAddr -> new VisorTaskUtils.SortableAddress(resolvedAddr.address()))).map(resolvedAddr -> {
if (!resolvedAddr.hostname().equals(resolvedAddr.address()))
return resolvedAddr.hostname() + "/" + resolvedAddr.address();
else
return resolvedAddr.address();
});
if (verbose) {
String hosts = String.join(",", sortedByIpHosts.collect(Collectors.toList()));
if (!hosts.isEmpty())
return ", Addresses=" + hosts;
else
return "";
} else
return sortedByIpHosts.findFirst().map(ip -> ", Address=" + ip).orElse("");
};
String crdStr = srvs.values().stream().filter(node -> node.getOrder() != null).min(Comparator.comparing(VisorBaselineNode::getOrder)).map(crd -> " (Coordinator: ConsistentId=" + crd.getConsistentId() + extractFormattedAddrs.apply(crd) + ", Order=" + crd.getOrder() + ")").orElse("");
logger.info("Current topology version: " + res.getTopologyVersion() + crdStr);
logger.info("");
if (F.isEmpty(baseline))
logger.info("Baseline nodes not found.");
else {
logger.info("Baseline nodes:");
for (VisorBaselineNode node : baseline.values()) {
VisorBaselineNode srvNode = srvs.get(node.getConsistentId());
String state = ", State=" + (srvNode != null ? "ONLINE" : "OFFLINE");
String order = srvNode != null ? ", Order=" + srvNode.getOrder() : "";
logger.info(DOUBLE_INDENT + "ConsistentId=" + node.getConsistentId() + extractFormattedAddrs.apply(srvNode) + state + order);
}
logger.info(DELIM);
logger.info("Number of baseline nodes: " + baseline.size());
logger.info("");
List<VisorBaselineNode> others = new ArrayList<>();
for (VisorBaselineNode node : srvs.values()) {
if (!baseline.containsKey(node.getConsistentId()))
others.add(node);
}
if (F.isEmpty(others))
logger.info("Other nodes not found.");
else {
logger.info("Other nodes:");
for (VisorBaselineNode node : others) logger.info(DOUBLE_INDENT + "ConsistentId=" + node.getConsistentId() + ", Order=" + node.getOrder());
logger.info("Number of other nodes: " + others.size());
}
}
}
Aggregations