Preparing for state statistics

As explained in the previous section the timings gathered by folder statistics are limited to a single process (or a very small set of parallel processed). In contrast state statistics can handle workflow segments of arbitrary length and complexity.

The internal job ticket for each job stores a "job state" field for this purpose. The value of the job state field can be adjusted each time the job passes through a folder (by setting the appropriate property value; see below). The idea is to mark the boundaries of relevant workflow segments by adjusting the job state field each time a job crosses those boundaries. This allows workflow segments to span multiple Switch flows (because a job retains its job state until it is explicitly updated). At the same time, some care is needed to correctly instruct any and all paths that cross a boundary to appropriately update the job state.

To set or update the job state field for all jobs passing through a folder, select the folder in the canvas and set its "Attach job state" property to a non-empty value, which is interpreted as the name of the job state (or workflow segment) being entered by passing through this folder. If the "Attach job state" property is set to the empty string (its default value), the job state is NOT updated (i.e. it is not set to the empty value).

Interpretation

When Switch detects that a job has fully arrived in a folder, and the folder has a non-empty "Attach job state" property value, Switch updates the job state in the job's internal job ticket. If due to this action the job's job state changed (from a non-empty value to a different non-empty value), Switch also logs the time spent in the previous job state in the statistics database.

This way Switch keeps track of the time a job spends in each job state. The time lapse includes the queuing time in the folder on the input boundary, but does NOT include the queuing time in the folder on the output boundary. The time lapse also includes any periods of time during which the job was blocked because a relevant flow was not active or Switch wasn't running.

The bar chart in the Statistics pane shows the average time a job spent in each state (i.e. the average total queuing and processing time in that state).

Note that, due to the fact that a state statistic is logged only when the job state changes, it is necessary to introduce an extra dummy state (which will never be logged) at the end of the last flow segment of interest. Also, due to an implementation limitation it is not possible to change the job state in a folder that has no outgoing connections (the "Attach job state" property is not present for such folders). Thus one must introduce an extra superfluous folder just before the last folder:



In this example, the time spent in MyState includes the processing time in the generic application and the queuing time in the first folder. The second folder was introduced to change the job state to a dummy value.