helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject [2/2] helix git commit: Fix issue in reporting MissingMinActiveReplicaPartitionGauge metric in ResourceMonitor when there is no IdealMapping persisted in IdealState.
Date Thu, 08 Mar 2018 21:57:10 GMT
Fix issue in reporting MissingMinActiveReplicaPartitionGauge metric in ResourceMonitor when
there is no IdealMapping persisted in IdealState.


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/f31d6465
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/f31d6465
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/f31d6465

Branch: refs/heads/master
Commit: f31d6465944adb4e4a6b66f4e35538610e6f4bbd
Parents: d9eb0e5
Author: Lei Xia <lxia@linkedin.com>
Authored: Mon Jan 29 18:12:56 2018 -0800
Committer: Lei Xia <lxia@linkedin.com>
Committed: Thu Mar 8 11:17:36 2018 -0800

----------------------------------------------------------------------
 .../apache/helix/monitoring/mbeans/ResourceMonitor.java  | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/f31d6465/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java
b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java
index 7c8382e..42d2bf2 100644
--- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java
@@ -219,11 +219,18 @@ public class ResourceMonitor extends DynamicMBeanProvider {
     try {
       replica = Integer.valueOf(idealState.getReplicas());
     } catch (NumberFormatException e) {
+      _logger.error("Invalid replica count for " + _resourceName + ", failed to update its
ResourceMonitor Mbean!");
+      return;
     }
 
     int minActiveReplica = idealState.getMinActiveReplicas();
     minActiveReplica = (minActiveReplica >= 0) ? minActiveReplica : replica;
 
+    Set<String> activeStates = new HashSet<>(stateModelDef.getStatesPriorityList());
+    activeStates.remove(stateModelDef.getInitialState());
+    activeStates.remove(HelixDefinedState.DROPPED.name());
+    activeStates.remove(HelixDefinedState.ERROR.name());
+
     for (String partition : partitions) {
       Map<String, String> idealRecord = idealState.getInstanceStateMap(partition);
       Map<String, String> externalViewRecord = externalView.getStateMap(partition);
@@ -248,10 +255,6 @@ public class ResourceMonitor extends DynamicMBeanProvider {
         if (topState != null && topState.equalsIgnoreCase(currentState)) {
           hasTopState = true;
         }
-
-        Map<String, Integer> stateCount =
-            stateModelDef.getStateCountMap(idealRecord.size(), replica);
-        Set<String> activeStates = stateCount.keySet();
         if (currentState != null && activeStates.contains(currentState)) {
           activeReplicaCount++;
         }


Mime
View raw message