Class TimeoutLimits

java.lang.Object
org.apache.tika.config.TimeoutLimits
All Implemented Interfaces:
Serializable, Initializable

public class TimeoutLimits extends Object implements Serializable, Initializable
Configuration for the task timeout system.

  • totalTaskTimeoutMillis — bounds entire task wall-clock time, including any embedded documents it recurses into (default: 3,600,000 ms = 1 hour)
  • progressTimeoutMillis — bounds time since the last progress update; catches infinite loops and hung processes (default: 120,000 ms = 2 minutes)
  • throwOnDeadline — whether reaching the total timeout mid-parse throws (via EmbeddedLimitReachedException) instead of skipping remaining embedded documents and returning content extracted so far (default: false)

The first two compose with any per-parser timeout via ParseTimeout.budgetFor(long): a parser's own timeout is honored, but no operation gets more than what remains of totalTaskTimeoutMillis. A bounded external call reports its own progress, so a legitimately long call (e.g. a multi-minute external process) doesn't need progressTimeoutMillis raised to accommodate it — see ProcessUtils.execute(java.lang.ProcessBuilder, long, int, int).

Example configuration:

 {
   "parse-context": {
     "timeout-limits": {
       "totalTaskTimeoutMillis": 3600000,
       "progressTimeoutMillis": 60000
     }
   }
 }
 
Since:
Apache Tika 4.0
See Also:
  • Field Details

    • DEFAULT_TOTAL_TASK_TIMEOUT_MILLIS

      public static final long DEFAULT_TOTAL_TASK_TIMEOUT_MILLIS
      See Also:
    • DEFAULT_PROGRESS_TIMEOUT_MILLIS

      public static final long DEFAULT_PROGRESS_TIMEOUT_MILLIS
      See Also:
  • Constructor Details

    • TimeoutLimits

      public TimeoutLimits()
      No-arg constructor for Jackson deserialization.
    • TimeoutLimits

      public TimeoutLimits(long totalTaskTimeoutMillis, long progressTimeoutMillis)
      Constructor with both timeout parameters.
      Parameters:
      totalTaskTimeoutMillis - maximum wall-clock time for a task
      progressTimeoutMillis - maximum time between progress updates
  • Method Details

    • getTotalTaskTimeoutMillis

      public long getTotalTaskTimeoutMillis()
      Gets the maximum wall-clock time in milliseconds for a parse task.
      Returns:
      total task timeout in milliseconds
    • setTotalTaskTimeoutMillis

      public void setTotalTaskTimeoutMillis(long totalTaskTimeoutMillis)
      Sets the maximum wall-clock time in milliseconds for a parse task.
      Parameters:
      totalTaskTimeoutMillis - total task timeout in milliseconds
    • getProgressTimeoutMillis

      public long getProgressTimeoutMillis()
      Gets the maximum time in milliseconds between progress updates before the task is considered stalled.
      Returns:
      progress timeout in milliseconds
    • setProgressTimeoutMillis

      public void setProgressTimeoutMillis(long progressTimeoutMillis)
      Sets the maximum time in milliseconds between progress updates before the task is considered stalled.
      Parameters:
      progressTimeoutMillis - progress timeout in milliseconds
    • initialize

      public void initialize() throws TikaConfigException
      Cross-field check, so it cannot live in the setters (Jackson calls them in JSON field order). Fails config load rather than every task at runtime; ParseTimeout.start repeats the check as the backstop for programmatic construction.
      Specified by:
      initialize in interface Initializable
      Throws:
      TikaConfigException - if there is a problem with the configuration
    • isThrowOnDeadline

      public boolean isThrowOnDeadline()
      Whether to throw when the task's total timeout is exhausted mid-parse, instead of skipping remaining embedded documents and returning content extracted so far. Default: false.
    • setThrowOnDeadline

      public void setThrowOnDeadline(boolean throwOnDeadline)
    • clampedTo

      public TimeoutLimits clampedTo(long maxMillis)
      Returns this instance if both timeouts are within maxMillis, otherwise a copy with each offending timeout reduced to maxMillis. Used at trust boundaries to cap request-supplied limits at an operator-set maximum.
    • get

      public static TimeoutLimits get(ParseContext context)
      Helper method to get TimeoutLimits from ParseContext with defaults.
      Parameters:
      context - the ParseContext (may be null)
      Returns:
      the TimeoutLimits from context, or a new instance with defaults if not found
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object