2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2002-06-21 06:52:47 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
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"
|
2005-03-10 22:05:42 +00:00
|
|
|
#include "filesys.h"
|
2003-01-02 23:12:05 +00:00
|
|
|
|
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) {
|
2005-03-10 00:43:22 +00:00
|
|
|
retval = init_master_fetch();
|
2003-05-13 18:55:07 +00:00
|
|
|
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-10-14 22:01:05 +00:00
|
|
|
// try to get work, from any project from which we need it
|
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
|
|
|
//
|
2005-05-09 04:49:56 +00:00
|
|
|
int SCHEDULER_OP::init_get_work(bool master_file_only, int urgency) {
|
2005-05-11 06:57:58 +00:00
|
|
|
int retval = 0;
|
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;
|
2005-05-09 04:49:56 +00:00
|
|
|
project = gstate.next_project_need_work(0, urgency);
|
2005-04-13 18:38:55 +00:00
|
|
|
if (project && !master_file_only) {
|
2004-07-14 20:55:26 +00:00
|
|
|
ns = project->work_request;
|
2004-10-14 22:01:05 +00:00
|
|
|
msg_printf(project, MSG_INFO, "Requesting %.2f seconds of work", ns);
|
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 {
|
2005-05-11 06:57:58 +00:00
|
|
|
bool ret = check_master_fetch_start();
|
|
|
|
retval = ret ? 1 : 0;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2002-11-16 00:36:31 +00:00
|
|
|
|
2005-05-11 06:57:58 +00:00
|
|
|
return retval;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2005-03-10 00:43:22 +00:00
|
|
|
retval = init_master_fetch();
|
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",
|
2005-03-09 23:47:45 +00:00
|
|
|
project->scheduler_urls[url_index].c_str(), retval
|
2003-01-02 23:12:05 +00:00
|
|
|
);
|
|
|
|
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) {
|
2004-10-25 20:16:30 +00:00
|
|
|
double 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
|
|
|
}
|
2004-10-25 20:16:30 +00:00
|
|
|
p->set_min_rpc_time(dtime() + exp_backoff);
|
2003-07-03 00:48:43 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2005-01-24 22:13:32 +00:00
|
|
|
// One of the following errors occurred:
|
|
|
|
// - connection failure in fetching master file
|
|
|
|
// - connection failure in scheduler RPC
|
|
|
|
// - got master file, but it didn't have any <scheduler> elements
|
|
|
|
// - tried all schedulers, none responded
|
|
|
|
// - sent nonzero work request, got a reply with no work
|
|
|
|
//
|
|
|
|
// Back off contacting this project's schedulers,
|
|
|
|
// and output an error msg if needed
|
2002-10-16 23:50:41 +00:00
|
|
|
//
|
2005-02-16 23:17:43 +00:00
|
|
|
void SCHEDULER_OP::backoff(PROJECT* p, const 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);
|
2005-05-09 04:49:56 +00:00
|
|
|
p->long_term_debt -= (p->min_rpc_time - dtime()) / gstate.global_prefs.max_projects_on_client;
|
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
|
|
|
|
2005-03-09 23:47:45 +00:00
|
|
|
safe_strcpy(scheduler_url, project->scheduler_urls[url_index].c_str());
|
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,
|
2005-05-05 18:35:25 +00:00
|
|
|
"Sending scheduler request to %s\n", scheduler_url
|
2003-07-01 22:44:58 +00:00
|
|
|
);
|
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
|
|
|
|
//
|
2005-03-10 00:43:22 +00:00
|
|
|
int SCHEDULER_OP::init_master_fetch() {
|
2002-07-15 05:34:32 +00:00
|
|
|
int retval;
|
2005-03-10 00:43:22 +00:00
|
|
|
char master_filename[256];
|
|
|
|
|
|
|
|
get_master_filename(*project, master_filename);
|
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_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);
|
2005-03-10 00:43:22 +00:00
|
|
|
retval = http_op.init_get(project->master_url, master_filename, 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// parse a master file.
|
|
|
|
//
|
2005-03-09 23:28:37 +00:00
|
|
|
int SCHEDULER_OP::parse_master_file(vector<std::string> &urls) {
|
2002-06-21 06:52:47 +00:00
|
|
|
char buf[256];
|
2005-03-10 00:43:22 +00:00
|
|
|
char master_filename[256];
|
2005-03-09 23:28:37 +00:00
|
|
|
std::string str;
|
2002-06-21 06:52:47 +00:00
|
|
|
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
|
|
|
|
2005-03-10 00:43:22 +00:00
|
|
|
get_master_filename(*project, master_filename);
|
2005-03-10 22:05:42 +00:00
|
|
|
f = boinc_fopen(master_filename, "r");
|
2002-06-21 06:52:47 +00:00
|
|
|
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)) {
|
2005-05-05 20:51:54 +00:00
|
|
|
|
|
|
|
// allow for the possibility of > 1 tag per line here
|
|
|
|
// (UMTS may collapse lines)
|
|
|
|
//
|
|
|
|
char* p = buf;
|
|
|
|
while (p && parse_str(p, "<scheduler>", str)) {
|
2005-03-10 00:43:22 +00:00
|
|
|
strip_whitespace(str);
|
2002-07-15 05:34:32 +00:00
|
|
|
urls.push_back(str);
|
2005-05-05 20:51:54 +00:00
|
|
|
p = strstr(p, "</scheduler>");
|
|
|
|
if (p) p += strlen("</schedule>");
|
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
|
|
|
|
2005-03-10 00:43:22 +00:00
|
|
|
// couldn't find any scheduler URLs in the master file?
|
2003-01-02 23:12:05 +00:00
|
|
|
//
|
|
|
|
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.
|
2005-03-09 23:28:37 +00:00
|
|
|
// transfer scheduler URLs to project.
|
2002-07-15 05:34:32 +00:00
|
|
|
// Return true if any of them is new
|
|
|
|
//
|
2005-03-09 23:28:37 +00:00
|
|
|
bool SCHEDULER_OP::update_urls(vector<std::string> &urls) {
|
2002-07-15 05:34:32 +00:00
|
|
|
unsigned int i, j;
|
|
|
|
bool found, any_new;
|
|
|
|
|
|
|
|
any_new = false;
|
|
|
|
for (i=0; i<urls.size(); i++) {
|
|
|
|
found = false;
|
2005-02-16 23:17:43 +00:00
|
|
|
for (j=0; j<project->scheduler_urls.size(); j++) {
|
2005-03-09 23:28:37 +00:00
|
|
|
if (urls[i] == project->scheduler_urls[j]) {
|
2002-07-15 05:34:32 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) any_new = true;
|
|
|
|
}
|
|
|
|
|
2005-02-16 23:17:43 +00:00
|
|
|
project->scheduler_urls.clear();
|
2002-07-15 05:34:32 +00:00
|
|
|
for (i=0; i<urls.size(); i++) {
|
2005-02-16 23:17:43 +00:00
|
|
|
project->scheduler_urls.push_back(urls[i]);
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2005-03-09 23:28:37 +00:00
|
|
|
vector<std::string> 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
|
|
|
|
//
|
2005-02-16 23:17:43 +00:00
|
|
|
changed = update_urls(urls);
|
2002-07-15 05:34:32 +00:00
|
|
|
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,
|
2005-05-05 18:35:25 +00:00
|
|
|
"Scheduler request to %s failed\n",
|
2005-03-09 23:28:37 +00:00
|
|
|
project->scheduler_urls[url_index].c_str()
|
2002-07-15 05:34:32 +00:00
|
|
|
);
|
|
|
|
}
|
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();
|
2005-05-09 04:49:56 +00:00
|
|
|
if (urgency != WORK_FETCH_DONT_NEED) {
|
|
|
|
project = gstate.next_project_need_work(project, urgency);
|
|
|
|
if (project) {
|
|
|
|
retval = init_op_project(project->work_request);
|
|
|
|
} else {
|
|
|
|
scheduler_op_done = true;
|
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
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,
|
2005-05-05 18:35:25 +00:00
|
|
|
"Scheduler request to %s succeeded\n",
|
2005-03-09 23:28:37 +00:00
|
|
|
project->scheduler_urls[url_index].c_str()
|
2002-07-15 05:34:32 +00:00
|
|
|
);
|
|
|
|
}
|
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 {
|
2005-01-24 22:15:39 +00:00
|
|
|
project->nrpc_failures = 0;
|
2004-05-13 04:43:42 +00:00
|
|
|
}
|
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();
|
2005-05-06 19:09:41 +00:00
|
|
|
if (urgency != WORK_FETCH_DONT_NEED) {
|
2005-05-09 04:49:56 +00:00
|
|
|
project = gstate.next_project_need_work(project, urgency);
|
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) {
|
2005-03-10 00:43:22 +00:00
|
|
|
retval = init_master_fetch();
|
2003-01-02 23:12:05 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2004-09-27 22:55:56 +00:00
|
|
|
// parse a scheduler reply.
|
|
|
|
// Some of the items go into the SCHEDULER_REPLY object.
|
|
|
|
// Others are copied straight to the PROJECT
|
|
|
|
//
|
2003-07-03 05:01:29 +00:00
|
|
|
int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
|
2005-01-31 22:19:03 +00:00
|
|
|
char buf[256], msg_buf[1024], pri_buf[256];
|
2004-09-23 22:27:41 +00:00
|
|
|
int retval, x;
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE mf;
|
2005-03-09 23:28:37 +00:00
|
|
|
std::string delete_file_name;
|
2004-06-12 04:45:36 +00:00
|
|
|
mf.init_file(in);
|
2004-10-15 19:19:03 +00:00
|
|
|
bool found_start_tag = false;
|
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;
|
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;
|
2005-01-31 22:19:03 +00:00
|
|
|
messages.clear();
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2004-10-15 19:19:03 +00:00
|
|
|
// First line should either be tag (HTTP 1.0) or
|
2002-08-12 21:54:19 +00:00
|
|
|
// hex length of response (HTTP 1.1)
|
2004-10-15 19:19:03 +00:00
|
|
|
//
|
2002-06-21 06:52:47 +00:00
|
|
|
while (fgets(buf, 256, in)) {
|
2004-10-15 19:19:03 +00:00
|
|
|
if (!found_start_tag) {
|
|
|
|
if (match_tag(buf, "<scheduler_reply")) {
|
|
|
|
found_start_tag = true;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2005-02-18 23:43:28 +00:00
|
|
|
if (match_tag(buf, "</scheduler_reply>")) {
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
// update statistics after parsing the scheduler reply
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
// check if vector is empty or we have a new day
|
|
|
|
if (project->statistics.empty() || project->statistics.back().day!=dday()) {
|
|
|
|
// check if max. number of statistics already saved
|
|
|
|
while (project->statistics.size()>30) {
|
|
|
|
project->statistics.erase(project->statistics.begin());
|
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
project->statistics.push_back(STATISTIC());
|
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
project->statistics.back().day=dday();
|
|
|
|
project->statistics.back().user_total_credit=project->user_total_credit;
|
|
|
|
project->statistics.back().user_expavg_credit=project->user_expavg_credit;
|
|
|
|
project->statistics.back().host_total_credit=project->host_total_credit;
|
|
|
|
project->statistics.back().host_expavg_credit=project->host_expavg_credit;
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
project->write_statistics_file();
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-13 18:38:55 +00:00
|
|
|
return 0;
|
2005-02-18 23:43:28 +00:00
|
|
|
}
|
2004-09-23 22:27:41 +00:00
|
|
|
else if (parse_str(buf, "<project_name>", project->project_name, sizeof(project->project_name))) continue;
|
2005-04-13 23:28:47 +00:00
|
|
|
else if (parse_str(buf, "<user_name>", project->user_name, sizeof(project->user_name))) continue;
|
2004-09-23 22:27:41 +00:00
|
|
|
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;
|
2005-02-08 20:12:43 +00:00
|
|
|
else if (parse_double(buf, "<user_create_time>", project->user_create_time)) continue;
|
2005-04-13 23:28:47 +00:00
|
|
|
else if (parse_str(buf, "<team_name>", project->team_name, sizeof(project->team_name))) continue;
|
2004-10-01 08:15:58 +00:00
|
|
|
else if (parse_int(buf, "<hostid>", hostid)) continue;
|
2004-09-23 22:27:41 +00:00
|
|
|
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;
|
2005-02-08 20:12:43 +00:00
|
|
|
else if (parse_double(buf, "<host_create_time>", project->host_create_time)) continue;
|
2004-10-25 20:16:30 +00:00
|
|
|
else if (parse_double(buf, "<request_delay>", request_delay)) continue;
|
2003-02-14 18:28:24 +00:00
|
|
|
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-27 19:44:40 +00:00
|
|
|
} else if (match_tag(buf, "<gui_urls>")) {
|
|
|
|
std::string foo;
|
|
|
|
retval = copy_element_contents(in, "</gui_urls>", foo);
|
|
|
|
if (!retval) {
|
|
|
|
project->gui_urls = "<gui_urls>\n"+foo+"</gui_urls>\n";
|
|
|
|
}
|
|
|
|
continue;
|
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) {
|
2005-02-23 06:19:20 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't parse code sign key in scheduler reply: %d",
|
|
|
|
retval
|
|
|
|
);
|
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) {
|
2005-02-23 06:19:20 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't parse app in scheduler reply: %d", retval
|
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} 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) {
|
2005-02-23 06:19:20 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't parse file info in scheduler reply: %d", retval
|
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} 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) {
|
2005-02-23 06:19:20 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't parse app version in scheduler reply: %d", retval
|
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} 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) {
|
2005-02-23 06:19:20 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't parse work unit in scheduler reply: %d", retval
|
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} 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) {
|
2005-02-23 06:19:20 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't parse result in scheduler reply: %d", retval
|
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} 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) {
|
2005-02-23 06:19:20 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't parse result ack in scheduler reply: %d", retval
|
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} else {
|
|
|
|
result_acks.push_back(result);
|
|
|
|
}
|
2005-03-09 23:28:37 +00:00
|
|
|
} else if (parse_str(buf, "<delete_file_info>", delete_file_name)) {
|
|
|
|
file_deletes.push_back(delete_file_name);
|
2005-01-31 22:19:03 +00:00
|
|
|
} else if (parse_str(buf, "<message", msg_buf, sizeof(msg_buf))) {
|
|
|
|
parse_attr(buf, "priority", pri_buf, sizeof(pri_buf));
|
|
|
|
USER_MESSAGE um(msg_buf, pri_buf);
|
|
|
|
messages.push_back(um);
|
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) {
|
2005-02-23 06:19:20 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"handle_trickle_down failed: %d\n", retval
|
|
|
|
);
|
2004-05-15 22:09:26 +00:00
|
|
|
}
|
|
|
|
continue;
|
2004-11-22 22:58:41 +00:00
|
|
|
} else if (match_tag(buf, "<non_cpu_intensive/>")) {
|
|
|
|
project->non_cpu_intensive = true;
|
|
|
|
continue;
|
2004-09-23 22:27:41 +00:00
|
|
|
} else if (parse_int(buf, "<non_cpu_intensive>", x)) {
|
2004-11-23 07:45:11 +00:00
|
|
|
project->non_cpu_intensive = (x != 0);
|
2004-05-18 18:33:01 +00:00
|
|
|
continue;
|
2004-11-22 22:58:41 +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
|
|
|
}
|
|
|
|
}
|
2004-10-15 19:19:03 +00:00
|
|
|
if (found_start_tag) {
|
|
|
|
msg_printf(project, MSG_ERROR, "No close tag in scheduler reply\n");
|
|
|
|
} else {
|
|
|
|
msg_printf(project, MSG_ERROR, "No start tag in scheduler reply\n");
|
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-31 22:19:03 +00:00
|
|
|
USER_MESSAGE::USER_MESSAGE(char* m, char* p) {
|
|
|
|
message = m;
|
|
|
|
priority = p;
|
|
|
|
}
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_11c806525b = "$Id$";
|