Browse Source

HDFS-17184. Improve BlockReceiver to throws DiskOutOfSpaceException when initialize. (#6044). Contributed by Haiyang Hu.

Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
huhaiyang 1 năm trước cách đây
mục cha
commit
cc66683b1a

+ 4 - 4
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java

@@ -57,6 +57,7 @@ import org.apache.hadoop.util.Daemon;
 import org.apache.hadoop.util.DataChecksum;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.Time;
+import org.apache.hadoop.util.DiskChecker.DiskOutOfSpaceException;
 import org.apache.hadoop.tracing.Span;
 import org.apache.hadoop.tracing.Tracer;
 
@@ -274,10 +275,9 @@ class BlockReceiver implements Closeable {
       if (isCreate) {
         BlockMetadataHeader.writeHeader(checksumOut, diskChecksum);
       } 
-    } catch (ReplicaAlreadyExistsException bae) {
-      throw bae;
-    } catch (ReplicaNotFoundException bne) {
-      throw bne;
+    } catch (ReplicaAlreadyExistsException | ReplicaNotFoundException
+        | DiskOutOfSpaceException e) {
+      throw e;
     } catch(IOException ioe) {
       if (replicaInfo != null) {
         replicaInfo.releaseAllBytesReserved();

+ 3 - 4
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/RoundRobinVolumeChoosingPolicy.java

@@ -117,14 +117,13 @@ public class RoundRobinVolumeChoosingPolicy<V extends FsVolumeSpi>
         maxAvailable = availableVolumeSize;
       }
 
+      LOG.warn("The volume[{}] with the available space (={} B) is "
+              + "less than the block size (={} B).", volume.getBaseURI(),
+          availableVolumeSize, blockSize);
       if (curVolume == startVolume) {
         throw new DiskOutOfSpaceException("Out of space: "
             + "The volume with the most available space (=" + maxAvailable
             + " B) is less than the block size (=" + blockSize + " B).");
-      } else {
-        LOG.warn("The volume[{}] with the available space (={} B) is "
-            + "less than the block size (={} B).", volume.getBaseURI(),
-            availableVolumeSize, blockSize);
       }
     }
   }