jiajunwang commented on a change in pull request #1000:
URL: https://github.com/apache/helix/pull/1000#discussion_r438332531



##########
File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
##########
@@ -818,4 +888,27 @@ public String getContent() {
         + ", _listener=" + _listener + ", _changeType=" + _changeType + ", 
_manager=" + _manager
         + ", _zkClient=" + _zkClient + '}';
   }
+
+  /**
+   * Used to initialize or reset a periodic refresh task
+   * Schedule tasks in a task executor with fixed intervals
+   */
+  private void initOrResetTriggerTask() {

Review comment:
       Just call it "reset" is fine.

##########
File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
##########
@@ -818,4 +888,27 @@ public String getContent() {
         + ", _listener=" + _listener + ", _changeType=" + _changeType + ", 
_manager=" + _manager
         + ", _zkClient=" + _zkClient + '}';
   }
+
+  /**
+   * Used to initialize or reset a periodic refresh task
+   * Schedule tasks in a task executor with fixed intervals
+   */
+  private void initOrResetTriggerTask() {
+    if (_periodicTriggerInterval <= 0) {
+      return;
+    }
+    _lastInvokeTime = System.currentTimeMillis();
+    if (_periodicTriggerExecutor == null) {
+      _periodicTriggerExecutor = new ScheduledThreadPoolExecutor(1);
+    }
+    // When cancelling the task future, it removes the task from the queue
+    // so we won't have a memory leakage when we cancel scheduled task
+    _periodicTriggerExecutor.setRemoveOnCancelPolicy(true);

Review comment:
       Shall we only set it once after the fresh construct?

##########
File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
##########
@@ -818,4 +888,27 @@ public String getContent() {
         + ", _listener=" + _listener + ", _changeType=" + _changeType + ", 
_manager=" + _manager
         + ", _zkClient=" + _zkClient + '}';
   }
+
+  /**
+   * Used to initialize or reset a periodic refresh task
+   * Schedule tasks in a task executor with fixed intervals
+   */
+  private void initOrResetTriggerTask() {
+    if (_periodicTriggerInterval <= 0) {
+      return;
+    }
+    _lastInvokeTime = System.currentTimeMillis();
+    if (_periodicTriggerExecutor == null) {

Review comment:
       If it is not null, shall we reset the executor somehow? Or the future 
cancellation would be good enough?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to