public class ScheduledTask extends BasicTask<java.lang.Object>
Note that some termination logic, including BasicTask.addListener(Runnable, java.util.concurrent.Executor)
,
is not precisely defined.
Modifier and Type | Class and Description |
---|---|
static class |
ScheduledTask.Builder |
BasicTask.SubmissionErrorCatchingExecutor, BasicTask.TaskFinalizer
TaskInternal.TaskCancellationMode
description, displayName, NO_OP, WARN_IF_NOT_RUN
Constructor and Description |
---|
ScheduledTask(java.util.concurrent.Callable<Task<?>> taskFactory) |
ScheduledTask(java.util.Map<?,?> flags,
java.util.concurrent.Callable<Task<?>> taskFactory) |
ScheduledTask(java.util.Map<?,?> flags,
Task<?> task)
Deprecated.
since 0.11.0; instead use
ScheduledTask(Map, Callable) . If using this method,
the task will be executed only once (ignoring any additional config such as "period").
This is because the task object is reused for the second execution, but it is
already "done" so does not re-execute. |
ScheduledTask(Task<?> task)
Deprecated.
since 0.11.0; instead use
ScheduledTask(Callable) . |
Modifier and Type | Method and Description |
---|---|
void |
blockUntilEnded()
Causes calling thread to block until the task is ended.
|
void |
blockUntilFirstScheduleStarted() |
boolean |
blockUntilNextRunFinished(Duration timeout)
Internal method used to allow callers to wait for underlying tasks to finished in the case of cancellation.
|
static ScheduledTask.Builder |
builder(java.util.concurrent.Callable<Task<?>> val) |
ScheduledTask |
cancelOnException(boolean cancel) |
ScheduledTask |
delay(Duration d) |
ScheduledTask |
delay(long val) |
java.lang.Object |
get() |
java.util.concurrent.ScheduledFuture<?> |
getNextScheduled() |
int |
getRunCount() |
java.util.concurrent.Callable<Task<?>> |
getTaskFactory() |
boolean |
isDone(boolean andTaskNoLongerRunning)
As
Task.isDone() , identical if the argument is false, but by supplying true
this will also check Task.getEndTimeUtc() if Task.isBegun()
to guarantee that the task is no longer running. |
ScheduledTask |
maxIterations(int val) |
Task<?> |
newTask() |
ScheduledTask |
period(Duration d) |
ScheduledTask |
period(long val) |
addListener, applyTagModifier, asTask, blockUntilEnded, blockUntilStarted, blockUntilStarted, cancel, cancel, cancel, equals, get, get, getBlockingDetails, getBlockingTask, getDescription, getDisplayName, getEndTimeUtc, getExtraStatusText, getId, getInternalFuture, getJob, getListeners, getMutableTags, getProxyTarget, getQueuedTimeUtc, getStartTimeUtc, getStatusDetail, getStatusSummary, getSubmittedByTask, getSubmittedByTaskId, getSubmitTimeUtc, getTags, getThread, getUnchecked, getUnchecked, hashCode, ignoreIfNotRun, initInternalFuture, isBegun, isCancelled, isDone, isError, isQueued, isQueuedAndNotSubmitted, isQueuedOrSubmitted, isSubmitted, markQueued, resetBlockingDetails, resetBlockingTask, runListeners, setBlockingDetails, setBlockingTask, setEndTimeUtc, setExtraStatusText, setFinalizer, setJob, setStartTimeUtc, setSubmittedByTask, setSubmittedByTask, setSubmitTimeUtc, setThread, toString, uncancel
public ScheduledTask(java.util.concurrent.Callable<Task<?>> taskFactory)
@Deprecated public ScheduledTask(Task<?> task)
ScheduledTask(Callable)
.#ScheduledTask(Map, Task)}
@Deprecated public ScheduledTask(java.util.Map<?,?> flags, Task<?> task)
ScheduledTask(Map, Callable)
. If using this method,
the task will be executed only once (ignoring any additional config such as "period").
This is because the task object is reused for the second execution, but it is
already "done" so does not re-execute.https://issues.apache.org/jira/browse/BROOKLYN-446}
public ScheduledTask(java.util.Map<?,?> flags, java.util.concurrent.Callable<Task<?>> taskFactory)
public int getRunCount()
public java.util.concurrent.ScheduledFuture<?> getNextScheduled()
public static ScheduledTask.Builder builder(java.util.concurrent.Callable<Task<?>> val)
public ScheduledTask delay(Duration d)
public ScheduledTask delay(long val)
public ScheduledTask period(Duration d)
public ScheduledTask period(long val)
public ScheduledTask maxIterations(int val)
public ScheduledTask cancelOnException(boolean cancel)
public java.util.concurrent.Callable<Task<?>> getTaskFactory()
public Task<?> newTask()
public boolean isDone(boolean andTaskNoLongerRunning)
Task
Task.isDone()
, identical if the argument is false, but by supplying true
this will also check Task.getEndTimeUtc()
if Task.isBegun()
to guarantee that the task is no longer running.
Task.isDone()
will return true for cancelled tasks even if they are still running.
In a task hierarchy, the threads of tasks submitted by this may still be ongoing.
To determine their completion, inspect the ExecutionManager
.
public void blockUntilFirstScheduleStarted()
public void blockUntilEnded()
Task
Either normally or by cancellation or error, but without throwing error on cancellation or error. (Errors are logged at debug.)
blockUntilEnded
in interface Task<java.lang.Object>
blockUntilEnded
in class BasicTask<java.lang.Object>
public java.lang.Object get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
public boolean blockUntilNextRunFinished(Duration timeout)
timeout
- maximum time to wait