Skip to main content
Jump to: navigation, search

Difference between revisions of "SMILA/Documentation/WorkerAndWorkflows"

(All workflows)
(Workers and Workflows)
Line 7: Line 7:
 
== Workers ==
 
== Workers ==
  
=== Worker Definition ===
+
=== Worker definition ===
  
The worker definition is provided with software. It defines default workers provided and must not be changed by the user.
+
A worker definition describes the input and output behavior as well as the required parameters of a worker. The definitions are provided with the software and must be known in the system before a worker can be added as an action to a workflow. They cannot be added or edited at runtime and are therefore not intended to be manipulated by the user.  
  
Worker definitions cannot be added at runtime. They describe worker behaviour as needed by job manager to generate appropriate tasks and data objects.
+
Typically, a worker definition consists of the following parts:
  
Required input and output data is described in terms of bucket types as defined before. Additional string parameters may be needed and must be defined when used in workflow. Values for these parameters must be added as properties to the tasks created for this worker. (I.e. the names of all input and output slots have to be explicitly linked to names of existing buckets by the workflow referencing the workers as actions, see below. The workflow doesn't not need to define output slots which are marked as <tt>optional</tt>.)  
+
# A '''parameter section''' declaring the workers's mandatory string parameters: These parameters must be set either in the workflow or in the job definition when using this worker.
 +
# An '''input slot''' describing the type of input objects that the worker is able to consume: All input slots must be connected to buckets in a workflow definition that wants to use this worker.
 +
# An '''output slot''' describing the type of output objects that the worker generates: All output slots must be connected to buckets in a workflow definition that wants to use this worker. An exception to this rule are output slots that were marked as optional in the worker definition or output slots that belong to another slot group (see below).
  
As an advanced feature, output slots can be arranged into ''groups''. The purpose of this is to describe which slots must or must not be used together: In a single workflow action it is not possible to use slot from different groups, but only slots of a single group and slots that are not marked with a group (they belong to each group implicitly). When using groups, the rules concerning optional and mandatory slots are as follows:
+
==== Slot groups ====
* A non-<tt>optional</tt> slot without a group must be always be connected to a bucket.
+
As an advanced feature, output slots can be associated with a group label. Slots having the same group label then belong to the same group. Grouping is used to define which slots can be used together in the same workflow and which not. Whereas slots that were not associated with a group label can be combined freely because they belong to each group implicitly, it is not possible to use slots from different groups in the same workflow. When using groups, the rules concerning optional and mandatory output slots are as follows:
* An <tt>optional</tt> slot without a group is allowed in combination with any group slot.
+
* A mandatory slot without a group label must always be connected to a bucket.
* If a group is used, all non-<tt>optional</tt> slots of the same group must be connected to a bucket, too.
+
* An optional slot without a group label is allowed in any combination with other any group slot.
* If each group contains at least one non-<tt>optional</tt> slot, at least one group must be connected. It's not possible to use only the groupless slots then.
+
* If a particular group shall be used, all mandatory slots of the group must be connected to a bucket.
 +
* If each group contains at least one mandatory slot, at least one group must be connected. It is not possible then to connect the slots without a group label only.
  
The worker properties in detail:
+
==== Worker properties in detail ====
* <tt>name</tt> is mandatory.
+
 
* <tt>modes</tt> is optional and describes the mode of the worker
+
* <tt>name</tt>: Required. Defines the name of the worker. Can be used in a workflow to add the worker as an action.
**<tt>bulkSource</tt>: Can start a workflow, does not need input data. A task for this worker is created on demand when the worker requests it (in-progress tasks only)
+
* <tt>modes</tt>: Optional. Sets a mode in the worker, controlling a special behavior.
**<tt>autoCommit</tt>: When the worker dies while working on a task (sends no keep-alive anymore) the started bulks are committed by the job manager and follow-up actions are triggered, the task is not rolled back.
+
* <tt>parameters</tt>: Optional. Gives the mandatory parameters.
* <tt>parameters</tt> is optional and describes the parameters needed to configure the worker
+
* <tt>taskGenerator</tt>: Optional. Defines the name of the OSGi service which should be used to create the tasks whenever there are changes in the respective input buckets. If the taskGenerator is not set, the default task generator is used.
* <tt>taskGenerator</tt> is optional and configures a piece of code (OSGi service) that is used to create the actual tasks after changes in the input buckets. Can be used to create multiple tasks for a single change event, or to filter events: If the generator does not actually create a task for the event, the action is cancelled.
+
* <tt>input</tt>: Optional. Describes the input slots:
 +
**<tt>name</tt>: Gives the name of a slot. Has to be bound as a parameter key to an existing bucket in a workflow.
 +
**<tt>type</tt>: Gives the required data object type of the input slot. The bucket bound in an actual workflow must comply with this type.
 +
**<tt>mode</tt>: Sets the mode(s) of the respective input slot, controlling a special behavior.
 +
* <tt>output</tt>: Optional. Describes the output slots:
 +
**<tt>name</tt>: Gives the name of the slot. Has to be bound as a parameter key to an existing bucket in a workflow.
 +
**<tt>type</tt>: Gives the required data object type of the output slot. The bucket bound in an actual workflow must comply with this type.
 +
**<tt>group</tt>: Gives the group label of this slot (see above).
 +
**<tt>mode</tt>: Sets the mode(s) of the respective output slot, controlling a special behavior.
 +
 
 +
 
 +
==== Example ====
 +
 
 +
An exemplary worker definition:
 +
 
 +
<pre>
 +
{
 +
  "name" : "exampleWorker",
 +
  "parameters" : [ "index" ],
 +
  "input" : [ {
 +
    "name" : "inputRecords",
 +
    "type" : "recordBulks"
 +
  } ],
 +
  "output" : [ {
 +
    "name" : "outputRecords",
 +
    "type" : "recordBulks"
 +
  }]
 +
}
 +
</pre>
  
 
=== List workers ===
 
=== List workers ===
Line 65: Line 96:
 
== Workflows ==
 
== Workflows ==
  
=== Workflow Definition ===
+
=== Workflow definition ===
 
Describes the work to be done by associating buckets to workers. All input and output slots of workers must be associated to buckets. The types of buckets must match the required bucket types described in the worker definition.
 
Describes the work to be done by associating buckets to workers. All input and output slots of workers must be associated to buckets. The types of buckets must match the required bucket types described in the worker definition.
  
 
A workflow run starts with the start-action. The order of the other actions is determined by their inputs and outputs.
 
A workflow run starts with the start-action. The order of the other actions is determined by their inputs and outputs.
  
 +
==== Workflow properties in detail ====
  
 
Description of a workflow:
 
Description of a workflow:
*<tt>name</tt>
 
** MANDATORY
 
** The name of a workflow
 
*<tt>parameters</tt> (MAP)
 
** The parameters defined within this workflow as a map
 
*<tt>startAction</tt> (MAP)
 
** MANDATORY
 
** the starting action of this workflow
 
** there can be only one starting action
 
*<tt>actions</tt> (LIST of MAPs)
 
** the non-starting-actions of this workflow which
 
  
Description of an action
+
*<tt>name</tt>: Required. Gives the name of the workflow.
*<tt>worker</tt>
+
*<tt>parameters</tt> (MAP): Optional. Sets the ''global workflow parameters''. They apply to all actions in the workflow as well as to the buckets used by these workers.
** the name of an existing worker definition
+
*<tt>startAction</tt> (MAP): Required. Defines the starting action of the workflow. There can be only one starting action within the workflow.
*<tt>parameters</tt>
+
*<tt>actions</tt> (LIST of MAPs): Optional. Defines the follow-up actions of the workflow.  
** the parameters the workflow defines for this worker (not for the buckets the worker uses!)
+
*<tt>input</tt> (MAP)
+
** The mapping of the worker's named input slots (KEY) to an existing bucket definition (VALUE)
+
** all of the worker's named input slots have to be resolved against an existing bucket of the same type.
+
*<tt>output</tt> (MAP)
+
** The mapping of the worker's named output slots (KEY) to an existing bucket definition (VALUE)
+
** all of the worker's named output slots have to be resolved against an existing bucket of the same type.
+
  
 +
Description of <tt>startAction</tt> and <tt>actions</tt>:
  
'''Parameters'''
+
*<tt>worker</tt>: Gives the name of a worker. This name must comply with the name given in the [[#Worker-definition|worker definition]].
 
+
*<tt>parameters</tt>: Sets the ''local worker parameters''. The apply to the referenced worker but not the buckets that this worker is using.
We have two kinds of parameters in the workflow definition:
+
*<tt>input</tt> (MAP): Maps the worker's named input slot(s) to an existing bucket definition. The name of an input slot must be the key and the name of the bucket must be the value of that key. All of the worker's named input slots have to be resolved against existing buckets of the expected type.
* ''Global workflow parameters'': Parameters that are set globally and apply to every action in the workflow.
+
*<tt>output</tt> (MAP): aps the worker's named output slot(s) to an existing bucket definition. The name of an output slot must be the key and the name of the bucket must be the value of that key. All of the worker's named output slots have to be resolved against existing buckets of the expected type.
* ''Local worker parameters'': Parameters that are set locally and are applied only to the action in which they were defined.
+
 
+
Please note that the local parameters do not affect the buckets that the respective worker is using. As a consequence, parameters declared in a data object type can only be initialized using global workflow parameters or job parameters alternatively.
+
 
+
Sample:
+
 
+
<pre>
+
    {
+
      "name": "myWorkflow",
+
      "parameters":
+
        {
+
            "myGlobalParam": "..."
+
        }
+
      "startAction":
+
        {
+
          "parameters":
+
            {
+
              "myLocalParam": "..."
+
            }
+
          "worker": "myWorker",
+
      ...
+
</pre>
+
 
+
Data object types and workers define parameter variables: ${...}
+
* Needed data object type variables that are not set in a bucket parameter must be either set as workflow or job parameter.
+
* Needed worker variables must be either set as workflow or job parameter.
+
  
 
=== List, create, and modify workflows ===
 
=== List, create, and modify workflows ===

Revision as of 09:57, 12 July 2011

Note.png
Available since SMILA 0.9!


Workers and Workflows

This page is work in progress.

Workers

Worker definition

A worker definition describes the input and output behavior as well as the required parameters of a worker. The definitions are provided with the software and must be known in the system before a worker can be added as an action to a workflow. They cannot be added or edited at runtime and are therefore not intended to be manipulated by the user.

Typically, a worker definition consists of the following parts:

  1. A parameter section declaring the workers's mandatory string parameters: These parameters must be set either in the workflow or in the job definition when using this worker.
  2. An input slot describing the type of input objects that the worker is able to consume: All input slots must be connected to buckets in a workflow definition that wants to use this worker.
  3. An output slot describing the type of output objects that the worker generates: All output slots must be connected to buckets in a workflow definition that wants to use this worker. An exception to this rule are output slots that were marked as optional in the worker definition or output slots that belong to another slot group (see below).

Slot groups

As an advanced feature, output slots can be associated with a group label. Slots having the same group label then belong to the same group. Grouping is used to define which slots can be used together in the same workflow and which not. Whereas slots that were not associated with a group label can be combined freely because they belong to each group implicitly, it is not possible to use slots from different groups in the same workflow. When using groups, the rules concerning optional and mandatory output slots are as follows:

  • A mandatory slot without a group label must always be connected to a bucket.
  • An optional slot without a group label is allowed in any combination with other any group slot.
  • If a particular group shall be used, all mandatory slots of the group must be connected to a bucket.
  • If each group contains at least one mandatory slot, at least one group must be connected. It is not possible then to connect the slots without a group label only.

Worker properties in detail

  • name: Required. Defines the name of the worker. Can be used in a workflow to add the worker as an action.
  • modes: Optional. Sets a mode in the worker, controlling a special behavior.
  • parameters: Optional. Gives the mandatory parameters.
  • taskGenerator: Optional. Defines the name of the OSGi service which should be used to create the tasks whenever there are changes in the respective input buckets. If the taskGenerator is not set, the default task generator is used.
  • input: Optional. Describes the input slots:
    • name: Gives the name of a slot. Has to be bound as a parameter key to an existing bucket in a workflow.
    • type: Gives the required data object type of the input slot. The bucket bound in an actual workflow must comply with this type.
    • mode: Sets the mode(s) of the respective input slot, controlling a special behavior.
  • output: Optional. Describes the output slots:
    • name: Gives the name of the slot. Has to be bound as a parameter key to an existing bucket in a workflow.
    • type: Gives the required data object type of the output slot. The bucket bound in an actual workflow must comply with this type.
    • group: Gives the group label of this slot (see above).
    • mode: Sets the mode(s) of the respective output slot, controlling a special behavior.


Example

An exemplary worker definition:

{
  "name" : "exampleWorker",
  "parameters" : [ "index" ],
  "input" : [ {
    "name" : "inputRecords",
    "type" : "recordBulks"
  } ],
  "output" : [ {
    "name" : "outputRecords",
    "type" : "recordBulks"
  }]
}

List workers

All workers

Use a GET request to list all worker definitions.

Supported operations:

  • GET: Returns a list of all worker definitions.

Usage:

  • URL: http://<hostname>:8080/smila/jobmanager/workers/
  • Allowed methods:
    • GET
  • Response status codes:
    • 200 OK: Upon successful execution.

Specific worker

Use a GET request to list the definition of a specific worker.

Supported operations:

  • GET: Returns the definition of the given worker.

Usage:

  • URL: http://<hostname>:8080/smila/jobmanager/workers/<worker-name>/
  • Allowed methods:
    • GET
  • Response status codes:
    • 200 OK: Upon successful execution.

Workflows

Workflow definition

Describes the work to be done by associating buckets to workers. All input and output slots of workers must be associated to buckets. The types of buckets must match the required bucket types described in the worker definition.

A workflow run starts with the start-action. The order of the other actions is determined by their inputs and outputs.

Workflow properties in detail

Description of a workflow:

  • name: Required. Gives the name of the workflow.
  • parameters (MAP): Optional. Sets the global workflow parameters. They apply to all actions in the workflow as well as to the buckets used by these workers.
  • startAction (MAP): Required. Defines the starting action of the workflow. There can be only one starting action within the workflow.
  • actions (LIST of MAPs): Optional. Defines the follow-up actions of the workflow.

Description of startAction and actions:

  • worker: Gives the name of a worker. This name must comply with the name given in the worker definition.
  • parameters: Sets the local worker parameters. The apply to the referenced worker but not the buckets that this worker is using.
  • input (MAP): Maps the worker's named input slot(s) to an existing bucket definition. The name of an input slot must be the key and the name of the bucket must be the value of that key. All of the worker's named input slots have to be resolved against existing buckets of the expected type.
  • output (MAP): aps the worker's named output slot(s) to an existing bucket definition. The name of an output slot must be the key and the name of the bucket must be the value of that key. All of the worker's named output slots have to be resolved against existing buckets of the expected type.

List, create, and modify workflows

All workflows

Use a GET request to list the definitions of all workflows. Use POST for adding or updating a workflow definition.

Supported operations:

  • GET: Returns a list of all workflow definitions. If there are no workflows defined, you will get an empty list.
  • POST: Create a new workflow definition or update an existing one. If the workflow already exists, it will be updated after successful validation. However, the changes will not apply until the next job run, i.e. the current job run is not influenced by the changes. Only workers for which worker definitions exist can be added to the workflow definition as actions. When adding a worker, all parameters defined in the worker's definition have to be satisfied. If not in the global or local sections of the workflow definition itself, then later in the job definition. Also, all input and output slots have to be connected to existing buckets if they are persistent ones or at least a bucket name must be provided in case of transient ones. Expceptions to this rule are optional slots or those of other slot groups which need not and must not (in the latter case) be connected to buckets. An error will be thrown:
    • If a required slot is not connected to a bucket.
    • If a referenced bucket, defined as persistent one, does not exist.

Usage:

  • URL: http://<hostname>:8080/smila/jobmanager/workflows.
  • Allowed methods:
    • GET
    • POST
  • Response status codes:
    • 200 OK: Upon successful execution (GET).
    • 201 CREATED: Upon successful execution (POST).
    • 400 Bad Request: name, startAction are mandatory fields. If they are not set, an HTTP 400 Bad Request including an error message in the response body will be returned.

Specific workflow

Use a GET request to retrieve the defintion of a specific workflow. Use DELETE to delete a specific workflow.

Supported operations:

  • GET: Returns the definition of the given workflow.
  • DELETE: Deletes the given workflow.

Usage:

  • URL: http://<hostname>:8080/smila/jobmanager/workflows/
  • Allowed methods:
    • GET
    • DELETE
  • Response status codes:
    • 200 OK: Upon successful execution (GET, DELETE). If the workflow to be deleted does not exist, you will get 200 anyway (DELETE).
    • 404 Not Found: If the workflow does not exist (GET).
    • 400 Bad Request: If the workflow to be deleted is stil referenced by a job definition (DELETE).

Back to the top