deadline-extension trickle handler: message tweaks

This commit is contained in:
David Anderson 2013-11-11 13:24:09 -08:00
parent d3a199b3d3
commit 863c9496b0
1 changed files with 28 additions and 15 deletions

View File

@ -16,10 +16,12 @@
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// The following is a deadline trickle handler.
// It extends the deadline of the task_id the app sends us.
// It extends the deadline of the result the app sends us.
// This prevents duplicating the job when the original deadline is reached.
// Note: there is no effect on the client;
// currently there's no mechanism for sending the new deadline to the client.
//
// message format:
// trickle message format:
//
// <result_name>x</result_name>
// <cpu_time>x</cpu_time>
@ -72,7 +74,7 @@ int handle_trickle(MSG_FROM_HOST& mfh) {
char buf[256];
int cpu_time = 0; // not needed but parsed to limit unexpected tag warnings
printf("got trickle-up \n%s\n\n", mfh.xml);
//printf("got trickle-up \n%s\n\n", mfh.xml);
MIOFILE mf;
@ -82,33 +84,44 @@ int handle_trickle(MSG_FROM_HOST& mfh) {
while (!xp.get_tag()) {
if (xp.parse_int("cpu_time", cpu_time)) break;
if (xp.parse_str("result_name", task_name, 256)) break;
log_messages.printf(MSG_NORMAL, "unexpected tag: %s\n", xp.parsed_tag);
log_messages.printf(MSG_NORMAL,
"[HOST#%u] unexpected tag: %s\n",
mfh.hostid, xp.parsed_tag
);
}
if (strlen(task_name) == 0) {
log_messages.printf(MSG_NORMAL,
"unexpected empty result_name attribute\n"
"[HOST#%u] unexpected empty result_name attribute\n",
mfh.hostid
);
return ERR_XML_PARSE;
}
DB_RESULT task;
sprintf(buf, " where name='%s'", task_name);
sprintf(buf, " where name='%s' and hostid=%u", task_name, mfh.hostid);
int retval = task.lookup(buf);
if (retval) return retval;
if (retval) {
log_messages.printf(MSG_CRITICAL,
"[HOST#%u] error while looking for result_name: %s\n",
mfh.hostid, task_name
);
return retval;
}
// sanity checks - customize as needed
//
if (task.report_deadline < dtime()) {
log_messages.printf(MSG_NORMAL,
"Report deadline is in the past: %d\n", task.report_deadline
"[RESULT#%u][HOST#%u] report deadline is in the past\n",
task.id, mfh.hostid
);
// don't do anything for now
// don't do anything for now (could reactivate the result here)
return 0;
}
if ((task.report_deadline - extension_timeframe) > dtime()) {
log_messages.printf(MSG_DEBUG,
"Report deadline is too far in the future: %d\n",
task.report_deadline
"[RESULT#%u][HOST#%u] report deadline is too far in the future\n",
task.id, mfh.hostid
);
// don't do anything
return 0;
@ -119,8 +132,8 @@ int handle_trickle(MSG_FROM_HOST& mfh) {
retval = task.update();
if (retval) return retval;
log_messages.printf(MSG_DEBUG,
"Report deadline of result %d extended to %d\n",
task.get_id(), task.report_deadline
"[RESULT#%u][HOST#%u] report deadline extended to %d\n",
task.id, mfh.hostid, task.report_deadline
);
return 0;
}
}