felixcheung commented on a change in pull request #3355: [ZEPPELIN-4133]. Idle 
sessions are no longer being closed even though TimeoutLifecycleManagement is 
configured properly
URL: https://github.com/apache/zeppelin/pull/3355#discussion_r278419433
 
 

 ##########
 File path: 
zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/lifecycle/TimeoutLifecycleManager.java
 ##########
 @@ -30,29 +32,30 @@
   private long checkInterval;
   private long timeoutThreshold;
 
-  private Timer checkTimer;
+  private ScheduledExecutorService checkScheduler;
 
   public TimeoutLifecycleManager(ZeppelinConfiguration zConf) {
     this.checkInterval = zConf.getLong(ZeppelinConfiguration.ConfVars
             .ZEPPELIN_INTERPRETER_LIFECYCLE_MANAGER_TIMEOUT_CHECK_INTERVAL);
     this.timeoutThreshold = zConf.getLong(
         
ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_LIFECYCLE_MANAGER_TIMEOUT_THRESHOLD);
-    this.checkTimer = new Timer(true);
-    this.checkTimer.scheduleAtFixedRate(new TimerTask() {
-      @Override
-      public void run() {
+    this.checkScheduler = Executors.newScheduledThreadPool(1);
+    this.checkScheduler.scheduleAtFixedRate(() -> {
+      try {
         long now = System.currentTimeMillis();
         for (Map.Entry<ManagedInterpreterGroup, Long> entry : 
interpreterGroups.entrySet()) {
           ManagedInterpreterGroup interpreterGroup = entry.getKey();
           Long lastTimeUsing = entry.getValue();
-          if ((now - lastTimeUsing) > timeoutThreshold )  {
+          if ((now - lastTimeUsing) > timeoutThreshold) {
             LOGGER.info("InterpreterGroup {} is timeout.", 
interpreterGroup.getId());
             interpreterGroup.close();
             interpreterGroups.remove(entry.getKey());
           }
         }
+      } catch (Exception e) {
+        LOGGER.warn("Fail to run periodical checking task", e);
 
 Review comment:
   perhaps put try catch around `interpreterGroup.close();`? it looks to me 
like other calls inside should not fail in most cases. if `close()` is 
expensive or could fail, then a try catch just around it could let other groups 
a chance to get clean up, instead of skipping all of the rest this is doing now.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to