Skip to content

Commit

Permalink
[IoTConsensus] Refine IoTConsensus Configuration logs (apache#14542)
Browse files Browse the repository at this point in the history
* refine logs

* Delete iotdb-connector/grafana-connector/pom.xml

* Update IoTConsensusServerImpl.java

(cherry picked from commit 530dd0b)
  • Loading branch information
HxpSerein committed Dec 26, 2024
1 parent 0b74512 commit b093f8e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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.",
Expand All @@ -690,7 +691,10 @@ 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;
}

Expand Down Expand Up @@ -721,20 +725,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<Peer> tmpPeerList = getConfiguration(dirPath, CONFIGURATION_TMP_FILE_NAME);
configuration.addAll(tmpPeerList);
logger.info(
"[IoTConsensus Configuration] recover configuration from tmpPeerList, {}",
configuration);
List<Peer> 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);
Expand Down Expand Up @@ -767,6 +784,10 @@ private List<Peer> 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));
Expand Down Expand Up @@ -979,6 +1000,7 @@ private void serializeConfigurationAndFsyncToDisk() throws IOException {
// ignore sync exception
}
}
logger.info("[IoTConsensus Configuration] serializeConfiguration: {}", peer);
}
}

Expand All @@ -1005,6 +1027,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();
Expand All @@ -1026,6 +1049,7 @@ private void deleteConfiguration() throws IOException {
filePath,
e);
}
logger.info("[IoTConsensus Configuration] deleteConfiguration: {}", filePath);
});
} catch (UncheckedIOException e) {
throw e.getCause();
Expand Down

0 comments on commit b093f8e

Please sign in to comment.