Class ServerProtocolIO

java.lang.Object
org.apache.tika.pipes.core.server.ServerProtocolIO

public class ServerProtocolIO extends Object
Centralizes protocol I/O operations shared by PipesServer and ConnectionHandler.

This class handles the pure protocol mechanics — serialization, framing, and ACK exchange. It does not make lifecycle decisions (exit vs. return, close connection vs. shut down JVM). Callers are responsible for catching exceptions and responding according to their own lifecycle policy.

  • Constructor Details

  • Method Details

    • writeFinished

      public void writeFinished(PipesResult pipesResult) throws IOException
      Writes a FINISHED message with the serialized result and waits for ACK.
      Throws:
      ShutDownReceivedException - if SHUT_DOWN is received instead of ACK
      IOException - on serialization or I/O errors
    • writeIntermediate

      public void writeIntermediate(Metadata metadata) throws IOException
      Writes an INTERMEDIATE_RESULT message with the serialized metadata and waits for ACK.
      Throws:
      ShutDownReceivedException - if SHUT_DOWN is received instead of ACK
      IOException - on serialization or I/O errors
    • writeCrash

      public void writeCrash(PipesMessageType crashType, Throwable t) throws IOException
      Writes a crash message (OOM, TIMEOUT, or UNSPECIFIED_CRASH) with the serialized stack trace and waits for ACK.
      Throws:
      IOException - on serialization, I/O, or unexpected ACK response
    • awaitAck

      public void awaitAck() throws IOException
      Reads a framed message and verifies it is an ACK.
      Throws:
      ShutDownReceivedException - if the message is SHUT_DOWN
      IOException - if the message is any other non-ACK type, or on I/O error
    • validateFetchEmitTuple

      public static void validateFetchEmitTuple(FetchEmitTuple fetchEmitTuple) throws TikaConfigException
      Validates that a FetchEmitTuple's configuration is consistent.

      If the tuple has an UnpackConfig with an emitter but ParseMode is not UNPACK, that's a configuration error.

      Throws:
      TikaConfigException