rpuch commented on code in PR #6308:
URL: https://github.com/apache/ignite-3/pull/6308#discussion_r2228563149
##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/server/impl/JraftServerImpl.java:
##########
@@ -621,12 +625,46 @@ private void destroyStorages(StoragesDestructionContext
context) {
// This destroys both meta storage and snapshots storage as they
are stored under nodeDataPath.
IgniteUtils.deleteIfExistsThrowable(dataPath);
} catch (Exception e) {
- throw new IgniteInternalException("Failed to delete storage for
node: " + nodeId, e);
+ throw new IgniteInternalException(INTERNAL_ERR, "Failed to delete
storage for node: " + nodeId, e);
}
groupStoragesDestructionIntents.removeStorageDestructionIntent(nodeId);
}
+ /**
+ * Returns Raft node IDs for all groups that are present on disk.
+ *
+ * <p>This method should only be called when no Raft nodes are started or
being started.
+ */
+ public Set<RawRaftNodeId> raftNodeIdsOnDisk() {
+ Set<String> groupIdsForStorage = new HashSet<>();
+
+ for (LogStorageFactory logStorageFactory :
groupStoragesContextResolver.logStorageFactories()) {
+
groupIdsForStorage.addAll(logStorageFactory.raftNodeStorageIdsOnDisk());
+ }
+ groupIdsForStorage.addAll(raftNodeMetaStorageIdsOnDisk());
+
+ return groupIdsForStorage.stream()
+ .map(RaftNodeId::fromNodeIdStringForStorage)
+ .collect(toUnmodifiableSet());
+ }
+
+ private Set<String> raftNodeMetaStorageIdsOnDisk() {
+ return groupStoragesContextResolver.serverDataPaths().stream()
+ .flatMap(JraftServerImpl::listUncheckingly)
+ .filter(Files::isDirectory)
+ .map(groupDirPath -> groupDirPath.getFileName().toString())
+ .collect(toUnmodifiableSet());
+ }
+
+ private static Stream<Path> listUncheckingly(Path dir) {
+ try {
+ return Files.list(dir);
Review Comment:
It is closed by the caller (`flatMap()` promises to do so in its Javadoc)
--
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]