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

umamahesh pushed a commit to branch HDDS-3816-ec
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/HDDS-3816-ec by this push:
     new 9ee6d72  HDDS-6373. EC: Exclude pipeline upon container close instead 
of exclude DNs. (#3137)
9ee6d72 is described below

commit 9ee6d72f313c008892ba7c24f3b8c10f841b5b77
Author: Gui Hecheng <[email protected]>
AuthorDate: Tue Mar 1 01:23:09 2022 +0800

    HDDS-6373. EC: Exclude pipeline upon container close instead of exclude 
DNs. (#3137)
---
 .../hadoop/ozone/client/io/ECKeyOutputStream.java  | 61 ++++++++++++++--------
 .../hadoop/ozone/client/io/KeyOutputStream.java    |  2 +-
 2 files changed, 41 insertions(+), 22 deletions(-)

diff --git 
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/ECKeyOutputStream.java
 
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/ECKeyOutputStream.java
index 1066f0a..11172ad 100644
--- 
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/ECKeyOutputStream.java
+++ 
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/ECKeyOutputStream.java
@@ -27,6 +27,7 @@ import org.apache.hadoop.hdds.client.ECReplicationConfig;
 import org.apache.hadoop.hdds.scm.OzoneClientConfig;
 import org.apache.hadoop.hdds.scm.XceiverClientFactory;
 import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
+import 
org.apache.hadoop.hdds.scm.container.common.helpers.ContainerNotOpenException;
 import org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList;
 import org.apache.hadoop.hdds.scm.storage.ECBlockOutputStream;
 import org.apache.hadoop.io.ByteBufferPool;
@@ -224,11 +225,13 @@ public class ECKeyOutputStream extends KeyOutputStream {
     }
 
     if (hasWriteFailure()) {
+      handleFailedStreams(false);
       return StripeWriteStatus.FAILED;
     }
     currentStreamEntry.executePutBlock(close);
 
     if (hasPutBlockFailure()) {
+      handleFailedStreams(true);
       return StripeWriteStatus.FAILED;
     }
     ECBlockOutputStreamEntry newBlockGroupStreamEntry =
@@ -274,6 +277,7 @@ public class ECKeyOutputStream extends KeyOutputStream {
       boolean isLastStripe) throws IOException {
     writeParityCells(parityCellSize);
     if (hasWriteFailure()) {
+      handleFailedStreams(false);
       return StripeWriteStatus.FAILED;
     }
 
@@ -286,6 +290,7 @@ public class ECKeyOutputStream extends KeyOutputStream {
         .executePutBlock(isLastStripe);
 
     if (hasPutBlockFailure()) {
+      handleFailedStreams(true);
       return StripeWriteStatus.FAILED;
     }
     ecChunkBufferCache.clear();
@@ -300,36 +305,51 @@ public class ECKeyOutputStream extends KeyOutputStream {
   }
 
   private boolean hasWriteFailure() {
-    List<ECBlockOutputStream> failedStreams =
-        blockOutputStreamEntryPool.getCurrentStreamEntry()
-            .streamsWithWriteFailure();
-    // Since writes are async, let's check the failures once.
-    if (failedStreams.size() > 0) {
-      addToExcludeNodesList(failedStreams);
-      return true;
-    }
-    return false;
+    return !blockOutputStreamEntryPool.getCurrentStreamEntry()
+        .streamsWithWriteFailure().isEmpty();
   }
 
   private boolean hasPutBlockFailure() {
-    List<ECBlockOutputStream> failedStreams =
-        blockOutputStreamEntryPool.getCurrentStreamEntry()
-            .streamsWithPutBlockFailure();
-    // Since writes are async, let's check the failures once.
-    if (failedStreams.size() > 0) {
-      addToExcludeNodesList(failedStreams);
-      return true;
-    }
-    return false;
+    return !blockOutputStreamEntryPool.getCurrentStreamEntry()
+        .streamsWithPutBlockFailure().isEmpty();
   }
 
-  private void addToExcludeNodesList(List<ECBlockOutputStream> failedStreams) {
+  private void handleFailedStreams(boolean forPutBlock) {
+    ECBlockOutputStreamEntry currentStreamEntry =
+        blockOutputStreamEntryPool.getCurrentStreamEntry();
+    List<ECBlockOutputStream> failedStreams = forPutBlock
+        ? currentStreamEntry.streamsWithPutBlockFailure()
+        : currentStreamEntry.streamsWithWriteFailure();
+
+    // Since writes are async, let's check the failures once.
+    boolean containerToExcludeAll = true;
     for (ECBlockOutputStream failedStream : failedStreams) {
+      Throwable cause = HddsClientUtils.checkForException(
+          failedStream.getIoException());
+      Preconditions.checkNotNull(cause);
+      if (!checkIfContainerToExclude(cause)) {
+        blockOutputStreamEntryPool.getExcludeList()
+            .addDatanode(failedStream.getDatanodeDetails());
+        containerToExcludeAll = false;
+      }
+    }
+
+    // NOTE: For now, this is mainly for ContainerNotOpenException
+    // due to container full, but may also for those cases that
+    // a DN do respond but with one with certain failures.
+    // In such cases we don't treat the replied DNs as failed.
+    if (containerToExcludeAll) {
       blockOutputStreamEntryPool.getExcludeList()
-          .addDatanode(failedStream.getDatanodeDetails());
+          .addPipeline(currentStreamEntry.getPipeline().getId());
     }
   }
 
+  @Override
+  protected boolean checkIfContainerToExclude(Throwable t) {
+    return super.checkIfContainerToExclude(t)
+        && t instanceof ContainerNotOpenException;
+  }
+
   void writeParityCells(int parityCellSize) throws IOException {
     final ByteBuffer[] buffers = ecChunkBufferCache.getDataBuffers();
     final ByteBuffer[] parityBuffers = ecChunkBufferCache.getParityBuffers();
@@ -420,7 +440,6 @@ public class ECKeyOutputStream extends KeyOutputStream {
       blockOutputStreamEntryPool.getExcludeList()
           .addPipeline(streamEntry.getPipeline().getId());
     }
-    // In EC, we will just close the current stream.
     markStreamAsFailed(exception);
   }
 
diff --git 
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java
 
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java
index f7b323c..c752e7a 100644
--- 
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java
+++ 
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java
@@ -431,7 +431,7 @@ public class KeyOutputStream extends OutputStream {
 
   // Every container specific exception from datatnode will be seen as
   // StorageContainerException
-  boolean checkIfContainerToExclude(Throwable t) {
+  protected boolean checkIfContainerToExclude(Throwable t) {
     return t instanceof StorageContainerException;
   }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to