Package org.apache.tika.pipes.core.async
Class AsyncProcessor
java.lang.Object
org.apache.tika.pipes.core.async.AsyncProcessor
- All Implemented Interfaces:
Closeable,AutoCloseable
This is the main class for handling async requests. This manages
AsyncClients and AsyncEmitters.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclose()voidfinished()intintTuples accepted but not yet picked up by a worker.longgetRestartCount(RestartReason reason) Restarts of this processor's own forks, summed over all servers, forreason.longbooleanReturns true if an application error has occurred during processing.static AsyncProcessorLoads an AsyncProcessor from a configuration file path.static AsyncProcessorload(Path tikaConfigPath, PipesIterator pipesIterator) Loads an AsyncProcessor from a configuration file path with a custom PipesIterator.booleanoffer(List<FetchEmitTuple> newFetchEmitTuples, long offerMs) booleanoffer(FetchEmitTuple t, long offerMs) voidsetStopOnlyOnFatal(boolean stopOnlyOnFatal) Long-running callers (tika-server) set true so one bad tuple (unknown fetcher, init failure) can't halt the shared workers; fatal errors always stop processing.
-
Method Details
-
load
Loads an AsyncProcessor from a configuration file path.This method pre-extracts plugins before loading, ensuring child processes don't race to extract the same plugins.
- Parameters:
tikaConfigPath- path to the tika-config.json file- Returns:
- a new AsyncProcessor instance
- Throws:
IOException- if reading config or plugin extraction failsTikaException- if configuration is invalid
-
load
public static AsyncProcessor load(Path tikaConfigPath, PipesIterator pipesIterator) throws TikaException, IOException Loads an AsyncProcessor from a configuration file path with a custom PipesIterator.This method pre-extracts plugins before loading, ensuring child processes don't race to extract the same plugins.
- Parameters:
tikaConfigPath- path to the tika-config.json filepipesIterator- optional custom pipes iterator (may be null)- Returns:
- a new AsyncProcessor instance
- Throws:
IOException- if reading config or plugin extraction failsTikaException- if configuration is invalid
-
offer
public boolean offer(List<FetchEmitTuple> newFetchEmitTuples, long offerMs) throws PipesException, InterruptedException - Throws:
PipesExceptionInterruptedException
-
getCapacity
public int getCapacity() -
getQueueDepth
public int getQueueDepth()Tuples accepted but not yet picked up by a worker. -
getRestartCount
Restarts of this processor's own forks, summed over all servers, forreason. -
setStopOnlyOnFatal
public void setStopOnlyOnFatal(boolean stopOnlyOnFatal) Long-running callers (tika-server) set true so one bad tuple (unknown fetcher, init failure) can't halt the shared workers; fatal errors always stop processing. -
offer
- Throws:
PipesExceptionInterruptedException
-
hasApplicationError
public boolean hasApplicationError()Returns true if an application error has occurred during processing. When this returns true, all workers have stopped or are stopping, and no new tuples can be offered.- Returns:
- true if an application error occurred
-
finished
- Throws:
InterruptedException
-
checkActive
- Throws:
InterruptedException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getTotalProcessed
public long getTotalProcessed()
-