You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ma...@apache.org on 2022/03/21 02:21:50 UTC

[ozone] branch HDDS-3816-ec updated: EC: Check isFullCell inside handleDataWrite (#3202)

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

markgui 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 217c191  EC: Check isFullCell inside handleDataWrite (#3202)
217c191 is described below

commit 217c1911b273018fe1a6e8b2770ab05d1247a509
Author: Kaijie Chen <ch...@kaijie.org>
AuthorDate: Mon Mar 21 10:21:33 2022 +0800

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

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