Class TikaServerConfig

java.lang.Object
org.apache.tika.server.core.TikaServerConfig

public class TikaServerConfig extends Object
  • Field Details

    • DEFAULT_PORT

      public static final int DEFAULT_PORT
      See Also:
    • DEFAULT_HOST

      public static final String DEFAULT_HOST
      See Also:
    • PRESETS_ENV

      public static final String PRESETS_ENV
      Comma-separated catalog presets to activate, read at startup like --preset.
      See Also:
    • DEFAULT_MAX_REQUEST_SIZE_BYTES

      public static final long DEFAULT_MAX_REQUEST_SIZE_BYTES
      Default request-body cap: 1 GiB. Generous enough for essentially any single-document upload, bounded so one request cannot fill the temp directory. Operators who genuinely need larger bodies raise it explicitly; setting a negative value restores no limit.
      See Also:
    • DEFAULT_MAX_REQUEST_READ_MILLIS

      public static final long DEFAULT_MAX_REQUEST_READ_MILLIS
      Default time allowed to receive a request body: 5 minutes, so 1 GiB needs about 29 Mbit/s.
      See Also:
    • DEFAULT_MAX_RESPONSE_WRITE_MILLIS

      public static final long DEFAULT_MAX_RESPONSE_WRITE_MILLIS
      Default time allowed to write a response body: 5 minutes.
      See Also:
    • DEFAULT_IDLE_TIMEOUT_MILLIS

      public static final int DEFAULT_IDLE_TIMEOUT_MILLIS
      Default connector idle timeout: 2 minutes. Ends clients that stop sending or reading entirely.
      See Also:
    • DEFAULT_MAX_IN_FLIGHT_REQUEST_BYTES

      public static final long DEFAULT_MAX_IN_FLIGHT_REQUEST_BYTES
      Default cap on request-body bytes in flight: 0, meaning maxRequestSizeBytes x 2 x pipes clients.
      See Also:
    • DEFAULT_MAX_QUEUE_PAUSE_MILLIS

      public static final long DEFAULT_MAX_QUEUE_PAUSE_MILLIS
      How long a full /async queue blocks a POST before it is rejected with 429.
      See Also:
  • Constructor Details

    • TikaServerConfig

      public TikaServerConfig()
  • Method Details

    • load

      public static TikaServerConfig load()
      Config with only the defaults
    • load

      public static TikaServerConfig load(org.apache.commons.cli.CommandLine commandLine) throws IOException, TikaException
      Throws:
      IOException
      TikaException
    • getPort

      public int getPort()
    • setPort

      public void setPort(int port)
    • isAllowPipes

      public boolean isAllowPipes()
      Whether the pipes/fetch endpoints (pipes, async) may be enabled. Off by default; selecting one of those endpoints without this set causes the server to refuse to start.
    • setAllowPipes

      public void setAllowPipes(boolean allowPipes)
    • isAllowPerRequestConfig

      public boolean isAllowPerRequestConfig()
      Whether callers may supply per-request parser configuration (the /config endpoints and the multipart config part). Off by default; when off, such requests are rejected with 403.
    • setAllowPerRequestConfig

      public void setAllowPerRequestConfig(boolean allowPerRequestConfig)
    • isAllowHttp2

      public boolean isAllowHttp2()
      Whether to accept cleartext HTTP/2 (h2c) as well as HTTP/1.1; off by default. HTTP/2 requests get no maxResponseWriteMillis: its abort closes the connection, which would end every request multiplexed on it. HTTP/2 over TLS is not offered either way (tika-server ships no ALPN server provider).
    • setAllowHttp2

      public void setAllowHttp2(boolean allowHttp2)
    • getHost

      public String getHost()
    • setHost

      public void setHost(String host)
    • getRequestLogLevel

      public String getRequestLogLevel()
      Severity at which each request URI is logged. Empty (the default) disables request logging entirely; this does not change the log level of anything else.
    • setRequestLogLevel

      public void setRequestLogLevel(String level) throws TikaConfigException
      Throws:
      TikaConfigException
    • getCors

      public String getCors()
      Returns:
      the origin url for cors, can be "*"
    • setCors

      public void setCors(String cors)
    • hasConfigFile

      public boolean hasConfigFile()
    • getPresets

      public List<String> getPresets()
      Catalog presets named with --preset or in "TIKA_PRESETS", activated like "presets": {"name": true} in the config, over the config's own entry for the name.
    • getConfigPathWithPresets

      public Path getConfigPathWithPresets() throws IOException
      The config file with getPresets() folded in: the file itself when there are none, else a temp copy, for components that load their configuration from a path.
      Throws:
      IOException
    • getConfigPath

      public Path getConfigPath()
    • setConfigPath

      public void setConfigPath(String path)
      Set from the -c argument at load time; not a user-settable config key.
    • getMaxRequestSizeBytes

      public long getMaxRequestSizeBytes()
      Maximum request body in bytes; defaults to DEFAULT_MAX_REQUEST_SIZE_BYTES (1 GiB). tika-server spools uploads to disk, so this bounds how much one request can write. A negative value disables the limit (the pre-4.0 behavior); an over-limit request is rejected with 413.
    • setMaxRequestSizeBytes

      public void setMaxRequestSizeBytes(long maxRequestSizeBytes)
    • getMaxRequestReadMillis

      public long getMaxRequestReadMillis()
      How long, from the start of the request, reading its body may take; defaults to DEFAULT_MAX_REQUEST_READ_MILLIS (5 minutes). A request still sending after that is rejected with 408. A negative value disables the deadline; zero is rejected.
    • setMaxRequestReadMillis

      public void setMaxRequestReadMillis(long maxRequestReadMillis) throws TikaConfigException
      Throws:
      TikaConfigException
    • getMaxResponseWriteMillis

      public long getMaxResponseWriteMillis()
      How long, from when its status line is sent, writing a response body may take; defaults to DEFAULT_MAX_RESPONSE_WRITE_MILLIS (5 minutes). A response still being written after that is cut off. A negative value disables the deadline; zero is rejected.
    • setMaxResponseWriteMillis

      public void setMaxResponseWriteMillis(long maxResponseWriteMillis) throws TikaConfigException
      Throws:
      TikaConfigException
    • getIdleTimeoutMillis

      public int getIdleTimeoutMillis()
      How long a connection may go without any bytes moving before it is closed; defaults to DEFAULT_IDLE_TIMEOUT_MILLIS (2 minutes). Jetty applies it only to a read or write waiting on the wire, so a request waiting on its parse is never ended by it. Must be positive: Jetty treats zero as "use its own default", not "never".
    • setIdleTimeoutMillis

      public void setIdleTimeoutMillis(int idleTimeoutMillis) throws TikaConfigException
      Throws:
      TikaConfigException
    • getMaxInFlightRequestBytes

      public long getMaxInFlightRequestBytes()
      How many request-body bytes all requests together may hold at once, counted as they are read and freed when each response completes; a request that would go over gets 429. This bounds the temp disk and memory request bodies take, without letting a client that sends slowly hold capacity it has not used. 0 (the default) means maxRequestSizeBytes x 2 x the pipes clients; negative disables it; a positive value below maxRequestSizeBytes is rejected, as a request of that size could never succeed.
    • setMaxInFlightRequestBytes

      public void setMaxInFlightRequestBytes(long maxInFlightRequestBytes)
    • getMaxQueuePauseMillis

      public long getMaxQueuePauseMillis()
      How long a POST to /async blocks when the queue is full before it is rejected with 429 (Retry-After); defaults to DEFAULT_MAX_QUEUE_PAUSE_MILLIS.
    • setMaxQueuePauseMillis

      public void setMaxQueuePauseMillis(long maxQueuePauseMillis)
    • getTlsConfig

      public TlsConfig getTlsConfig()
      Null when the config has no tlsConfig block, i.e. plain HTTP.
    • tlsEnabled

      public boolean tlsEnabled()
    • setTlsConfig

      public void setTlsConfig(TlsConfig tlsConfig)
    • getMetricsPort

      public Integer getMetricsPort()
      Prometheus scrape port; null means metrics are off. The listener binds to getHost().
    • setMetricsPort

      public void setMetricsPort(Integer metricsPort)
    • getEndpoints

      public ArrayList<String> getEndpoints()
    • setEndpoints

      public void setEndpoints(ArrayList<String> endpoints)
    • getId

      public String getId()
      Identifier for this server, surfaced in the startup log. Defaults to a random UUID.
    • setId

      public void setId(String id)