This is an automated email from the ASF dual-hosted git repository.
sammichen pushed a commit to branch HDDS-7593
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/HDDS-7593 by this push:
new aa729597fb HDDS-10592. [hsync]Use Direct ByteBuffer in Output stream
lastChunkBuffer. (#6455)
aa729597fb is described below
commit aa729597fb34109e10d1166adf13f624615c1b82
Author: Ashish Kumar <[email protected]>
AuthorDate: Thu May 16 11:54:51 2024 +0530
HDDS-10592. [hsync]Use Direct ByteBuffer in Output stream lastChunkBuffer.
(#6455)
---
.../apache/hadoop/hdds/scm/storage/BlockOutputStream.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
index f29bf49038..c1f92c8337 100644
---
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
+++
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
@@ -52,6 +52,7 @@ import org.apache.hadoop.ozone.common.ChunkBuffer;
import org.apache.hadoop.ozone.common.OzoneChecksumException;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
+import org.apache.hadoop.util.DirectBufferPool;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
@@ -104,6 +105,7 @@ public class BlockOutputStream extends OutputStream {
private int chunkIndex;
private final AtomicLong chunkOffset = new AtomicLong();
private final BufferPool bufferPool;
+ private static final DirectBufferPool DIRECT_BUFFER_POOL = new
DirectBufferPool();
// The IOException will be set by response handling thread in case there is
an
// exception received in the response. If the exception is set, the next
// request will fail upfront.
@@ -183,9 +185,10 @@ public class BlockOutputStream extends OutputStream {
// tell DataNode I will send incremental chunk list
if (config.getIncrementalChunkList()) {
this.containerBlockData.addMetadata(INCREMENTAL_CHUNK_LIST_KV);
- this.lastChunkBuffer =
- ByteBuffer.allocate(config.getStreamBufferSize());
+ this.lastChunkBuffer =
DIRECT_BUFFER_POOL.getBuffer(config.getStreamBufferSize());
this.lastChunkOffset = 0;
+ } else {
+ this.lastChunkBuffer = null;
}
this.xceiverClient = xceiverClientManager.acquireClient(pipeline);
this.bufferPool = bufferPool;
@@ -701,10 +704,14 @@ public class BlockOutputStream extends OutputStream {
xceiverClient = null;
cleanup();
- if (bufferList != null) {
+ if (bufferList != null) {
bufferList.clear();
}
bufferList = null;
+ if (lastChunkBuffer != null) {
+ DIRECT_BUFFER_POOL.returnBuffer(lastChunkBuffer);
+ lastChunkBuffer = null;
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]