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

  • 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, enforcing MAX_PAYLOAD_BYTES.
      Throws:
      ProtocolDesyncException - if magic bytes don't match
      EOFException - if the stream ends before a complete message
      PayloadLimitExceededException - if the payload length exceeds MAX_PAYLOAD_BYTES
      IOException - on other I/O errors
    • read

      public static PipesMessage read(DataInputStream in, int maxPayloadBytes) throws IOException
      Reads one framed message from the stream, enforcing the given payload limit. Use this overload when the caller has a per-connection limit from config.
      Parameters:
      maxPayloadBytes - maximum allowed payload size in bytes
      Throws:
      ProtocolDesyncException - if magic bytes don't match
      EOFException - if the stream ends before a complete message
      PayloadLimitExceededException - if the payload length exceeds maxPayloadBytes
      IOException - on other 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()
      Creates a WORKING heartbeat. Empty payload: the client treats WORKING as a pure liveness signal and never reads anything from it.
    • 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)
    • 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