org.apache.hadoop.hdfs.protocol
Class DataTransferProtocol.PacketHeader

java.lang.Object
  extended by org.apache.hadoop.hdfs.protocol.DataTransferProtocol.PacketHeader
All Implemented Interfaces:
org.apache.hadoop.io.Writable
Enclosing interface:
DataTransferProtocol

public static class DataTransferProtocol.PacketHeader
extends Object
implements org.apache.hadoop.io.Writable

Header data for each packet that goes through the read/write pipelines.


Field Summary
static int PKT_HEADER_LEN
          Header size for a packet
 
Constructor Summary
DataTransferProtocol.PacketHeader()
           
DataTransferProtocol.PacketHeader(int packetLen, long offsetInBlock, long seqno, boolean lastPacketInBlock, int dataLen)
           
 
Method Summary
 boolean equals(Object o)
           
 int getDataLen()
           
 long getOffsetInBlock()
           
 int getPacketLen()
           
 long getSeqno()
           
 int hashCode()
           
 boolean isLastPacketInBlock()
           
 void putInBuffer(ByteBuffer buf)
          Write the header into the buffer.
 void readFields(ByteBuffer buf)
           
 void readFields(DataInput in)
           
 boolean sanityCheck(long lastSeqNo)
          Perform a sanity check on the packet, returning true if it is sane.
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PKT_HEADER_LEN

public static final int PKT_HEADER_LEN
Header size for a packet

See Also:
Constant Field Values
Constructor Detail

DataTransferProtocol.PacketHeader

public DataTransferProtocol.PacketHeader()

DataTransferProtocol.PacketHeader

public DataTransferProtocol.PacketHeader(int packetLen,
                                         long offsetInBlock,
                                         long seqno,
                                         boolean lastPacketInBlock,
                                         int dataLen)
Method Detail

getDataLen

public int getDataLen()

isLastPacketInBlock

public boolean isLastPacketInBlock()

getSeqno

public long getSeqno()

getOffsetInBlock

public long getOffsetInBlock()

getPacketLen

public int getPacketLen()

toString

public String toString()
Overrides:
toString in class Object

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

readFields

public void readFields(ByteBuffer buf)
                throws IOException
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

putInBuffer

public void putInBuffer(ByteBuffer buf)
Write the header into the buffer. This requires that PKT_HEADER_LEN bytes are available.


sanityCheck

public boolean sanityCheck(long lastSeqNo)
Perform a sanity check on the packet, returning true if it is sane.

Parameters:
lastSeqNo - the previous sequence number received - we expect the current sequence number to be larger by 1.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2009 The Apache Software Foundation