Class PacketHeader
java.lang.Object
org.apache.hadoop.hdfs.protocol.datatransfer.PacketHeader
Header data for each packet that goes through the read/write pipelines.
Includes all of the information about the packet, excluding checksums and
actual data.
This data includes:
- the offset in bytes into the HDFS block of the data in this packet
- the sequence number of this packet in the pipeline
- whether or not this is the last packet in the pipeline
- the length of the data in this packet
- whether or not this packet should be synced by the DNs.
When serialized, this header is written out as a protocol buffer, preceded
by a 4-byte integer representing the full packet length, and a 2-byte short
representing the header length.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionPacketHeader(int packetLen, long offsetInBlock, long seqno, boolean lastPacketInBlock, int dataLen, boolean syncBlock) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbyte[]getBytes()intlongintlonggetSeqno()intbooleaninthashCode()booleanvoidputInBuffer(ByteBuffer buf) Write the header into the buffer.voidvoidreadFields(ByteBuffer buf) booleansanityCheck(long lastSeqNo) Perform a sanity check on the packet, returning true if it is sane.voidsetFieldsFromData(int packetLen, byte[] headerData) toString()voidwrite(DataOutputStream out)
-
Field Details
-
PKT_LENGTHS_LEN
public static final int PKT_LENGTHS_LEN- See Also:
-
PKT_MAX_HEADER_LEN
public static final int PKT_MAX_HEADER_LEN
-
-
Constructor Details
-
PacketHeader
public PacketHeader() -
PacketHeader
public PacketHeader(int packetLen, long offsetInBlock, long seqno, boolean lastPacketInBlock, int dataLen, boolean syncBlock)
-
-
Method Details
-
getDataLen
public int getDataLen() -
isLastPacketInBlock
public boolean isLastPacketInBlock() -
getSeqno
public long getSeqno() -
getOffsetInBlock
public long getOffsetInBlock() -
getPacketLen
public int getPacketLen() -
getSyncBlock
public boolean getSyncBlock() -
toString
-
setFieldsFromData
public void setFieldsFromData(int packetLen, byte[] headerData) throws org.apache.hadoop.thirdparty.protobuf.InvalidProtocolBufferException - Throws:
org.apache.hadoop.thirdparty.protobuf.InvalidProtocolBufferException
-
readFields
- Throws:
IOException
-
readFields
- Throws:
IOException
-
getSerializedSize
public int getSerializedSize()- Returns:
- the number of bytes necessary to write out this header, including the length-prefixing of the payload and header
-
putInBuffer
Write the header into the buffer. This requires that PKT_HEADER_LEN bytes are available. -
write
- Throws:
IOException
-
getBytes
public byte[] getBytes() -
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
-
hashCode
public int hashCode()
-