Package com.github.ambry.network
Class BoundedByteBufferSend
- java.lang.Object
-
- com.github.ambry.utils.AbstractByteBufHolder<BoundedByteBufferSend>
-
- com.github.ambry.network.BoundedByteBufferSend
-
- All Implemented Interfaces:
Send
,io.netty.buffer.ByteBufHolder
,io.netty.util.ReferenceCounted
public class BoundedByteBufferSend extends com.github.ambry.utils.AbstractByteBufHolder<BoundedByteBufferSend> implements Send
A byte buffer version of Send to buffer the outgoing responses before sending. This is mainly used to optimize serialization of response objects on the request handler threads rather than the network threads.
-
-
Constructor Summary
Constructors Constructor Description BoundedByteBufferSend(Send request)
BoundedByteBufferSend(java.nio.ByteBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.netty.buffer.ByteBuf
content()
Return the data which is held by thisByteBufHolder
.BoundedByteBufferSend
duplicate()
boolean
isSendComplete()
Returns true if the all data has been writtenBoundedByteBufferSend
replace(io.netty.buffer.ByteBuf content)
long
sizeInBytes()
The total size in bytes that needs to be written to the channellong
writeTo(java.nio.channels.WritableByteChannel channel)
Writes content into the provided channel-
Methods inherited from class com.github.ambry.utils.AbstractByteBufHolder
copy, refCnt, release, release, retain, retain, retainedDuplicate, touch, touch
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
BoundedByteBufferSend
public BoundedByteBufferSend(Send request) throws java.io.IOException
- Throws:
java.io.IOException
-
BoundedByteBufferSend
public BoundedByteBufferSend(java.nio.ByteBuffer buffer)
-
-
Method Detail
-
writeTo
public long writeTo(java.nio.channels.WritableByteChannel channel) throws java.io.IOException
Description copied from interface:Send
Writes content into the provided channel
-
isSendComplete
public boolean isSendComplete()
Description copied from interface:Send
Returns true if the all data has been written- Specified by:
isSendComplete
in interfaceSend
- Returns:
- True if all the data has been written else false
-
sizeInBytes
public long sizeInBytes()
Description copied from interface:Send
The total size in bytes that needs to be written to the channel- Specified by:
sizeInBytes
in interfaceSend
- Returns:
- The size of the data in bytes to be written
-
content
public io.netty.buffer.ByteBuf content()
Description copied from interface:Send
Return the data which is held by thisByteBufHolder
.- Specified by:
content
in interfaceio.netty.buffer.ByteBufHolder
- Specified by:
content
in interfaceSend
- Specified by:
content
in classcom.github.ambry.utils.AbstractByteBufHolder<BoundedByteBufferSend>
-
replace
public BoundedByteBufferSend replace(io.netty.buffer.ByteBuf content)
- Specified by:
replace
in interfaceio.netty.buffer.ByteBufHolder
- Specified by:
replace
in classcom.github.ambry.utils.AbstractByteBufHolder<BoundedByteBufferSend>
-
duplicate
public BoundedByteBufferSend duplicate()
- Specified by:
duplicate
in interfaceio.netty.buffer.ByteBufHolder
- Overrides:
duplicate
in classcom.github.ambry.utils.AbstractByteBufHolder<BoundedByteBufferSend>
-
-