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

markgui pushed a commit to branch revert-3202-HDDS-6459
in repository https://gitbox.apache.org/repos/asf/ozone.git

commit c5788178118d37553ba67b2f95c748a6b20a6850
Author: Gui Hecheng <[email protected]>
AuthorDate: Mon Mar 21 10:24:46 2022 +0800

    Revert "EC: Check isFullCell inside handleDataWrite (#3202)"
    
    This reverts commit 217c1911b273018fe1a6e8b2770ab05d1247a509.
---
 .../hadoop/ozone/client/io/ECKeyOutputStream.java  | 24 +++++++++++++++-------
 1 file changed, 17 insertions(+), 7 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 234c1d3..34a6957 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
@@ -160,11 +160,16 @@ public class ECKeyOutputStream extends KeyOutputStream {
             .getCurrentStreamEntry().getCurrentStreamIdx();
         int bufferRem =
             ecChunkBufferCache.dataBuffers[currentStreamIdx].remaining();
-        int writeLen = Math.min(rem, Math.min(bufferRem, ecChunkSize));
-        int pos = handleDataWrite(currentStreamIdx, b, off, writeLen);
+        int expectedWriteLen = Math.min(rem, Math.min(bufferRem, ecChunkSize));
+        int oldPos =
+            ecChunkBufferCache.dataBuffers[currentStreamIdx].position();
+        int pos =
+            handleDataWrite(currentStreamIdx, b, off, expectedWriteLen,
+                oldPos + expectedWriteLen == ecChunkSize);
         checkAndWriteParityCells(pos);
-        rem -= writeLen;
-        off += writeLen;
+        long writtenLength = pos - oldPos;
+        rem -= writtenLength;
+        off += writtenLength;
       } catch (Exception e) {
         markStreamClosed();
         throw new IOException(e.getMessage());
@@ -370,9 +375,14 @@ public class ECKeyOutputStream extends KeyOutputStream {
     }
   }
 
-  private int handleDataWrite(int currIdx, byte[] b, int off, int len) {
-    int pos = ecChunkBufferCache.addToDataBuffer(currIdx, b, off, len);
-    if (pos == ecChunkSize) {
+  private int handleDataWrite(int currIdx, byte[] b, int off, long len,
+      boolean isFullCell) {
+    int pos = ecChunkBufferCache.addToDataBuffer(currIdx, b, off, (int) len);
+
+    if (isFullCell) {
+      Preconditions.checkArgument(pos == ecChunkSize,
+          "When full cell passed, the pos: " + pos
+              + " should match to ec chunk size.");
       handleOutputStreamWrite(currIdx, pos, false);
       blockOutputStreamEntryPool.getCurrentStreamEntry().useNextBlockStream();
     }

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

Reply via email to