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 . |
List<BlockingControlLink> |
controlLinksBlocking()
Get the control links that prevent this processor from running.
|
List<BlockingControlLink> |
controlLinksWaitingFor()
Get the control links that this processor will notify once it completes
running.
|
Activity |
createActivity(Profile profile)
Create an untyped activity for the processor.
|
Configuration |
createConfiguration(Profile profile)
Create a configuration for a processor.
|
Activity |
getActivity(Profile profile)
Get the activity bound to this processor in the given profile.
|
Configuration |
getActivityConfiguration(Profile profile)
Get the configuration of the activity bound to this processor in the
given profile.
|
ProcessorBinding |
getBinding(Profile profile)
Get the binding for this processor in the given profile.
|
Configuration |
getConfiguration(Profile profile)
Find the configuration of this processor in a profile.
|
List<Configuration> |
getConfigurations(Profile profile)
Find all configurations of this processor in a profile.
|
NamedSet<InputProcessorPort> |
getInputPorts()
Returns the
NamedSet of input ports. |
IterationStrategyStack |
getIterationStrategyStack()
Returns the
IterationStrategyStack or null if
there is no IterationStrategyStack . |
Workflow |
getNestedWorkflow(Profile profile)
Get the workflow nested within this processor.
|
NamedSet<OutputProcessorPort> |
getOutputPorts()
Returns the
NamedSet of output ports. |
Workflow |
getParent()
Returns the parent
Workflow of null if this
Processor is an orphan. |
Set<Processor> |
getPossibleDownStreamProcessors()
Get the collection of processors that can be downstream of this
processor.
|
Set<Processor> |
getPossibleUpStreamProcessors()
Get the collection of processors that can be upstream of this
processor.
|
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, getAnnotations, getName, getRelativeURI, getURI, hashCode, setName, toString
clone, cloneWorkflowBean, getTools, getUriTools
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
.public List<Configuration> getConfigurations(Profile profile)
profile
- The profile to search within.Scufl2Tools.configurationsFor(Configurable,Profile)
public Configuration getConfiguration(Profile profile)
profile
- The profile to search within.IllegalStateException
- If there are more than one configuration for the processor.IndexOutOfBoundsException
- If there aren't any configurations for the processor.Scufl2Tools.configurationFor(Configurable,Profile)
public Configuration createConfiguration(Profile profile)
profile
- The profile to create the configuration within.Scufl2Tools#createConfigurationFor(Configurable,Profile)
public Configuration getActivityConfiguration(Profile profile)
profile
- The profile that provides the binding and the configuration.Scufl2Tools.configurationForActivityBoundToProcessor(Processor,Profile)
public Activity createActivity(Profile profile)
profile
- The profile to create the activity within.Scufl2Tools.createActivityFromProcessor(Processor,Profile)
public Workflow getNestedWorkflow(Profile profile)
profile
- The profile that bound the nested workflow to this processor.Scufl2Tools.nestedWorkflowForProcessor(Processor,Profile)
public List<BlockingControlLink> controlLinksBlocking()
Scufl2Tools.controlLinksBlocking(Processor)
public List<BlockingControlLink> controlLinksWaitingFor()
Scufl2Tools.controlLinksWaitingFor(Processor)
public ProcessorBinding getBinding(Profile profile)
profile
- The profile to search within.IllegalStateException
- If there are more than one binding for the processor.IndexOutOfBoundsException
- If there aren't any bindings for the processor.Scufl2Tools.processorBindingForProcessor(Processor,Profile)
public Activity getActivity(Profile profile)
profile
- The profile to search within.IllegalStateException
- If there are more than one activity for the processor.IndexOutOfBoundsException
- If there aren't any activities for the processor.getBinding(Profile)
,
Scufl2Tools.processorBindingForProcessor(Processor,Profile)
public Set<Processor> getPossibleDownStreamProcessors()
Scufl2Tools.possibleDownStreamProcessors(Workflow,Processor)
public Set<Processor> getPossibleUpStreamProcessors()
Scufl2Tools.possibleUpStreamProcessors(Workflow,Processor)
Copyright © 2015–2016 The Apache Software Foundation. All rights reserved.