Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IoTConsensus] Refine IoTConsensus Configuration logs #14542

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading