Package org.apache.tika.config
Class TimeoutLimits
java.lang.Object
org.apache.tika.config.TimeoutLimits
- All Implemented Interfaces:
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 (viaEmbeddedLimitReachedException) 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final long -
Constructor Summary
ConstructorsConstructorDescriptionNo-arg constructor for Jackson deserialization.TimeoutLimits(long totalTaskTimeoutMillis, long progressTimeoutMillis) Constructor with both timeout parameters. -
Method Summary
Modifier and TypeMethodDescriptionclampedTo(long maxMillis) Returns this instance if both timeouts are withinmaxMillis, otherwise a copy with each offending timeout reduced tomaxMillis.booleanstatic TimeoutLimitsget(ParseContext context) Helper method to get TimeoutLimits from ParseContext with defaults.longGets the maximum time in milliseconds between progress updates before the task is considered stalled.longGets the maximum wall-clock time in milliseconds for a parse task.inthashCode()voidCross-field check, so it cannot live in the setters (Jackson calls them in JSON field order).booleanWhether to throw when the task's total timeout is exhausted mid-parse, instead of skipping remaining embedded documents and returning content extracted so far.voidsetProgressTimeoutMillis(long progressTimeoutMillis) Sets the maximum time in milliseconds between progress updates before the task is considered stalled.voidsetThrowOnDeadline(boolean throwOnDeadline) voidsetTotalTaskTimeoutMillis(long totalTaskTimeoutMillis) Sets the maximum wall-clock time in milliseconds for a parse task.toString()
-
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 taskprogressTimeoutMillis- 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
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:
initializein interfaceInitializable- 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
Returns this instance if both timeouts are withinmaxMillis, otherwise a copy with each offending timeout reduced tomaxMillis. Used at trust boundaries to cap request-supplied limits at an operator-set maximum. -
get
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
-
equals
-
hashCode
public int hashCode()
-