4 * The {@code PollableTaskI} interface should be implemented by classes
5 * representing a background task that must be polled repeatedly to check for
6 * completion. Those are typically jobs that run on a remote host and need to be
7 * periodically checked for status updates.
9 * The life-cycle of a task consist of calling {@link #start} method once to
10 * start the process, followed by repeated calls to {@link #poll} that should
11 * check for execution status and finally {@link #done} method that finalizes
14 * The instances can be started with {@link PollingTaskExecutor} which manages
15 * start up, polling and finalization of the task using a thread executor.
20 public interface PollableTaskI
23 * Called by the executor once and the beginning to start the task. May throw
24 * any exception, in such case the task will be interrupted.
28 void start() throws Exception;
31 * Called repeatedly by the executor to check for task completion. The
32 * implementation should check the remote host for job status updates and
33 * return true when the task is finished. If any exception is thrown, the task
36 * @return whether the task is done
39 boolean poll() throws Exception;
42 * @return whether the task is done
47 * Called once the task is done running ({@link #poll} returned true) to
48 * finalize the task and collect the results.