You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "ChenSammi (via GitHub)" <gi...@apache.org> on 2026/01/05 05:43:31 UTC
Re: [PR] HDDS-14114. [DiskBalancer] Fix DiskBalancer tmp directory to be under hdds//tmp [ozone]
ChenSammi commented on code in PR #9515:
URL: https://github.com/apache/ozone/pull/9515#discussion_r2660347539
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -177,17 +174,45 @@ public synchronized void refresh(DiskBalancerInfo diskBalancerInfo) throws IOExc
applyDiskBalancerInfo(diskBalancerInfo);
}
- private void constructTmpDir() throws IOException {
+ /**
+ * Cleans up stale diskBalancer temporary directories on startup.
+ *
+ * @throws IOException if cleanup fails
+ */
+ private void cleanupTmpDir() throws IOException {
for (HddsVolume volume:
StorageVolumeUtil.getHddsVolumesList(volumeSet.getVolumesList())) {
- Path tmpDir = getDiskBalancerTmpDir(volume);
+ Path diskBalancerTmpDir = null;
try {
- FileUtils.deleteDirectory(tmpDir.toFile());
- FileUtils.forceMkdir(tmpDir.toFile());
+ File tmpDir = volume.getTmpDir();
+ if (tmpDir != null) {
+ // If tmpDir is initialized, use it directly
+ diskBalancerTmpDir = tmpDir.toPath().resolve(DISK_BALANCER_DIR);
+ } else {
+ // If tmpDir is not initialized, construct the path manually
+ // This handles the case where stale directories exist from previous
+ // failed moves even though volumes haven't been initialized yet
+ String clusterId = volume.getClusterID();
+ if (clusterId == null) {
+ // Skip volumes without clusterID - they're not properly formatted
+ continue;
+ }
+ String workDirName = volume.getWorkingDirName();
+ if (workDirName == null) {
+ workDirName = clusterId;
+ }
+ diskBalancerTmpDir = Paths.get(volume.getStorageDir().toString(),
+ workDirName, "tmp", DISK_BALANCER_DIR);
Review Comment:
Use StorageVolume#TMP_DIR_NAME
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org