Package org.jvnet.hudson.reactor
Class Reactor
- java.lang.Object
-
- org.jvnet.hudson.reactor.Reactor
-
- All Implemented Interfaces:
Iterable<org.jvnet.hudson.reactor.Reactor.Node>
public class Reactor extends Object implements Iterable<org.jvnet.hudson.reactor.Reactor.Node>
Executes a set ofTasks that dependend on each other.As a
Set, this object represents a read-only view of allTasks.- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description Reactor(Collection<? extends TaskBuilder> builders)Reactor(TaskBuilder... builders)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Task t)Adds a newTaskto the reactor.voidaddAll(Iterable<? extends Task> _tasks)Adds a set of tasks to the reactor.voidexecute(Executor e)voidexecute(Executor e, ReactorListener listener)Executes this initialization session with the given executor.Iterator<org.jvnet.hudson.reactor.Reactor.Node>iterator()protected voidrunTask(Task t)Can be overridden by the subtype to enclose the entire execution of the task.intsize()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
Reactor
public Reactor(Collection<? extends TaskBuilder> builders) throws IOException
- Throws:
IOException
-
Reactor
public Reactor(TaskBuilder... builders) throws IOException
- Throws:
IOException
-
-
Method Detail
-
iterator
public Iterator<org.jvnet.hudson.reactor.Reactor.Node> iterator()
-
size
public int size()
-
execute
public void execute(Executor e) throws InterruptedException, ReactorException
- Throws:
InterruptedExceptionReactorException
-
add
public void add(Task t)
Adds a newTaskto the reactor.This can be even invoked during execution.
-
addAll
public void addAll(Iterable<? extends Task> _tasks)
Adds a set of tasks to the reactor.When adding a series of related tasks, it's often necessary to add them as a bulk, or else the newly added task can start executing before its dependencies are added.
-
execute
public void execute(Executor e, ReactorListener listener) throws InterruptedException, ReactorException
Executes this initialization session with the given executor.- Parameters:
e- Used for executingTasks.listener- Receives callbacks during the execution.- Throws:
InterruptedException- if this thread is interrupted while waiting for the execution of tasks to complete.ReactorException- if one of the tasks failed by throwing an exception. The caller is responsible for canceling existingTasks that are in progress inExecutor, if that's desired.
-
-