2004-01-04 06:48:40 +00:00
|
|
|
<?
|
|
|
|
require_once("docutil.php");
|
|
|
|
page_head("Trickle messages");
|
|
|
|
echo "
|
|
|
|
<h2>Trickle messages</h2>
|
|
|
|
<p>
|
|
|
|
<b>Trickle messages</b>
|
|
|
|
let applications communicate with the server
|
|
|
|
during the execution of a workunit.
|
|
|
|
That are intended for applications that have
|
|
|
|
long work units (multiple days).
|
2004-03-02 03:46:04 +00:00
|
|
|
Trickle messages may be in either direction
|
|
|
|
(application to server, or vice versa).
|
2004-01-04 06:48:40 +00:00
|
|
|
Typical uses of this mechanism:
|
|
|
|
<ul>
|
2004-03-02 03:46:04 +00:00
|
|
|
<li>
|
|
|
|
The application reports its current CPU usage,
|
2004-01-04 06:48:40 +00:00
|
|
|
so that users can be granted incremental credit
|
|
|
|
(rather than waiting until the end of the work unit).
|
2004-03-02 03:46:04 +00:00
|
|
|
|
|
|
|
<li>
|
|
|
|
The application reports a summary of the computational state,
|
2004-01-04 06:48:40 +00:00
|
|
|
so that server logic can decide if the computation should be aborted.
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p>
|
2004-03-02 03:46:04 +00:00
|
|
|
Trickle messages are asynchronous and reliable.
|
|
|
|
A trickle message may not be delivered immediately after it is sent.
|
|
|
|
If there is a message waiting to be sent,
|
|
|
|
the BOINC client may contact the scheduling server,
|
|
|
|
but this may take a while if the client is offline.
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
|
|
|
|
<h3>API (client)</h3>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<code>int boinc_send_trickle(char*)</code>
|
|
|
|
</pre>
|
|
|
|
sends a trickle message.
|
|
|
|
Returns zero if success.
|
|
|
|
<p>
|
|
|
|
<pre>
|
|
|
|
<code>bool boinc_receive_trickle(char* buf, int len)</code>
|
|
|
|
</pre>
|
|
|
|
receives a trickle message.
|
|
|
|
Returns true if there was a message.
|
|
|
|
Messages are delivered in order.
|
|
|
|
|
|
|
|
<h3>API (server)</h3>
|
|
|
|
|
|
|
|
The server C library API:
|
|
|
|
<pre>
|
|
|
|
<code>
|
|
|
|
int get_trickle_message(
|
|
|
|
int applicationid,
|
|
|
|
int& resultid,
|
|
|
|
int& messagid,
|
|
|
|
char* buf,
|
|
|
|
int len
|
|
|
|
);
|
|
|
|
|
|
|
|
int mark_trickle_processed(int messagid);
|
|
|
|
|
|
|
|
int send_trickle_message(
|
|
|
|
int resultid,
|
|
|
|
char* buf
|
|
|
|
);
|
|
|
|
</code>
|
|
|
|
</pre>
|
|
|
|
get_trickle_message() gets an unprocessed trickle message
|
|
|
|
for the given application,
|
|
|
|
returning the result and message IDs as well as the message itself.
|
|
|
|
mark_trickle_processed() flags a trickle message as processed.
|
|
|
|
send_trickle_message() sends a trickle message to the
|
|
|
|
client handling the given result.
|
|
|
|
<p>
|
|
|
|
These functions are also available as scriptable command-line programs.
|
2004-01-04 06:48:40 +00:00
|
|
|
|
|
|
|
<h3>Implementation</h3>
|
|
|
|
<p>
|
2004-03-02 03:46:04 +00:00
|
|
|
On the client,
|
|
|
|
<code>boinc_send_trickle()</code>
|
2004-01-04 06:48:40 +00:00
|
|
|
creates a file 'trickle' in the slot directory
|
|
|
|
and signals the core client via shared memory.
|
|
|
|
When the core client gets this signal,
|
|
|
|
or when the application exits,
|
|
|
|
it moves the file from 'slot/trickle'
|
|
|
|
to 'project/trickle_resultid_time'.
|
|
|
|
<p>
|
|
|
|
When the core client sends an RPC to a server,
|
2004-02-15 19:22:01 +00:00
|
|
|
it scans the project directory for trickle files
|
2004-01-04 06:48:40 +00:00
|
|
|
and includes them in the request.
|
|
|
|
On successful RPC completion it deletes the trickle files.
|
|
|
|
|
2004-03-02 03:46:04 +00:00
|
|
|
<p>
|
|
|
|
boinc_receive_trickle() sets a flag in the result record;
|
|
|
|
this flag is conveyed to the scheduling server.
|
|
|
|
<p>
|
|
|
|
The server database has two tables,
|
|
|
|
trickle_to_server and trickle_to_client.
|
|
|
|
The scheduling server extracts trickle messages from
|
|
|
|
the request message and inserts them in trickle_to_server.
|
|
|
|
If the above flag is set for a given result,
|
|
|
|
it queries the trickle_to_client table for that result
|
|
|
|
and appends any messages to the reply.
|
|
|
|
|
|
|
|
|
2004-01-04 06:48:40 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
page_tail();
|
|
|
|
?>
|