Pilots and Jobs
Pilots are created completely independently of the server and contact the server via HTTP once they are initiated. The server searches its database of "defined jobs", sorts the jobs by priority and sends a reference to a job to the pilot which sent the request. In the current version, the job reference contains the path to the executable, its parameters and also the part of the job environment which helps to reference the data both in the input and the output by using environment variables.
- finished (completion of a job)
- stopped (timeout w/o getting a job)
- dispatched (sent to a pilot for execution)
Matching jobs to pilots
Jobs are created in the "template" state and won't be matched
DAG as a template
- DAG describes the topology and general properties of a workflow, and serves as a template for workflows. The system stores multiple templates referred to by their names.
- Vertex and Edge tables: vertices are jobs and the edges are data. The edge class has the following attributes at a minimum
- Source node
- Target node
The ID is important if we want to support multiple edges between same nodes (e.g. files of different types produced by one job and consumed by another). This type of DAG is sometimes called MultiDiGraph but terminology may vary. Of course other useful parameters are implemented (path, state etc) as the edges refer to actual data.
- Leaves of a DAG: can only be a job, not data (since all data are edges and not vertices). This also has the benefit of not having final data unaccounted for - it must me either flushed or moved to permanent storage in most cases. The job/task responsible for either of these operations forms the leaf. If the data source for the root of the tree is purely external, such DAG nodes is assigned a special type "NOOP" and is handled accordingly (e.g. no pilots are necessary for its execution and it's essentially a pass-through)
Below is a scenario of the actual operation of the p3s prototype as it is tested:
- DAGs which are templates for actual workflows are defined in XML and sent to the p3s server where they are stored, as needed. There is no limit on how many templates can be in the system, and they can be updated or deleted at will. They are identified by a unique name and I propose to use this for versioning too, for simplicity.
- Also for simplicity, payloads are fixed in a particular DAG - which means DAGs of same topology but with different node content (or with different data types corresponding to edges) will be considered different. Doing proper inheritance quickly became too complex so I skipped it. To illustrate, if you change an executable in a single node or a single file format in a DAG, you will have to create a new DAG (and under a new name, presumably).
- a watcher script detects existence of a file (configurable) in a directory (configurable), it will loop and sleep as configured. If triggered, it's configured to create a workflow based on a specific DAG template.
- as per the above statement, the server is prompted via HTTP to create a workflow based on a pre-loaded template of a certain kind; the edges in the DAG which served as placeholders are populated with the actual file path information provided by the watcher (or rather its instance, which can be many). Multiple files can be plugged into a DAG if needed via the same interface.
- if the first node in the graph is a NOOP it's automatically toggled to "finished" so the rest of the DAG can proceed. This covers the scenario where the source of the data is purely external - however it doesn't need to be and the file finding jobs can be the first node (I think you suggested this once). The "first node" is picked via topological sorting, so it's scientific.
- the first unfinished job in the graph which is not dummy (NOOP) is automatically set to "defined" state, which means it can be matched to a pilot. Other jobs remain in the "template" state until their ancestors are executed.
- in the meantime, an independent script on some worker node is creating pilots (again, looping and sleeping as configured)
- brokerage (matching) happens and jobs get executed; their children in the graph are then toggled to "defined" state so they in turn can be picked by the pilots.
- every time a job is finished we check if it was the last one in a DAG, in which case the whole workflow is toggled to "finished" state.