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-08 21:30:47 +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-08 21:30:47 +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-12-03 18:57:40 +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.,
|
2007-10-09 11:35:47 +00:00
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-12-03 18:57:40 +00:00
|
|
|
|
|
|
|
// Parse a server configuration file
|
|
|
|
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstring>
|
2003-10-03 06:46:22 +00:00
|
|
|
#include <string>
|
2004-08-03 21:51:30 +00:00
|
|
|
#include <unistd.h>
|
2002-10-03 18:33:46 +00:00
|
|
|
|
|
|
|
#include "parse.h"
|
|
|
|
#include "error_numbers.h"
|
|
|
|
|
2006-06-07 04:10:04 +00:00
|
|
|
#include "sched_msgs.h"
|
2007-04-18 20:49:58 +00:00
|
|
|
#include "sched_util.h"
|
2003-08-15 00:45:25 +00:00
|
|
|
#include "sched_config.h"
|
2002-10-03 18:33:46 +00:00
|
|
|
|
2004-07-03 21:38:22 +00:00
|
|
|
#ifdef _USING_FCGI_
|
|
|
|
#include "fcgi_stdio.h"
|
|
|
|
#endif
|
|
|
|
|
2003-09-02 21:16:55 +00:00
|
|
|
const char* CONFIG_FILE = "config.xml";
|
2003-07-08 21:30:47 +00:00
|
|
|
|
2008-02-25 18:05:04 +00:00
|
|
|
SCHED_CONFIG config;
|
|
|
|
|
2008-02-21 20:10:10 +00:00
|
|
|
const int MAX_NCPUS = 8;
|
|
|
|
// max multiplier for daily_result_quota and max_wus_in_progress;
|
|
|
|
// need to change as multicore processors expand
|
|
|
|
|
2006-05-25 05:22:10 +00:00
|
|
|
int SCHED_CONFIG::parse(FILE* f) {
|
2008-02-25 18:05:04 +00:00
|
|
|
char tag[1024], buf[256];
|
2006-08-21 22:25:21 +00:00
|
|
|
bool is_tag;
|
2006-08-22 21:52:44 +00:00
|
|
|
MIOFILE mf;
|
|
|
|
XML_PARSER xp(&mf);
|
2008-02-25 18:05:04 +00:00
|
|
|
int retval;
|
|
|
|
regex_t re;
|
2006-05-25 05:22:10 +00:00
|
|
|
|
2006-08-22 21:52:44 +00:00
|
|
|
mf.init_file(f);
|
2006-05-25 05:22:10 +00:00
|
|
|
max_wus_to_send = 10;
|
|
|
|
default_disk_max_used_gb = 100.;
|
|
|
|
default_disk_max_used_pct = 50.;
|
|
|
|
default_disk_min_free_gb = .001;
|
2008-02-21 21:00:58 +00:00
|
|
|
sched_debug_level = MSG_NORMAL;
|
|
|
|
fuh_debug_level = MSG_NORMAL;
|
2007-06-27 20:09:18 +00:00
|
|
|
strcpy(httpd_user, "apache");
|
2008-02-21 20:10:10 +00:00
|
|
|
max_ncpus = MAX_NCPUS;
|
2008-03-18 21:22:44 +00:00
|
|
|
debug_version_select = false;
|
2006-08-21 22:25:21 +00:00
|
|
|
|
|
|
|
if (!xp.parse_start("boinc")) return ERR_XML_PARSE;
|
|
|
|
if (!xp.parse_start("config")) return ERR_XML_PARSE;
|
2006-08-23 03:34:30 +00:00
|
|
|
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
2006-08-21 22:25:21 +00:00
|
|
|
if (!is_tag) {
|
|
|
|
fprintf(stderr, "SCHED_CONFIG::parse(): unexpected text %s\n", tag);
|
|
|
|
continue;
|
|
|
|
}
|
2006-05-25 05:22:10 +00:00
|
|
|
if (!strcmp(tag, "/config")) {
|
|
|
|
char hostname[256];
|
|
|
|
gethostname(hostname, 256);
|
|
|
|
if (!strcmp(hostname, db_host)) strcpy(db_host, "localhost");
|
|
|
|
return 0;
|
|
|
|
}
|
2007-06-27 20:09:18 +00:00
|
|
|
if (xp.parse_str(tag, "master_url", master_url, sizeof(master_url))) continue;
|
|
|
|
if (xp.parse_str(tag, "long_name", long_name, sizeof(long_name))) continue;
|
|
|
|
if (xp.parse_str(tag, "db_name", db_name, sizeof(db_name))) continue;
|
|
|
|
if (xp.parse_str(tag, "db_user", db_user, sizeof(db_user))) continue;
|
|
|
|
if (xp.parse_str(tag, "db_passwd", db_passwd, sizeof(db_passwd))) continue;
|
|
|
|
if (xp.parse_str(tag, "db_host", db_host, sizeof(db_host))) continue;
|
|
|
|
if (xp.parse_int(tag, "shmem_key", shmem_key)) continue;
|
|
|
|
if (xp.parse_str(tag, "key_dir", key_dir, sizeof(key_dir))) continue;
|
|
|
|
if (xp.parse_str(tag, "download_url", download_url, sizeof(download_url))) continue;
|
|
|
|
if (xp.parse_str(tag, "download_dir", download_dir, sizeof(download_dir))) continue;
|
|
|
|
if (xp.parse_str(tag, "upload_url", upload_url, sizeof(upload_url))) continue;
|
|
|
|
if (xp.parse_str(tag, "upload_dir", upload_dir, sizeof(upload_dir))) continue;
|
|
|
|
if (xp.parse_str(tag, "sched_lockfile_dir", sched_lockfile_dir, sizeof(sched_lockfile_dir))) continue;
|
|
|
|
if (xp.parse_bool(tag, "one_result_per_user_per_wu", one_result_per_user_per_wu)) continue;
|
|
|
|
if (xp.parse_bool(tag, "one_result_per_host_per_wu", one_result_per_host_per_wu)) continue;
|
|
|
|
if (xp.parse_bool(tag, "non_cpu_intensive", non_cpu_intensive)) continue;
|
|
|
|
if (xp.parse_bool(tag, "verify_files_on_app_start", verify_files_on_app_start)) continue;
|
|
|
|
if (xp.parse_int(tag, "homogeneous_redundancy", homogeneous_redundancy)) continue;
|
|
|
|
if (xp.parse_bool(tag, "locality_scheduling", locality_scheduling)) continue;
|
|
|
|
if (xp.parse_bool(tag, "locality_scheduling_sorted_order", locality_scheduling_sorted_order)) continue;
|
|
|
|
if (xp.parse_bool(tag, "msg_to_host", msg_to_host)) continue;
|
|
|
|
if (xp.parse_bool(tag, "ignore_upload_certificates", ignore_upload_certificates)) continue;
|
|
|
|
if (xp.parse_bool(tag, "dont_generate_upload_certificates", dont_generate_upload_certificates)) continue;
|
|
|
|
if (xp.parse_bool(tag, "ignore_delay_bound", ignore_delay_bound)) continue;
|
|
|
|
if (xp.parse_int(tag, "min_sendwork_interval", min_sendwork_interval)) continue;
|
|
|
|
if (xp.parse_int(tag, "max_wus_to_send", max_wus_to_send)) continue;
|
|
|
|
if (xp.parse_int(tag, "max_wus_in_progress", max_wus_in_progress)) continue;
|
|
|
|
if (xp.parse_int(tag, "daily_result_quota", daily_result_quota)) continue;
|
|
|
|
if (xp.parse_int(tag, "uldl_dir_fanout", uldl_dir_fanout)) continue;
|
|
|
|
if (xp.parse_int(tag, "locality_scheduling_wait_period", locality_scheduling_wait_period)) continue;
|
|
|
|
if (xp.parse_int(tag, "locality_scheduling_send_timeout", locality_scheduling_send_timeout)) continue;
|
|
|
|
if (xp.parse_int(tag, "min_core_client_version", min_core_client_version)) continue;
|
|
|
|
if (xp.parse_int(tag, "min_core_client_version_announced", min_core_client_version_announced)) continue;
|
|
|
|
if (xp.parse_int(tag, "min_core_client_upgrade_deadline", min_core_client_upgrade_deadline)) continue;
|
|
|
|
if (xp.parse_bool(tag, "choose_download_url_by_timezone", choose_download_url_by_timezone)) continue;
|
|
|
|
if (xp.parse_bool(tag, "cache_md5_info", cache_md5_info)) continue;
|
|
|
|
if (xp.parse_bool(tag, "nowork_skip", nowork_skip)) continue;
|
|
|
|
if (xp.parse_bool(tag, "resend_lost_results", resend_lost_results)) continue;
|
|
|
|
if (xp.parse_bool(tag, "send_result_abort", send_result_abort)) continue;
|
|
|
|
if (xp.parse_double(tag, "fp_benchmark_weight", fp_benchmark_weight)) {
|
2006-08-21 19:41:25 +00:00
|
|
|
if (fp_benchmark_weight < 0 || fp_benchmark_weight > 1) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"CONFIG FILE ERROR: fp_benchmark_weight outside of 0..1"
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
use_benchmark_weights = true;
|
|
|
|
}
|
2007-06-27 20:09:18 +00:00
|
|
|
continue;
|
2006-05-25 05:22:10 +00:00
|
|
|
}
|
2007-06-27 20:09:18 +00:00
|
|
|
if (xp.parse_double(tag, "default_disk_max_used_gb", default_disk_max_used_gb)) continue;
|
|
|
|
if (xp.parse_double(tag, "default_disk_max_used_pct", default_disk_max_used_pct)) continue;
|
|
|
|
if (xp.parse_double(tag, "default_disk_min_free_gb", default_disk_min_free_gb)) continue;
|
|
|
|
if (xp.parse_str(tag, "symstore", symstore, sizeof(symstore))) continue;
|
|
|
|
if (xp.parse_double(tag, "next_rpc_delay", next_rpc_delay)) continue;
|
|
|
|
if (xp.parse_int(tag, "sched_debug_level", sched_debug_level)) continue;
|
|
|
|
if (xp.parse_int(tag, "fuh_debug_level", fuh_debug_level)) continue;
|
|
|
|
if (xp.parse_int(tag, "reliable_max_avg_turnaround", reliable_max_avg_turnaround)) continue;
|
2008-03-07 21:13:01 +00:00
|
|
|
if (xp.parse_double(tag, "reliable_max_error_rate", reliable_max_error_rate)) continue;
|
2007-06-27 20:09:18 +00:00
|
|
|
if (xp.parse_int(tag, "reliable_priority_on_over", reliable_priority_on_over)) continue;
|
|
|
|
if (xp.parse_int(tag, "reliable_priority_on_over_except_error", reliable_priority_on_over_except_error)) continue;
|
|
|
|
if (xp.parse_int(tag, "reliable_on_priority", reliable_on_priority)) continue;
|
|
|
|
if (xp.parse_double(tag, "reliable_reduced_delay_bound", reliable_reduced_delay_bound)) continue;
|
|
|
|
if (xp.parse_int(tag, "grace_period_hours", grace_period_hours)) continue;
|
|
|
|
if (xp.parse_int(tag, "delete_delay_hours", delete_delay_hours)) continue;
|
2008-03-27 21:39:02 +00:00
|
|
|
if (xp.parse_bool(tag, "distinct_beta_apps", distinct_beta_apps)) continue;
|
2007-06-27 20:09:18 +00:00
|
|
|
if (xp.parse_bool(tag, "workload_sim", workload_sim)) continue;
|
|
|
|
if (xp.parse_bool(tag, "ended", ended)) continue;
|
|
|
|
if (xp.parse_int(tag, "shmem_work_items", shmem_work_items)) continue;
|
|
|
|
if (xp.parse_int(tag, "feeder_query_size", feeder_query_size)) continue;
|
2008-03-07 21:13:01 +00:00
|
|
|
if (xp.parse_int(tag, "granted_credit_ramp_up", granted_credit_ramp_up)) continue;
|
|
|
|
if (xp.parse_double(tag, "granted_credit_weight", granted_credit_weight)) continue;
|
|
|
|
|
2008-02-25 18:05:04 +00:00
|
|
|
if (xp.parse_bool(tag, "no_darwin_6", no_darwin_6)) {
|
|
|
|
if (no_darwin_6) {
|
|
|
|
regcomp(&re, ".*Darwin.*\t.*(5\\.|6\\.).*", REG_EXTENDED|REG_NOSUB);
|
|
|
|
ban_os.push_back(re);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (xp.parse_bool(tag, "no_amd_k6", no_amd_k6)) {
|
|
|
|
if (no_amd_k6) {
|
|
|
|
regcomp(&re, ".*AMD.*\t.*Family 5 Model 8 Stepping 0.*", REG_EXTENDED|REG_NOSUB);
|
|
|
|
ban_cpu.push_back(re);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2007-06-27 20:09:18 +00:00
|
|
|
if (xp.parse_str(tag, "httpd_user", httpd_user, sizeof(httpd_user))) continue;
|
2007-09-17 15:58:36 +00:00
|
|
|
if (xp.parse_int(tag, "file_deletion_strategy", file_deletion_strategy)) continue;
|
2008-01-13 00:12:14 +00:00
|
|
|
if (xp.parse_bool(tag, "request_time_stats_log", request_time_stats_log)) continue;
|
2008-02-21 00:47:50 +00:00
|
|
|
if (xp.parse_bool(tag, "enable_assignment", enable_assignment)) continue;
|
2008-02-21 20:10:10 +00:00
|
|
|
if (xp.parse_int(tag, "max_ncpus", max_ncpus)) continue;
|
2008-02-25 18:05:04 +00:00
|
|
|
if (xp.parse_str(tag, "ban_os", buf, sizeof(buf))) {
|
|
|
|
retval = regcomp(&re, buf, REG_EXTENDED|REG_NOSUB);
|
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
|
|
|
} else {
|
|
|
|
ban_os.push_back(re);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (xp.parse_str(tag, "ban_cpu", buf, sizeof(buf))) {
|
|
|
|
retval = regcomp(&re, buf, REG_EXTENDED|REG_NOSUB);
|
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
|
|
|
} else {
|
|
|
|
ban_cpu.push_back(re);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2008-03-18 21:22:44 +00:00
|
|
|
if (xp.parse_bool(tag, "debug_version_select", debug_version_select)) continue;
|
|
|
|
if (xp.parse_bool(tag, "debug_assignment", debug_assignment)) continue;
|
2008-04-23 23:34:26 +00:00
|
|
|
if (xp.parse_bool(tag, "debug_prefs", debug_prefs)) continue;
|
2007-06-27 20:09:18 +00:00
|
|
|
|
|
|
|
// don't complain about unparsed XML;
|
|
|
|
// there are lots of tags the scheduler doesn't know about
|
|
|
|
|
2007-07-03 21:55:50 +00:00
|
|
|
xp.skip_unexpected(
|
|
|
|
tag, log_messages.debug_level==3, "SCHED_CONFIG::parse"
|
|
|
|
);
|
2006-05-25 05:22:10 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
2005-02-16 23:17:43 +00:00
|
|
|
int SCHED_CONFIG::parse_file(const char* dir) {
|
2003-09-02 21:16:55 +00:00
|
|
|
char path[256];
|
2004-04-30 23:18:56 +00:00
|
|
|
int retval;
|
2002-10-03 18:33:46 +00:00
|
|
|
|
2003-09-02 21:16:55 +00:00
|
|
|
sprintf(path, "%s/%s", dir, CONFIG_FILE);
|
2006-05-25 05:22:10 +00:00
|
|
|
FILE* f = fopen(path, "r");
|
|
|
|
if (!f) return ERR_FOPEN;
|
|
|
|
retval = parse(f);
|
|
|
|
fclose(f);
|
|
|
|
return retval;
|
2002-10-03 18:33:46 +00:00
|
|
|
}
|
2004-04-04 02:59:42 +00:00
|
|
|
|
2007-04-19 22:11:25 +00:00
|
|
|
int SCHED_CONFIG::upload_path(const char* filename, char* path) {
|
|
|
|
return ::dir_hier_path(filename, upload_dir, uldl_dir_fanout, path, true);
|
2007-04-19 03:12:13 +00:00
|
|
|
}
|
|
|
|
|
2007-04-19 22:11:25 +00:00
|
|
|
int SCHED_CONFIG::download_path(const char* filename, char* path) {
|
|
|
|
return ::dir_hier_path(filename, download_dir, uldl_dir_fanout, path, true);
|
2007-04-18 20:49:58 +00:00
|
|
|
}
|
|
|
|
|
2004-04-04 02:59:42 +00:00
|
|
|
void get_project_dir(char* p, int len) {
|
2007-04-18 20:49:58 +00:00
|
|
|
char* unused = getcwd(p, len);
|
2004-04-04 02:59:42 +00:00
|
|
|
char* q = strrchr(p, '/');
|
|
|
|
if (q) *q = 0;
|
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_3704204cfd = "$Id$";
|