zstan commented on a change in pull request #9527:
URL: https://github.com/apache/ignite/pull/9527#discussion_r737358783



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
##########
@@ -329,10 +339,51 @@ public void updateTag(String newTag) throws 
IgniteCheckedException {
      * </ul>
      */
     public void onLocalJoin() {
-        cluster.setId(locClusterId != null ? locClusterId : UUID.randomUUID());
+        Collection<ClusterNode> rmtNodes = cluster.forServers().nodes();
+        List<ClusterNode> rmtNodes0 = new ArrayList<>(rmtNodes);
+
+        rmtNodes0.sort(Comparator.comparing(ClusterNode::id));
+
+        @Nullable Collection<BaselineNode> bltNodes = 
cluster.currentBaselineTopology();
+
+        if (F.isEmpty(bltNodes)) {
+            log.info("Baseline node collection is empty.");
+
+            return;
+        }
+
+        @Nullable UUID first = null;
+
+        Collection<Object> srvIds = F.nodeConsistentIds(bltNodes);
+
+        for (ClusterNode node : rmtNodes0) {
+            if (F.contains(srvIds, node.consistentId())) {
+                first = node.id();
+
+                break;
+            }
+        }
+
+        ClusterNode locNode = ctx.config().getDiscoverySpi().getLocalNode();
+
+        if (first == locNode.id() || locClusterId != null) {
+            cluster.setId(locClusterId != null ? locClusterId : 
UUID.randomUUID());
+
+            cluster.setTag(locClusterTag != null ? locClusterTag :
+                ClusterTagGenerator.generateTag());
 
-        cluster.setTag(locClusterTag != null ? locClusterTag :
-            ClusterTagGenerator.generateTag());
+            ClusterIdAndTag idAndTag = new ClusterIdAndTag(cluster.id(), 
cluster.tag());
+
+            if (log.isInfoEnabled())
+                log.info("Writing cluster ID and tag to metastorage on ready 
for write " + idAndTag);
+
+            try {
+                metastorage.writeAsync(CLUSTER_ID_TAG_KEY, idAndTag);

Review comment:
       1. yes, that`s right
   2. I think that TC tests all we have for such checks, i have no ideas how 
additionally test external instruments... 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to