| 1 | = Core client: finite-state machine (FSM) structure = |
| 2 | |
| 3 | The core client can perform many activities (file transfers, computations, RPCs to scheduling servers) in parallel. To manage this parallelism, the core client is structured as a number of '''finite-state machines''' (FSM). For example, an HTTP transaction is represented by an FSM whose states might include: |
| 4 | |
| 5 | |
| 6 | * Waiting for connection establishment. |
| 7 | * Waiting to send request header. |
| 8 | * Waiting to send send request body. |
| 9 | * Waiting for reply header. |
| 10 | * Waiting for reply body. |
| 11 | * Finished. |
| 12 | |
| 13 | FSMs of a particular type are managed by an '''FSM container'''. Each FSM container manages a set of FSMs, and provides a '''poll()''' function for detecting and performing state transitions. These functions are nonblocking; at the lowest level, they must use non-blocking network sockets, accessed using select(). |
| 14 | |
| 15 | The core client uses the following FSM types: |
| 16 | |
| 17 | |
| 18 | * '''NET_XFER''' (container: '''NET_XFER_SET'''). Each instance represents a network connection, for which data is being transferred to/from memory or a disk file. The '''poll()''' function uses '''select()''' to manage the FSM without blocking. |
| 19 | * '''HTTP_OP''' (container: '''HTTP_OP_SET'''). Each instance represents an HTTP operation (GET, PUT or POST). |
| 20 | * '''FILE_XFER''' (container: '''FILE_XFER_SET'''). Each instance represents a file transfer (upload or download) in progress. |
| 21 | * '''PERS_FILE_XFER''' (container: '''PERS_FILE_XFER_SET'''). Each instance represents a 'persistent file transfer', which recovers from server failures and disconnections, and implements retry and give-up policies. |
| 22 | * '''SCHEDULER_OP'''. There is only one instance. It encapsulates communication with scheduling servers, including backoff and retry policies. |
| 23 | * '''ACTIVE_TASK''' (container: '''ACTIVE_TASK_SET'''). Each instance represents a running application. |
| 24 | |
| 25 | An FSM may be implemented using other FSMs; for example, FILE_XFER is implemented using HTTP_OP, which in turn is implemented using NET_XFER. |
| 26 | |