kaijchen commented on a change in pull request #3120:
URL: https://github.com/apache/ozone/pull/3120#discussion_r812532746
##########
File path:
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/ECKeyOutputStream.java
##########
@@ -157,57 +155,47 @@ public void write(byte[] b, int off, int len) throws
IOException {
if (len == 0) {
return;
}
- blockOutputStreamEntryPool.allocateBlockIfNeeded();
+ handleWrite(b, off, len, false);
+ writeOffset += len;
+ }
- int currentStreamIdx = blockOutputStreamEntryPool.getCurrentStreamEntry()
- .getCurrentStreamIdx();
- int currentChunkBufferRemainingLength =
- ecChunkBufferCache.dataBuffers[currentStreamIdx].remaining();
- int currentChunkBufferLen =
- ecChunkBufferCache.dataBuffers[currentStreamIdx]
- .position();
- int maxLenToCurrChunkBuffer = Math.min(len, ecChunkSize);
- int currentWriterChunkLenToWrite =
- Math.min(currentChunkBufferRemainingLength, maxLenToCurrChunkBuffer);
- int pos = handleDataWrite(currentStreamIdx, b, off,
- currentWriterChunkLenToWrite,
- currentChunkBufferLen + currentWriterChunkLenToWrite == ecChunkSize);
- checkAndWriteParityCells(pos, false);
- int remLen = len - currentWriterChunkLenToWrite;
- int iters = remLen / ecChunkSize;
- int lastCellSize = remLen % ecChunkSize;
- off += currentWriterChunkLenToWrite;
-
- while (iters > 0) {
- currentStreamIdx = blockOutputStreamEntryPool.getCurrentStreamEntry()
- .getCurrentStreamIdx();
- pos = handleDataWrite(currentStreamIdx, b, off, ecChunkSize, true);
- off += ecChunkSize;
- iters--;
- checkAndWriteParityCells(pos, iters > 0 || remLen > 0);
- }
-
- if (lastCellSize > 0) {
- currentStreamIdx = blockOutputStreamEntryPool.getCurrentStreamEntry()
- .getCurrentStreamIdx();
- pos = handleDataWrite(currentStreamIdx, b, off,
- lastCellSize, false);
- checkAndWriteParityCells(pos, false);
+ private void handleWrite(byte[] b, int off, long len, boolean retry)
Review comment:
If we make KeyOutputStream#handleWrite() protected. We can override it
here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]