HDFS-14010. Pass correct DF usage to ReservedSpaceCalculator builder. Contributed by Virajith Jalaparti.
This commit is contained in:
parent
e188bb12b0
commit
335c1c9938
@ -163,6 +163,13 @@ public class FsVolumeImpl implements FsVolumeSpi {
|
|||||||
this.storageType = storageLocation.getStorageType();
|
this.storageType = storageLocation.getStorageType();
|
||||||
this.configuredCapacity = -1;
|
this.configuredCapacity = -1;
|
||||||
this.usage = usage;
|
this.usage = usage;
|
||||||
|
if (this.usage != null) {
|
||||||
|
reserved = new ReservedSpaceCalculator.Builder(conf)
|
||||||
|
.setUsage(this.usage).setStorageType(storageType).build();
|
||||||
|
} else {
|
||||||
|
reserved = null;
|
||||||
|
LOG.warn("Setting reserved to null as usage is null");
|
||||||
|
}
|
||||||
if (currentDir != null) {
|
if (currentDir != null) {
|
||||||
File parent = currentDir.getParentFile();
|
File parent = currentDir.getParentFile();
|
||||||
cacheExecutor = initializeCacheExecutor(parent);
|
cacheExecutor = initializeCacheExecutor(parent);
|
||||||
@ -173,8 +180,6 @@ public class FsVolumeImpl implements FsVolumeSpi {
|
|||||||
}
|
}
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
this.fileIoProvider = fileIoProvider;
|
this.fileIoProvider = fileIoProvider;
|
||||||
this.reserved = new ReservedSpaceCalculator.Builder(conf)
|
|
||||||
.setUsage(usage).setStorageType(storageType).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ThreadPoolExecutor initializeCacheExecutor(File parent) {
|
protected ThreadPoolExecutor initializeCacheExecutor(File parent) {
|
||||||
@ -473,7 +478,7 @@ public class FsVolumeImpl implements FsVolumeSpi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long getReserved(){
|
long getReserved(){
|
||||||
return reserved.getReserved();
|
return reserved != null ? reserved.getReserved() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -353,6 +353,14 @@ public class TestProvidedImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReserved() throws Exception {
|
||||||
|
for (FsVolumeSpi vol : providedVolumes) {
|
||||||
|
// the reserved space for provided volumes should be 0.
|
||||||
|
assertEquals(0, ((FsVolumeImpl) vol).getReserved());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProvidedVolumeImpl() throws IOException {
|
public void testProvidedVolumeImpl() throws IOException {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user