Class InboundChannelBuffer

java.lang.Object
org.elasticsearch.nio.InboundChannelBuffer
All Implemented Interfaces:
AutoCloseable

public final class InboundChannelBuffer extends Object implements AutoCloseable
This is a channel byte buffer composed internally of 16kb pages. When an entire message has been read and consumed, the release(long) method releases the bytes from the head of the buffer and closes the pages internally. If more space is needed at the end of the buffer ensureCapacity(long) can be called and the buffer will expand using the supplier provided.
  • Field Details

  • Constructor Details

    • InboundChannelBuffer

      public InboundChannelBuffer(IntFunction<Page> pageAllocator)
  • Method Details

    • allocatingInstance

      public static InboundChannelBuffer allocatingInstance()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • ensureCapacity

      public void ensureCapacity(long requiredCapacity)
    • release

      public void release(long bytesToRelease)
      This method will release bytes from the head of this buffer. If you release bytes past the current index the index is truncated to zero.
      Parameters:
      bytesToRelease - number of bytes to drop
    • sliceBuffersTo

      public ByteBuffer[] sliceBuffersTo(long to)
      This method will return an array of ByteBuffer representing the bytes from the beginning of this buffer up through the index argument that was passed. The buffers will be duplicates of the internal buffers, so any modifications to the markers Buffer.position(), Buffer.limit(), etc will not modify the this class.
      Parameters:
      to - the index to slice up to
      Returns:
      the byte buffers
    • sliceAndRetainPagesTo

      public Page[] sliceAndRetainPagesTo(long to)
      This method will return an array of Page representing the bytes from the beginning of this buffer up through the index argument that was passed. The pages and buffers will be duplicates of the internal components, so any modifications to the markers Buffer.position(), Buffer.limit(), etc will not modify the this class. Additionally, this will internally retain the underlying pages, so the pages returned by this method must be closed.
      Parameters:
      to - the index to slice up to
      Returns:
      the pages
    • sliceBuffersFrom

      public ByteBuffer[] sliceBuffersFrom(long from)
      This method will return an array of ByteBuffer representing the bytes from the index passed through the end of this buffer. The buffers will be duplicates of the internal buffers, so any modifications to the markers Buffer.position(), Buffer.limit(), etc will not modify the this class.
      Parameters:
      from - the index to slice from
      Returns:
      the byte buffers
    • incrementIndex

      public void incrementIndex(long delta)
    • getIndex

      public long getIndex()
    • getCapacity

      public long getCapacity()
    • getRemaining

      public long getRemaining()