2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-08-04 03:50:04 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2005-08-04 03:50:04 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// 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.
|
2005-08-04 03:50:04 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-08-04 03:50:04 +00:00
|
|
|
// 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.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2005-08-04 03:50:04 +00:00
|
|
|
|
2006-08-16 03:44:47 +00:00
|
|
|
// scheduler code related to homogeneous redundancy
|
2005-08-04 03:50:04 +00:00
|
|
|
|
2005-11-21 18:34:44 +00:00
|
|
|
#include "config.h"
|
2005-08-04 03:50:04 +00:00
|
|
|
#include <ctime>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <stdlib.h>
|
2008-02-27 23:26:38 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <string>
|
2005-08-04 03:50:04 +00:00
|
|
|
|
|
|
|
#include "error_numbers.h"
|
|
|
|
|
2009-08-10 04:49:02 +00:00
|
|
|
#include "sched_types.h"
|
2005-08-04 03:50:04 +00:00
|
|
|
#include "sched_config.h"
|
|
|
|
#include "sched_msgs.h"
|
2009-08-10 04:49:02 +00:00
|
|
|
#include "sched_main.h"
|
2007-06-20 22:34:06 +00:00
|
|
|
#include "hr.h"
|
2005-08-04 03:58:00 +00:00
|
|
|
#include "sched_hr.h"
|
2005-08-04 03:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef _USING_FCGI_
|
2008-09-09 19:10:42 +00:00
|
|
|
#include "boinc_fcgi.h"
|
2005-08-04 03:50:04 +00:00
|
|
|
#endif
|
|
|
|
|
2007-06-14 18:02:00 +00:00
|
|
|
// return true if HR rules out sending any work to this host
|
|
|
|
//
|
|
|
|
bool hr_unknown_platform(HOST& host) {
|
|
|
|
for (int i=0; i<ssp->napps; i++) {
|
|
|
|
APP& app = ssp->apps[i];
|
2010-04-05 18:59:16 +00:00
|
|
|
if (!hr_unknown_class(host, app_hr_type(app))) return false;
|
2007-06-14 18:02:00 +00:00
|
|
|
}
|
|
|
|
return true;
|
2007-05-29 23:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// quick check for platform compatibility
|
|
|
|
//
|
2008-12-19 18:14:02 +00:00
|
|
|
bool already_sent_to_different_platform_quick(WORKUNIT& wu, APP& app) {
|
|
|
|
if (wu.hr_class && (hr_class(g_request->host, app_hr_type(app)) != wu.hr_class)) {
|
2007-06-14 15:05:20 +00:00
|
|
|
return true;
|
2007-05-29 23:41:31 +00:00
|
|
|
}
|
2005-11-30 22:52:23 +00:00
|
|
|
return false;
|
2005-08-04 03:50:04 +00:00
|
|
|
}
|
|
|
|
|
2006-08-16 03:44:47 +00:00
|
|
|
// If we've already sent a result of this WU to a different platform
|
2005-11-30 22:52:23 +00:00
|
|
|
// return true
|
|
|
|
// else if we haven't sent a result to ANY platform
|
|
|
|
// update WU with platform code
|
2006-08-16 03:44:47 +00:00
|
|
|
// return false
|
2005-11-30 22:52:23 +00:00
|
|
|
//
|
|
|
|
// (where "platform" is os_name + p_vendor; may want to sharpen this for Unix)
|
2005-08-04 03:50:04 +00:00
|
|
|
//
|
2007-06-14 18:02:00 +00:00
|
|
|
// This is "careful" in that it rereads the WU from DB
|
|
|
|
//
|
2008-12-19 18:14:02 +00:00
|
|
|
bool already_sent_to_different_platform_careful(WORKUNIT& workunit, APP& app) {
|
2005-08-04 03:50:04 +00:00
|
|
|
DB_WORKUNIT db_wu;
|
2007-05-29 23:41:31 +00:00
|
|
|
int retval, wu_hr_class;
|
2008-02-10 05:17:57 +00:00
|
|
|
char buf[256], buf2[256];
|
2005-08-04 03:50:04 +00:00
|
|
|
|
|
|
|
// reread hr_class field from DB in case it's changed
|
|
|
|
//
|
|
|
|
db_wu.id = workunit.id;
|
2007-05-29 23:41:31 +00:00
|
|
|
retval = db_wu.get_field_int("hr_class", wu_hr_class);
|
2005-08-04 03:50:04 +00:00
|
|
|
if (retval) {
|
2008-02-21 21:00:58 +00:00
|
|
|
log_messages.printf(MSG_CRITICAL,
|
2010-11-08 17:51:57 +00:00
|
|
|
"can't get hr_class for [WU#%d]: %s\n", db_wu.id, boincerror(retval)
|
2005-08-04 03:50:04 +00:00
|
|
|
);
|
|
|
|
return true;
|
|
|
|
}
|
2008-12-19 18:14:02 +00:00
|
|
|
g_wreq->hr_reject_temp = false;
|
|
|
|
int host_hr_class = hr_class(g_request->host, app_hr_type(app));
|
2007-05-29 23:41:31 +00:00
|
|
|
if (wu_hr_class) {
|
|
|
|
if (host_hr_class != wu_hr_class) {
|
2008-12-19 18:14:02 +00:00
|
|
|
g_wreq->hr_reject_temp = true;
|
2005-08-04 03:50:04 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-02-08 17:20:09 +00:00
|
|
|
// do a "careful update" to make sure the WU's hr_class hasn't
|
|
|
|
// changed since we read it earlier
|
|
|
|
//
|
2008-02-10 05:17:57 +00:00
|
|
|
sprintf(buf, "hr_class=%d", host_hr_class);
|
|
|
|
sprintf(buf2, "hr_class=%d", wu_hr_class);
|
|
|
|
retval = db_wu.update_field(buf, buf2);
|
2008-02-08 17:20:09 +00:00
|
|
|
if (retval) return true;
|
2008-02-18 04:57:27 +00:00
|
|
|
if (boinc_db.affected_rows() != 1) return true;
|
2005-08-04 03:50:04 +00:00
|
|
|
}
|
2008-12-19 18:14:02 +00:00
|
|
|
return g_wreq->hr_reject_temp;
|
2005-08-04 03:50:04 +00:00
|
|
|
}
|
|
|
|
|
2005-09-13 09:01:56 +00:00
|
|
|
const char *BOINC_RCSID_4196d9a5b4="$Id$";
|