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

 ##########
 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:
   Make sense to me. I updated it. 

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