You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/04/01 07:18:39 UTC

[GitHub] [iotdb] liu-hai opened a new pull request #2961: [ISSUE-2911]Fix The write stream is not closed when executing the command 'tracing off' , The previous branch 'fix_tracing' was broken and I checked out a new branch to submit

liu-hai opened a new pull request #2961:
URL: https://github.com/apache/iotdb/pull/2961


   The write stream is not closed when executing the command 'tracing off'
   Fix the bug by adding the following changes
   
   Content1 ...
   server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
   update:
   /** when tracing off need Close the stream */
   private void operateTracing(TracingPlan plan) {
   IoTDBDescriptor.getInstance().getConfig().setEnablePerformanceTracing(plan.isTracingOn());
   if (!plan.isTracingOn()) {
   TracingManager.getInstance().close();
   } else {
   if (!TracingManager.getInstance().getWriterStatus()) {
   TracingManager.getInstance().openTracingWriteStream();
   }
   }
   }
   
   Content2 ...
   server/src/main/java/org/apache/iotdb/db/query/control/TracingManager.java
   add:
   public void close() {
   try {
   writer.close();
   } catch (IOException e) {
   logger.error("Meeting error while Close the tracing log stream : {}", e.getMessage());
   }
   }
   
   public boolean getWriterStatus() {
   try {
   writer.flush();
   return true;
   } catch (IOException e) {
   return false;
   }
   }
   
   public void openTracingWriteStream() {
   File tracingDir =
   SystemFileFactory.INSTANCE.getFile(
   IoTDBDescriptor.getInstance().getConfig().getTracingDir());
   if (!tracingDir.exists()) {
   if (tracingDir.mkdirs()) {
   logger.info("create performance folder {}.", tracingDir);
   } else {
   logger.info("create performance folder {} failed.", tracingDir);
   }
   }
   File logFile =
   SystemFileFactory.INSTANCE.getFile(
   IoTDBDescriptor.getInstance().getConfig().getTracingDir()
   + File.separator
   + IoTDBConstant.TRACING_LOG);
   FileWriter fileWriter = null;
   try {
   fileWriter = new FileWriter(logFile, true);
   } catch (IOException e) {
   logger.error("Meeting error while creating TracingManager: {}", e.getMessage());
   }
   writer = new BufferedWriter(fileWriter);
   }
   
   Content3 ...
   server/src/test/java/org/apache/iotdb/db/query/control/TracingManagerTest.java
   add:
   tracingManager.openTracingWriteStream();


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



[GitHub] [iotdb] jixuan1989 merged pull request #2961: [ISSUE-2911]Fix The write stream is not closed when executing the command 'tracing off' , The previous branch 'fix_tracing' was broken and I checked out a new branch to submit

Posted by GitBox <gi...@apache.org>.
jixuan1989 merged pull request #2961:
URL: https://github.com/apache/iotdb/pull/2961


   


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



[GitHub] [iotdb] liu-hai commented on a change in pull request #2961: [ISSUE-2911]Fix The write stream is not closed when executing the command 'tracing off' , The previous branch 'fix_tracing' was broken and I checked out a new branch to submit

Posted by GitBox <gi...@apache.org>.
liu-hai commented on a change in pull request #2961:
URL: https://github.com/apache/iotdb/pull/2961#discussion_r605523002



##########
File path: server/src/main/java/org/apache/iotdb/db/query/control/TracingManager.java
##########
@@ -198,8 +198,46 @@ public void writeEndTime(long queryId) throws IOException {
     writer.flush();
   }
 
-  public void close() throws IOException {
-    writer.close();
+  public void close() {
+    try {
+      writer.close();
+    } catch (IOException e) {
+      logger.error("Meeting error while Close the tracing log stream : {}", e.getMessage());
+    }
+  }
+
+  public boolean getWriterStatus() {
+    try {
+      writer.flush();
+      return true;
+    } catch (IOException e) {
+      return false;
+    }
+  }
+
+  public void openTracingWriteStream() {
+    File tracingDir =
+        SystemFileFactory.INSTANCE.getFile(
+            IoTDBDescriptor.getInstance().getConfig().getTracingDir());
+    if (!tracingDir.exists()) {
+      if (tracingDir.mkdirs()) {
+        logger.info("create performance folder {}.", tracingDir);
+      } else {
+        logger.info("create performance folder {} failed.", tracingDir);
+      }
+    }

Review comment:
       no problem




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



[GitHub] [iotdb] Alima777 commented on a change in pull request #2961: [ISSUE-2911]Fix The write stream is not closed when executing the command 'tracing off' , The previous branch 'fix_tracing' was broken and I checked out a new branch to submit

Posted by GitBox <gi...@apache.org>.
Alima777 commented on a change in pull request #2961:
URL: https://github.com/apache/iotdb/pull/2961#discussion_r605499121



##########
File path: server/src/main/java/org/apache/iotdb/db/query/control/TracingManager.java
##########
@@ -198,8 +198,46 @@ public void writeEndTime(long queryId) throws IOException {
     writer.flush();
   }
 
-  public void close() throws IOException {
-    writer.close();
+  public void close() {
+    try {
+      writer.close();
+    } catch (IOException e) {
+      logger.error("Meeting error while Close the tracing log stream : {}", e.getMessage());
+    }
+  }
+
+  public boolean getWriterStatus() {
+    try {
+      writer.flush();
+      return true;
+    } catch (IOException e) {
+      return false;
+    }
+  }
+
+  public void openTracingWriteStream() {
+    File tracingDir =
+        SystemFileFactory.INSTANCE.getFile(
+            IoTDBDescriptor.getInstance().getConfig().getTracingDir());
+    if (!tracingDir.exists()) {
+      if (tracingDir.mkdirs()) {
+        logger.info("create performance folder {}.", tracingDir);
+      } else {
+        logger.info("create performance folder {} failed.", tracingDir);
+      }
+    }

Review comment:
       Hi, could you abstract the logic in constructor of TracingManager and this as a single method?




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