Version of 17th February 2006
A single server runs at any one time (for a given user). If you try to start a second instance then the new process will hand you off to the first and close down.
Once the server is running you can send requests to it. These requests are wrapped in XML of the form:
<db_request> <command>command</command> <argument>arg1</argument> <argument>arg2</argument> ... <request_id>id</request_id> </db_request>
The args are specific to the command. The id is some string without whitespace that the connecting application can use to match up the responses that the server sends back.
The server response is in XML of the form:
<db_response> <status>status</status> <result>message/result</result> <response_id>id</response_id> </db_response>
The response elements are:
status | The status reflects the success or failure of the request being processed by the handler. It is possible for the handler to return status OK even though the request itself may result in a null value or error for the command. Usually the status will be "OK" or "ERROR" |
message/result | Dependent on the command - for example, if the command was a request for data then this will hold the actual data. If the status is ERROR then this will probably be an error message. |
id | The id string supplied by the client when making the request |
Note: the status reflects the success or failure of the request being processed by the handler. It is possible for the handler to return status OK even though the request itself may result in a null value or error for the command.
The server can also send "broadcast messages" to clients. Broadcasts are not in direct response to a client request, they are triggered by a change in the database status and are intended to notify clients that a change has taken place (for example, if a new job has been registered). The broadcasts are also in XML, of the form:
<db_broadcast> <message>message</message> </db_broadcast>
where message is a text string detailing the changes.
dbCCP4i supports two command line options:
Usage: dbccp4i [-port <no>] dbccp4i -shutdown
dbccp4i starts up an instance of the server, which then opens up a port to listen for connections. Specifying the -port option tells the server to send back a notification saying which port it is using. The message is the string of the form "Server started on port <portno>".
dbccp4i -shutdown will shut down any server that is currently running, and then close down itself.
As described above, commands are sent to the server in the form of XML wrapping. The following sections list the commands without the XML, in the form:
command arg1 arg2 ...
This is a peculiarity of CCP4i at present. Once started, running jobs talk directly to the handler rather than to the main CCP4i process in order to report progress and update the record that they are associated with.
The procedure is: the main CCP4i process "opens" the record in question for writing purposes, using DbRegisterJob. The running job connects to the handler each time it needs to update the database, using DbReceive. When a job sends a termination notice then the handler "closes" the record and notifies the original CCP4i process so that it can perform clean up or review.
There are obviously some issues here, for example: 1) what happens to records that are never closed (e.g. running job fails without informing the handler)? 2) what happens if the initiating CCP4i process has finished in the meantime?
So this setup is not ideal and should probably be overhauled in future.