Confirmed users
1,927
edits
(Created page with "= Overall Design = The SUTAgent must handle multiple connections and concurrent events. It is expected, however, that often only one or two connections will be established. Thre...") |
|||
Line 13: | Line 13: | ||
== BufferedSocket == | == BufferedSocket == | ||
BufferedSocket is just a wrapper around a socket that allows buffering in userspace | BufferedSocket is just a wrapper around a socket that allows buffering in userspace. | ||
== Reactor == | == Reactor == | ||
Line 24: | Line 24: | ||
An abstract class with three functions, all used by the Reactor: | An abstract class with three functions, all used by the Reactor: | ||
* | * getPollDescs(): returns any descriptors for which the handler would like notifications | ||
* | * handleEvent(): takes a list of events for which the Reactor received a notification in the last iteration. The Handler does application-specific processing here. | ||
* closed(): indicates if a handler is finished, which means it should be deleted by the Reactor (or proxy, see below). | * closed(): indicates if a handler is finished, which means it should be deleted by the Reactor (or proxy, see below). | ||
== SocketAcceptorEventHandler == | == SocketAcceptorEventHandler == | ||
An EventHandler that listens for connections on the given socket and creates | An EventHandler that listens for connections on the given socket and creates CommandEventHandlers, adding them to the Reactor. | ||
== | == CommandEventHandler == | ||
A CommandEventHandler represents one session, e.g. the duration of a connection. Because connections can have two states--commands and data--it may act as a proxy to another EventHandler, for potentially long-running commands like 'push' or 'pull' that require some state. | |||
Its handleEvent() implementation either reads a line and passes it to handleLine(), if in command mode, or just passes the event to the data event handler. It also flushes the BufferedSocket output buffer, if needed. | |||
Similarly, its getPollDescs() implementation returns either just a read event for the socket, if in command mode, or collects descriptors from the data event handler. It also adds a write event for the BufferedSocket, if there is buffered, unsent data. | |||
== | == PushFileEventHandler / PullFileEventHandler == | ||
Represents a data stream. Used for push and pull commands. Maintains some state, i.e. how much of the file has been received or sent. When finished, closes itself, so that the | Represents a data stream. Used for push and pull commands. Maintains some state, i.e. how much of the file has been received or sent. When finished, closes itself, so that the CommandEventHandler deletes it, returning to regular command processing. | ||
== SubprocessEventHandler == | == SubprocessEventHandler == | ||
Represents a subprocess. Its | Represents a subprocess. Its getPollDescs() just returns a timeout, since, for platform-independence, we have to poll subprocesses to determine when they are complete. It may also write data to the BufferedSocket. It is expected that this will have to be subclassed for each platform and probably created via a platform-specific factory object. When the process exits, this EventHandler closes, so that the CommandEventHandler can delete it and return to command processing. |