amaliujia commented on code in PR #11427:
URL: https://github.com/apache/ozone/pull/11427#discussion_r4215445383
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/KeyValueStreamDataChannel.java:
##########
@@ -141,30 +142,45 @@ protected void cleanupInternal() throws IOException {
* Note that the PutBlock proto at the end is ignored; see HDDS-12007.
*/
private void writeBuffers() throws IOException {
- final ReferenceCountedObject<ByteBuf> ref = buffers.pollAll();
- final ByteBuf buf = ref.retain();
- try {
- setEndIndex(buf);
- // write the remaining data
- writeFully(buf.nioBuffer(), super::writeFileChannel);
- } finally {
- ref.release();
+ pollAllAndWrite(buffers, super::writeFileChannel, b -> {
+ setEndIndex(b);
+ return null;
+ });
+ }
+
+ /**
+ * Write all the data in {@link #buffers} to the channel.
+ * It must be called before committing a PutBlock in the middle of the
stream;
+ * otherwise, the buffered data is not yet in the block file.
+ */
+ public void drainBuffers() throws IOException {
+ assertOpen();
+ if (!buffers.isEmpty()) {
+ pollAllAndWrite(buffers, super::writeFileChannel, b -> null);
}
}
Review Comment:
Sure I reverted.
I think it makes sense as we are adding critical new code, let's try to have
the new code only works for the draining so even though we introduce bugs or
issues, it does not affect existing running-well close/write path
--
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]