You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by li...@apache.org on 2019/01/21 01:50:39 UTC

[incubator-iotdb] branch force-in-thread-periodically updated: use isActivated

This is an automated email from the ASF dual-hosted git repository.

liurui pushed a commit to branch force-in-thread-periodically
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git


The following commit(s) were added to refs/heads/force-in-thread-periodically by this push:
     new 9e8e97c  use isActivated
9e8e97c is described below

commit 9e8e97c37c8ea20217d0680136f28534ed042658
Author: liuruiyiyang <24...@qq.com>
AuthorDate: Mon Jan 21 09:50:25 2019 +0800

    use isActivated
---
 .../writelog/manager/MultiFileLogNodeManager.java  | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
index 4ecc6f0..588b509 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
@@ -150,36 +150,26 @@ public class MultiFileLogNodeManager implements WriteLogNodeManager, IService {
     }
   }
 
-  private boolean isThreadIneffective(Thread thread) {
-    return thread == null || !thread.isAlive();
-  }
-
   @Override
   public void close() {
-    if (isThreadIneffective(syncThread) && isThreadIneffective(forceThread)) {
+    if (!isActivated(syncThread) && !isActivated(forceThread)){
       logger.error("MultiFileLogNodeManager has not yet started");
       return;
     }
     logger.info("LogNodeManager starts closing..");
-    if (!isThreadIneffective(syncThread) && isThreadIneffective(forceThread)) {
+    if (isActivated(syncThread)) {
       syncThread.interrupt();
       logger.info("Waiting for sync thread to stop");
       while (syncThread.isAlive()) {
         // wait for syncThread
       }
-    } else if (isThreadIneffective(syncThread) && !isThreadIneffective(forceThread)) {
+    }
+    if (isActivated(forceThread)) {
       forceThread.interrupt();
       logger.info("Waiting for force thread to stop");
       while (forceThread.isAlive()) {
         // wait for forceThread
       }
-    } else {
-      syncThread.interrupt();
-      forceThread.interrupt();
-      logger.info("Waiting for sync and force threads to stop");
-      while (syncThread.isAlive() || forceThread.isAlive()) {
-        // wait for syncThread and forceThread
-      }
     }
     logger.info("{} nodes to be closed", nodeMap.size());
     for (WriteLogNode node : nodeMap.values()) {
@@ -259,6 +249,10 @@ public class MultiFileLogNodeManager implements WriteLogNodeManager, IService {
     return ServiceType.WAL_SERVICE;
   }
 
+  private boolean isActivated(Thread thread) {
+    return thread != null && thread.isAlive();
+  }
+
   private static class InstanceHolder {
 
     private static MultiFileLogNodeManager instance = new MultiFileLogNodeManager();