Class TimeoutLimits

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

public class TimeoutLimits extends Object implements Serializable
Configuration for the two-tier task timeout system.

  • totalTaskTimeoutMillis — bounds entire task wall-clock time (default: 3,600,000 ms = 1 hour)
  • progressTimeoutMillis — bounds time since the last progress update; catches infinite loops and hung processes (default: 60,000 ms = 1 minute)

Parsers that never call TikaProgressTracker.update() effectively get progressTimeoutMillis as their total timeout (same as the old single-timeout behavior). Parsers that do update progress can run up to totalTaskTimeoutMillis.

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
    • 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
    • getProcessTimeoutMillis

      public static long getProcessTimeoutMillis(ParseContext context, long defaultMs)
      Returns the per-process timeout to use for external process execution.

      This checks for TimeoutLimits in the ParseContext and returns max(0, progressTimeoutMillis - 100) to give the monitoring loop a small window to detect the timeout before the process itself times out. Falls back to defaultMs if no TimeoutLimits is found.

      Parameters:
      context - the ParseContext (may be null)
      defaultMs - default timeout if no TimeoutLimits in context
      Returns:
      timeout in milliseconds for external process execution
    • 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