Record Class PipesMessage

java.lang.Object
java.lang.Record
org.apache.tika.pipes.core.protocol.PipesMessage

public record PipesMessage(PipesMessageType type, byte[] payload) extends Record
Uniform framed message for the PipesClient/PipesServer IPC protocol.

Wire format: [MAGIC 0x54 0x4B][TYPE 1B][LEN 4B][PAYLOAD]

  • MAGIC — two bytes 0x54 0x4B ("TK") for desync detection
  • TYPE — one byte identifying the PipesMessageType
  • LEN — four-byte big-endian payload length (0 for empty payloads)
  • PAYLOAD — LEN bytes of payload data
  • Field Details

    • MAX_PAYLOAD_BYTES

      public static final int MAX_PAYLOAD_BYTES
      Maximum payload size: 100 MB (same as old MAX_FETCH_EMIT_TUPLE_BYTES).
      See Also:
  • Constructor Details

    • PipesMessage

      public PipesMessage(PipesMessageType type, byte[] payload)
      Creates an instance of a PipesMessage record class.
      Parameters:
      type - the value for the type record component
      payload - the value for the payload record component
  • Method Details

    • read

      public static PipesMessage read(DataInputStream in) throws IOException
      Reads one framed message from the stream.
      Throws:
      ProtocolDesyncException - if magic bytes don't match
      EOFException - if the stream ends before a complete message
      IOException - on payload size violations or I/O errors
    • write

      public void write(DataOutputStream out) throws IOException
      Writes this message to the stream and flushes.
      Throws:
      IOException
    • ping

      public static PipesMessage ping()
    • ack

      public static PipesMessage ack()
    • ready

      public static PipesMessage ready()
    • shutDown

      public static PipesMessage shutDown()
    • working

      public static PipesMessage working(long lastProgressMillis)
      Creates a WORKING heartbeat with the last-progress timestamp in the payload.
      Parameters:
      lastProgressMillis - epoch millis of the last progress update
    • newRequest

      public static PipesMessage newRequest(byte[] payload)
    • finished

      public static PipesMessage finished(byte[] payload)
    • intermediateResult

      public static PipesMessage intermediateResult(byte[] payload)
    • startupFailed

      public static PipesMessage startupFailed(byte[] payload)
    • crash

      public static PipesMessage crash(PipesMessageType crashType, byte[] payload)
    • lastProgressMillis

      public long lastProgressMillis()
      Extracts the last-progress timestamp from a WORKING message payload.
      Returns:
      epoch millis of the last progress update reported by the server
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public PipesMessageType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • payload

      public byte[] payload()
      Returns the value of the payload record component.
      Returns:
      the value of the payload record component