You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by lx...@apache.org on 2018/03/23 18:58:12 UTC

[3/6] helix git commit: Add cluster level metrics to show whether cluster is in maintenance mode or paused.

Add cluster level metrics to show whether cluster is in maintenance mode or paused.


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

Branch: refs/heads/master
Commit: 986e79c9f1b7d40242411c384028d0cd36436cb5
Parents: fb0b674
Author: Lei Xia <lx...@linkedin.com>
Authored: Wed Feb 21 12:25:52 2018 -0800
Committer: Lei Xia <lx...@linkedin.com>
Committed: Fri Mar 23 11:57:06 2018 -0700

----------------------------------------------------------------------
 .../controller/GenericHelixController.java      |  2 ++
 .../monitoring/mbeans/ClusterStatusMonitor.java | 25 +++++++++++++++++++-
 .../mbeans/ClusterStatusMonitorMBean.java       | 13 ++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/986e79c9/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
index f2709a6..df5c86b 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
@@ -606,6 +606,8 @@ public class GenericHelixController implements IdealStateChangeListener,
           updateControllerState(changeContext, maintenanceSignal, _inMaintenanceMode);
       enableClusterStatusMonitor(true);
       _clusterStatusMonitor.setEnabled(!_paused);
+      _clusterStatusMonitor.setPaused(_paused);
+      _clusterStatusMonitor.setMaintenance(_inMaintenanceMode);
     } else {
       enableClusterStatusMonitor(false);
     }

http://git-wip-us.apache.org/repos/asf/helix/blob/986e79c9/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
index fe682ac..40801b1 100644
--- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
@@ -56,6 +56,9 @@ public class ClusterStatusMonitor implements ClusterStatusMonitorMBean {
   private final MBeanServer _beanServer;
 
   private boolean _enabled = true;
+  private boolean _inMaintenance = false;
+  private boolean _paused = false;
+
   private Set<String> _liveInstances = Collections.emptySet();
   private Set<String> _instances = Collections.emptySet();
   private Set<String> _disabledInstances = Collections.emptySet();
@@ -659,7 +662,8 @@ public class ClusterStatusMonitor implements ClusterStatusMonitorMBean {
   private synchronized void unregisterPerInstanceResources(Collection<PerInstanceResourceMonitor.BeanName> beanNames)
       throws MalformedObjectNameException {
     for (PerInstanceResourceMonitor.BeanName beanName : beanNames) {
-      unregister(getObjectName(getPerInstanceResourceBeanName(beanName.instanceName(), beanName.resourceName())));
+      unregister(getObjectName(
+          getPerInstanceResourceBeanName(beanName.instanceName(), beanName.resourceName())));
     }
     _perInstanceResourceMap.keySet().removeAll(beanNames);
   }
@@ -759,6 +763,25 @@ public class ClusterStatusMonitor implements ClusterStatusMonitorMBean {
     return _enabled ? 1 : 0;
   }
 
+  @Override
+  public long getMaintenance() {
+    return _inMaintenance ? 1 : 0;
+  }
+
+  public void setMaintenance(boolean inMaintenance) {
+    _inMaintenance = inMaintenance;
+  }
+
+
+  @Override
+  public long getPaused() {
+    return _paused ? 1 : 0;
+  }
+
+  public void setPaused(boolean paused) {
+    _paused = paused;
+  }
+
   public void setEnabled(boolean enabled) {
     this._enabled = enabled;
   }

http://git-wip-us.apache.org/repos/asf/helix/blob/986e79c9/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitorMBean.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitorMBean.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitorMBean.java
index 483e4d8..4cdd357 100644
--- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitorMBean.java
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitorMBean.java
@@ -48,4 +48,17 @@ public interface ClusterStatusMonitorMBean extends SensorNameProvider {
    * @return 1 if cluster is enabled, otherwise 0
    */
   public long getEnabled();
+
+  /**
+   *
+   * @return 1 if cluster is in maintenance mode, otherwise 0
+   */
+  public long getMaintenance();
+
+
+  /**
+   *
+   * @return 1 if cluster is paused, otherwise 0
+   */
+  public long getPaused();
 }