diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java index 884fa42484..c595026174 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java @@ -844,6 +844,11 @@ private boolean generateParityCellsForLastStripe() { void writeParityCells() throws IOException { final ByteBuffer[] buffers = cellBuffers.getBuffers(); + // Skips encoding and writing parity cells if there are no healthy parity + // data streamers + if (!checkAnyParityStreamerIsHealthy()) { + return; + } //encode the data cells encode(encoder, numDataBlocks, buffers); for (int i = numDataBlocks; i < numAllBlocks; i++) { @@ -852,6 +857,19 @@ void writeParityCells() throws IOException { cellBuffers.clear(); } + private boolean checkAnyParityStreamerIsHealthy() { + for (int i = numDataBlocks; i < numAllBlocks; i++) { + if (streamers.get(i).isHealthy()) { + return true; + } + } + if (LOG.isDebugEnabled()) { + LOG.debug("Skips encoding and writing parity cells as there are " + + "no healthy parity data streamers: " + streamers); + } + return false; + } + void writeParity(int index, ByteBuffer buffer, byte[] checksumBuf) throws IOException { final StripedDataStreamer current = setCurrentStreamer(index); diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index aa26088d86..a87fe76b34 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -184,6 +184,9 @@ Trunk (Unreleased) HDFS-9070. Allow fsck display pending replica location information for being-written blocks. (GAO Rui via jing9) + HDFS-9261. Erasure Coding: Skip encoding the data cells if all the parity data + streamers are failed for the current block group. (Rakesh R via umamahesh) + OPTIMIZATIONS BUG FIXES