Search in sources :

Example 1 with VisorBaselineNode

use of org.apache.ignite.internal.visor.baseline.VisorBaselineNode in project ignite by apache.

the class CommandHandler method baselinePrint0.

/**
 * Print baseline topology.
 *
 * @param res Task result with baseline topology.
 */
private void baselinePrint0(VisorBaselineTaskResult res) {
    log("Cluster state: " + (res.isActive() ? "active" : "inactive"));
    log("Current topology version: " + res.getTopologyVersion());
    nl();
    Map<String, VisorBaselineNode> baseline = res.getBaseline();
    Map<String, VisorBaselineNode> servers = res.getServers();
    if (F.isEmpty(baseline))
        log("Baseline nodes not found.");
    else {
        log("Baseline nodes:");
        for (VisorBaselineNode node : baseline.values()) {
            log("    ConsistentID=" + node.getConsistentId() + ", STATE=" + (servers.containsKey(node.getConsistentId()) ? "ONLINE" : "OFFLINE"));
        }
        log(DELIM);
        log("Number of baseline nodes: " + baseline.size());
        nl();
        List<VisorBaselineNode> others = new ArrayList<>();
        for (VisorBaselineNode node : servers.values()) {
            if (!baseline.containsKey(node.getConsistentId()))
                others.add(node);
        }
        if (F.isEmpty(others))
            log("Other nodes not found.");
        else {
            log("Other nodes:");
            for (VisorBaselineNode node : others) log("    ConsistentID=" + node.getConsistentId());
            log("Number of other nodes: " + others.size());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) VisorBaselineNode(org.apache.ignite.internal.visor.baseline.VisorBaselineNode)

Example 2 with VisorBaselineNode

use of org.apache.ignite.internal.visor.baseline.VisorBaselineNode 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());
        }
    }
}
Also used : BaselineSubcommands(org.apache.ignite.internal.commandline.baseline.BaselineSubcommands) DELIM(org.apache.ignite.internal.commandline.CommandHandler.DELIM) TaskExecutor.executeTaskByNameOnNode(org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode) VisorBaselineTask(org.apache.ignite.internal.visor.baseline.VisorBaselineTask) DOUBLE_INDENT(org.apache.ignite.internal.commandline.CommandLogger.DOUBLE_INDENT) Function(java.util.function.Function) CommandArgUtils(org.apache.ignite.internal.commandline.argument.CommandArgUtils) ArrayList(java.util.ArrayList) Map(java.util.Map) VisorBaselineNode(org.apache.ignite.internal.visor.baseline.VisorBaselineNode) Collections.singletonMap(java.util.Collections.singletonMap) GridClientNode(org.apache.ignite.internal.client.GridClientNode) VisorTaskUtils(org.apache.ignite.internal.visor.util.VisorTaskUtils) F(org.apache.ignite.internal.util.typedef.F) CommandLogger.optional(org.apache.ignite.internal.commandline.CommandLogger.optional) CMD_AUTO_CONFIRMATION(org.apache.ignite.internal.commandline.CommonArgParser.CMD_AUTO_CONFIRMATION) GridClient(org.apache.ignite.internal.client.GridClient) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) Set(java.util.Set) UUID(java.util.UUID) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) VisorBaselineAutoAdjustSettings(org.apache.ignite.internal.visor.baseline.VisorBaselineAutoAdjustSettings) List(java.util.List) Stream(java.util.stream.Stream) AutoAdjustCommandArg(org.apache.ignite.internal.commandline.baseline.AutoAdjustCommandArg) BaselineArguments(org.apache.ignite.internal.commandline.baseline.BaselineArguments) BaselineSubcommands.of(org.apache.ignite.internal.commandline.baseline.BaselineSubcommands.of) Optional(java.util.Optional) Comparator(java.util.Comparator) BASELINE(org.apache.ignite.internal.commandline.CommandList.BASELINE) Collections(java.util.Collections) VisorBaselineTaskArg(org.apache.ignite.internal.visor.baseline.VisorBaselineTaskArg) TRUE(java.lang.Boolean.TRUE) VisorBaselineTaskResult(org.apache.ignite.internal.visor.baseline.VisorBaselineTaskResult) ArrayList(java.util.ArrayList) VisorBaselineAutoAdjustSettings(org.apache.ignite.internal.visor.baseline.VisorBaselineAutoAdjustSettings) Stream(java.util.stream.Stream) VisorBaselineNode(org.apache.ignite.internal.visor.baseline.VisorBaselineNode)

Aggregations

ArrayList (java.util.ArrayList)2 VisorBaselineNode (org.apache.ignite.internal.visor.baseline.VisorBaselineNode)2 TRUE (java.lang.Boolean.TRUE)1 Collections (java.util.Collections)1 Collections.singletonMap (java.util.Collections.singletonMap)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 GridClient (org.apache.ignite.internal.client.GridClient)1 GridClientConfiguration (org.apache.ignite.internal.client.GridClientConfiguration)1 GridClientNode (org.apache.ignite.internal.client.GridClientNode)1 DELIM (org.apache.ignite.internal.commandline.CommandHandler.DELIM)1 BASELINE (org.apache.ignite.internal.commandline.CommandList.BASELINE)1