[ASTERIXDB-2019][CLUS] Sync getting cluster state
user model changes: no
storage format changes: no
interface changes: no
Details:
- Leave it to the caller when to refresh the cluster state
after register/deregister of cluster partitions.
- Synchronize cluster state to avoid getting invalid state
during partitions reg/dereg
Change-Id: I2bc5f86cedeb4728ccbb9811a36a4655a7786246
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1920
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
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 8156a23..ab7d657 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
@@ -225,7 +225,7 @@
}
@Override
- public ClusterState getState() {
+ public synchronized ClusterState getState() {
return state;
}
@@ -268,7 +268,7 @@
new AlgebricksAbsolutePartitionConstraint(clusterActiveLocations.toArray(new String[] {}));
}
- public boolean isClusterActive() {
+ public synchronized boolean isClusterActive() {
if (cluster == null) {
// this is a virtual cluster
return true;
@@ -374,12 +374,6 @@
clusterPartitions.put(nodePartition.getPartitionId(), nodePartition);
}
node2PartitionsMap.put(nodeId, nodePartitions);
- //TODO fix exception propagation from refreshState
- try {
- refreshState();
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
}
@Override
@@ -394,7 +388,6 @@
for (ClusterPartition nodePartition : nodePartitions) {
clusterPartitions.remove(nodePartition.getPartitionId());
}
- refreshState();
}
}