This is an automated email from the ASF dual-hosted git repository.

mhubail pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 195ce0f  [NO ISSUE][CLUS] Add API to check for failed nodes
195ce0f is described below

commit 195ce0f2f2f0004c1e863339c0d39e038db23fa4
Author: Murtadha Hubail <[email protected]>
AuthorDate: Fri Sep 17 21:20:36 2021 +0300

    [NO ISSUE][CLUS] Add API to check for failed nodes
    
    - user model changes: no
    - storage format changes: no
    - interface changes: yes
    
    Details:
    
    - Add API to check if some nodes failed in ClusterStateManager.
    - Add sync progress to PartitionReplica toString.
    
    Change-Id: I7a5eb5b070f0a8a7a2f1a952fd7db35df244246e
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/13283
    Reviewed-by: Ali Alsuliman <[email protected]>
    Integration-Tests: Jenkins <[email protected]>
    Tested-by: Jenkins <[email protected]>
---
 .../org/apache/asterix/common/cluster/IClusterStateManager.java   | 8 ++++++++
 .../java/org/apache/asterix/replication/api/PartitionReplica.java | 1 +
 .../org/apache/asterix/runtime/utils/ClusterStateManager.java     | 5 +++++
 3 files changed, 14 insertions(+)

diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java
index 41f786a..76802d9 100644
--- 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java
@@ -272,4 +272,12 @@ public interface IClusterStateManager {
      * @return the cluster partitions map
      */
     Map<Integer, ClusterPartition> getClusterPartitions();
+
+    /**
+     * Returns true if any of the nodes in {@code nodesId} is currently 
inactive
+     *
+     * @param nodeIds
+     * @return true if any of the nodes is currently inactive, otherwise false
+     */
+    boolean nodesFailed(Set<String> nodeIds);
 }
diff --git 
a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java
 
b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java
index c49bb7b..e1f99f4 100644
--- 
a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java
+++ 
b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java
@@ -160,6 +160,7 @@ public class PartitionReplica implements IPartitionReplica {
         ObjectNode json = OBJECT_MAPPER.createObjectNode();
         json.put("id", id.toString());
         json.put("status", status.name());
+        json.put("syncProgress", syncProgress);
         return json;
     }
 
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 c5398e1..6de1dda 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
@@ -478,6 +478,11 @@ public class ClusterStateManager implements 
IClusterStateManager {
         return Collections.unmodifiableMap(clusterPartitions);
     }
 
+    @Override
+    public synchronized boolean nodesFailed(Set<String> nodeIds) {
+        return nodeIds.stream().anyMatch(failedNodes::contains);
+    }
+
     private void updateClusterCounters(String nodeId, NcLocalCounters 
localCounters) {
         final IResourceIdManager resourceIdManager = 
appCtx.getResourceIdManager();
         resourceIdManager.report(nodeId, localCounters.getMaxResourceId());

Reply via email to