Class DFSPacket

java.lang.Object
org.apache.hadoop.hdfs.DFSPacket

@Private public class DFSPacket extends Object
DFSPacket is used by DataStreamer and DFSOutputStream. DFSOutputStream generates packets and then ask DatStreamer to send them to datanodes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DFSPacket(byte[] buf, int chunksPerPkt, long offsetInBlock, long seqno, int checksumSize, boolean lastPacketInBlock)
    Create a new packet.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addTraceParent(org.apache.hadoop.tracing.Span span)
    Add a trace parent span for this packet.
    void
    addTraceParent(org.apache.hadoop.tracing.SpanContext ctx)
     
    org.apache.hadoop.tracing.Span
     
    org.apache.hadoop.tracing.SpanContext[]
    Get the trace parent spans for this packet.
    void
    setSpan(org.apache.hadoop.tracing.Span span)
     
     
    void
    writeChecksum(byte[] inarray, int off, int len)
    Write checksums to this packet
    void
    writeData(ByteBuffer inBuffer, int len)
     
    void
    Write the full packet, including the header, to the given output stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • 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 checksums
      chunksPerPkt - maximum number of chunks per packet.
      offsetInBlock - offset in bytes into the HDFS block.
      seqno - the sequence number of this packet
      checksumSize - the size of checksum
      lastPacketInBlock - if this is the last packet
  • Method Details

    • writeData

      public void writeData(ByteBuffer inBuffer, int len) throws ClosedChannelException
      Throws:
      ClosedChannelException
    • writeChecksum

      public void writeChecksum(byte[] inarray, int off, int len) throws ClosedChannelException
      Write checksums to this packet
      Parameters:
      inarray - input array of checksums
      off - the offset of checksums to write
      len - the length of checksums to write
      Throws:
      ClosedChannelException
    • writeTo

      public void writeTo(DataOutputStream stm) throws IOException
      Write the full packet, including the header, to the given output stream.
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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()