You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ra...@apache.org on 2019/08/09 08:38:50 UTC
[hadoop] branch trunk updated: HDFS-14700. Clean up pmem cache
before setting pmem cache capacity. Contributed by Feilong He.
This is an automated email from the ASF dual-hosted git repository.
rakeshr pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new f6fa865 HDFS-14700. Clean up pmem cache before setting pmem cache capacity. Contributed by Feilong He.
f6fa865 is described below
commit f6fa865d6fcb0ef0a25a00615f16f383e5032373
Author: Rakesh Radhakrishnan <ra...@apache.org>
AuthorDate: Fri Aug 9 14:07:54 2019 +0530
HDFS-14700. Clean up pmem cache before setting pmem cache capacity. Contributed by Feilong He.
---
.../datanode/fsdataset/impl/PmemVolumeManager.java | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/PmemVolumeManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/PmemVolumeManager.java
index 2d77f7a..969d18b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/PmemVolumeManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/PmemVolumeManager.java
@@ -218,6 +218,8 @@ public final class PmemVolumeManager {
try {
File pmemDir = new File(volumes[n]);
File realPmemDir = verifyIfValidPmemVolume(pmemDir);
+ // Clean up the cache left before, if any.
+ cleanup(realPmemDir);
this.pmemVolumes.add(realPmemDir.getPath());
long maxBytes;
if (maxBytesPerPmem == -1) {
@@ -242,17 +244,20 @@ public final class PmemVolumeManager {
throw new IOException(
"At least one valid persistent memory volume is required!");
}
- cleanup();
+ }
+
+ void cleanup(File realPmemDir) {
+ try {
+ FileUtils.cleanDirectory(realPmemDir);
+ } catch (IOException e) {
+ LOG.error("Failed to clean up " + realPmemDir.getPath(), e);
+ }
}
void cleanup() {
// Remove all files under the volume.
- for (String pmemDir: pmemVolumes) {
- try {
- FileUtils.cleanDirectory(new File(pmemDir));
- } catch (IOException e) {
- LOG.error("Failed to clean up " + pmemDir, e);
- }
+ for (String pmemVolume : pmemVolumes) {
+ cleanup(new File(pmemVolume));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org