Record Class PipesMessage
java.lang.Object
java.lang.Record
org.apache.tika.pipes.core.protocol.PipesMessage
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 —
LENbytes of payload data
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum payload size. -
Constructor Summary
ConstructorsConstructorDescriptionPipesMessage(PipesMessageType type, byte[] payload) Creates an instance of aPipesMessagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic PipesMessageack()static PipesMessagecrash(PipesMessageType crashType, byte[] payload) final booleanIndicates whether some other object is "equal to" this one.static PipesMessagefinished(byte[] payload) final inthashCode()Returns a hash code value for this object.static PipesMessageintermediateResult(byte[] payload) static PipesMessagenewRequest(byte[] payload) byte[]payload()Returns the value of thepayloadrecord component.static PipesMessageping()static PipesMessageread(DataInputStream in) Reads one framed message from the stream, enforcingMAX_PAYLOAD_BYTES.static PipesMessageread(DataInputStream in, int maxPayloadBytes) Reads one framed message from the stream, enforcing the given payload limit.static PipesMessageready()static PipesMessageshutDown()static PipesMessagestartupFailed(byte[] payload) final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.static PipesMessageworking()Creates a WORKING heartbeat.voidwrite(DataOutputStream out) Writes this message to the stream and flushes.
-
Field Details
-
MAX_PAYLOAD_BYTES
public static final int MAX_PAYLOAD_BYTESDefault maximum payload size. Override per-read viaread(DataInputStream, int).- See Also:
-
-
Constructor Details
-
PipesMessage
Creates an instance of aPipesMessagerecord class.- Parameters:
type- the value for thetyperecord componentpayload- the value for thepayloadrecord component
-
-
Method Details
-
read
Reads one framed message from the stream, enforcingMAX_PAYLOAD_BYTES.- Throws:
ProtocolDesyncException- if magic bytes don't matchEOFException- if the stream ends before a complete messagePayloadLimitExceededException- if the payload length exceedsMAX_PAYLOAD_BYTESIOException- on other I/O errors
-
read
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 matchEOFException- if the stream ends before a complete messagePayloadLimitExceededException- if the payload length exceedsmaxPayloadBytesIOException- on other I/O errors
-
write
Writes this message to the stream and flushes.- Throws:
IOException
-
ping
-
ack
-
ready
-
shutDown
-
working
Creates a WORKING heartbeat. Empty payload: the client treats WORKING as a pure liveness signal and never reads anything from it. -
newRequest
-
finished
-
intermediateResult
-
startupFailed
-
crash
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
payload
public byte[] payload()Returns the value of thepayloadrecord component.- Returns:
- the value of the
payloadrecord component
-