Class 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.
    • 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 this ByteBufHolder.
      BoundedByteBufferSend duplicate()  
      boolean isSendComplete()
      Returns true if the all data has been written
      BoundedByteBufferSend replace​(io.netty.buffer.ByteBuf content)  
      long sizeInBytes()
      The total size in bytes that needs to be written to the channel
      long 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
      • Methods inherited from interface io.netty.buffer.ByteBufHolder

        copy, retain, retain, retainedDuplicate, touch, touch
      • Methods inherited from interface io.netty.util.ReferenceCounted

        refCnt, release, release
      • Methods inherited from interface com.github.ambry.network.Send

        writeTo
    • 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
        Specified by:
        writeTo in interface Send
        Parameters:
        channel - The channel into which data needs to be written to
        Returns:
        Number of bytes written
        Throws:
        java.io.IOException
      • isSendComplete

        public boolean isSendComplete()
        Description copied from interface: Send
        Returns true if the all data has been written
        Specified by:
        isSendComplete in interface Send
        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 interface Send
        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 this ByteBufHolder.
        Specified by:
        content in interface io.netty.buffer.ByteBufHolder
        Specified by:
        content in interface Send
        Specified by:
        content in class com.github.ambry.utils.AbstractByteBufHolder<BoundedByteBufferSend>
      • replace

        public BoundedByteBufferSend replace​(io.netty.buffer.ByteBuf content)
        Specified by:
        replace in interface io.netty.buffer.ByteBufHolder
        Specified by:
        replace in class com.github.ambry.utils.AbstractByteBufHolder<BoundedByteBufferSend>
      • duplicate

        public BoundedByteBufferSend duplicate()
        Specified by:
        duplicate in interface io.netty.buffer.ByteBufHolder
        Overrides:
        duplicate in class com.github.ambry.utils.AbstractByteBufHolder<BoundedByteBufferSend>