An activity is required to have published the names of its inputs and outputs (defined in Perform documents) before returning from its constructor, using the mechanisms described shortly. This is necessary so that the engine can access this information and link activities together. The engine will access these names via each activity's getInputs() and getOutputs() methods.
To facilitate publishing the names of an activity's inputs and outputs two String arrays, mInputs and mOutputs, are defined in the Activity base class. These arrays are returned by the getInputs() and getOutputs() methods respectively. Each of these arrays is set to a String array of zero length when the activity is created. This means that if an activity does not have any inputs it needs do nothing to publicise the fact. Therefore to publish the inputs and outputs of an activity all that is necessary is to set mInputs and mOutputs to arrays containing the names, e.g. mInputs = new String[] {input};.
It is possible for the engine to determine the inputs and outputs for an activity without the names being published. This is achieved by validating incoming Perform documents using the Xerces PSVI parser. The code to do this is present (in SchemaMap.validate(InputSource) and in Activity.getInputs/getOutputs) but commented out. This was done because it was thought that it would be more useful to disable validation of incoming Perform documents for performance reasons than to extract inputs/outputs without developer assistance. The two are mutually exclusive because once activities are written without explicitly publishing their inputs and outputs then validation cannot be disabled.
If an activity does not publish any outputs it is given special treatment by the engine. The handler that is used to manage its execution is the uk.org.ogsadai.engine.RunAheadHandler (see below) rather than the standard uk.org.ogsadai.engine.SimpleHandler that is assigned to all other activities.
The RunAheadHandler is a threaded handler that continually loops, calling the processBlock method of its activity, until the activity's status changes to either COMPLETE, or ERROR. The output pipes constructed for the activity's outputs are instances of SynchronizedPipe. A SynchronizedPipe is created with a buffer size, N. If no objects are being extracted from the pipe by a consumer, then the producer activity can run ahead by N blocks before being forced to wait for the consumer. If the consumer extracts a single block then the producer can then produce N more blocks before being made to wait, it will have to wait until the number of blocks buffered falls back to N. This means there can be up to N - 1 blocks present in the pipe at any one time.
| Back: The Life-cycle of an Activity During Execution of a Perform Document | Up: How Activities Work | Next: Controlling Activity Execution Within the Engine |
| © International Business Machines Corporation, 2004. | © The University of Edinburgh, 2004. |