You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2019/02/18 14:09:26 UTC

[GitHub] macrergate commented on a change in pull request #6118: IGNITE-11243 fix NPE if a cluster node has old version of VisorBaseli…

macrergate commented on a change in pull request #6118: IGNITE-11243 fix NPE if a cluster node has old version of VisorBaseli…
URL: https://github.com/apache/ignite/pull/6118#discussion_r257709489
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommandHandler.java
 ##########
 @@ -1302,14 +1301,20 @@ private void baselinePrint0(VisorBaselineTaskResult res) {
 
         Map<String, VisorBaselineNode> srvs = res.getServers();
 
-        Optional<VisorBaselineNode> crdOpt = srvs.values().stream()
-            .min(Comparator.comparing(VisorBaselineNode::getOrder));
-
-        String crdStr = crdOpt.map(
-            crd -> "ConsistentId=" + crd.getConsistentId() + ", Order=" + crd.getOrder())
+        // 1) if we have a node with order == 1, then it's the CRD, otherwise
+        // 2) if we have a node with order == null, then CRD can't be evaluated, otherwise
+        // 3) the node with minimal order is CRD
+
+        String crdStr = srvs.values().stream()
+            // sort: 1, null, 2, 3, ...
+            .min(Comparator.comparing(node1 -> node1.getOrder() != null ? node1.getOrder() << 1 : 3))
+            // check for not null
+            .filter(node1 -> node1.getOrder() != null)
+            // format
+            .map(crd -> " (Coordinator: ConsistentId=" + crd.getConsistentId() + ", Order=" + crd.getOrder() + ")")
 
 Review comment:
   thanks @vldpyatkov. I've simplified code. Actually we can have 2 cases only
   1)  all nodes  order != null  in case task launched on a new node =>  crd = min node
   2) all nodes orde == null in case task launched on old versioned node  => crd can't be specified.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services