public class BatchProcess extends Object implements Callable<ParallelFileProcessingResult>
FileResourceCrawler
and FileResourceConsumer
s, and it can also
support a StatusReporter
and an Interrupter
.
This is designed to shutdown if a parser has timed out or if there is
an OutOfMemoryError. Consider using BatchProcessDriverCLI
as a daemon/watchdog that monitors and can restart this batch process;
Note that this classs redirects stderr to stdout so that it can communicate without interference with the parent process on stderr.
Modifier and Type | Class and Description |
---|---|
static class |
BatchProcess.BATCH_CONSTANTS |
Constructor and Description |
---|
BatchProcess(FileResourceCrawler fileResourceCrawler,
ConsumersManager consumersManager,
StatusReporter reporter,
Interrupter interrupter) |
Modifier and Type | Method and Description |
---|---|
ParallelFileProcessingResult |
call()
Runs main execution loop.
|
void |
setMaxAliveTimeSeconds(int maxAliveTimeSeconds)
The maximum amount of time that this process can be alive.
|
void |
setPauseOnEarlyTerminationMillis(long pauseOnEarlyTerminationMillis)
If there is an early termination via an interrupt or too many timed out consumers
or because a consumer or other Runnable threw a Throwable, pause this long
before interrupting the consumers and other threads.
|
void |
setTimeoutCheckPulseMillis(long timeoutCheckPulseMillis) |
void |
setTimeoutThresholdMillis(long timeoutThresholdMillis)
The amount of time allowed before a consumer should be timed out.
|
public BatchProcess(FileResourceCrawler fileResourceCrawler, ConsumersManager consumersManager, StatusReporter reporter, Interrupter interrupter)
public ParallelFileProcessingResult call() throws InterruptedException
Redirects stdout to stderr to keep clean communications over stdout with parent process
call
in interface Callable<ParallelFileProcessingResult>
InterruptedException
public void setPauseOnEarlyTerminationMillis(long pauseOnEarlyTerminationMillis)
Typically makes sense for this to be the same or slightly larger than timeoutThresholdMillis
pauseOnEarlyTerminationMillis
- how long to pause if there is an early terminationpublic void setTimeoutThresholdMillis(long timeoutThresholdMillis)
timeoutThresholdMillis
- threshold in milliseconds before declaring a consumer timed outpublic void setTimeoutCheckPulseMillis(long timeoutCheckPulseMillis)
public void setMaxAliveTimeSeconds(int maxAliveTimeSeconds)
maxAliveTimeSeconds
- maximum amount of time in seconds to remain aliveCopyright © 2007–2023 The Apache Software Foundation. All rights reserved.