From da83d26414be56b8e5c830ac7172d63acc8cc740 Mon Sep 17 00:00:00 2001 From: Xiangpeng Hu Date: Tue, 24 Dec 2024 23:03:23 +0800 Subject: [PATCH 1/3] refine logs --- iotdb-connector/grafana-connector/pom.xml | 0 .../cache/node/DataNodeHeartbeatCache.java | 3 +- .../consensus/iot/IoTConsensusServerImpl.java | 44 ++++++++++++++++++- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 iotdb-connector/grafana-connector/pom.xml diff --git a/iotdb-connector/grafana-connector/pom.xml b/iotdb-connector/grafana-connector/pom.xml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/node/DataNodeHeartbeatCache.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/node/DataNodeHeartbeatCache.java index 36bed0ecc67b..6654d3f1f158 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/node/DataNodeHeartbeatCache.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/node/DataNodeHeartbeatCache.java @@ -81,7 +81,8 @@ public synchronized void updateCurrentStatistics(boolean forceUpdate) { currentStatistics.set(new NodeStatistics(currentNanoTime, status, statusReason, loadScore)); if (forceUpdate) { - LOGGER.info("Force update NodeCache: status={}, currentNanoTime={}", status, currentNanoTime); + LOGGER.debug( + "Force update NodeCache: status={}, currentNanoTime={}", status, currentNanoTime); } } diff --git a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java index 1a32248853a0..c83b03d902c9 100644 --- a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java +++ b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java @@ -662,7 +662,7 @@ public void buildSyncLogChannel(Peer targetPeer, long initialSyncIndex) { configuration.add(targetPeer); // step 3, persist configuration persistConfiguration(); - logger.info("[IoTConsensus] persist new configuration: {}", configuration); + logger.info("[IoTConsensus Configuration] persist new configuration: {}", configuration); } /** @@ -674,6 +674,7 @@ public boolean removeSyncLogChannel(Peer targetPeer) { String suggestion = ""; try { logDispatcher.removeLogDispatcherThread(targetPeer); + logger.info("[IoTConsensus] log dispatcher to {} removed and cleanup", targetPeer); } catch (Exception e) { logger.warn( "[IoTConsensus] Exception happened during removing log dispatcher thread, but configuration.dat will still be removed.", @@ -690,17 +691,36 @@ public boolean removeSyncLogChannel(Peer targetPeer) { checkAndUpdateSafeDeletedSearchIndex(); // step 3, persist configuration persistConfiguration(); - logger.info("[IoTConsensus] Configuration updated to {}. {}", this.configuration, suggestion); + logger.info( + "[IoTConsensus Configuration] Configuration updated to {}. {}", + this.configuration, + suggestion); return !exceptionHappened; } public void persistConfiguration() { try { + logger.info( + "[IoTConsensus Configuration] start persist configuration, {}", this.configuration); removeDuplicateConfiguration(); + logger.info( + "[IoTConsensus Configuration] removeDuplicateConfiguration completed, {}", + this.configuration); renameTmpConfigurationFileToRemoveSuffix(); + logger.info( + "[IoTConsensus Configuration] first renameTmpConfigurationFileToRemoveSuffix completed, {}", + this.configuration); serializeConfigurationAndFsyncToDisk(); + logger.info( + "[IoTConsensus Configuration] serializeConfigurationAndFsyncToDisk completed, {}", + this.configuration); deleteConfiguration(); + logger.info( + "[IoTConsensus Configuration] deleteConfiguration completed, {}", this.configuration); renameTmpConfigurationFileToRemoveSuffix(); + logger.info( + "[IoTConsensus Configuration] second renameTmpConfigurationFileToRemoveSuffix, completed {}", + this.configuration); } catch (IOException e) { // TODO: (xingtanzjr) need to handle the IOException because the IoTConsensus won't // work expectedly @@ -721,20 +741,33 @@ public void recoverConfiguration() { if (Files.exists(tmpConfigurationPath)) { Files.deleteIfExists(configurationPath); Files.move(tmpConfigurationPath, configurationPath); + logger.info( + "[IoTConsensus Configuration] recover configuration from tmpConfigurationFile, {}", + tmpConfigurationPath); } if (Files.exists(configurationPath)) { recoverFromOldConfigurationFile(configurationPath); + logger.info( + "[IoTConsensus Configuration] recover configuration from oldConfigurationFile, {}", + configurationPath); } else { // recover from split configuration file + logger.info( + "[IoTConsensus Configuration] recover configuration from old split configuration file"); Path dirPath = Paths.get(storageDir); List tmpPeerList = getConfiguration(dirPath, CONFIGURATION_TMP_FILE_NAME); configuration.addAll(tmpPeerList); + logger.info( + "[IoTConsensus Configuration] recover configuration from tmpPeerList, {}", + configuration); List peerList = getConfiguration(dirPath, CONFIGURATION_FILE_NAME); for (Peer peer : peerList) { if (!configuration.contains(peer)) { configuration.add(peer); } } + logger.info( + "[IoTConsensus Configuration] recover configuration from peerList, {}", configuration); persistConfiguration(); } logger.info("Recover IoTConsensus server Impl, configuration: {}", configuration); @@ -767,6 +800,10 @@ private List getConfiguration(Path dirPath, String configurationFileName) .filter(Files::isRegularFile) .filter(filePath -> filePath.getFileName().toString().contains(configurationFileName)) .toArray(Path[]::new); + logger.info( + "[IoTConsensus Configuration] getConfiguration: fileName, {}, fileList: {}", + configurationFileName, + files); for (Path file : files) { buffer = ByteBuffer.wrap(Files.readAllBytes(file)); tmpConfiguration.add(Peer.deserialize(buffer)); @@ -979,6 +1016,7 @@ private void serializeConfigurationAndFsyncToDisk() throws IOException { // ignore sync exception } } + logger.info("[IoTConsensus Configuration] serializeConfiguration: {}", peer); } } @@ -1005,6 +1043,7 @@ private void renameTmpConfigurationFileToRemoveSuffix() throws IOException { if (!filePath.toFile().renameTo(targetFile)) { logger.error("Unexpected error occurs when rename file: {} -> {}", filePath, targetPath); } + logger.info("[IoTConsensus Configuration] renameTmpConfigurationFile: {}", targetPath); } } catch (UncheckedIOException e) { throw e.getCause(); @@ -1026,6 +1065,7 @@ private void deleteConfiguration() throws IOException { filePath, e); } + logger.info("[IoTConsensus Configuration] deleteConfiguration: {}", filePath); }); } catch (UncheckedIOException e) { throw e.getCause(); From ace0232023d49ef6377cffba1c1e3c84ccf76164 Mon Sep 17 00:00:00 2001 From: Xiangpeng Hu <65238551+HxpSerein@users.noreply.github.com> Date: Wed, 25 Dec 2024 11:07:01 +0800 Subject: [PATCH 2/3] Delete iotdb-connector/grafana-connector/pom.xml --- iotdb-connector/grafana-connector/pom.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 iotdb-connector/grafana-connector/pom.xml diff --git a/iotdb-connector/grafana-connector/pom.xml b/iotdb-connector/grafana-connector/pom.xml deleted file mode 100644 index e69de29bb2d1..000000000000 From b3f2cc6a174118659fa179f0efcf8927033f6516 Mon Sep 17 00:00:00 2001 From: Xiangpeng Hu <65238551+HxpSerein@users.noreply.github.com> Date: Wed, 25 Dec 2024 11:09:15 +0800 Subject: [PATCH 3/3] Update IoTConsensusServerImpl.java --- .../consensus/iot/IoTConsensusServerImpl.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java index c83b03d902c9..ee049ee4d9c2 100644 --- a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java +++ b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java @@ -700,27 +700,11 @@ public boolean removeSyncLogChannel(Peer targetPeer) { public void persistConfiguration() { try { - logger.info( - "[IoTConsensus Configuration] start persist configuration, {}", this.configuration); removeDuplicateConfiguration(); - logger.info( - "[IoTConsensus Configuration] removeDuplicateConfiguration completed, {}", - this.configuration); renameTmpConfigurationFileToRemoveSuffix(); - logger.info( - "[IoTConsensus Configuration] first renameTmpConfigurationFileToRemoveSuffix completed, {}", - this.configuration); serializeConfigurationAndFsyncToDisk(); - logger.info( - "[IoTConsensus Configuration] serializeConfigurationAndFsyncToDisk completed, {}", - this.configuration); deleteConfiguration(); - logger.info( - "[IoTConsensus Configuration] deleteConfiguration completed, {}", this.configuration); renameTmpConfigurationFileToRemoveSuffix(); - logger.info( - "[IoTConsensus Configuration] second renameTmpConfigurationFileToRemoveSuffix, completed {}", - this.configuration); } catch (IOException e) { // TODO: (xingtanzjr) need to handle the IOException because the IoTConsensus won't // work expectedly