2003-07-01 20:37:09 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2002-06-21 06:52:47 +00:00
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
2003-07-01 20:37:09 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2002-06-21 06:52:47 +00:00
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
2003-07-02 02:02:18 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2002-06-21 06:52:47 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
2003-07-01 20:37:09 +00:00
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2003-07-02 02:02:18 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2002-06-21 06:52:47 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
2003-01-02 23:12:05 +00:00
|
|
|
|
2004-03-04 11:41:43 +00:00
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cmath>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <ctime>
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2003-01-02 23:12:05 +00:00
|
|
|
#include "util.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "error_numbers.h"
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
#include "client_state.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "client_types.h"
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "client_msgs.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "file_names.h"
|
|
|
|
#include "log_flags.h"
|
|
|
|
#include "scheduler_op.h"
|
|
|
|
|
2004-06-30 18:17:21 +00:00
|
|
|
using std::vector;
|
|
|
|
|
2003-05-13 18:55:07 +00:00
|
|
|
extern void project_add_failed(PROJECT*);
|
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
SCHEDULER_OP::SCHEDULER_OP(HTTP_OP_SET* h) {
|
|
|
|
state = SCHEDULER_OP_STATE_IDLE;
|
|
|
|
http_op.http_op_state = HTTP_STATE_IDLE;
|
|
|
|
http_ops = h;
|
|
|
|
}
|
|
|
|
|
2003-05-13 18:55:07 +00:00
|
|
|
// see if there's a pending master file fetch. start it if so.
|
|
|
|
//
|
|
|
|
bool SCHEDULER_OP::check_master_fetch_start() {
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
project = gstate.next_project_master_pending();
|
|
|
|
if (project) {
|
|
|
|
retval = init_master_fetch(project);
|
|
|
|
if (retval) {
|
2003-10-23 06:29:24 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Couldn't read master page for %s: error %d",
|
|
|
|
project->get_project_name(), retval
|
|
|
|
);
|
2003-05-13 18:55:07 +00:00
|
|
|
if (project->tentative) {
|
2003-10-23 06:29:24 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "Detaching from project - check for URL error");
|
2003-05-13 18:55:07 +00:00
|
|
|
project_add_failed(project);
|
|
|
|
} else {
|
|
|
|
project->master_fetch_failures++;
|
|
|
|
backoff(project, "Master file fetch failed\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-09-22 22:09:54 +00:00
|
|
|
// try to get some work, from any project from which we need it
|
|
|
|
// PRECONDITION: compute_work_requests() has been called
|
|
|
|
// to fill in PROJECT::work_request
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
|
|
|
int SCHEDULER_OP::init_get_work() {
|
2002-10-14 23:37:41 +00:00
|
|
|
int retval;
|
2002-10-16 23:50:41 +00:00
|
|
|
char err_msg[256];
|
2004-07-14 20:55:26 +00:00
|
|
|
double ns;
|
2004-05-05 21:15:34 +00:00
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
must_get_work = true;
|
2004-09-22 22:09:54 +00:00
|
|
|
project = gstate.next_project_need_work(0);
|
2002-07-15 05:34:32 +00:00
|
|
|
if (project) {
|
2004-07-14 20:55:26 +00:00
|
|
|
// for new work fetch policy
|
|
|
|
ns = project->work_request;
|
2003-12-24 21:50:41 +00:00
|
|
|
msg_printf(project, MSG_INFO,
|
2004-06-01 22:19:24 +00:00
|
|
|
"Requesting %.0f seconds of work", ns
|
2003-12-24 21:50:41 +00:00
|
|
|
);
|
2003-01-02 23:12:05 +00:00
|
|
|
retval = init_op_project(ns);
|
|
|
|
if (retval) {
|
2003-03-08 23:48:05 +00:00
|
|
|
sprintf(err_msg, "init_op_project failed, error %d\n", retval);
|
2002-10-16 23:50:41 +00:00
|
|
|
backoff(project, err_msg);
|
2002-11-19 22:57:05 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
} else {
|
2003-05-13 18:55:07 +00:00
|
|
|
check_master_fetch_start();
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2002-11-16 00:36:31 +00:00
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// report results for a particular project.
|
2004-09-22 22:09:54 +00:00
|
|
|
// PRECONDITION: compute_work_requests() has been called
|
|
|
|
// to fill in PROJECT::work_request
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2004-09-22 22:09:54 +00:00
|
|
|
int SCHEDULER_OP::init_return_results(PROJECT* p) {
|
2002-07-15 05:34:32 +00:00
|
|
|
must_get_work = false;
|
|
|
|
project = p;
|
2004-09-22 22:09:54 +00:00
|
|
|
return init_op_project(p->work_request);
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// try to initiate an RPC to the current project.
|
|
|
|
// If there are multiple schedulers, start with the first one
|
|
|
|
//
|
|
|
|
int SCHEDULER_OP::init_op_project(double ns) {
|
|
|
|
int retval;
|
2003-01-02 23:12:05 +00:00
|
|
|
char err_msg[256];
|
2002-07-15 05:34:32 +00:00
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
|
2003-07-02 02:02:18 +00:00
|
|
|
|
|
|
|
scope_messages.printf("SCHEDULER_OP::init_op_project(): starting op for %s\n", project->master_url);
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
// if project has no schedulers, skip everything else
|
|
|
|
// and just get its master file.
|
|
|
|
//
|
2003-01-08 23:35:26 +00:00
|
|
|
url_index = 0;
|
2002-07-15 05:34:32 +00:00
|
|
|
if (project->scheduler_urls.size() == 0) {
|
2002-11-26 00:47:57 +00:00
|
|
|
retval = init_master_fetch(project);
|
2003-01-02 23:12:05 +00:00
|
|
|
goto done;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
retval = gstate.make_scheduler_request(project, ns);
|
|
|
|
if (retval) {
|
2003-07-03 05:01:29 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "make_scheduler_request: %d\n", retval);
|
2003-01-02 23:12:05 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
retval = start_rpc();
|
|
|
|
done:
|
|
|
|
if (retval) {
|
|
|
|
sprintf(err_msg,
|
|
|
|
"scheduler init_op_project to %s failed, error %d\n",
|
|
|
|
project->scheduler_urls[url_index].text, retval
|
|
|
|
);
|
|
|
|
backoff(project, err_msg);
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
return retval;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set a project's min RPC time to something in the future,
|
|
|
|
// based on exponential backoff
|
|
|
|
//
|
|
|
|
int SCHEDULER_OP::set_min_rpc_time(PROJECT* p) {
|
2002-11-27 21:31:17 +00:00
|
|
|
int exp_backoff;
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
int n = p->nrpc_failures;
|
2003-06-11 22:15:25 +00:00
|
|
|
if (n > gstate.retry_cap) n = gstate.retry_cap;
|
2003-01-02 23:12:05 +00:00
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2002-11-18 23:15:32 +00:00
|
|
|
// we've hit the limit on master_url fetches
|
2003-01-02 23:12:05 +00:00
|
|
|
//
|
2003-06-11 22:15:25 +00:00
|
|
|
if (p->master_fetch_failures >= gstate.master_fetch_retry_cap) {
|
2003-07-02 02:02:18 +00:00
|
|
|
scope_messages.printf("SCHEDULER_OP::set_min_rpc_time(): we've hit the limit on master_url fetches\n");
|
2003-06-28 00:15:42 +00:00
|
|
|
exp_backoff = calculate_exponential_backoff("scheduler_op/master_url",
|
|
|
|
p->master_fetch_failures, gstate.sched_retry_delay_min,
|
2003-07-01 22:44:58 +00:00
|
|
|
gstate.master_fetch_interval
|
|
|
|
);
|
2003-01-02 23:12:05 +00:00
|
|
|
} else {
|
2003-06-28 00:15:42 +00:00
|
|
|
exp_backoff = calculate_exponential_backoff("scheduler_op",
|
2003-06-11 22:15:25 +00:00
|
|
|
n, gstate.sched_retry_delay_min, gstate.sched_retry_delay_max,
|
2003-07-01 22:44:58 +00:00
|
|
|
gstate.retry_base_period
|
|
|
|
);
|
2002-11-19 22:57:05 +00:00
|
|
|
}
|
2003-07-03 00:48:43 +00:00
|
|
|
p->set_min_rpc_time(time(0) + exp_backoff);
|
|
|
|
// note: we don't need to print a message now, it will be printed the
|
|
|
|
// next time p->waiting_until_min_rpc_time() is called.
|
2002-07-15 05:34:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-10-01 04:31:05 +00:00
|
|
|
// Back off contacting scheduler and output an error msg if needed
|
2002-10-16 23:50:41 +00:00
|
|
|
//
|
2003-03-13 21:49:52 +00:00
|
|
|
void SCHEDULER_OP::backoff(PROJECT* p, char *error_msg ) {
|
2003-06-03 22:47:15 +00:00
|
|
|
msg_printf(p, MSG_ERROR, error_msg);
|
2003-06-09 23:50:49 +00:00
|
|
|
|
2003-06-11 22:15:25 +00:00
|
|
|
if (p->master_fetch_failures >= gstate.master_fetch_retry_cap) {
|
2002-12-02 23:09:45 +00:00
|
|
|
p->master_url_fetch_pending = true;
|
2003-05-16 19:22:57 +00:00
|
|
|
} else {
|
|
|
|
// if nrpc failures is a multiple of master_fetch_period,
|
|
|
|
// then set master_url_fetch_pending and initialize again
|
|
|
|
//
|
2003-06-11 22:15:25 +00:00
|
|
|
if (p->nrpc_failures == gstate.master_fetch_period) {
|
2003-05-16 19:22:57 +00:00
|
|
|
p->master_url_fetch_pending = true;
|
|
|
|
p->min_rpc_time = 0;
|
|
|
|
p->nrpc_failures = 0;
|
|
|
|
p->master_fetch_failures++;
|
|
|
|
}
|
2003-06-09 23:50:49 +00:00
|
|
|
|
2003-05-16 19:22:57 +00:00
|
|
|
p->nrpc_failures++;
|
2002-11-26 00:47:57 +00:00
|
|
|
}
|
|
|
|
set_min_rpc_time(p);
|
2002-10-16 23:50:41 +00:00
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// low-level routine to initiate an RPC
|
2003-01-02 23:12:05 +00:00
|
|
|
// If successful, creates an HTTP_OP that must be polled
|
2004-09-22 22:09:54 +00:00
|
|
|
// PRECONDITION: the request file has been created
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2002-06-21 06:52:47 +00:00
|
|
|
int SCHEDULER_OP::start_rpc() {
|
2002-07-15 05:34:32 +00:00
|
|
|
int retval;
|
2004-09-22 22:09:54 +00:00
|
|
|
char request_file[1024], reply_file[1024];
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2003-04-03 18:35:40 +00:00
|
|
|
safe_strcpy(scheduler_url, project->scheduler_urls[url_index].text);
|
2002-06-21 06:52:47 +00:00
|
|
|
if (log_flags.sched_ops) {
|
2003-07-01 22:44:58 +00:00
|
|
|
msg_printf(
|
|
|
|
project, MSG_INFO,
|
|
|
|
"Sending request to scheduler: %s\n", scheduler_url
|
|
|
|
);
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2004-09-22 22:09:54 +00:00
|
|
|
get_sched_request_filename(*project, request_file);
|
|
|
|
get_sched_reply_filename(*project, reply_file);
|
|
|
|
|
|
|
|
scope_messages.printf_file(request_file, "req:");
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2004-09-26 04:16:52 +00:00
|
|
|
http_op.set_proxy(&gstate.proxy_info);
|
2002-07-15 05:34:32 +00:00
|
|
|
retval = http_op.init_post(
|
2004-09-22 22:09:54 +00:00
|
|
|
scheduler_url, request_file, reply_file
|
2002-06-21 06:52:47 +00:00
|
|
|
);
|
2002-07-15 05:34:32 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
retval = http_ops->insert(&http_op);
|
|
|
|
if (retval) return retval;
|
2002-06-21 06:52:47 +00:00
|
|
|
project->rpc_seqno++;
|
|
|
|
state = SCHEDULER_OP_STATE_RPC;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// initiate a fetch of a project's master URL file
|
|
|
|
//
|
|
|
|
int SCHEDULER_OP::init_master_fetch(PROJECT* p) {
|
|
|
|
int retval;
|
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
project = p;
|
2003-07-02 02:02:18 +00:00
|
|
|
scope_messages.printf("SCHEDULER_OP::init_master_fetch(): Fetching master file for %s\n", project->master_url);
|
2004-09-26 04:16:52 +00:00
|
|
|
http_op.set_proxy(&gstate.proxy_info);
|
2002-08-07 22:52:10 +00:00
|
|
|
retval = http_op.init_get(project->master_url, MASTER_FILE_NAME, true);
|
2002-07-15 05:34:32 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
retval = http_ops->insert(&http_op);
|
|
|
|
if (retval) return retval;
|
|
|
|
state = SCHEDULER_OP_STATE_GET_MASTER;
|
2002-06-21 06:52:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-11-28 19:19:11 +00:00
|
|
|
static void trim(STRING256& str) {
|
2003-08-20 23:11:15 +00:00
|
|
|
char* last_char = str.text + strlen(str.text);
|
|
|
|
while (isspace(*(last_char-1)) && last_char > str.text) {
|
|
|
|
--last_char;
|
|
|
|
}
|
|
|
|
*last_char = '\0';
|
|
|
|
char *first_char = str.text;
|
|
|
|
if (isspace(*first_char)) {
|
2003-11-28 19:19:11 +00:00
|
|
|
while (isspace(*first_char)) {
|
2003-08-20 23:11:15 +00:00
|
|
|
++first_char;
|
2003-11-28 19:19:11 +00:00
|
|
|
}
|
2003-08-20 23:11:15 +00:00
|
|
|
char* dest = str.text;
|
|
|
|
while (*first_char) {
|
|
|
|
*dest++ = *first_char++;
|
|
|
|
}
|
|
|
|
*dest = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
// parse a master file.
|
|
|
|
//
|
2002-07-15 05:34:32 +00:00
|
|
|
int SCHEDULER_OP::parse_master_file(vector<STRING256> &urls) {
|
2002-06-21 06:52:47 +00:00
|
|
|
char buf[256];
|
|
|
|
STRING256 str;
|
|
|
|
FILE* f;
|
2003-06-09 23:50:49 +00:00
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
f = fopen(MASTER_FILE_NAME, "r");
|
|
|
|
if (!f) {
|
2003-07-01 22:44:58 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "Can't open master file\n");
|
2002-06-21 06:52:47 +00:00
|
|
|
return ERR_FOPEN;
|
|
|
|
}
|
|
|
|
project->scheduler_urls.clear();
|
|
|
|
while (fgets(buf, 256, f)) {
|
2002-09-22 23:27:14 +00:00
|
|
|
if (parse_str(buf, "<scheduler>", str.text, sizeof(str.text))) {
|
2003-08-20 23:11:15 +00:00
|
|
|
trim(str);
|
2002-07-15 05:34:32 +00:00
|
|
|
urls.push_back(str);
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-29 04:19:51 +00:00
|
|
|
fclose(f);
|
2003-07-02 02:02:18 +00:00
|
|
|
scope_messages.printf("SCHEDULER_OP::parse_master_file(): got %d scheduler URLs\n", (int)urls.size());
|
2003-06-09 23:50:49 +00:00
|
|
|
|
2003-01-02 23:12:05 +00:00
|
|
|
// couldn't find any urls in the master file?
|
|
|
|
//
|
|
|
|
if ((int) urls.size() == 0) {
|
2003-10-21 18:18:41 +00:00
|
|
|
return ERR_XML_PARSE;
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// A master file has just been read.
|
|
|
|
// transfer scheduler urls to project.
|
|
|
|
// Return true if any of them is new
|
|
|
|
//
|
|
|
|
bool SCHEDULER_OP::update_urls(PROJECT& project, vector<STRING256> &urls) {
|
|
|
|
unsigned int i, j;
|
|
|
|
bool found, any_new;
|
|
|
|
|
|
|
|
any_new = false;
|
|
|
|
for (i=0; i<urls.size(); i++) {
|
|
|
|
found = false;
|
|
|
|
for (j=0; j<project.scheduler_urls.size(); j++) {
|
|
|
|
if (!strcmp(urls[i].text, project.scheduler_urls[i].text)) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) any_new = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
project.scheduler_urls.clear();
|
|
|
|
for (i=0; i<urls.size(); i++) {
|
|
|
|
project.scheduler_urls.push_back(urls[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return any_new;
|
|
|
|
}
|
|
|
|
|
|
|
|
// poll routine. If an operation is in progress, check for completion
|
|
|
|
//
|
2002-08-22 22:28:51 +00:00
|
|
|
bool SCHEDULER_OP::poll() {
|
2003-01-02 23:12:05 +00:00
|
|
|
int retval, nresults;
|
2002-07-15 05:34:32 +00:00
|
|
|
vector<STRING256> urls;
|
2003-01-02 23:12:05 +00:00
|
|
|
bool changed, scheduler_op_done;
|
2003-05-23 17:20:37 +00:00
|
|
|
bool action = false, err = false;
|
2004-02-02 22:17:48 +00:00
|
|
|
char err_msg[256], *err_url=NULL;
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
switch(state) {
|
|
|
|
case SCHEDULER_OP_STATE_GET_MASTER:
|
2002-07-15 05:34:32 +00:00
|
|
|
// here we're fetching the master file for a project
|
|
|
|
//
|
2002-06-21 06:52:47 +00:00
|
|
|
if (http_op.http_op_state == HTTP_STATE_DONE) {
|
2002-08-25 07:54:33 +00:00
|
|
|
action = true;
|
2002-07-15 05:34:32 +00:00
|
|
|
project->master_url_fetch_pending = false;
|
2003-02-28 22:39:36 +00:00
|
|
|
gstate.set_client_state_dirty("master URL fetch done");
|
2002-06-21 06:52:47 +00:00
|
|
|
http_ops->remove(&http_op);
|
2002-07-15 05:34:32 +00:00
|
|
|
if (http_op.http_op_retval == 0) {
|
2003-10-19 02:54:35 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"SCHEDULER_OP::poll(): Got master file from %s; parsing\n",
|
|
|
|
project->master_url
|
|
|
|
);
|
2002-07-15 05:34:32 +00:00
|
|
|
retval = parse_master_file(urls);
|
2003-01-02 23:12:05 +00:00
|
|
|
if (retval) {
|
|
|
|
// master file parse failed.
|
|
|
|
//
|
2003-05-21 17:59:10 +00:00
|
|
|
if (project->tentative) {
|
2003-10-19 02:54:35 +00:00
|
|
|
PROJECT* project_temp = project;
|
|
|
|
project = 0; // keep detach(0) from removing HTTP OP
|
2004-06-01 22:19:24 +00:00
|
|
|
state = SCHEDULER_OP_STATE_IDLE; // avoid double remove
|
2003-10-19 02:54:35 +00:00
|
|
|
project_add_failed(project_temp);
|
2003-06-06 22:08:46 +00:00
|
|
|
err = true;
|
2003-05-21 17:59:10 +00:00
|
|
|
} else {
|
|
|
|
project->master_fetch_failures++;
|
|
|
|
backoff(project, "Master file parse failed\n");
|
|
|
|
err_url = project->master_url;
|
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
} else {
|
|
|
|
// everything succeeded. Clear error counters
|
|
|
|
//
|
2002-07-15 05:34:32 +00:00
|
|
|
changed = update_urls(*project, urls);
|
|
|
|
if (changed) {
|
|
|
|
project->min_rpc_time = 0;
|
|
|
|
project->nrpc_failures = 0;
|
2002-11-19 22:57:05 +00:00
|
|
|
project->master_fetch_failures = 0;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
} else {
|
2003-01-02 23:12:05 +00:00
|
|
|
// master file fetch failed.
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2003-01-02 23:12:05 +00:00
|
|
|
project->master_fetch_failures++;
|
2002-11-19 22:57:05 +00:00
|
|
|
backoff(project, "Master file fetch failed\n");
|
2002-12-12 22:55:56 +00:00
|
|
|
err_url = project->master_url;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
|
2004-09-22 22:09:54 +00:00
|
|
|
// Done with master file fetch.
|
|
|
|
// If tentative project and don't have any schedulers,
|
2003-01-02 23:12:05 +00:00
|
|
|
// it may be the wrong URL. notify the user
|
|
|
|
//
|
2003-10-19 02:54:35 +00:00
|
|
|
if (!err && project->scheduler_urls.size() == 0) {
|
2003-05-13 18:55:07 +00:00
|
|
|
if (project->tentative) {
|
2004-06-01 22:19:24 +00:00
|
|
|
state = SCHEDULER_OP_STATE_IDLE; // avoid double remove
|
2003-05-13 18:55:07 +00:00
|
|
|
project_add_failed(project);
|
|
|
|
} else {
|
|
|
|
sprintf(err_msg,
|
|
|
|
"Could not contact any schedulers for %s.",
|
|
|
|
err_url
|
|
|
|
);
|
2003-06-03 22:47:15 +00:00
|
|
|
msg_printf(project, MSG_ERROR, err_msg);
|
2003-05-13 18:55:07 +00:00
|
|
|
project->master_fetch_failures++;
|
|
|
|
backoff(project, err_msg);
|
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
|
|
|
|
2003-05-13 18:55:07 +00:00
|
|
|
// See if need to read master file for another project;
|
|
|
|
// if not, we're done for now
|
2003-01-02 23:12:05 +00:00
|
|
|
//
|
2003-05-13 18:55:07 +00:00
|
|
|
if (!check_master_fetch_start()) {
|
2002-07-15 05:34:32 +00:00
|
|
|
state = SCHEDULER_OP_STATE_IDLE;
|
2003-07-02 02:02:18 +00:00
|
|
|
scope_messages.printf("SCHEDULER_OP::poll(): return to idle state\n");
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCHEDULER_OP_STATE_RPC:
|
2003-01-02 23:12:05 +00:00
|
|
|
|
|
|
|
// here we're doing a scheduler RPC
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
|
|
|
scheduler_op_done = false;
|
2002-06-21 06:52:47 +00:00
|
|
|
if (http_op.http_op_state == HTTP_STATE_DONE) {
|
2002-08-25 07:54:33 +00:00
|
|
|
action = true;
|
2002-06-21 06:52:47 +00:00
|
|
|
http_ops->remove(&http_op);
|
2002-07-15 05:34:32 +00:00
|
|
|
if (http_op.http_op_retval) {
|
2003-07-01 22:44:58 +00:00
|
|
|
if (log_flags.sched_ops) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
2003-07-15 23:59:20 +00:00
|
|
|
"Scheduler RPC to %s failed\n",
|
2002-07-15 05:34:32 +00:00
|
|
|
project->scheduler_urls[url_index].text
|
|
|
|
);
|
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
|
|
|
|
// scheduler RPC failed. Try another scheduler if one exists
|
|
|
|
//
|
2002-07-15 05:34:32 +00:00
|
|
|
url_index++;
|
|
|
|
if (url_index < project->scheduler_urls.size()) {
|
|
|
|
start_rpc();
|
|
|
|
} else {
|
2003-01-02 23:12:05 +00:00
|
|
|
backoff(project, "No schedulers responded");
|
2002-07-15 05:34:32 +00:00
|
|
|
if (must_get_work) {
|
2004-07-14 20:55:26 +00:00
|
|
|
int urgency = gstate.compute_work_requests();
|
2004-09-22 22:09:54 +00:00
|
|
|
project = gstate.next_project_need_work(project);
|
2004-07-14 20:55:26 +00:00
|
|
|
if (project && urgency != DONT_NEED_WORK) {
|
|
|
|
retval = init_op_project(project->work_request);
|
2002-07-15 05:34:32 +00:00
|
|
|
} else {
|
|
|
|
scheduler_op_done = true;
|
|
|
|
}
|
2003-05-13 18:55:07 +00:00
|
|
|
} else {
|
2002-07-15 05:34:32 +00:00
|
|
|
scheduler_op_done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2003-07-01 22:44:58 +00:00
|
|
|
if (log_flags.sched_ops) {
|
|
|
|
msg_printf(
|
|
|
|
project, MSG_INFO,
|
2003-07-15 23:59:20 +00:00
|
|
|
"Scheduler RPC to %s succeeded\n",
|
2002-07-15 05:34:32 +00:00
|
|
|
project->scheduler_urls[url_index].text
|
|
|
|
);
|
|
|
|
}
|
2004-05-13 04:43:42 +00:00
|
|
|
retval = gstate.handle_scheduler_reply(project, scheduler_url, nresults);
|
2003-01-02 23:12:05 +00:00
|
|
|
|
2003-05-13 18:55:07 +00:00
|
|
|
// if this was a tentative project and we didn't get user name,
|
|
|
|
// the account ID must be bad. Tell the user.
|
2003-01-02 23:12:05 +00:00
|
|
|
//
|
2003-05-13 18:55:07 +00:00
|
|
|
if (project->tentative) {
|
2004-05-13 04:43:42 +00:00
|
|
|
if (retval || strlen(project->user_name)==0) {
|
2004-06-01 22:19:24 +00:00
|
|
|
state = SCHEDULER_OP_STATE_IDLE; // avoid double remove
|
2004-05-13 04:43:42 +00:00
|
|
|
project_add_failed(project);
|
|
|
|
} else {
|
2003-05-13 18:55:07 +00:00
|
|
|
project->tentative = false;
|
2004-09-22 21:08:26 +00:00
|
|
|
retval = project->write_account_file();
|
|
|
|
if (retval) {
|
|
|
|
project_add_failed(project);
|
|
|
|
}
|
2004-08-11 15:50:51 +00:00
|
|
|
#if 0
|
2004-08-06 20:43:31 +00:00
|
|
|
gstate.calc_all_proj_size();
|
2004-08-11 15:50:51 +00:00
|
|
|
#endif
|
2003-05-13 18:55:07 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
} else {
|
2004-06-22 22:56:50 +00:00
|
|
|
switch (retval) {
|
|
|
|
case 0:
|
2004-05-13 04:43:42 +00:00
|
|
|
// if we asked for work and didn't get any,
|
|
|
|
// back off this project
|
|
|
|
//
|
|
|
|
if (must_get_work && nresults==0) {
|
|
|
|
backoff(project, "No work from project\n");
|
|
|
|
} else {
|
|
|
|
project->nrpc_failures = 0;
|
|
|
|
project->min_rpc_time = 0;
|
|
|
|
}
|
2004-06-22 22:56:50 +00:00
|
|
|
break;
|
|
|
|
case ERR_PROJECT_DOWN:
|
|
|
|
backoff(project, "Project is down");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
backoff(project, "Can't parse scheduler reply");
|
|
|
|
break;
|
2003-05-13 18:55:07 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
2003-06-09 23:50:49 +00:00
|
|
|
|
2003-01-02 23:12:05 +00:00
|
|
|
// if we didn't get all the work we needed,
|
|
|
|
// ask another project for work
|
|
|
|
//
|
2002-07-15 05:34:32 +00:00
|
|
|
if (must_get_work) {
|
2004-07-14 20:55:26 +00:00
|
|
|
int urgency = gstate.compute_work_requests();
|
|
|
|
if (urgency != DONT_NEED_WORK) {
|
2004-09-22 22:09:54 +00:00
|
|
|
project = gstate.next_project_need_work(project);
|
2002-07-15 05:34:32 +00:00
|
|
|
if (project) {
|
2004-07-14 20:55:26 +00:00
|
|
|
retval = init_op_project(project->work_request);
|
2002-07-15 05:34:32 +00:00
|
|
|
} else {
|
|
|
|
scheduler_op_done = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
scheduler_op_done = true;
|
|
|
|
}
|
2002-08-26 22:57:17 +00:00
|
|
|
} else {
|
2002-11-19 22:57:05 +00:00
|
|
|
scheduler_op_done = true;
|
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
|
|
|
|
// If no outstanding ops, see if need a master fetch
|
|
|
|
//
|
2002-07-15 05:34:32 +00:00
|
|
|
if (scheduler_op_done) {
|
2003-01-02 23:12:05 +00:00
|
|
|
project = gstate.next_project_master_pending();
|
2002-11-19 22:57:05 +00:00
|
|
|
if (project) {
|
2003-01-02 23:12:05 +00:00
|
|
|
retval = init_master_fetch(project);
|
|
|
|
if (retval) {
|
2003-07-02 02:02:18 +00:00
|
|
|
scope_messages.printf("SCHEDULER_OP::poll(): init_master_fetch failed.\n" );
|
2002-11-26 00:47:57 +00:00
|
|
|
backoff(project, "Scheduler op: init_master_fetch failed.\n" );
|
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
} else {
|
2002-11-19 22:57:05 +00:00
|
|
|
state = SCHEDULER_OP_STATE_IDLE;
|
2003-07-02 02:02:18 +00:00
|
|
|
scope_messages.printf("SCHEDULER_OP::poll(): return to idle state\n");
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
2002-08-22 22:28:51 +00:00
|
|
|
return action;
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
|
|
|
|
2002-07-07 20:39:24 +00:00
|
|
|
SCHEDULER_REPLY::SCHEDULER_REPLY() {
|
2002-09-29 00:32:11 +00:00
|
|
|
global_prefs_xml = 0;
|
|
|
|
project_prefs_xml = 0;
|
2002-07-07 20:39:24 +00:00
|
|
|
code_sign_key = 0;
|
|
|
|
code_sign_key_signature = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SCHEDULER_REPLY::~SCHEDULER_REPLY() {
|
2002-09-29 00:32:11 +00:00
|
|
|
if (global_prefs_xml) free(global_prefs_xml);
|
|
|
|
if (project_prefs_xml) free(project_prefs_xml);
|
2002-07-07 20:39:24 +00:00
|
|
|
if (code_sign_key) free(code_sign_key);
|
|
|
|
if (code_sign_key_signature) free(code_sign_key_signature);
|
|
|
|
}
|
|
|
|
|
2003-07-03 05:01:29 +00:00
|
|
|
int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
|
2002-07-15 05:34:32 +00:00
|
|
|
char buf[256], *p;
|
2004-09-23 22:27:41 +00:00
|
|
|
int retval, x;
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE mf;
|
2004-08-05 21:50:35 +00:00
|
|
|
char delete_file_name[256];
|
2004-06-12 04:45:36 +00:00
|
|
|
mf.init_file(in);
|
2002-08-15 21:21:08 +00:00
|
|
|
|
2004-05-18 22:47:08 +00:00
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
|
|
|
|
|
2003-02-18 23:07:48 +00:00
|
|
|
hostid = 0;
|
|
|
|
request_delay = 0;
|
2003-03-19 01:15:46 +00:00
|
|
|
strcpy(message, "");
|
|
|
|
strcpy(message_priority, "");
|
2002-09-29 00:32:11 +00:00
|
|
|
global_prefs_xml = 0;
|
|
|
|
project_prefs_xml = 0;
|
2003-03-19 01:15:46 +00:00
|
|
|
strcpy(host_venue, "");
|
2002-07-07 20:39:24 +00:00
|
|
|
code_sign_key = 0;
|
|
|
|
code_sign_key_signature = 0;
|
2004-07-06 04:01:15 +00:00
|
|
|
message_ack = false;
|
2004-06-22 22:56:50 +00:00
|
|
|
project_is_down = false;
|
2004-07-06 18:31:56 +00:00
|
|
|
send_file_list = false;
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
p = fgets(buf, 256, in);
|
2003-02-12 19:21:44 +00:00
|
|
|
if (!p) {
|
2003-07-03 05:01:29 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "SCHEDULER_REPLY::parse(): empty file\n");
|
2003-02-12 19:21:44 +00:00
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
// First part of content should either be tag (HTTP 1.0) or
|
2002-08-12 21:54:19 +00:00
|
|
|
// hex length of response (HTTP 1.1)
|
2002-08-15 20:50:15 +00:00
|
|
|
if (!match_tag(buf, "<scheduler_reply>")) {
|
2003-07-03 05:01:29 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "SCHEDULER_REPLY::parse(): bad first tag %s\n", buf);
|
2002-06-21 06:52:47 +00:00
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
while (fgets(buf, 256, in)) {
|
2002-08-12 21:54:19 +00:00
|
|
|
if (match_tag(buf, "<scheduler_reply>")) {
|
|
|
|
// Do nothing
|
2003-02-14 18:28:24 +00:00
|
|
|
} else if (match_tag(buf, "</scheduler_reply>")) return 0;
|
2004-09-23 22:27:41 +00:00
|
|
|
else if (parse_str(buf, "<project_name>", project->project_name, sizeof(project->project_name))) continue;
|
|
|
|
else if (parse_str(buf, "<user_name>", project->user_name, sizeof(project->user_name))) continue;
|
|
|
|
else if (parse_double(buf, "<user_total_credit>", project->user_total_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<user_expavg_credit>", project->user_expavg_credit)) continue;
|
|
|
|
else if (parse_int(buf, "<user_create_time>", (int&)project->user_create_time)) continue;
|
|
|
|
else if (parse_str(buf, "<team_name>", project->team_name, sizeof(project->team_name))) continue;
|
|
|
|
else if (parse_int(buf, "<hostid>", hostid)) {
|
|
|
|
project->hostid = hostid;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (parse_double(buf, "<host_total_credit>", project->host_total_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<host_expavg_credit>", project->host_expavg_credit)) continue;
|
2003-03-06 00:42:18 +00:00
|
|
|
else if (parse_str(buf, "<host_venue>", host_venue, sizeof(host_venue))) continue;
|
2004-09-23 22:27:41 +00:00
|
|
|
else if (parse_int(buf, "<host_create_time>", (int&)project->host_create_time)) continue;
|
2003-02-14 18:28:24 +00:00
|
|
|
else if (parse_int(buf, "<request_delay>", request_delay)) continue;
|
|
|
|
else if (match_tag(buf, "<global_preferences>")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2003-02-11 00:52:44 +00:00
|
|
|
in,
|
|
|
|
"</global_preferences>",
|
2003-02-11 19:41:08 +00:00
|
|
|
&global_prefs_xml
|
2003-02-11 00:52:44 +00:00
|
|
|
);
|
2002-09-29 00:32:11 +00:00
|
|
|
if (retval) return ERR_XML_PARSE;
|
2003-11-28 19:19:11 +00:00
|
|
|
msg_printf(project, MSG_INFO,
|
|
|
|
"General preferences have been updated\n"
|
|
|
|
);
|
2002-09-29 00:32:11 +00:00
|
|
|
} else if (match_tag(buf, "<project_preferences>")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2003-02-11 00:52:44 +00:00
|
|
|
in,
|
|
|
|
"</project_preferences>",
|
2003-02-11 19:41:08 +00:00
|
|
|
&project_prefs_xml
|
2003-02-11 00:52:44 +00:00
|
|
|
);
|
2002-06-21 06:52:47 +00:00
|
|
|
if (retval) return ERR_XML_PARSE;
|
2004-09-23 22:27:41 +00:00
|
|
|
#if 0
|
2004-08-05 21:50:35 +00:00
|
|
|
} else if (match_tag(buf, "<deletion_policy_priority/>")) {
|
2004-09-23 22:27:41 +00:00
|
|
|
project->deletion_policy_priority = true;
|
2004-08-05 21:50:35 +00:00
|
|
|
continue;
|
|
|
|
} else if (match_tag(buf, "<deletion_policy_expire>")) {
|
2004-09-23 22:27:41 +00:00
|
|
|
project->deletion_policy_expire = true;
|
2004-08-05 21:50:35 +00:00
|
|
|
continue;
|
2004-09-23 22:27:41 +00:00
|
|
|
#endif
|
2002-07-07 20:39:24 +00:00
|
|
|
} else if (match_tag(buf, "<code_sign_key>")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2003-02-11 00:52:44 +00:00
|
|
|
in,
|
|
|
|
"</code_sign_key>",
|
2003-02-11 19:41:08 +00:00
|
|
|
&code_sign_key
|
2003-02-11 00:52:44 +00:00
|
|
|
);
|
2002-07-11 01:09:53 +00:00
|
|
|
if (retval) {
|
2003-07-03 05:01:29 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "SCHEDULER_REPLY.parse(): xml parsing error\n");
|
2002-07-11 01:09:53 +00:00
|
|
|
return ERR_XML_PARSE;
|
2002-08-25 07:54:33 +00:00
|
|
|
}
|
2002-07-07 20:39:24 +00:00
|
|
|
} else if (match_tag(buf, "<code_sign_key_signature>")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2003-02-11 00:52:44 +00:00
|
|
|
in,
|
|
|
|
"</code_sign_key_signature>",
|
2003-02-11 19:41:08 +00:00
|
|
|
&code_sign_key_signature
|
2003-02-11 00:52:44 +00:00
|
|
|
);
|
2002-07-07 20:39:24 +00:00
|
|
|
if (retval) return ERR_XML_PARSE;
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<app>")) {
|
|
|
|
APP app;
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = app.parse(mf);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR, "Can't parse app in scheduler reply");
|
|
|
|
} else {
|
|
|
|
apps.push_back(app);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<file_info>")) {
|
|
|
|
FILE_INFO file_info;
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = file_info.parse(mf, true);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR, "Can't parse file info in scheduler reply");
|
|
|
|
} else {
|
|
|
|
file_infos.push_back(file_info);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<app_version>")) {
|
|
|
|
APP_VERSION av;
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = av.parse(mf);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR, "Can't parse app version in scheduler reply");
|
|
|
|
} else {
|
|
|
|
app_versions.push_back(av);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<workunit>")) {
|
|
|
|
WORKUNIT wu;
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = wu.parse(mf);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR, "Can't parse work unit in scheduler reply");
|
|
|
|
} else {
|
|
|
|
workunits.push_back(wu);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<result>")) {
|
|
|
|
RESULT result; // make sure this is here so constructor
|
|
|
|
// gets called each time
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = result.parse_server(mf);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR, "Can't parse result in scheduler reply");
|
|
|
|
} else {
|
|
|
|
results.push_back(result);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<result_ack>")) {
|
|
|
|
RESULT result;
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = result.parse_ack(in);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR, "Can't parse result ack in scheduler reply");
|
|
|
|
} else {
|
|
|
|
result_acks.push_back(result);
|
|
|
|
}
|
2004-08-05 21:50:35 +00:00
|
|
|
} else if (parse_str(buf, "<delete_file_info>", delete_file_name, sizeof(delete_file_name))) {
|
|
|
|
STRING256 delete_file;
|
|
|
|
strcpy(delete_file.text, delete_file_name);
|
|
|
|
file_deletes.push_back(delete_file);
|
2002-09-22 23:27:14 +00:00
|
|
|
} else if (parse_str(buf, "<message", message, sizeof(message))) {
|
|
|
|
parse_attr(buf, "priority", message_priority, sizeof(message_priority));
|
2002-06-21 06:52:47 +00:00
|
|
|
continue;
|
2004-07-06 04:01:15 +00:00
|
|
|
} else if (match_tag(buf, "<message_ack/>")) {
|
|
|
|
message_ack = true;
|
2004-06-22 22:56:50 +00:00
|
|
|
} else if (match_tag(buf, "<project_is_down/>")) {
|
|
|
|
project_is_down = true;
|
2004-04-19 20:56:57 +00:00
|
|
|
} else if (parse_str(buf, "<email_hash>", project->email_hash, sizeof(project->email_hash))) {
|
|
|
|
continue;
|
|
|
|
} else if (parse_str(buf, "<cross_project_id>", project->cross_project_id, sizeof(project->cross_project_id))) {
|
|
|
|
continue;
|
2004-05-12 21:21:09 +00:00
|
|
|
} else if (match_tag(buf, "<trickle_down>")) {
|
2004-05-15 22:09:26 +00:00
|
|
|
retval = gstate.handle_trickle_down(project, in);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR, "handle_trickle_down failed: %d\n", retval);
|
|
|
|
}
|
|
|
|
continue;
|
2004-09-23 22:27:41 +00:00
|
|
|
} else if (parse_int(buf, "<non_cpu_intensive>", x)) {
|
|
|
|
project->non_cpu_intensive = (!x);
|
2004-05-18 18:33:01 +00:00
|
|
|
continue;
|
2004-07-06 17:37:58 +00:00
|
|
|
} else if (match_tag(buf, "<request_file_list/>")) {
|
|
|
|
send_file_list = true;
|
|
|
|
} else if (strlen(buf)>1){
|
2004-05-18 22:47:08 +00:00
|
|
|
scope_messages.printf("SCHEDULER_REPLY::parse(): unrecognized %s\n", buf);
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-03 05:01:29 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "SCHEDULER_REPLY::parse(): no close tag\n");
|
2002-06-21 06:52:47 +00:00
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|