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 we...@apache.org on 2019/06/18 07:36:04 UTC

[hadoop] branch trunk updated: HDFS-14010. Pass correct DF usage to ReservedSpaceCalculator builder. Contributed by Virajith Jalaparti.

This is an automated email from the ASF dual-hosted git repository.

weichiu 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 335c1c9  HDFS-14010. Pass correct DF usage to ReservedSpaceCalculator builder. Contributed by Virajith Jalaparti.
335c1c9 is described below

commit 335c1c9938147a464f893f5368c1851c6c0becc6
Author: Wei-Chiu Chuang <we...@apache.org>
AuthorDate: Tue Jun 18 00:33:10 2019 -0700

    HDFS-14010. Pass correct DF usage to ReservedSpaceCalculator builder. Contributed by Virajith Jalaparti.
---
 .../hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java     | 11 ++++++++---
 .../hdfs/server/datanode/fsdataset/impl/TestProvidedImpl.java |  8 ++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
index 517bbc6..9ffced1 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
@@ -163,6 +163,13 @@ public class FsVolumeImpl implements FsVolumeSpi {
     this.storageType = storageLocation.getStorageType();
     this.configuredCapacity = -1;
     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) {
       File parent = currentDir.getParentFile();
       cacheExecutor = initializeCacheExecutor(parent);
@@ -173,8 +180,6 @@ public class FsVolumeImpl implements FsVolumeSpi {
     }
     this.conf = conf;
     this.fileIoProvider = fileIoProvider;
-    this.reserved = new ReservedSpaceCalculator.Builder(conf)
-        .setUsage(usage).setStorageType(storageType).build();
   }
 
   protected ThreadPoolExecutor initializeCacheExecutor(File parent) {
@@ -473,7 +478,7 @@ public class FsVolumeImpl implements FsVolumeSpi {
   }
 
   long getReserved(){
-    return reserved.getReserved();
+    return reserved != null ? reserved.getReserved() : 0;
   }
 
   @VisibleForTesting
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestProvidedImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestProvidedImpl.java
index a48e2f8..f383590 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestProvidedImpl.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestProvidedImpl.java
@@ -354,6 +354,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
   public void testProvidedVolumeImpl() throws IOException {
 
     assertEquals(NUM_LOCAL_INIT_VOLUMES + NUM_PROVIDED_INIT_VOLUMES,


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org