Config to change the interval of healthReport collection

To better support the health report, the configurable collection time interval 
is necessary. Add this configuration in system environment since there is no 
zookeeper connection happens before create healthreport tasks.


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

Branch: refs/heads/master
Commit: bd113a181a25611b7e2581f0bcbbce24d4aab1eb
Parents: 177d5bd
Author: Junkai Xue <j...@linkedin.com>
Authored: Tue Oct 3 15:22:47 2017 -0700
Committer: Junkai Xue <j...@linkedin.com>
Committed: Tue Oct 3 15:22:47 2017 -0700

----------------------------------------------------------------------
 .../helix/healthcheck/ParticipantHealthReportTask.java      | 9 ++++++++-
 .../java/org/apache/helix/manager/zk/ZKHelixManager.java    | 9 +++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/bd113a18/helix-core/src/main/java/org/apache/helix/healthcheck/ParticipantHealthReportTask.java
----------------------------------------------------------------------
diff --git 
a/helix-core/src/main/java/org/apache/helix/healthcheck/ParticipantHealthReportTask.java
 
b/helix-core/src/main/java/org/apache/helix/healthcheck/ParticipantHealthReportTask.java
index f1c4c24..e0f38ba 100644
--- 
a/helix-core/src/main/java/org/apache/helix/healthcheck/ParticipantHealthReportTask.java
+++ 
b/helix-core/src/main/java/org/apache/helix/healthcheck/ParticipantHealthReportTask.java
@@ -29,6 +29,7 @@ import org.apache.log4j.Logger;
 public class ParticipantHealthReportTask extends HelixTimerTask {
   private static final Logger LOG = 
Logger.getLogger(ParticipantHealthReportTask.class);
   public final static int DEFAULT_REPORT_LATENCY = 60 * 1000;
+  private final int _reportLatency;
 
   Timer _timer;
   final ParticipantHealthReportCollectorImpl _healthReportCollector;
@@ -42,7 +43,13 @@ public class ParticipantHealthReportTask extends 
HelixTimerTask {
   }
 
   public ParticipantHealthReportTask(ParticipantHealthReportCollectorImpl 
healthReportCollector) {
+    this(healthReportCollector, DEFAULT_REPORT_LATENCY);
+  }
+
+  public ParticipantHealthReportTask(ParticipantHealthReportCollectorImpl 
healthReportCollector,
+      int reportLatency) {
     _healthReportCollector = healthReportCollector;
+    _reportLatency = reportLatency;
   }
 
   @Override
@@ -51,7 +58,7 @@ public class ParticipantHealthReportTask extends 
HelixTimerTask {
       LOG.info("Start HealthCheckInfoReportingTask");
       _timer = new Timer("ParticipantHealthReportTimerTask", true);
       _timer.scheduleAtFixedRate(new ParticipantHealthReportTimerTask(),
-          new Random().nextInt(DEFAULT_REPORT_LATENCY), 
DEFAULT_REPORT_LATENCY);
+          new Random().nextInt(_reportLatency), _reportLatency);
     } else {
       LOG.warn("ParticipantHealthReportTimerTask already started");
     }

http://git-wip-us.apache.org/repos/asf/helix/blob/bd113a18/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
----------------------------------------------------------------------
diff --git 
a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java 
b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
index 670a65e..fdc6a55 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
@@ -100,6 +100,7 @@ public class ZKHelixManager implements HelixManager, 
IZkStateListener {
    * helix version#
    */
   private final String _version;
+  private int _reportLatency;
 
   protected ZkClient _zkclient = null;
   private final DefaultMessagingService _messagingService;
@@ -231,6 +232,8 @@ public class ZKHelixManager implements HelixManager, 
IZkStateListener {
 
     _connectionRetryTimeout =
         getSystemPropertyAsInt("zk.connectionReEstablishment.timeout", 
DEFAULT_CONNECTION_ESTABLISHMENT_RETRY_TIMEOUT);
+    _reportLatency = 
getSystemPropertyAsInt("helixmanager.participantHealthReport.reportLatency",
+        ParticipantHealthReportTask.DEFAULT_REPORT_LATENCY);
 
     /**
      * instance type specific init
@@ -240,7 +243,8 @@ public class ZKHelixManager implements HelixManager, 
IZkStateListener {
       _stateMachineEngine = new HelixStateMachineEngine(this);
       _participantHealthInfoCollector =
           new ParticipantHealthReportCollectorImpl(this, _instanceName);
-      _timerTasks.add(new 
ParticipantHealthReportTask(_participantHealthInfoCollector));
+      _timerTasks
+          .add(new 
ParticipantHealthReportTask(_participantHealthInfoCollector, _reportLatency));
       break;
     case CONTROLLER:
       _stateMachineEngine = null;
@@ -253,7 +257,8 @@ public class ZKHelixManager implements HelixManager, 
IZkStateListener {
       _participantHealthInfoCollector =
           new ParticipantHealthReportCollectorImpl(this, _instanceName);
 
-      _timerTasks.add(new 
ParticipantHealthReportTask(_participantHealthInfoCollector));
+      _timerTasks
+          .add(new 
ParticipantHealthReportTask(_participantHealthInfoCollector, _reportLatency));
       _controllerTimerTasks.add(new StatusDumpTask(this));
       break;
     case ADMINISTRATOR:

Reply via email to