public class Processor extends AbstractNamed implements Child<Workflow>, Ported, Configurable
Processor
is a Workflow
component that controls the
invocation of activities.
When a Workflow
is run, a particular Activity
will be
specified as bound to the Processor
by the Profile
.
A Processor
contains an IterationStrategyStack
to
describe iterations, and may have input
and
output
ports. The Processor
can be
configured with a Configuration
within a Profile
to specify
execution details such as retries or parallel jobs.
The getType()
of a Processor is normally fixed to the value given by
. The configuration of a processor should
correspondingly be of the type given by the constant .
The default (implied) configuration of a Processor is as of Taverna 3.0 alpha 2:
{ "retry": { "maxRetries": 0, "initialDelay": 1000, "maxDelay": 5000, "backoffFactor": 1.0 }, "parallelize": { "maxJobs": 1 }These defaults mean that the processor would not retry the operation, and would only perform one concurrent invocation within a given workflow run.
You can provide a partial configuration, e.g. to activate 5 retries using the
default initialDelay, add a Configuration
of this Processor
to the Profile
with the keys:
{ "retry": { "maxRetries": 5 } }
Additionally, do..while-style looping can be configured using the key "loop":
{ "loop": { "comparePort": "outputB", "comparison": "EqualTo", "compareValue": "15", "delay": 0.5, "runFirst": true, "isFeedBack": false, "conditionActivity": "looping-loop" } }
Note that this is different from looping over incoming values, which happens
according to the getIterationStrategyStack()
..
if "isFeedBack": true
, then outputs from the processor will on
repeated invocations replace the original input values where the port names
match. Note that the processor ports should be connected in the containing
workflow.
"runFirst": true
means that the activity is called at least
once, which is generally needed to get a port value to compare.
The "conditionActivity"
indicates the name of an
Activity
within the Profile
, here called "looping-loop". This
activity is invoked with the current processor output values as input ports,
and if its output port "loop" contains the string value "true", then the
processor is invoked again. If the condition output port matches a processor
input port, then the returned values are used instead of the original
processor inputs. The conditionActivity is then repeated on the new output
values, repeated until "loop" no longer is "true".
As of Taverna 3 alpha 2, the "conditionActivity" is called directly without consideration of the other parameters. This typically contains a beanshell script generated from the above parameters and performs the actual comparisons.
FIXME: This conditionActivity currently has to be regenerated when the other parameters have changed. This now happens within the Taverna 3 workbench user interface when configuring looping. The ideal SCUFL2 behaviour would be to EITHER provide a custom conditionActivity OR the parameters.
AbstractCloneable.Cloning, AbstractCloneable.CopyVisitor
Modifier and Type | Field and Description |
---|---|
static URI |
CONFIG_TYPE |
static URI |
PROCESSOR_TYPE |
INVALID_NAME
Constructor and Description |
---|
Processor()
Constructs a
Processor with a random UUID as the name and no parent
Workflow . |
Processor(Workflow parent,
String name)
Constructs a
Processor with the specified parent Workflow and name. |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Visitor visitor)
Accepts a
Visitor to this WorkflowBean . |
NamedSet<InputProcessorPort> |
getInputPorts()
Returns the
NamedSet of input ports. |
IterationStrategyStack |
getIterationStrategyStack()
Returns the
IterationStrategyStack or null if there is no
IterationStrategyStack . |
NamedSet<OutputProcessorPort> |
getOutputPorts()
Returns the
NamedSet of output ports. |
Workflow |
getParent()
Returns the parent
Workflow of null if this Processor is an orphan. |
URI |
getType()
Returns the type of the
WorkflowBean . |
void |
setInputPorts(Set<InputProcessorPort> inputPorts)
Sets the input ports.
|
void |
setIterationStrategyStack(IterationStrategyStack iterationStrategyStack)
Sets the
IterationStrategyStack . |
void |
setOutputPorts(Set<OutputProcessorPort> outputPorts)
Sets the output ports.
|
void |
setParent(Workflow parent)
Sets the parent of this workflow bean.
|
void |
setType(URI type)
Sets the type of the
WorkflowBean . |
cloneInto, compareTo, equals, getName, hashCode, setName, toString
clone, cloneWorkflowBean
finalize, getClass, notify, notifyAll, wait, wait, wait
clone
public static final URI PROCESSOR_TYPE
public static final URI CONFIG_TYPE
public Processor()
Processor
with a random UUID as the name and no parent
Workflow
.public boolean accept(Visitor visitor)
WorkflowBean
Visitor
to this WorkflowBean
.accept
in interface WorkflowBean
visitor
- the Visitor
to accepttrue
if this WorkflowBeans
children should be visited.public NamedSet<InputProcessorPort> getInputPorts()
NamedSet
of input ports.
Returns an empty NamedSet
if there are no input ports.getInputPorts
in interface Ported
public IterationStrategyStack getIterationStrategyStack()
IterationStrategyStack
or null
if there is no
IterationStrategyStack
.IterationStrategyStack
or null
if there is no
IterationStrategyStack
public NamedSet<OutputProcessorPort> getOutputPorts()
NamedSet
of output ports.
Returns an empty NamedSet
if there are no output ports.getOutputPorts
in interface Ported
public Workflow getParent()
Workflow
of null if this Processor
is an orphan.public void setInputPorts(Set<InputProcessorPort> inputPorts)
public void setIterationStrategyStack(IterationStrategyStack iterationStrategyStack)
IterationStrategyStack
.iterationStrategyStack
- the IterationStrategyStack
. Can be null
public void setOutputPorts(Set<OutputProcessorPort> outputPorts)
public void setParent(Workflow parent)
Child
Setting the parent would normally also add the object to the relevant collection in the parent if it does not already exist there.
If the child has an existing, object-identity different parent, the child will first be removed from the parent collection if it exists there.
Note:If the child is Named
the parent collection will be a
NamedSet
. This implicit insertion would overwrite any conflicting sibling with the
same Named.getName()
- to avoid this, add the child to the parent collection by using
NamedSet.addWithUniqueName(Named)
before setting the parent.
public URI getType()
Typed
WorkflowBean
.public void setType(URI type)
Typed
WorkflowBean
.Copyright © 2014 myGrid. All rights reserved.