org.apache.kafka.common.network
Class ByteBufferSend

java.lang.Object
  extended by org.apache.kafka.common.network.ByteBufferSend
All Implemented Interfaces:
Send
Direct Known Subclasses:
NetworkSend

public class ByteBufferSend
extends java.lang.Object
implements Send

A send backed by an array of byte buffers


Field Summary
protected  java.nio.ByteBuffer[] buffers
           
 
Constructor Summary
ByteBufferSend(int destination, java.nio.ByteBuffer... buffers)
           
 
Method Summary
 boolean completed()
          Is this send complete?
 int destination()
          The numeric id for the destination of this send
 java.nio.ByteBuffer[] reify()
          An optional method to turn this send into an array of ByteBuffers if possible (otherwise returns null)
 int remaining()
          The number of bytes remaining to send
 int size()
           
 long writeTo(java.nio.channels.GatheringByteChannel channel)
          Write some as-yet unwritten bytes from this send to the provided channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffers

protected final java.nio.ByteBuffer[] buffers
Constructor Detail

ByteBufferSend

public ByteBufferSend(int destination,
                      java.nio.ByteBuffer... buffers)
Method Detail

destination

public int destination()
Description copied from interface: Send
The numeric id for the destination of this send

Specified by:
destination in interface Send

completed

public boolean completed()
Description copied from interface: Send
Is this send complete?

Specified by:
completed in interface Send

reify

public java.nio.ByteBuffer[] reify()
Description copied from interface: Send
An optional method to turn this send into an array of ByteBuffers if possible (otherwise returns null)

Specified by:
reify in interface Send

remaining

public int remaining()
Description copied from interface: Send
The number of bytes remaining to send

Specified by:
remaining in interface Send

size

public int size()

writeTo

public long writeTo(java.nio.channels.GatheringByteChannel channel)
             throws java.io.IOException
Description copied from interface: Send
Write some as-yet unwritten bytes from this send to the provided channel. It may take multiple calls for the send to be completely written

Specified by:
writeTo in interface Send
Parameters:
channel - The channel to write to
Returns:
The number of bytes written
Throws:
java.io.IOException - If the write fails