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

spricoder pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new a1cdd6851ad Fix Some Code Smells of DataNode Module (#11590)
a1cdd6851ad is described below

commit a1cdd6851ada0135c8ef1bc67b3bb29082d8faf7
Author: Bo Cui <[email protected]>
AuthorDate: Tue Nov 21 17:14:03 2023 +0800

    Fix Some Code Smells of DataNode Module (#11590)
---
 .../queryengine/plan/analyze/LoadTsfileAnalyzer.java   |  8 +++-----
 .../planner/plan/node/load/LoadSingleTsFileNode.java   |  4 ++--
 .../planner/plan/node/load/LoadTsFilePieceNode.java    |  8 ++++----
 .../plan/scheduler/load/LoadTsFileDispatcherImpl.java  | 18 +++++++++---------
 .../mtree/impl/pbtree/CachedMTreeStore.java            | 16 ++++++++--------
 5 files changed, 26 insertions(+), 28 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/LoadTsfileAnalyzer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/LoadTsfileAnalyzer.java
index 42620e5dca1..2ef08186e88 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/LoadTsfileAnalyzer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/LoadTsfileAnalyzer.java
@@ -136,7 +136,7 @@ public class LoadTsfileAnalyzer {
 
       if (tsFile.length() == 0) {
         if (LOGGER.isWarnEnabled()) {
-          LOGGER.warn(String.format("TsFile %s is empty.", tsFile.getPath()));
+          LOGGER.warn("TsFile {} is empty.", tsFile.getPath());
         }
         if (LOGGER.isInfoEnabled()) {
           LOGGER.info(
@@ -156,9 +156,7 @@ public class LoadTsfileAnalyzer {
       } catch (IllegalArgumentException e) {
         schemaAutoCreatorAndVerifier.clear();
         LOGGER.warn(
-            String.format(
-                "Parse file %s to resource error, this TsFile maybe empty.", 
tsFile.getPath()),
-            e);
+            "Parse file {} to resource error, this TsFile maybe empty.", 
tsFile.getPath(), e);
         throw new SemanticException(
             String.format("TsFile %s is empty or incomplete.", 
tsFile.getPath()));
       } catch (AuthException e) {
@@ -169,7 +167,7 @@ public class LoadTsfileAnalyzer {
         return analysis;
       } catch (Exception e) {
         schemaAutoCreatorAndVerifier.clear();
-        LOGGER.warn(String.format("Parse file %s to resource error.", 
tsFile.getPath()), e);
+        LOGGER.warn("Parse file {} to resource error.", tsFile.getPath(), e);
         throw new SemanticException(
             String.format(
                 "Parse file %s to resource error, because %s", 
tsFile.getPath(), e.getMessage()));
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/load/LoadSingleTsFileNode.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/load/LoadSingleTsFileNode.java
index c4ff3c34407..7da6f247155 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/load/LoadSingleTsFileNode.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/load/LoadSingleTsFileNode.java
@@ -52,7 +52,7 @@ import java.util.Set;
 import java.util.function.Function;
 
 public class LoadSingleTsFileNode extends WritePlanNode {
-  private static final Logger logger = 
LoggerFactory.getLogger(LoadSingleTsFileNode.class);
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(LoadSingleTsFileNode.class);
 
   private final File tsFile;
   private final TsFileResource resource;
@@ -219,7 +219,7 @@ public class LoadSingleTsFileNode extends WritePlanNode {
             new File(tsFile.getAbsolutePath() + 
ModificationFile.FILE_SUFFIX).toPath());
       }
     } catch (IOException e) {
-      logger.warn(String.format("Delete After Loading %s error.", tsFile), e);
+      LOGGER.warn("Delete After Loading {} error.", tsFile, e);
     }
   }
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/load/LoadTsFilePieceNode.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/load/LoadTsFilePieceNode.java
index ab7f9367e8d..fbc36e2e19a 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/load/LoadTsFilePieceNode.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/load/LoadTsFilePieceNode.java
@@ -47,7 +47,7 @@ import java.util.List;
 import java.util.Objects;
 
 public class LoadTsFilePieceNode extends WritePlanNode {
-  private static final Logger logger = 
LoggerFactory.getLogger(LoadTsFilePieceNode.class);
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(LoadTsFilePieceNode.class);
 
   private File tsFile;
 
@@ -120,7 +120,7 @@ public class LoadTsFilePieceNode extends WritePlanNode {
       serializeAttributes(stream);
       byteBuffer.put(byteOutputStream.toByteArray());
     } catch (IOException e) {
-      logger.error("Serialize to ByteBuffer error.", e);
+      LOGGER.error("Serialize to ByteBuffer error.", e);
     }
   }
 
@@ -133,7 +133,7 @@ public class LoadTsFilePieceNode extends WritePlanNode {
       try {
         tsFileData.serialize(stream);
       } catch (IOException e) {
-        logger.error(
+        LOGGER.error(
             String.format(
                 "Serialize data of TsFile %s error, skip TsFileData %s",
                 tsFile.getPath(), tsFileData));
@@ -160,7 +160,7 @@ public class LoadTsFilePieceNode extends WritePlanNode {
       pieceNode.setPlanNodeId(PlanNodeId.deserialize(stream));
       return pieceNode;
     } catch (IOException | PageException | IllegalPathException e) {
-      logger.error(String.format("Deserialize %s error.", 
LoadTsFilePieceNode.class.getName()), e);
+      LOGGER.error("Deserialize {} error.", 
LoadTsFilePieceNode.class.getName(), e);
       return null;
     }
   }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileDispatcherImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileDispatcherImpl.java
index 620920a01a8..84e65dd35d5 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileDispatcherImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileDispatcherImpl.java
@@ -60,7 +60,7 @@ import java.util.concurrent.Future;
 import static com.google.common.util.concurrent.Futures.immediateFuture;
 
 public class LoadTsFileDispatcherImpl implements IFragInstanceDispatcher {
-  private static final Logger logger = 
LoggerFactory.getLogger(LoadTsFileDispatcherImpl.class);
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(LoadTsFileDispatcherImpl.class);
 
   private String uuid;
   private final String localhostIpAddr;
@@ -99,7 +99,7 @@ public class LoadTsFileDispatcherImpl implements 
IFragInstanceDispatcher {
             } catch (FragmentInstanceDispatchException e) {
               return new FragInstanceDispatchResult(e.getFailureStatus());
             } catch (Exception t) {
-              logger.warn("cannot dispatch FI for load operation", t);
+              LOGGER.warn("cannot dispatch FI for load operation", t);
               return new FragInstanceDispatchResult(
                   RpcUtils.getStatus(
                       TSStatusCode.INTERNAL_SERVER_ERROR, "Unexpected errors: 
" + t.getMessage()));
@@ -141,12 +141,12 @@ public class LoadTsFileDispatcherImpl implements 
IFragInstanceDispatcher {
         internalServiceClientManager.borrowClient(endPoint)) {
       TLoadResp loadResp = client.sendTsFilePieceNode(loadTsFileReq);
       if (!loadResp.isAccepted()) {
-        logger.warn(loadResp.message);
+        LOGGER.warn(loadResp.message);
         throw new FragmentInstanceDispatchException(loadResp.status);
       }
     } catch (ClientManagerException | TException e) {
       String warning = NODE_CONNECTION_ERROR;
-      logger.warn(warning, endPoint, e);
+      LOGGER.warn(warning, endPoint, e);
       TSStatus status = new TSStatus();
       status.setCode(TSStatusCode.DISPATCH_ERROR.getStatusCode());
       status.setMessage(warning + endPoint);
@@ -160,11 +160,11 @@ public class LoadTsFileDispatcherImpl implements 
IFragInstanceDispatcher {
         internalServiceClientManager.borrowClient(endPoint)) {
       TLoadResp loadResp = client.sendLoadCommand(loadCommandReq);
       if (!loadResp.isAccepted()) {
-        logger.warn(loadResp.message);
+        LOGGER.warn(loadResp.message);
         throw new FragmentInstanceDispatchException(loadResp.status);
       }
     } catch (ClientManagerException | TException e) {
-      logger.warn(NODE_CONNECTION_ERROR, endPoint, e);
+      LOGGER.warn(NODE_CONNECTION_ERROR, endPoint, e);
       TSStatus status = new TSStatus();
       status.setCode(TSStatusCode.DISPATCH_ERROR.getStatusCode());
       status.setMessage(
@@ -189,7 +189,7 @@ public class LoadTsFileDispatcherImpl implements 
IFragInstanceDispatcher {
   }
 
   public void dispatchLocally(FragmentInstance instance) throws 
FragmentInstanceDispatchException {
-    logger.info("Receive load node from uuid {}.", uuid);
+    LOGGER.info("Receive load node from uuid {}.", uuid);
 
     ConsensusGroupId groupId =
         ConsensusGroupId.Factory.createFromTConsensusGroupId(
@@ -218,7 +218,7 @@ public class LoadTsFileDispatcherImpl implements 
IFragInstanceDispatcher {
                 ((LoadSingleTsFileNode) planNode).isDeleteAfterLoad(),
                 isGeneratedByPipe);
       } catch (LoadFileException e) {
-        logger.warn(String.format("Load TsFile Node %s error.", planNode), e);
+        LOGGER.warn("Load TsFile Node {} error.", planNode, e);
         TSStatus resultStatus = new TSStatus();
         resultStatus.setCode(TSStatusCode.LOAD_FILE_ERROR.getStatusCode());
         resultStatus.setMessage(e.getMessage());
@@ -248,7 +248,7 @@ public class LoadTsFileDispatcherImpl implements 
IFragInstanceDispatcher {
       } catch (FragmentInstanceDispatchException e) {
         return immediateFuture(new 
FragInstanceDispatchResult(e.getFailureStatus()));
       } catch (Exception t) {
-        logger.warn("cannot dispatch LoadCommand for load operation", t);
+        LOGGER.warn("cannot dispatch LoadCommand for load operation", t);
         return immediateFuture(
             new FragInstanceDispatchResult(
                 RpcUtils.getStatus(
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/CachedMTreeStore.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/CachedMTreeStore.java
index 2a0b2de01c5..59e0d9646c4 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/CachedMTreeStore.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/CachedMTreeStore.java
@@ -57,7 +57,7 @@ import java.util.function.Consumer;
 
 public class CachedMTreeStore implements IMTreeStore<ICachedMNode> {
 
-  private static final Logger logger = 
LoggerFactory.getLogger(CachedMTreeStore.class);
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(CachedMTreeStore.class);
 
   private final int schemaRegionId;
 
@@ -487,7 +487,7 @@ public class CachedMTreeStore implements 
IMTreeStore<ICachedMNode> {
           file.clear();
           file.close();
         } catch (MetadataException | IOException e) {
-          logger.error(String.format("Error occurred during PBTree clear, %s", 
e.getMessage()));
+          LOGGER.error("Error occurred during PBTree clear, {}", 
e.getMessage());
         }
       }
       file = null;
@@ -584,9 +584,9 @@ public class CachedMTreeStore implements 
IMTreeStore<ICachedMNode> {
 
         long time = System.currentTimeMillis() - startTime;
         if (time > 10_000) {
-          logger.info("It takes {}ms to flush MTree in SchemaRegion {}", time, 
schemaRegionId);
+          LOGGER.info("It takes {}ms to flush MTree in SchemaRegion {}", time, 
schemaRegionId);
         } else {
-          logger.debug("It takes {}ms to flush MTree in SchemaRegion {}", 
time, schemaRegionId);
+          LOGGER.debug("It takes {}ms to flush MTree in SchemaRegion {}", 
time, schemaRegionId);
         }
       }
 
@@ -594,10 +594,10 @@ public class CachedMTreeStore implements 
IMTreeStore<ICachedMNode> {
         flushCallback.run();
       }
     } catch (MetadataException | IOException e) {
-      logger.warn(
+      LOGGER.warn(
           "Exception occurred during MTree flush, current SchemaRegionId is 
{}", schemaRegionId, e);
     } catch (Throwable e) {
-      logger.error(
+      LOGGER.error(
           "Error occurred during MTree flush, current SchemaRegionId is {}", 
schemaRegionId, e);
       e.printStackTrace();
     }
@@ -614,7 +614,7 @@ public class CachedMTreeStore implements 
IMTreeStore<ICachedMNode> {
       file.updateDatabaseNode(updatedStorageGroupMNode);
       return true;
     } catch (IOException e) {
-      logger.warn(
+      LOGGER.warn(
           "IOException occurred during updating StorageGroupMNode {}",
           updatedStorageGroupMNode.getFullPath(),
           e);
@@ -669,7 +669,7 @@ public class CachedMTreeStore implements 
IMTreeStore<ICachedMNode> {
         try {
           readNext();
         } catch (MetadataException e) {
-          logger.error(String.format("Error occurred during readNext, %s", 
e.getMessage()));
+          LOGGER.error("Error occurred during readNext, {}", e.getMessage());
           return false;
         }
         return nextNode != null;

Reply via email to