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 2022/01/12 08:16:53 UTC
[GitHub] [ignite] ibessonov commented on a change in pull request #9527: IGNITE-15733 Eventually failure of baseline registration
ibessonov commented on a change in pull request #9527:
URL: https://github.com/apache/ignite/pull/9527#discussion_r782031754
##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
##########
@@ -328,11 +340,67 @@ public void updateTag(String newTag) throws IgniteCheckedException {
* when it becomes ready for read.</li>
* </ul>
*/
+ public void onChangeState() {
+ 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();
Review comment:
Let me explain than. You could write it like
```
Optional<UUID> first = cluster.forServers().nodes().stream()
.filter(node -> srvIds.contains(node.consistentId())
.min(comparing(ClusterNode::id))
```
Fewer explicit actions, cleaner code, I think
##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
##########
@@ -328,11 +340,67 @@ public void updateTag(String newTag) throws IgniteCheckedException {
* when it becomes ready for read.</li>
* </ul>
*/
+ public void onChangeState() {
+ 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() || locClusterTag != null) {
Review comment:
Reference equality for UUIDs, can you please fix it?
##########
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);
+ }
+ catch (IgniteCheckedException e) {
+ ctx.failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e));
Review comment:
Situation - node, that should invoke `metastorage.writeAsync(CLUSTER_ID_TAG_KEY, idAndTag);`, fails before doing so. What will hapen?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org