This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch ratis_snapshot
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/ratis_snapshot by this push:
new d6278ed378 snapshot detail info (#9492)
d6278ed378 is described below
commit d6278ed378ccbcf1fdd6579642713cd87b05afd4
Author: William Song <[email protected]>
AuthorDate: Fri Mar 31 14:42:21 2023 +0800
snapshot detail info (#9492)
---
.../iotdb/consensus/ratis/RatisConsensus.java | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git
a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
index 7cac28eb17..ffad6bcb1f 100644
---
a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
+++
b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
@@ -81,6 +81,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -92,6 +93,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
+import static
org.apache.iotdb.consensus.common.Utils.listAllRegularFilesRecursively;
+
/** A multi-raft consensus implementation based on Apache Ratis. */
class RatisConsensus implements IConsensus {
@@ -723,10 +726,27 @@ class RatisConsensus implements IConsensus {
continue;
}
- final long currentDirLength =
- calcMap.computeIfAbsent(currentDir,
MemorizedFileSizeCalc::new).getTotalFolderSize();
+ final List<Path> allFiles = listAllRegularFilesRecursively(currentDir);
+ final long currentDirLength = allFiles.stream().mapToLong(p ->
p.toFile().length()).sum();
+ final StringBuilder allFilesString = new StringBuilder();
+ allFiles.forEach(
+ p ->
+ allFilesString
+ .append(p.toFile().getAbsolutePath())
+ .append(":\t")
+ .append(p.toFile().length())
+ .append("\n"));
final long triggerSnapshotFileSize =
config.getImpl().getTriggerSnapshotFileSize();
+ logger.warn(
+ "SNAPSHOT-SZY: {} checks snapshot for group {}, current dir {},
total size {}, triggers {}, file details: {}",
+ this,
+ raftGroupId,
+ currentDir,
+ currentDirLength,
+ currentDirLength >= triggerSnapshotFileSize,
+ allFilesString);
+
if (currentDirLength >= triggerSnapshotFileSize) {
ConsensusGenericResponse consensusGenericResponse =
triggerSnapshot(Utils.fromRaftGroupIdToConsensusGroupId(raftGroupId));