Michael Blow has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2749

Change subject: [NO ISSUE] Avoid needless transition to UNUSABLE on node join
......................................................................

[NO ISSUE] Avoid needless transition to UNUSABLE on node join

Change-Id: Ie9bb351144e165a6e67ded4add830ff7c0a7b258
---
M 
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/transaction/ResourceIdManager.java
M 
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java
2 files changed, 13 insertions(+), 9 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/49/2749/1

diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/transaction/ResourceIdManager.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/transaction/ResourceIdManager.java
index 6d3077e..2ff05f3 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/transaction/ResourceIdManager.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/transaction/ResourceIdManager.java
@@ -51,6 +51,9 @@
     public void report(String nodeId, long maxResourceId) throws 
HyracksDataException {
         globalResourceId.updateAndGet(prev -> Math.max(maxResourceId, prev));
         if (reportedNodes.add(nodeId)) {
+            synchronized (csm) {
+                csm.notifyAll();
+            }
             csm.refreshState();
         }
     }
diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java
index 8539fa4..8080910 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java
@@ -133,8 +133,17 @@
     }
 
     @Override
-    public synchronized void updateNodePartitions(String nodeId, boolean 
active) {
+    public synchronized void updateNodePartitions(String nodeId, boolean 
active) throws HyracksDataException {
         if (active) {
+            IResourceIdManager resourceIdManager = 
appCtx.getResourceIdManager();
+            while (!resourceIdManager.reported(nodeId)) {
+                LOGGER.info("Partitions are ready but {} has not yet 
registered its max resource id...", nodeId);
+                try {
+                    wait();
+                } catch (InterruptedException e) { // NOSONAR
+                    throw HyracksDataException.create(e);
+                }
+            }
             participantNodes.add(nodeId);
         } else {
             participantNodes.remove(nodeId);
@@ -183,14 +192,6 @@
             return;
         }
 
-        IResourceIdManager resourceIdManager = appCtx.getResourceIdManager();
-        for (String node : participantNodes) {
-            if (!resourceIdManager.reported(node)) {
-                LOGGER.info("Partitions are ready but {} has not yet 
registered its max resource id...", node);
-                setState(ClusterState.UNUSABLE);
-                return;
-            }
-        }
         // the metadata bootstrap & global recovery must be complete before 
the cluster can be active
         if (metadataNodeActive) {
             if (state != ClusterState.ACTIVE && state != 
ClusterState.RECOVERING) {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2749
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie9bb351144e165a6e67ded4add830ff7c0a7b258
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <[email protected]>

Reply via email to