HDFS-14700. Clean up pmem cache before setting pmem cache capacity. Contributed by Feilong He.
(cherry picked from commit f6fa865d6f
)
This commit is contained in:
parent
f2563dcca1
commit
cd1277398a
|
@ -218,6 +218,8 @@ public final class PmemVolumeManager {
|
||||||
try {
|
try {
|
||||||
File pmemDir = new File(volumes[n]);
|
File pmemDir = new File(volumes[n]);
|
||||||
File realPmemDir = verifyIfValidPmemVolume(pmemDir);
|
File realPmemDir = verifyIfValidPmemVolume(pmemDir);
|
||||||
|
// Clean up the cache left before, if any.
|
||||||
|
cleanup(realPmemDir);
|
||||||
this.pmemVolumes.add(realPmemDir.getPath());
|
this.pmemVolumes.add(realPmemDir.getPath());
|
||||||
long maxBytes;
|
long maxBytes;
|
||||||
if (maxBytesPerPmem == -1) {
|
if (maxBytesPerPmem == -1) {
|
||||||
|
@ -242,17 +244,20 @@ public final class PmemVolumeManager {
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
"At least one valid persistent memory volume is required!");
|
"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() {
|
void cleanup() {
|
||||||
// Remove all files under the volume.
|
// Remove all files under the volume.
|
||||||
for (String pmemDir: pmemVolumes) {
|
for (String pmemVolume : pmemVolumes) {
|
||||||
try {
|
cleanup(new File(pmemVolume));
|
||||||
FileUtils.cleanDirectory(new File(pmemDir));
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.error("Failed to clean up " + pmemDir, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue