org.apache.kafka.common.network
Class NetworkReceive

java.lang.Object
  extended by org.apache.kafka.common.network.NetworkReceive
All Implemented Interfaces:
Receive

public class NetworkReceive
extends java.lang.Object
implements Receive

A size delimited Receive that consists of a 4 byte network-ordered size N followed by N bytes of content


Constructor Summary
NetworkReceive(int source)
           
NetworkReceive(int source, java.nio.ByteBuffer buffer)
           
 
Method Summary
 boolean complete()
          Are we done receiving data?
 java.nio.ByteBuffer payload()
           
 long readFrom(java.nio.channels.ScatteringByteChannel channel)
          Read bytes into this receive from the given channel
 java.nio.ByteBuffer[] reify()
          Turn this receive into ByteBuffer instances, if possible (otherwise returns null).
 int source()
          The numeric id of the source from which we are receiving data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkReceive

public NetworkReceive(int source,
                      java.nio.ByteBuffer buffer)

NetworkReceive

public NetworkReceive(int source)
Method Detail

source

public int source()
Description copied from interface: Receive
The numeric id of the source from which we are receiving data.

Specified by:
source in interface Receive

complete

public boolean complete()
Description copied from interface: Receive
Are we done receiving data?

Specified by:
complete in interface Receive

reify

public java.nio.ByteBuffer[] reify()
Description copied from interface: Receive
Turn this receive into ByteBuffer instances, if possible (otherwise returns null).

Specified by:
reify in interface Receive

readFrom

public long readFrom(java.nio.channels.ScatteringByteChannel channel)
              throws java.io.IOException
Description copied from interface: Receive
Read bytes into this receive from the given channel

Specified by:
readFrom in interface Receive
Parameters:
channel - The channel to read from
Returns:
The number of bytes read
Throws:
java.io.IOException - If the reading fails

payload

public java.nio.ByteBuffer payload()