2010-09-13 21:20:30 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2010 University of California
|
|
|
|
//
|
|
|
|
// BOINC 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 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC 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.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
#include "sched_main.h"
|
|
|
|
|
2010-05-24 23:14:48 +00:00
|
|
|
#include "sched_limit.h"
|
|
|
|
|
|
|
|
int RSC_JOB_LIMIT::parse(XML_PARSER& xp, const char* end_tag) {
|
2011-05-17 19:11:44 +00:00
|
|
|
per_proc = false;
|
2011-08-10 17:11:08 +00:00
|
|
|
while (!xp.get_tag()) {
|
|
|
|
if (!xp.is_tag) {
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag(end_tag)) {
|
2010-05-24 23:14:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_int("jobs", base_limit)) {
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("per_proc", per_proc)) {
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int JOB_LIMIT::parse(XML_PARSER& xp, const char* end_tag) {
|
2011-08-10 17:11:08 +00:00
|
|
|
while (!xp.get_tag()) {
|
|
|
|
if (!xp.is_tag) {
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag(end_tag)) {
|
2010-05-24 23:14:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_str("app_name", app_name, sizeof(app_name))) {
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag("total_limit")) {
|
2010-06-04 16:57:33 +00:00
|
|
|
total.parse(xp, "/total_limit");
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag("cpu_limit")) {
|
2010-06-04 16:57:33 +00:00
|
|
|
cpu.parse(xp, "/cpu_limit");
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag("gpu_limit")) {
|
2010-06-04 16:57:33 +00:00
|
|
|
gpu.parse(xp, "/gpu_limit");
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int JOB_LIMITS::parse(XML_PARSER& xp, const char* end_tag) {
|
2011-08-10 17:11:08 +00:00
|
|
|
while (!xp.get_tag()) {
|
|
|
|
if (!xp.is_tag) {
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag(end_tag)) {
|
2010-05-24 23:14:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag("project")) {
|
2010-05-24 23:14:48 +00:00
|
|
|
project_limits.parse(xp, "/project");
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag("app")) {
|
2010-05-24 23:14:48 +00:00
|
|
|
JOB_LIMIT jl;
|
|
|
|
jl.parse(xp, "/app");
|
|
|
|
if (!strlen(jl.app_name)) {
|
|
|
|
log_messages.printf(MSG_NORMAL, "missing app name\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
app_limits.push_back(jl);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2010-06-04 16:57:33 +00:00
|
|
|
return ERR_XML_PARSE;
|
2010-05-24 23:14:48 +00:00
|
|
|
}
|