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



##########
File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
##########
@@ -200,6 +208,37 @@ protected void handleEvent(NotificationContext event) {
         logger.warn("Exception in callback processing thread. Skipping 
callback", e);
       }
     }
+
+    public boolean queueIsEmpty() {
+      return _eventQueue.isEmpty();
+    }
+  }
+
+  class RefreshTask implements Runnable {
+    @Override
+    public void run() {
+      try {
+        while (true) {
+          long currentTime = System.currentTimeMillis();
+          long remainingTime = _lastEventTime + 
_periodicRefreshTriggerInterval - currentTime;
+          if (remainingTime <= 0) {
+            // If there is no event in the queue, meaning this long idle time 
could be due to lack of events
+            // Otherwise, if there is event in the queue, this long idle time 
is due to slow process of events
+            if (_batchCallbackProcessor == null || 
_batchCallbackProcessor.queueIsEmpty()) {
+              NotificationContext changeContext = new 
NotificationContext(_manager);
+              changeContext.setType(Type.CALLBACK);
+              changeContext.setChangeType(_changeType);
+              enqueueTask(changeContext);

Review comment:
       The problem of parallelism here is not 2 threads try to run at the same 
time. As you mentioned it is protected by synchronization.
   
   The concern is out of order. I mentioned this scenario during the 
discussion. But I guess the argument that it won't make it worse since we are 
basically doing a similar batch mode processing here.
   Meaning, whatever potential issues that we saw in the batch mode may appear 
in this refresh.
   
   Let's put this concern aside. Since if any problem, we will need to fix it 
for the batch mode anyway.




----------------------------------------------------------------
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