liyuheng55555 commented on code in PR #12293:
URL: https://github.com/apache/iotdb/pull/12293#discussion_r1555343131
##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensus.java:
##########
@@ -414,28 +417,41 @@ public List<ConsensusGroupId> getAllConsensusGroupIds() {
return new ArrayList<>(stateMachineMap.keySet());
}
+ @Override
+ public List<ConsensusGroupId> getAllConsensusGroupIdsFromDisk() {
+ List<ConsensusGroupId> consensusGroupIds = new ArrayList<>();
+ try (DirectoryStream<Path> stream =
Files.newDirectoryStream(storageDir.toPath())) {
+ for (Path path : stream) {
+ String[] items = path.getFileName().toString().split("_");
+ ConsensusGroupId consensusGroupId =
+ ConsensusGroupId.Factory.create(Integer.parseInt(items[0]),
Integer.parseInt(items[1]));
+ consensusGroupIds.add(consensusGroupId);
+ }
+ } catch (IOException e) {
+ logger.error("Failed to get all consensus group ids from disk", e);
+ }
+ return consensusGroupIds;
+ }
+
Review Comment:
> This logic is the same as IoTConsensus, so may no need to add UT
@BUAAserein I still believe it is necessary, as UT are an effective tools to
ensure the logic consistency between two functions. This can be exemplified by
the numerous serialize-deserialize UTs in IoTDB, such as
NodeInfoTest.testSnapshot.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]