mgao0 commented on a change in pull request #1000:
URL: https://github.com/apache/helix/pull/1000#discussion_r438383693
##########
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:
Just cancelling the future is fine. When the future is cancelled, the
scheduled tasks will be removed from the task queue. If there is an ongoing
task, we will interrupt it and it will throw InterruptedException and the task
thread will be interrupted. Then we schedule a new task in the following lines.
So it functions like a reset.
##########
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:
Good point. Updated.
----------------------------------------------------------------
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]