Class PollingBlockingTask
- java.lang.Object
-
- com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
-
- com.inductiveautomation.ignition.common.execution.PollingBlockingTask
-
- Direct Known Subclasses:
PerspectivePollingBlockingTask
public class PollingBlockingTask extends AbstractLifecycle
Scaffolding for managing the execution of a blocking task that may need to poll or be executed on-demand.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPollingBlockingTask.State
-
Constructor Summary
Constructors Constructor Description PollingBlockingTask(java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.ExecutorService executor, java.lang.Runnable task, long rate, java.util.concurrent.TimeUnit rateTimeUnit, java.lang.String diagnosticId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected longgetInitialRate()Default implementation returns the rate from the constructor, but provides a place for subclasses to re-define the rate on startup if necessary.protected voidonShutdown()protected voidonStartup()voidsetRate(long rate, java.util.concurrent.TimeUnit unit)voidsubmitIfIdle()Submits the task immediately if currently idle or scheduled.-
Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
-
-
-
-
Field Detail
-
LOG
protected static final LoggerEx LOG
-
-
Constructor Detail
-
PollingBlockingTask
public PollingBlockingTask(java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.ExecutorService executor, java.lang.Runnable task, long rate, java.util.concurrent.TimeUnit rateTimeUnit, java.lang.String diagnosticId)- Parameters:
scheduler- No blocking work will be done on this schedulerexecutor- Blocking work will be done on this executortask- The task to execute, blocking is acceptablerate- If positive, the task will be executed once on startup, and then repeatedly with this amount of time as a delay between executions. If zero or less, will be executed once on startup, and again wheneversubmitIfIdle()is called.rateTimeUnit- Time unit for the rate.diagnosticId- Will be set during task execution using MDC as "task-id" key
-
-
Method Detail
-
submitIfIdle
public void submitIfIdle()
Submits the task immediately if currently idle or scheduled.
-
getInitialRate
protected long getInitialRate()
Default implementation returns the rate from the constructor, but provides a place for subclasses to re-define the rate on startup if necessary.
-
onStartup
protected void onStartup()
- Specified by:
onStartupin classAbstractLifecycle
-
onShutdown
protected void onShutdown()
- Specified by:
onShutdownin classAbstractLifecycle
-
setRate
public void setRate(long rate, java.util.concurrent.TimeUnit unit)
-
-