hongzhi-gao commented on code in PR #16811:
URL: https://github.com/apache/iotdb/pull/16811#discussion_r2588511567
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/disk/FolderManager.java:
##########
@@ -104,6 +105,37 @@ public String getNextFolder() throws
DiskSpaceInsufficientException {
}
}
+ /**
+ * Get folder by hash ID (typically consensus group ID), distributing as
evenly as possible among
+ * healthy folders using hash-based distribution
+ *
+ * @param hashId the hash ID (typically consensus group ID) used to
determine folder selection
+ * @return the selected folder path
+ * @throws DiskSpaceInsufficientException if no healthy folders are available
+ */
+ public String getFolderByHashId(int hashId) throws
DiskSpaceInsufficientException {
+ if (folders.isEmpty()) {
+ throw new DiskSpaceInsufficientException(folders);
+ }
+
+ List<String> healthyFolders =
+ folders.stream()
+ .filter(
+ folder ->
+ foldersStates.getOrDefault(folder, FolderState.ABNORMAL)
== FolderState.HEALTHY)
+ .collect(Collectors.toList());
+
+ if (healthyFolders.isEmpty()) {
+ logger.error("No healthy folders available, change system mode to
read-only.");
+
CommonDescriptor.getInstance().getConfig().setNodeStatus(NodeStatus.ReadOnly);
+
CommonDescriptor.getInstance().getConfig().setStatusReason(NodeStatus.DISK_FULL);
+ throw new DiskSpaceInsufficientException(folders);
+ }
+
+ int index = Math.abs(hashId) % healthyFolders.size();
+ return healthyFolders.get(index);
+ }
Review Comment:
removed
##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensus.java:
##########
@@ -465,7 +542,7 @@ public List<ConsensusGroupId> getAllConsensusGroupIds() {
@Override
public String getRegionDirFromConsensusGroupId(ConsensusGroupId groupId) {
- return buildPeerDir(storageDir, groupId);
+ return null;
}
Review Comment:
removed
--
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]