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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]