HDFS-12631. Ozone: ContainerStorageLocation#scmUsage should count only SCM usage. Contributed by Xiaoyu Yao.

This commit is contained in:
Nandakumar 2017-10-11 17:28:09 +05:30 committed by Owen O'Malley
parent d19b4c8763
commit 5ed663b32f

View File

@ -25,6 +25,7 @@
import org.apache.hadoop.hdfs.server.datanode.StorageLocation; import org.apache.hadoop.hdfs.server.datanode.StorageLocation;
import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage; import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage;
import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.util.ShutdownHookManager; import org.apache.hadoop.util.ShutdownHookManager;
import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Time;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -37,6 +38,7 @@
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Scanner; import java.util.Scanner;
import static org.apache.hadoop.util.RunJar.SHUTDOWN_HOOK_PRIORITY; import static org.apache.hadoop.util.RunJar.SHUTDOWN_HOOK_PRIORITY;
@ -62,7 +64,17 @@ public ContainerStorageLocation(StorageLocation dataLoc, Configuration conf)
throws IOException { throws IOException {
this.dataLocation = dataLoc; this.dataLocation = dataLoc;
this.storageUuId = DatanodeStorage.generateUuid(); this.storageUuId = DatanodeStorage.generateUuid();
File dataDir = new File(dataLoc.getNormalizedUri().getPath()); File dataDir = Paths.get(dataLoc.getNormalizedUri()).resolve(
OzoneConsts.CONTAINER_PREFIX).toFile();
// Initialize container data root if it does not exist as required by DF/DU
if (!dataDir.exists()) {
if (!dataDir.mkdirs()) {
LOG.error("Unable to create the container storage location at : {}",
dataDir);
throw new IllegalArgumentException("Unable to create the container" +
" storage location at : " + dataDir);
}
}
scmUsedFile = new File(dataDir, DU_CACHE_FILE); scmUsedFile = new File(dataDir, DU_CACHE_FILE);
// get overall disk usage // get overall disk usage
this.usage = new DF(dataDir, conf); this.usage = new DF(dataDir, conf);