Package org.apache.hadoop.hdfs
Class DFSPacket
java.lang.Object
org.apache.hadoop.hdfs.DFSPacket
DFSPacket is used by DataStreamer and DFSOutputStream.
DFSOutputStream generates packets and then ask DatStreamer
to send them to datanodes.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDFSPacket(byte[] buf, int chunksPerPkt, long offsetInBlock, long seqno, int checksumSize, boolean lastPacketInBlock) Create a new packet. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTraceParent(org.apache.hadoop.tracing.Span span) Add a trace parent span for this packet.voidaddTraceParent(org.apache.hadoop.tracing.SpanContext ctx) org.apache.hadoop.tracing.SpangetSpan()org.apache.hadoop.tracing.SpanContext[]Get the trace parent spans for this packet.voidsetSpan(org.apache.hadoop.tracing.Span span) toString()voidwriteChecksum(byte[] inarray, int off, int len) Write checksums to this packetvoidwriteData(ByteBuffer inBuffer, int len) voidwriteTo(DataOutputStream stm) Write the full packet, including the header, to the given output stream.
-
Field Details
-
HEART_BEAT_SEQNO
public static final long HEART_BEAT_SEQNO- See Also:
-
-
Constructor Details
-
DFSPacket
public DFSPacket(byte[] buf, int chunksPerPkt, long offsetInBlock, long seqno, int checksumSize, boolean lastPacketInBlock) Create a new packet.- Parameters:
buf- the buffer storing data and checksumschunksPerPkt- maximum number of chunks per packet.offsetInBlock- offset in bytes into the HDFS block.seqno- the sequence number of this packetchecksumSize- the size of checksumlastPacketInBlock- if this is the last packet
-
-
Method Details
-
writeData
- Throws:
ClosedChannelException
-
writeChecksum
Write checksums to this packet- Parameters:
inarray- input array of checksumsoff- the offset of checksums to writelen- the length of checksums to write- Throws:
ClosedChannelException
-
writeTo
Write the full packet, including the header, to the given output stream.- Throws:
IOException
-
toString
-
addTraceParent
public void addTraceParent(org.apache.hadoop.tracing.Span span) Add a trace parent span for this packet.Trace parent spans for a packet are the trace spans responsible for adding data to that packet. We store them as an array of longs for efficiency.
Protected by the DFSOutputStream dataQueue lock.
-
addTraceParent
public void addTraceParent(org.apache.hadoop.tracing.SpanContext ctx) -
getTraceParents
public org.apache.hadoop.tracing.SpanContext[] getTraceParents()Get the trace parent spans for this packet.Will always be non-null.
Protected by the DFSOutputStream dataQueue lock.
-
setSpan
public void setSpan(org.apache.hadoop.tracing.Span span) -
getSpan
public org.apache.hadoop.tracing.Span getSpan()
-