2008-08-06 18:36:30 +00:00
// This file is part of BOINC.
2005-01-20 23:22:22 +00:00
// http://boinc.berkeley.edu
2008-08-06 18:36:30 +00:00
// Copyright (C) 2008 University of California
2003-07-25 20:26:38 +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.
2003-07-25 20:26:38 +00:00
//
2008-08-06 18:36:30 +00:00
// BOINC is distributed in the hope that it will be useful,
2005-01-20 23:22:22 +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.
2003-07-01 20:37:09 +00:00
//
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/>.
2004-01-04 06:48:40 +00:00
2005-11-21 18:34:44 +00:00
# include "config.h"
2003-08-11 04:28:23 +00:00
# include <cstdlib>
2010-09-20 17:16:44 +00:00
# include <string>
2003-08-11 04:28:23 +00:00
# include <cstring>
# include <ctime>
# include <unistd.h>
2004-07-13 13:54:09 +00:00
# include <cmath>
2004-01-04 06:48:40 +00:00
2005-05-10 17:45:22 +00:00
// For machines with finite() defined in ieeefp.h
2011-09-27 19:45:27 +00:00
# if HAVE_IEEEFP_H
2005-05-10 17:45:22 +00:00
# include <ieeefp.h>
# endif
2010-08-29 08:43:40 +00:00
# include "common_defs.h"
2007-02-21 16:26:51 +00:00
# include "str_util.h"
2009-06-16 20:54:44 +00:00
# include "str_replace.h"
2008-09-22 20:33:59 +00:00
# include "util.h"
2006-01-19 21:46:25 +00:00
# include "error_numbers.h"
2003-06-04 17:21:26 +00:00
# include "boinc_db.h"
2004-07-03 21:38:08 +00:00
# ifdef _USING_FCGI_
# include "fcgi_stdio.h"
# endif
2010-09-20 17:16:44 +00:00
using std : : string ;
2004-10-04 22:37:08 +00:00
extern " C " {
int isnan ( double ) ;
}
2003-09-05 21:26:21 +00:00
DB_CONN boinc_db ;
2003-08-11 04:28:23 +00:00
static struct random_init {
2003-11-11 20:49:07 +00:00
random_init ( ) {
2003-08-11 04:28:23 +00:00
srand48 ( getpid ( ) + time ( 0 ) ) ;
}
} random_init ;
2004-04-09 23:33:50 +00:00
# define ESCAPE(x) escape_string(x, sizeof(x))
# define UNESCAPE(x) unescape_string(x, sizeof(x))
2003-06-04 17:21:26 +00:00
void PLATFORM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void APP : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void APP_VERSION : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void USER : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void TEAM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void HOST : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2013-04-25 07:27:35 +00:00
void RESULT : : clear ( ) {
memset ( this , 0 , sizeof ( * this ) ) ;
size_class = - 1 ;
}
void WORKUNIT : : clear ( ) {
memset ( this , 0 , sizeof ( * this ) ) ;
size_class = - 1 ;
}
2007-05-02 23:17:52 +00:00
void CREDITED_JOB : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2004-06-22 22:56:50 +00:00
void MSG_FROM_HOST : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void MSG_TO_HOST : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2008-02-21 00:47:50 +00:00
void ASSIGNMENT : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2004-07-06 18:30:22 +00:00
void TRANSITIONER_ITEM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2004-10-08 22:41:33 +00:00
void VALIDATOR_ITEM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2004-07-06 18:30:22 +00:00
void SCHED_RESULT_ITEM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2010-03-29 22:28:20 +00:00
void HOST_APP_VERSION : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2012-12-06 07:09:22 +00:00
void USER_SUBMIT : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2009-06-23 21:45:22 +00:00
void STATE_COUNTS : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2010-03-05 22:55:16 +00:00
void FILE_ITEM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void FILESET_ITEM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void FILESET_FILE_ITEM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void SCHED_TRIGGER_ITEM : : clear ( ) {
id = 0 ;
fileset_id = 0 ;
need_work = false ;
work_available = false ;
no_work_available = false ;
working_set_removal = false ;
}
void FILESET_SCHED_TRIGGER_ITEM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2012-01-23 05:03:52 +00:00
void VDA_FILE : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void VDA_CHUNK_HOST : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2014-05-19 02:19:05 +00:00
void BADGE : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void BADGE_USER : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void BADGE_TEAM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2014-08-15 21:01:32 +00:00
void CREDIT_USER : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
void CREDIT_TEAM : : clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
2003-06-04 17:21:26 +00:00
2004-10-04 23:23:57 +00:00
DB_PLATFORM : : DB_PLATFORM ( DB_CONN * dc ) :
DB_BASE ( " platform " , dc ? dc : & boinc_db ) { }
DB_APP : : DB_APP ( DB_CONN * dc ) :
DB_BASE ( " app " , dc ? dc : & boinc_db ) { }
DB_APP_VERSION : : DB_APP_VERSION ( DB_CONN * dc ) :
DB_BASE ( " app_version " , dc ? dc : & boinc_db ) { }
DB_USER : : DB_USER ( DB_CONN * dc ) :
DB_BASE ( " user " , dc ? dc : & boinc_db ) { }
DB_TEAM : : DB_TEAM ( DB_CONN * dc ) :
DB_BASE ( " team " , dc ? dc : & boinc_db ) { }
DB_HOST : : DB_HOST ( DB_CONN * dc ) :
DB_BASE ( " host " , dc ? dc : & boinc_db ) { }
DB_WORKUNIT : : DB_WORKUNIT ( DB_CONN * dc ) :
DB_BASE ( " workunit " , dc ? dc : & boinc_db ) { }
2007-05-02 23:17:52 +00:00
DB_CREDITED_JOB : : DB_CREDITED_JOB ( DB_CONN * dc ) :
DB_BASE ( " credited_job " , dc ? dc : & boinc_db ) { }
2004-10-04 23:23:57 +00:00
DB_RESULT : : DB_RESULT ( DB_CONN * dc ) :
2013-05-03 22:09:45 +00:00
DB_BASE ( " result " , dc ? dc : & boinc_db ) , RESULT ( ) { }
2004-10-04 23:23:57 +00:00
DB_MSG_FROM_HOST : : DB_MSG_FROM_HOST ( DB_CONN * dc ) :
DB_BASE ( " msg_from_host " , dc ? dc : & boinc_db ) { }
DB_MSG_TO_HOST : : DB_MSG_TO_HOST ( DB_CONN * dc ) :
DB_BASE ( " msg_to_host " , dc ? dc : & boinc_db ) { }
2008-02-21 00:47:50 +00:00
DB_ASSIGNMENT : : DB_ASSIGNMENT ( DB_CONN * dc ) :
DB_BASE ( " assignment " , dc ? dc : & boinc_db ) { }
2010-03-29 22:28:20 +00:00
DB_HOST_APP_VERSION : : DB_HOST_APP_VERSION ( DB_CONN * dc ) :
DB_BASE ( " host_app_version " , dc ? dc : & boinc_db ) { }
2012-12-06 07:09:22 +00:00
DB_USER_SUBMIT : : DB_USER_SUBMIT ( DB_CONN * dc ) :
DB_BASE ( " user_submit " , dc ? dc : & boinc_db ) { }
2009-06-23 21:45:22 +00:00
DB_STATE_COUNTS : : DB_STATE_COUNTS ( DB_CONN * dc ) :
DB_BASE ( " state_counts " , dc ? dc : & boinc_db ) { }
2004-10-04 23:23:57 +00:00
DB_TRANSITIONER_ITEM_SET : : DB_TRANSITIONER_ITEM_SET ( DB_CONN * dc ) :
DB_BASE_SPECIAL ( dc ? dc : & boinc_db ) { }
2004-10-08 22:41:33 +00:00
DB_VALIDATOR_ITEM_SET : : DB_VALIDATOR_ITEM_SET ( DB_CONN * dc ) :
DB_BASE_SPECIAL ( dc ? dc : & boinc_db ) { }
2004-10-04 23:23:57 +00:00
DB_WORK_ITEM : : DB_WORK_ITEM ( DB_CONN * dc ) :
2007-06-22 23:48:37 +00:00
DB_BASE_SPECIAL ( dc ? dc : & boinc_db
) {
start_id = 0 ;
}
2007-04-05 17:02:01 +00:00
DB_IN_PROGRESS_RESULT : : DB_IN_PROGRESS_RESULT ( DB_CONN * dc ) :
DB_BASE_SPECIAL ( dc ? dc : & boinc_db ) { }
2004-10-04 23:23:57 +00:00
DB_SCHED_RESULT_ITEM_SET : : DB_SCHED_RESULT_ITEM_SET ( DB_CONN * dc ) :
DB_BASE_SPECIAL ( dc ? dc : & boinc_db ) { }
2010-03-05 22:55:16 +00:00
DB_FILE : : DB_FILE ( DB_CONN * dc ) :
DB_BASE ( " file " , dc ? dc : & boinc_db ) { }
DB_FILESET : : DB_FILESET ( DB_CONN * dc ) :
DB_BASE ( " fileset " , dc ? dc : & boinc_db ) { }
DB_FILESET_FILE : : DB_FILESET_FILE ( DB_CONN * dc ) :
DB_BASE ( " fileset_file " , dc ? dc : & boinc_db ) { }
DB_SCHED_TRIGGER : : DB_SCHED_TRIGGER ( DB_CONN * dc ) :
DB_BASE ( " sched_trigger " , dc ? dc : & boinc_db ) {
id = 0 ;
fileset_id = 0 ;
need_work = false ;
work_available = false ;
no_work_available = false ;
working_set_removal = false ;
}
DB_FILESET_SCHED_TRIGGER_ITEM : : DB_FILESET_SCHED_TRIGGER_ITEM ( DB_CONN * dc ) :
DB_BASE_SPECIAL ( dc ? dc : & boinc_db ) { }
DB_FILESET_SCHED_TRIGGER_ITEM_SET : : DB_FILESET_SCHED_TRIGGER_ITEM_SET ( DB_CONN * dc ) :
DB_BASE_SPECIAL ( dc ? dc : & boinc_db ) { }
2012-01-23 05:03:52 +00:00
DB_VDA_FILE : : DB_VDA_FILE ( DB_CONN * dc ) :
DB_BASE ( " vda_file " , dc ? dc : & boinc_db ) { }
DB_VDA_CHUNK_HOST : : DB_VDA_CHUNK_HOST ( DB_CONN * dc ) :
DB_BASE ( " vda_chunk_host " , dc ? dc : & boinc_db ) { }
2014-05-19 02:19:05 +00:00
DB_BADGE : : DB_BADGE ( DB_CONN * dc ) :
DB_BASE ( " badge " , dc ? dc : & boinc_db ) { }
DB_BADGE_USER : : DB_BADGE_USER ( DB_CONN * dc ) :
DB_BASE ( " badge_user " , dc ? dc : & boinc_db ) { }
DB_BADGE_TEAM : : DB_BADGE_TEAM ( DB_CONN * dc ) :
DB_BASE ( " badge_team " , dc ? dc : & boinc_db ) { }
2014-08-15 21:01:32 +00:00
DB_CREDIT_USER : : DB_CREDIT_USER ( DB_CONN * dc ) :
DB_BASE ( " credit_user " , dc ? dc : & boinc_db ) { }
DB_CREDIT_TEAM : : DB_CREDIT_TEAM ( DB_CONN * dc ) :
DB_BASE ( " credit_team " , dc ? dc : & boinc_db ) { }
2003-06-04 17:21:26 +00:00
int DB_PLATFORM : : get_id ( ) { return id ; }
int DB_APP : : get_id ( ) { return id ; }
int DB_APP_VERSION : : get_id ( ) { return id ; }
int DB_USER : : get_id ( ) { return id ; }
int DB_TEAM : : get_id ( ) { return id ; }
int DB_HOST : : get_id ( ) { return id ; }
int DB_WORKUNIT : : get_id ( ) { return id ; }
int DB_RESULT : : get_id ( ) { return id ; }
2004-06-22 22:56:50 +00:00
int DB_MSG_FROM_HOST : : get_id ( ) { return id ; }
int DB_MSG_TO_HOST : : get_id ( ) { return id ; }
2008-02-21 00:47:50 +00:00
int DB_ASSIGNMENT : : get_id ( ) { return id ; }
2009-06-23 21:45:22 +00:00
int DB_STATE_COUNTS : : get_id ( ) { return appid ; }
2010-03-05 22:55:16 +00:00
int DB_FILE : : get_id ( ) { return id ; }
int DB_FILESET : : get_id ( ) { return id ; }
int DB_SCHED_TRIGGER : : get_id ( ) { return id ; }
2012-01-23 05:03:52 +00:00
int DB_VDA_FILE : : get_id ( ) { return id ; }
2003-06-04 17:21:26 +00:00
void DB_PLATFORM : : db_print ( char * buf ) {
sprintf ( buf ,
2004-06-16 19:10:24 +00:00
" create_time=%d, name='%s', user_friendly_name='%s', "
2003-12-11 19:05:52 +00:00
" deprecated=%d " ,
2004-06-16 19:10:24 +00:00
create_time , name , user_friendly_name ,
deprecated
2003-06-04 17:21:26 +00:00
) ;
}
void DB_PLATFORM : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
2006-05-31 17:19:29 +00:00
id = atoi ( r [ i + + ] ) ;
create_time = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
strcpy2 ( name , r [ i + + ] ) ;
strcpy2 ( user_friendly_name , r [ i + + ] ) ;
2006-05-31 17:19:29 +00:00
deprecated = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
}
void DB_APP : : db_print ( char * buf ) {
sprintf ( buf ,
2010-03-29 22:28:20 +00:00
" create_time=%d, "
" name='%s', "
" min_version=%d, "
" deprecated=%d, "
" user_friendly_name='%s', "
" homogeneous_redundancy=%d, "
" weight=%.15e, "
" beta=%d, "
" target_nresults=%d, "
" min_avg_pfc=%.15e, "
2011-06-06 03:40:42 +00:00
" host_scale_check=%d, "
2012-08-25 04:09:24 +00:00
" homogeneous_app_version=%d, "
2012-08-27 17:00:43 +00:00
" non_cpu_intensive=%d, "
2013-04-25 07:27:35 +00:00
" locality_scheduling=%d, "
2014-05-04 07:02:32 +00:00
" n_size_classes=%d, "
" fraction_done_exact=%d " ,
2010-03-29 22:28:20 +00:00
create_time ,
name ,
min_version ,
deprecated ? 1 : 0 ,
user_friendly_name ,
homogeneous_redundancy ,
weight ,
beta ? 1 : 0 ,
target_nresults ,
min_avg_pfc ,
2011-06-06 03:40:42 +00:00
host_scale_check ? 1 : 0 ,
2012-08-25 04:09:24 +00:00
homogeneous_app_version ? 1 : 0 ,
2012-08-27 17:00:43 +00:00
non_cpu_intensive ? 1 : 0 ,
2013-04-25 07:27:35 +00:00
locality_scheduling ,
2014-05-04 07:02:32 +00:00
n_size_classes ,
fraction_done_exact ? 1 : 0
2003-06-04 17:21:26 +00:00
) ;
}
void DB_APP : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
2006-05-31 17:19:29 +00:00
id = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
create_time = atoi ( r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
min_version = atoi ( r [ i + + ] ) ;
2003-12-11 19:05:52 +00:00
deprecated = atoi ( r [ i + + ] ) ;
strcpy2 ( user_friendly_name , r [ i + + ] ) ;
2004-09-27 04:26:51 +00:00
homogeneous_redundancy = atoi ( r [ i + + ] ) ;
2006-07-11 21:49:20 +00:00
weight = atof ( r [ i + + ] ) ;
2006-10-22 00:42:44 +00:00
beta = atoi ( r [ i + + ] ) ;
2008-06-04 23:04:12 +00:00
target_nresults = atoi ( r [ i + + ] ) ;
2010-03-29 22:28:20 +00:00
min_avg_pfc = atof ( r [ i + + ] ) ;
host_scale_check = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2011-06-06 03:40:42 +00:00
homogeneous_app_version = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2012-08-25 04:09:24 +00:00
non_cpu_intensive = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2012-08-28 06:33:53 +00:00
locality_scheduling = atoi ( r [ i + + ] ) ;
2013-04-25 07:27:35 +00:00
n_size_classes = atoi ( r [ i + + ] ) ;
2014-05-04 07:02:32 +00:00
fraction_done_exact = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2003-06-04 17:21:26 +00:00
}
void DB_APP_VERSION : : db_print ( char * buf ) {
sprintf ( buf ,
2010-03-29 22:28:20 +00:00
" create_time=%d, "
" appid=%d, "
" version_num=%d, "
" platformid=%d, "
2003-06-04 17:21:26 +00:00
" xml_doc='%s', "
2010-03-29 22:28:20 +00:00
" min_core_version=%d, "
" max_core_version=%d, "
" deprecated=%d, "
" plan_class='%s', "
" pfc_n=%.15e, "
" pfc_avg=%.15e, "
" pfc_scale=%.15e, "
" expavg_credit=%.15e, "
2014-06-05 16:51:01 +00:00
" expavg_time=%.15e, "
" beta=%d " ,
2010-03-29 22:28:20 +00:00
create_time ,
appid ,
version_num ,
platformid ,
2003-06-04 17:21:26 +00:00
xml_doc ,
2010-03-29 22:28:20 +00:00
min_core_version ,
max_core_version ,
deprecated ,
plan_class ,
pfc . n ,
pfc . avg ,
pfc_scale ,
expavg_credit ,
2014-06-05 16:51:01 +00:00
expavg_time ,
beta
2003-06-04 17:21:26 +00:00
) ;
}
void DB_APP_VERSION : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
2006-05-31 17:19:29 +00:00
id = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
create_time = atoi ( r [ i + + ] ) ;
appid = atoi ( r [ i + + ] ) ;
version_num = atoi ( r [ i + + ] ) ;
platformid = atoi ( r [ i + + ] ) ;
strcpy2 ( xml_doc , r [ i + + ] ) ;
min_core_version = atoi ( r [ i + + ] ) ;
max_core_version = atoi ( r [ i + + ] ) ;
2003-12-24 21:49:35 +00:00
deprecated = atoi ( r [ i + + ] ) ;
2008-03-13 22:57:24 +00:00
strcpy2 ( plan_class , r [ i + + ] ) ;
2010-03-29 22:28:20 +00:00
pfc . n = atof ( r [ i + + ] ) ;
pfc . avg = atof ( r [ i + + ] ) ;
pfc_scale = atof ( r [ i + + ] ) ;
expavg_credit = atof ( r [ i + + ] ) ;
expavg_time = atof ( r [ i + + ] ) ;
2014-06-05 16:51:01 +00:00
beta = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
}
void DB_USER : : db_print ( char * buf ) {
2004-04-09 23:33:50 +00:00
ESCAPE ( email_addr ) ;
ESCAPE ( name ) ;
ESCAPE ( country ) ;
ESCAPE ( postal_code ) ;
ESCAPE ( global_prefs ) ;
ESCAPE ( project_prefs ) ;
ESCAPE ( url ) ;
ESCAPE ( signature ) ;
2003-06-04 17:21:26 +00:00
sprintf ( buf ,
2004-06-16 19:10:24 +00:00
" create_time=%d, email_addr='%s', name='%s', "
2003-06-04 17:21:26 +00:00
" authenticator='%s', "
" country='%s', postal_code='%s', "
2003-08-12 20:58:24 +00:00
" total_credit=%.15e, expavg_credit=%.15e, expavg_time=%.15e, "
2003-06-04 17:21:26 +00:00
" global_prefs='%s', project_prefs='%s', "
2003-08-15 20:35:44 +00:00
" teamid=%d, venue='%s', url='%s', send_email=%d, show_hosts=%d, "
2003-10-24 20:13:50 +00:00
" posts=%d, "
" seti_id=%d, seti_nresults=%d, seti_last_result_time=%d, "
2004-04-18 18:40:13 +00:00
" seti_total_cpu=%.15e, signature='%s', has_profile=%d, "
2005-08-25 23:07:58 +00:00
" cross_project_id='%s', passwd_hash='%s', "
" email_validated=%d, donated=%d " ,
2004-06-16 19:10:24 +00:00
create_time , email_addr , name ,
2003-06-04 17:21:26 +00:00
authenticator ,
2003-12-18 00:22:25 +00:00
country , postal_code ,
total_credit , expavg_credit , expavg_time ,
global_prefs , project_prefs ,
teamid , venue , url , send_email , show_hosts ,
2003-10-24 20:13:50 +00:00
posts ,
2003-12-18 00:22:25 +00:00
seti_id , seti_nresults , seti_last_result_time ,
2004-04-18 18:40:13 +00:00
seti_total_cpu , signature , has_profile ,
2005-08-25 23:07:58 +00:00
cross_project_id , passwd_hash ,
email_validated , donated
2003-06-04 17:21:26 +00:00
) ;
2004-04-09 23:33:50 +00:00
UNESCAPE ( email_addr ) ;
UNESCAPE ( name ) ;
UNESCAPE ( country ) ;
UNESCAPE ( postal_code ) ;
UNESCAPE ( global_prefs ) ;
UNESCAPE ( project_prefs ) ;
UNESCAPE ( url ) ;
UNESCAPE ( signature ) ;
2003-06-04 17:21:26 +00:00
}
void DB_USER : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
create_time = atoi ( r [ i + + ] ) ;
strcpy2 ( email_addr , r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
strcpy2 ( authenticator , r [ i + + ] ) ;
strcpy2 ( country , r [ i + + ] ) ;
strcpy2 ( postal_code , r [ i + + ] ) ;
total_credit = atof ( r [ i + + ] ) ;
expavg_credit = atof ( r [ i + + ] ) ;
expavg_time = atof ( r [ i + + ] ) ;
strcpy2 ( global_prefs , r [ i + + ] ) ;
strcpy2 ( project_prefs , r [ i + + ] ) ;
teamid = atoi ( r [ i + + ] ) ;
strcpy2 ( venue , r [ i + + ] ) ;
strcpy2 ( url , r [ i + + ] ) ;
send_email = atoi ( r [ i + + ] ) ;
show_hosts = atoi ( r [ i + + ] ) ;
2003-11-25 07:40:45 +00:00
posts = safe_atoi ( r [ i + + ] ) ;
seti_id = safe_atoi ( r [ i + + ] ) ;
seti_nresults = safe_atoi ( r [ i + + ] ) ;
seti_last_result_time = safe_atoi ( r [ i + + ] ) ;
seti_total_cpu = safe_atof ( r [ i + + ] ) ;
2003-11-28 23:11:22 +00:00
strcpy2 ( signature , r [ i + + ] ) ;
2003-12-15 02:31:29 +00:00
has_profile = atoi ( r [ i + + ] ) ;
2004-04-18 18:40:13 +00:00
strcpy2 ( cross_project_id , r [ i + + ] ) ;
2005-08-07 01:33:15 +00:00
strcpy2 ( passwd_hash , r [ i + + ] ) ;
email_validated = atoi ( r [ i + + ] ) ;
2005-08-25 23:07:58 +00:00
donated = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
}
void DB_TEAM : : db_print ( char * buf ) {
2004-04-09 23:33:50 +00:00
ESCAPE ( name ) ;
ESCAPE ( name_lc ) ;
ESCAPE ( url ) ;
ESCAPE ( name_html ) ;
ESCAPE ( description ) ;
2003-06-04 17:21:26 +00:00
sprintf ( buf ,
2004-06-16 19:10:24 +00:00
" create_time=%d, userid=%d, name='%s', "
2003-06-04 17:21:26 +00:00
" name_lc='%s', url='%s', "
" type=%d, name_html='%s', description='%s', nusers=%d, "
2004-01-14 20:24:24 +00:00
" country='%s', "
" total_credit=%.15e, expavg_credit=%.15e, expavg_time=%.15e, "
2006-12-06 20:59:29 +00:00
" seti_id=%d, ping_user=%d, ping_time=%d " ,
2003-06-04 17:21:26 +00:00
create_time ,
userid ,
name ,
name_lc ,
url ,
type ,
name_html ,
description ,
nusers ,
country ,
total_credit ,
2003-10-24 20:13:50 +00:00
expavg_credit ,
2004-01-14 20:24:24 +00:00
expavg_time ,
2006-12-06 20:59:29 +00:00
seti_id ,
ping_user ,
ping_time
2003-06-04 17:21:26 +00:00
) ;
2004-04-09 23:33:50 +00:00
UNESCAPE ( name ) ;
UNESCAPE ( name_lc ) ;
UNESCAPE ( url ) ;
UNESCAPE ( name_html ) ;
UNESCAPE ( description ) ;
2003-06-04 17:21:26 +00:00
}
void DB_TEAM : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
create_time = atoi ( r [ i + + ] ) ;
userid = atoi ( r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
strcpy2 ( name_lc , r [ i + + ] ) ;
strcpy2 ( url , r [ i + + ] ) ;
type = atoi ( r [ i + + ] ) ;
strcpy2 ( name_html , r [ i + + ] ) ;
strcpy2 ( description , r [ i + + ] ) ;
nusers = atoi ( r [ i + + ] ) ;
strcpy2 ( country , r [ i + + ] ) ;
total_credit = atof ( r [ i + + ] ) ;
expavg_credit = atof ( r [ i + + ] ) ;
2004-01-14 20:24:24 +00:00
expavg_time = atof ( r [ i + + ] ) ;
2003-11-25 07:40:45 +00:00
seti_id = safe_atoi ( r [ i + + ] ) ;
2006-12-06 20:59:29 +00:00
ping_user = safe_atoi ( r [ i + + ] ) ;
ping_time = safe_atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
}
2005-05-05 20:42:06 +00:00
// set NaNs and infs to zeroes
//
2004-01-19 01:12:53 +00:00
void HOST : : fix_nans ( ) {
2005-05-05 20:42:06 +00:00
if ( ! finite ( p_fpops ) ) p_fpops = 0 ;
if ( ! finite ( p_iops ) ) p_iops = 0 ;
if ( ! finite ( p_membw ) ) p_membw = 0 ;
if ( ! finite ( m_nbytes ) ) m_nbytes = 0 ;
if ( ! finite ( m_cache ) ) m_cache = 0 ;
if ( ! finite ( m_swap ) ) m_swap = 0 ;
if ( ! finite ( d_total ) ) d_total = 0 ;
if ( ! finite ( d_free ) ) d_free = 0 ;
if ( ! finite ( d_boinc_used_total ) ) d_boinc_used_total = 0 ;
if ( ! finite ( d_boinc_used_project ) ) d_boinc_used_project = 0 ;
if ( ! finite ( d_boinc_max ) ) d_boinc_max = 0 ;
if ( ! finite ( n_bwup ) ) n_bwup = 0 ;
if ( ! finite ( n_bwdown ) ) n_bwdown = 0 ;
2004-01-19 01:12:53 +00:00
}
2003-06-04 17:21:26 +00:00
void DB_HOST : : db_print ( char * buf ) {
2004-04-09 23:33:50 +00:00
ESCAPE ( domain_name ) ;
ESCAPE ( serialnum ) ;
ESCAPE ( last_ip_addr ) ;
2005-01-20 18:50:49 +00:00
ESCAPE ( host_cpid ) ;
2004-04-09 23:33:50 +00:00
ESCAPE ( p_vendor ) ;
ESCAPE ( p_model ) ;
ESCAPE ( os_name ) ;
ESCAPE ( os_version ) ;
2013-05-24 06:30:42 +00:00
ESCAPE ( product_name ) ;
2003-06-04 17:21:26 +00:00
sprintf ( buf ,
2004-06-16 19:10:24 +00:00
" create_time=%d, userid=%d, "
2003-06-04 17:21:26 +00:00
" rpc_seqno=%d, rpc_time=%d, "
2003-08-12 20:58:24 +00:00
" total_credit=%.12e, expavg_credit=%.12e, expavg_time=%.15e, "
2003-06-04 17:21:26 +00:00
" timezone=%d, domain_name='%s', serialnum='%s', "
" last_ip_addr='%s', nsame_ip_addr=%d, "
2005-06-23 07:42:45 +00:00
" on_frac=%.15e, connected_frac=%.15e, "
" active_frac=%.15e, cpu_efficiency=%.15e, "
" duration_correction_factor=%.15e, "
2003-06-04 17:21:26 +00:00
" p_ncpus=%d, p_vendor='%s', p_model='%s', "
2003-08-12 20:58:24 +00:00
" p_fpops=%.15e, p_iops=%.15e, p_membw=%.15e, "
2003-06-04 17:21:26 +00:00
" os_name='%s', os_version='%s', "
2003-08-12 20:58:24 +00:00
" m_nbytes=%.15e, m_cache=%.15e, m_swap=%.15e, "
" d_total=%.15e, d_free=%.15e, "
" d_boinc_used_total=%.15e, d_boinc_used_project=%.15e, d_boinc_max=%.15e, "
" n_bwup=%.15e, n_bwdown=%.15e, "
" credit_per_cpu_sec=%.15e, "
2004-12-06 22:41:19 +00:00
" venue='%s', nresults_today=%d, "
2010-03-29 22:28:20 +00:00
" avg_turnaround=%.15e, "
2007-04-24 23:21:42 +00:00
" host_cpid='%s', external_ip_addr='%s', max_results_day=%d, "
2013-05-24 06:30:42 +00:00
" error_rate=%.15e, "
2014-03-06 21:23:52 +00:00
" product_name='%s', "
" gpu_active_frac=%.15e " ,
2004-06-16 19:10:24 +00:00
create_time , userid ,
2003-06-04 17:21:26 +00:00
rpc_seqno , rpc_time ,
total_credit , expavg_credit , expavg_time ,
timezone , domain_name , serialnum ,
last_ip_addr , nsame_ip_addr ,
2014-03-06 21:23:52 +00:00
on_frac , connected_frac ,
active_frac , cpu_efficiency ,
duration_correction_factor ,
2003-06-04 17:21:26 +00:00
p_ncpus , p_vendor , p_model ,
p_fpops , p_iops , p_membw ,
os_name , os_version ,
m_nbytes , m_cache , m_swap ,
d_total , d_free ,
2003-06-17 18:59:36 +00:00
d_boinc_used_total , d_boinc_used_project , d_boinc_max ,
2003-06-04 17:21:26 +00:00
n_bwup , n_bwdown ,
credit_per_cpu_sec ,
2004-12-06 22:41:19 +00:00
venue , nresults_today ,
2005-01-20 18:50:49 +00:00
avg_turnaround ,
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
host_cpid , external_ip_addr , _max_results_day ,
2013-05-24 06:30:42 +00:00
_error_rate ,
2014-03-06 21:23:52 +00:00
product_name ,
gpu_active_frac
2003-06-04 17:21:26 +00:00
) ;
2004-04-09 23:33:50 +00:00
UNESCAPE ( domain_name ) ;
UNESCAPE ( serialnum ) ;
UNESCAPE ( last_ip_addr ) ;
UNESCAPE ( p_vendor ) ;
UNESCAPE ( p_model ) ;
UNESCAPE ( os_name ) ;
UNESCAPE ( os_version ) ;
2005-01-20 18:50:49 +00:00
UNESCAPE ( host_cpid ) ;
2013-05-24 06:30:42 +00:00
UNESCAPE ( product_name ) ;
2003-06-04 17:21:26 +00:00
}
void DB_HOST : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
2006-05-31 17:19:29 +00:00
id = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
create_time = atoi ( r [ i + + ] ) ;
userid = atoi ( r [ i + + ] ) ;
rpc_seqno = atoi ( r [ i + + ] ) ;
rpc_time = atoi ( r [ i + + ] ) ;
total_credit = atof ( r [ i + + ] ) ;
expavg_credit = atof ( r [ i + + ] ) ;
expavg_time = atof ( r [ i + + ] ) ;
timezone = atoi ( r [ i + + ] ) ;
strcpy2 ( domain_name , r [ i + + ] ) ;
strcpy2 ( serialnum , r [ i + + ] ) ;
strcpy2 ( last_ip_addr , r [ i + + ] ) ;
nsame_ip_addr = atoi ( r [ i + + ] ) ;
on_frac = atof ( r [ i + + ] ) ;
connected_frac = atof ( r [ i + + ] ) ;
active_frac = atof ( r [ i + + ] ) ;
2005-06-23 07:42:45 +00:00
cpu_efficiency = atof ( r [ i + + ] ) ;
duration_correction_factor = atof ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
p_ncpus = atoi ( r [ i + + ] ) ;
strcpy2 ( p_vendor , r [ i + + ] ) ;
strcpy2 ( p_model , r [ i + + ] ) ;
p_fpops = atof ( r [ i + + ] ) ;
p_iops = atof ( r [ i + + ] ) ;
p_membw = atof ( r [ i + + ] ) ;
strcpy2 ( os_name , r [ i + + ] ) ;
strcpy2 ( os_version , r [ i + + ] ) ;
m_nbytes = atof ( r [ i + + ] ) ;
m_cache = atof ( r [ i + + ] ) ;
m_swap = atof ( r [ i + + ] ) ;
d_total = atof ( r [ i + + ] ) ;
d_free = atof ( r [ i + + ] ) ;
2003-06-17 18:59:36 +00:00
d_boinc_used_total = atof ( r [ i + + ] ) ;
d_boinc_used_project = atof ( r [ i + + ] ) ;
d_boinc_max = atof ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
n_bwup = atof ( r [ i + + ] ) ;
n_bwdown = atof ( r [ i + + ] ) ;
credit_per_cpu_sec = atof ( r [ i + + ] ) ;
strcpy2 ( venue , r [ i + + ] ) ;
2004-05-27 18:13:00 +00:00
nresults_today = atoi ( r [ i + + ] ) ;
2004-12-06 22:41:19 +00:00
avg_turnaround = atof ( r [ i + + ] ) ;
2005-01-20 18:50:49 +00:00
strcpy2 ( host_cpid , r [ i + + ] ) ;
2005-01-21 07:54:15 +00:00
strcpy2 ( external_ip_addr , r [ i + + ] ) ;
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
_max_results_day = atoi ( r [ i + + ] ) ;
_error_rate = atof ( r [ i + + ] ) ;
2013-05-24 06:30:42 +00:00
strcpy2 ( product_name , r [ i + + ] ) ;
2014-03-06 21:23:52 +00:00
gpu_active_frac = atof ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
}
2010-03-29 22:28:20 +00:00
int DB_HOST : : update_diff_validator ( HOST & h ) {
char buf [ BLOB_SIZE ] , updates [ BLOB_SIZE ] , query [ BLOB_SIZE ] ;
strcpy ( updates , " " ) ;
if ( avg_turnaround ! = h . avg_turnaround ) {
sprintf ( buf , " avg_turnaround=%.15e, " , avg_turnaround ) ;
strcat ( updates , buf ) ;
}
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
#if 0
2010-03-29 22:28:20 +00:00
if ( error_rate ! = h . error_rate ) {
sprintf ( buf , " error_rate=%.15e, " , error_rate ) ;
strcat ( updates , buf ) ;
}
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
# endif
2010-03-29 22:28:20 +00:00
if ( total_credit ! = h . total_credit ) {
sprintf ( buf , " total_credit=total_credit+%.15e, " ,
total_credit - h . total_credit
) ;
strcat ( updates , buf ) ;
}
if ( expavg_credit ! = h . expavg_credit ) {
2010-04-19 21:46:45 +00:00
sprintf ( buf , " expavg_credit=%.15e, " , expavg_credit ) ;
2010-03-29 22:28:20 +00:00
strcat ( updates , buf ) ;
}
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
if ( expavg_time ! = h . expavg_time ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " expavg_time=%.15e, " , expavg_time ) ;
strcat ( updates , buf ) ;
}
2010-04-19 21:46:45 +00:00
#if 0
2010-03-29 22:28:20 +00:00
if ( credit_per_cpu_sec ! = h . credit_per_cpu_sec ) {
sprintf ( buf , " credit_per_cpu_sec=%.15e, " , credit_per_cpu_sec ) ;
strcat ( updates , buf ) ;
}
2010-04-19 21:46:45 +00:00
# endif
2010-03-29 22:28:20 +00:00
int n = strlen ( updates ) ;
if ( n = = 0 ) return 0 ;
updates [ n - 1 ] = 0 ; // trim the final comma
sprintf ( query , " update host set %s where id=%d " , updates , id ) ;
return db - > do_query ( query ) ;
}
2007-04-24 23:21:42 +00:00
// Update fields that differ from the argument HOST.
2010-03-29 22:28:20 +00:00
// Called from scheduler (handle_request.cpp),
2007-04-24 23:21:42 +00:00
// so only include fields modified by the scheduler.
2005-05-03 21:50:51 +00:00
//
2010-03-29 22:28:20 +00:00
int DB_HOST : : update_diff_sched ( HOST & h ) {
2008-03-31 16:19:45 +00:00
char buf [ BLOB_SIZE ] , updates [ BLOB_SIZE ] , query [ BLOB_SIZE ] ;
2005-05-03 21:50:51 +00:00
strcpy ( updates , " " ) ;
if ( rpc_seqno ! = h . rpc_seqno ) {
sprintf ( buf , " rpc_seqno=%d, " , rpc_seqno ) ;
strcat ( updates , buf ) ;
}
if ( rpc_time ! = h . rpc_time ) {
sprintf ( buf , " rpc_time=%d, " , rpc_time ) ;
strcat ( updates , buf ) ;
}
if ( timezone ! = h . timezone ) {
sprintf ( buf , " timezone=%d, " , timezone ) ;
strcat ( updates , buf ) ;
}
if ( strcmp ( domain_name , h . domain_name ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( domain_name , sizeof ( domain_name ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " domain_name='%s', " , domain_name ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( domain_name , sizeof ( domain_name ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( strcmp ( serialnum , h . serialnum ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( serialnum , sizeof ( serialnum ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " serialnum='%s', " , serialnum ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( serialnum , sizeof ( serialnum ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( strcmp ( last_ip_addr , h . last_ip_addr ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( last_ip_addr , sizeof ( last_ip_addr ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " last_ip_addr='%s', " , last_ip_addr ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( last_ip_addr , sizeof ( last_ip_addr ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( nsame_ip_addr ! = h . nsame_ip_addr ) {
sprintf ( buf , " nsame_ip_addr=%d, " , nsame_ip_addr ) ;
strcat ( updates , buf ) ;
}
if ( on_frac ! = h . on_frac ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " on_frac=%.15e, " , on_frac ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( connected_frac ! = h . connected_frac ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " connected_frac=%.15e, " , connected_frac ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( active_frac ! = h . active_frac ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " active_frac=%.15e, " , active_frac ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
2005-06-23 07:42:45 +00:00
if ( cpu_efficiency ! = h . cpu_efficiency ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " cpu_efficiency=%.15e, " , cpu_efficiency ) ;
2005-06-23 07:42:45 +00:00
strcat ( updates , buf ) ;
}
if ( duration_correction_factor ! = h . duration_correction_factor ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " duration_correction_factor=%.15e, " , duration_correction_factor ) ;
2005-06-23 07:42:45 +00:00
strcat ( updates , buf ) ;
}
2005-05-03 21:50:51 +00:00
if ( p_ncpus ! = h . p_ncpus ) {
sprintf ( buf , " p_ncpus=%d, " , p_ncpus ) ;
strcat ( updates , buf ) ;
}
if ( strcmp ( p_vendor , h . p_vendor ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( p_vendor , sizeof ( p_vendor ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " p_vendor='%s', " , p_vendor ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( p_vendor , sizeof ( p_vendor ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( strcmp ( p_model , h . p_model ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( p_model , sizeof ( p_model ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " p_model='%s', " , p_model ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( p_model , sizeof ( p_model ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( p_fpops ! = h . p_fpops ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " p_fpops=%.15e, " , p_fpops ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( p_iops ! = h . p_iops ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " p_iops=%.15e, " , p_iops ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( p_membw ! = h . p_membw ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " p_membw=%.15e, " , p_membw ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( strcmp ( os_name , h . os_name ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( os_name , sizeof ( os_name ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " os_name='%s', " , os_name ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( os_name , sizeof ( os_name ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( strcmp ( os_version , h . os_version ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( os_version , sizeof ( os_version ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " os_version='%s', " , os_version ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( os_version , sizeof ( os_version ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( m_nbytes ! = h . m_nbytes ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " m_nbytes=%.15e, " , m_nbytes ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( m_cache ! = h . m_cache ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " m_cache=%.15e, " , m_cache ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( m_swap ! = h . m_swap ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " m_swap=%.15e, " , m_swap ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( d_total ! = h . d_total ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " d_total=%.15e, " , d_total ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( d_free ! = h . d_free ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " d_free=%.15e, " , d_free ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( d_boinc_used_total ! = h . d_boinc_used_total ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " d_boinc_used_total=%.15e, " , d_boinc_used_total ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( d_boinc_used_project ! = h . d_boinc_used_project ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " d_boinc_used_project=%.15e, " , d_boinc_used_project ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( d_boinc_max ! = h . d_boinc_max ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " d_boinc_max=%.15e, " , d_boinc_max ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
2007-08-21 20:41:29 +00:00
if ( n_bwdown ! = h . n_bwdown ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " n_bwdown=%.15e, " , n_bwdown ) ;
2007-08-21 20:41:29 +00:00
strcat ( updates , buf ) ;
}
2005-05-03 21:50:51 +00:00
if ( n_bwup ! = h . n_bwup ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " n_bwup=%.15e, " , n_bwup ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( strcmp ( venue , h . venue ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( venue , sizeof ( venue ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " venue='%s', " , venue ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( venue , sizeof ( venue ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( nresults_today ! = h . nresults_today ) {
sprintf ( buf , " nresults_today=%d, " , nresults_today ) ;
strcat ( updates , buf ) ;
}
if ( avg_turnaround ! = h . avg_turnaround ) {
2010-03-29 22:28:20 +00:00
sprintf ( buf , " avg_turnaround=%.15e, " , avg_turnaround ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( strcmp ( host_cpid , h . host_cpid ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( host_cpid , sizeof ( host_cpid ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " host_cpid='%s', " , host_cpid ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( host_cpid , sizeof ( host_cpid ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
if ( strcmp ( external_ip_addr , h . external_ip_addr ) ) {
2005-05-05 20:42:06 +00:00
escape_string ( external_ip_addr , sizeof ( external_ip_addr ) ) ;
2005-05-03 21:50:51 +00:00
sprintf ( buf , " external_ip_addr='%s', " , external_ip_addr ) ;
2005-05-05 20:42:06 +00:00
unescape_string ( external_ip_addr , sizeof ( external_ip_addr ) ) ;
2005-05-03 21:50:51 +00:00
strcat ( updates , buf ) ;
}
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
#if 0
2005-05-03 21:50:51 +00:00
if ( max_results_day ! = h . max_results_day ) {
sprintf ( buf , " max_results_day=%d, " , max_results_day ) ;
strcat ( updates , buf ) ;
}
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
# endif
2013-05-24 06:30:42 +00:00
if ( strcmp ( product_name , h . product_name ) ) {
escape_string ( product_name , sizeof ( product_name ) ) ;
sprintf ( buf , " product_name='%s', " , product_name ) ;
unescape_string ( product_name , sizeof ( product_name ) ) ;
strcat ( updates , buf ) ;
}
2014-03-06 21:23:52 +00:00
if ( gpu_active_frac ! = h . gpu_active_frac ) {
sprintf ( buf , " gpu_active_frac=%.15e, " , gpu_active_frac ) ;
strcat ( updates , buf ) ;
}
2005-05-03 21:50:51 +00:00
int n = strlen ( updates ) ;
2010-03-29 22:28:20 +00:00
if ( n = = 0 ) return 0 ;
updates [ n - 1 ] = 0 ; // trim the final comma
2005-05-03 21:50:51 +00:00
sprintf ( query , " update host set %s where id=%d " , updates , id ) ;
return db - > do_query ( query ) ;
}
2011-09-13 21:01:42 +00:00
int DB_HOST : : fpops_percentile ( double percentile , double & fpops ) {
char query [ 256 ] ;
int n , retval ;
sprintf ( query , " where expavg_credit>10 " ) ;
retval = count ( n , query ) ;
if ( retval ) return retval ;
if ( n = = 0 ) return ERR_NULL ;
int m = ( int ) ( n * percentile / 100. ) ;
sprintf ( query ,
" select p_fpops from host where expavg_credit>10 order by p_fpops limit %d,1 " ,
m
) ;
2013-12-15 00:36:18 +00:00
return db - > get_double ( query , fpops ) ;
2011-09-13 21:01:42 +00:00
}
2012-01-09 17:35:48 +00:00
int DB_HOST : : fpops_mean ( double & mean ) {
char query [ 256 ] ;
sprintf ( query ,
" select avg(p_fpops) from host where expavg_credit>10 "
) ;
2013-12-15 00:36:18 +00:00
return db - > get_double ( query , mean ) ;
2012-01-09 17:35:48 +00:00
}
int DB_HOST : : fpops_stddev ( double & stddev ) {
char query [ 256 ] ;
sprintf ( query ,
" select stddev(p_fpops) from host where expavg_credit>10 "
) ;
2013-12-15 00:36:18 +00:00
return db - > get_double ( query , stddev ) ;
2012-01-09 17:35:48 +00:00
}
2003-06-04 17:21:26 +00:00
void DB_WORKUNIT : : db_print ( char * buf ) {
sprintf ( buf ,
2004-06-16 19:10:24 +00:00
" create_time=%d, appid=%d, "
2003-06-04 17:21:26 +00:00
" name='%s', xml_doc='%s', batch=%d, "
2003-09-04 00:41:51 +00:00
" rsc_fpops_est=%.15e, rsc_fpops_bound=%.15e, "
" rsc_memory_bound=%.15e, rsc_disk_bound=%.15e, "
2003-06-04 17:21:26 +00:00
" need_validate=%d, "
2011-11-09 07:41:49 +00:00
" canonical_resultid=%u, canonical_credit=%.15e, "
2003-08-15 20:35:44 +00:00
" transition_time=%d, delay_bound=%d, "
2003-06-04 17:21:26 +00:00
" error_mask=%d, file_delete_state=%d, assimilate_state=%d, "
2010-03-29 22:28:20 +00:00
" hr_class=%d, opaque=%.15e, "
2003-08-15 20:35:44 +00:00
" min_quorum=%d, target_nresults=%d, max_error_results=%d, "
2003-08-15 23:44:28 +00:00
" max_total_results=%d, max_success_results=%d, "
2004-12-06 22:41:19 +00:00
" result_template_file='%s', "
2008-03-07 21:13:01 +00:00
" priority=%d, "
2010-03-05 22:55:16 +00:00
" rsc_bandwidth_bound=%.15e, "
2011-06-06 03:40:42 +00:00
" fileset_id=%d, "
2012-01-30 22:39:13 +00:00
" app_version_id=%d, "
2013-04-25 07:27:35 +00:00
" transitioner_flags=%d, "
" size_class=%d " ,
2004-06-16 19:10:24 +00:00
create_time , appid ,
2003-06-04 17:21:26 +00:00
name , xml_doc , batch ,
2003-09-04 00:41:51 +00:00
rsc_fpops_est , rsc_fpops_bound , rsc_memory_bound , rsc_disk_bound ,
2003-06-04 17:21:26 +00:00
need_validate ,
canonical_resultid , canonical_credit ,
2003-08-15 20:35:44 +00:00
transition_time , delay_bound ,
2003-06-04 17:21:26 +00:00
error_mask , file_delete_state , assimilate_state ,
2004-12-06 22:41:19 +00:00
hr_class , opaque ,
2003-08-15 20:35:44 +00:00
min_quorum ,
target_nresults ,
max_error_results ,
max_total_results ,
2003-08-15 23:44:28 +00:00
max_success_results ,
2004-12-06 22:41:19 +00:00
result_template_file ,
2008-03-07 21:13:01 +00:00
priority ,
2010-03-05 22:55:16 +00:00
rsc_bandwidth_bound ,
2011-06-06 03:40:42 +00:00
fileset_id ,
2012-01-30 22:39:13 +00:00
app_version_id ,
2013-04-25 07:27:35 +00:00
transitioner_flags ,
size_class
2003-06-04 17:21:26 +00:00
) ;
}
2014-04-11 06:53:19 +00:00
void DB_WORKUNIT : : db_print_values ( char * buf ) {
sprintf ( buf ,
" (0, %d, %d, "
" '%s', '%s', %d, "
" %f, %f, "
" %f, %f, "
" %d, "
" %u, %f, "
" %d, %d, "
" %d, %d, %d, "
" %d, %f, "
" %d, %d, %d, "
" %d, %d, "
2014-04-11 22:54:41 +00:00
" '%s', "
" %d, NOW(), "
2014-04-11 06:53:19 +00:00
" %f, "
" %d, "
" %d, "
" %d, "
" %d) " ,
create_time , appid ,
name , xml_doc , batch ,
rsc_fpops_est , rsc_fpops_bound , rsc_memory_bound , rsc_disk_bound ,
need_validate ,
canonical_resultid , canonical_credit ,
transition_time , delay_bound ,
error_mask , file_delete_state , assimilate_state ,
hr_class , opaque ,
min_quorum ,
target_nresults ,
max_error_results ,
max_total_results ,
max_success_results ,
result_template_file ,
priority ,
rsc_bandwidth_bound ,
fileset_id ,
app_version_id ,
transitioner_flags ,
size_class
) ;
}
2003-06-04 17:21:26 +00:00
void DB_WORKUNIT : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
2006-05-31 17:19:29 +00:00
id = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
create_time = atoi ( r [ i + + ] ) ;
appid = atoi ( r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
strcpy2 ( xml_doc , r [ i + + ] ) ;
batch = atoi ( r [ i + + ] ) ;
2003-09-04 00:41:51 +00:00
rsc_fpops_est = atof ( r [ i + + ] ) ;
rsc_fpops_bound = atof ( r [ i + + ] ) ;
rsc_memory_bound = atof ( r [ i + + ] ) ;
rsc_disk_bound = atof ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
need_validate = atoi ( r [ i + + ] ) ;
canonical_resultid = atoi ( r [ i + + ] ) ;
canonical_credit = atof ( r [ i + + ] ) ;
2003-08-15 20:35:44 +00:00
transition_time = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
delay_bound = atoi ( r [ i + + ] ) ;
error_mask = atoi ( r [ i + + ] ) ;
file_delete_state = atoi ( r [ i + + ] ) ;
assimilate_state = atoi ( r [ i + + ] ) ;
2004-12-06 22:41:19 +00:00
hr_class = atoi ( r [ i + + ] ) ;
2003-12-12 21:10:39 +00:00
opaque = atof ( r [ i + + ] ) ;
2003-08-15 20:35:44 +00:00
min_quorum = atoi ( r [ i + + ] ) ;
target_nresults = atoi ( r [ i + + ] ) ;
max_error_results = atoi ( r [ i + + ] ) ;
max_total_results = atoi ( r [ i + + ] ) ;
max_success_results = atoi ( r [ i + + ] ) ;
2004-07-02 19:17:53 +00:00
strcpy2 ( result_template_file , r [ i + + ] ) ;
2004-12-06 22:41:19 +00:00
priority = atoi ( r [ i + + ] ) ;
strcpy2 ( mod_time , r [ i + + ] ) ;
2008-03-07 21:13:01 +00:00
rsc_bandwidth_bound = atof ( r [ i + + ] ) ;
2010-03-05 22:55:16 +00:00
fileset_id = atoi ( r [ i + + ] ) ;
2011-06-06 03:40:42 +00:00
app_version_id = atoi ( r [ i + + ] ) ;
2012-01-30 22:39:13 +00:00
transitioner_flags = atoi ( r [ i + + ] ) ;
2013-04-25 07:27:35 +00:00
size_class = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
}
2007-05-02 23:17:52 +00:00
void DB_CREDITED_JOB : : db_print ( char * buf ) {
2007-05-02 18:51:51 +00:00
sprintf ( buf ,
2007-06-20 22:34:06 +00:00
" userid=%d, workunitid=%f " ,
2007-05-02 18:51:51 +00:00
userid , workunitid
) ;
}
2007-05-02 23:17:52 +00:00
void DB_CREDITED_JOB : : db_parse ( MYSQL_ROW & r ) {
2007-05-02 18:51:51 +00:00
int i = 0 ;
clear ( ) ;
userid = atoi ( r [ i + + ] ) ;
2007-06-20 22:34:06 +00:00
workunitid = atof ( r [ i + + ] ) ;
2007-05-02 18:51:51 +00:00
} ;
2003-06-04 17:21:26 +00:00
void DB_RESULT : : db_print ( char * buf ) {
2004-04-09 23:33:50 +00:00
ESCAPE ( xml_doc_out ) ;
ESCAPE ( stderr_out ) ;
2003-07-25 20:26:38 +00:00
sprintf (
buf ,
2004-06-16 19:10:24 +00:00
" create_time=%d, workunitid=%d, "
2003-06-04 17:21:26 +00:00
" server_state=%d, outcome=%d, client_state=%d, "
2003-10-16 18:10:56 +00:00
" hostid=%d, userid=%d, "
" report_deadline=%d, sent_time=%d, received_time=%d, "
2003-08-12 20:58:24 +00:00
" name='%s', cpu_time=%.15e, "
2003-06-04 17:21:26 +00:00
" xml_doc_in='%s', xml_doc_out='%s', stderr_out='%s', "
" batch=%d, file_delete_state=%d, validate_state=%d, "
2010-03-29 22:28:20 +00:00
" claimed_credit=%.15e, granted_credit=%.15e, opaque=%.15e, random=%d, "
2004-12-06 22:41:19 +00:00
" app_version_num=%d, appid=%d, exit_status=%d, teamid=%d, "
2013-07-19 00:10:54 +00:00
" priority=%d, elapsed_time=%.15e, flops_estimate=%.15e, "
2014-04-03 02:35:59 +00:00
" app_version_id=%d, runtime_outlier=%d, size_class=%d, "
" peak_working_set_size=%.0f, "
" peak_swap_size=%.0f, "
" peak_disk_usage=%.0f " ,
2004-06-16 19:10:24 +00:00
create_time , workunitid ,
2003-06-04 17:21:26 +00:00
server_state , outcome , client_state ,
2003-10-16 18:10:56 +00:00
hostid , userid ,
report_deadline , sent_time , received_time ,
2003-06-04 17:21:26 +00:00
name , cpu_time ,
xml_doc_in , xml_doc_out , stderr_out ,
batch , file_delete_state , validate_state ,
2003-11-11 20:49:07 +00:00
claimed_credit , granted_credit , opaque , random ,
2004-12-06 22:41:19 +00:00
app_version_num , appid , exit_status , teamid ,
2011-09-16 16:43:15 +00:00
priority , elapsed_time , flops_estimate ,
app_version_id ,
2013-04-25 07:27:35 +00:00
runtime_outlier ? 1 : 0 ,
2014-04-03 02:35:59 +00:00
size_class ,
peak_working_set_size ,
peak_swap_size ,
peak_disk_usage
2003-06-04 17:21:26 +00:00
) ;
2004-04-09 23:33:50 +00:00
UNESCAPE ( xml_doc_out ) ;
UNESCAPE ( stderr_out ) ;
2003-06-04 17:21:26 +00:00
}
2004-12-06 22:41:19 +00:00
// the following used for "batch insert" from transitioner
//
2004-07-21 21:50:25 +00:00
void DB_RESULT : : db_print_values ( char * buf ) {
ESCAPE ( xml_doc_out ) ;
ESCAPE ( stderr_out ) ;
sprintf (
buf ,
" (0, %d, %d, "
" %d, %d, %d, "
" %d, %d, "
" %d, %d, %d, "
" '%s', %.15e, "
" '%s', '%s', '%s', "
" %d, %d, %d, "
2010-03-29 22:28:20 +00:00
" %.15e, %.15e, %.15e, %d, "
2014-04-03 02:35:59 +00:00
" %d, %d, %d, %d, %d, NOW(), 0, 0, 0, 0, %d, 0, 0, 0) " ,
2004-07-21 21:50:25 +00:00
create_time , workunitid ,
server_state , outcome , client_state ,
hostid , userid ,
report_deadline , sent_time , received_time ,
name , cpu_time ,
xml_doc_in , xml_doc_out , stderr_out ,
batch , file_delete_state , validate_state ,
claimed_credit , granted_credit , opaque , random ,
2013-04-25 07:27:35 +00:00
app_version_num , appid , exit_status , teamid , priority , size_class
2004-07-21 21:50:25 +00:00
) ;
UNESCAPE ( xml_doc_out ) ;
UNESCAPE ( stderr_out ) ;
}
2006-03-17 04:47:51 +00:00
// called from scheduler when dispatch this result.
// The "... and server_state=%d" is a safeguard against
// the case where another scheduler tries to send this result at the same time
2004-12-06 22:41:19 +00:00
//
2011-02-23 21:22:45 +00:00
int DB_RESULT : : mark_as_sent ( int old_server_state , int report_grace_period ) {
2004-07-22 15:32:30 +00:00
char query [ MAX_QUERY_LEN ] ;
2006-03-17 04:47:51 +00:00
int retval ;
2004-07-22 15:32:30 +00:00
sprintf ( query ,
2011-11-09 17:27:50 +00:00
" update result set server_state=%d, hostid=%d, userid=%d, sent_time=%d, report_deadline=%d, flops_estimate=%.15e, app_version_id=%d where id=%u and server_state=%d " ,
2011-02-15 22:07:14 +00:00
server_state ,
hostid ,
userid ,
sent_time ,
report_deadline + report_grace_period ,
flops_estimate ,
app_version_id ,
id ,
old_server_state
2004-07-22 15:32:30 +00:00
) ;
2006-03-17 04:47:51 +00:00
retval = db - > do_query ( query ) ;
if ( retval ) return retval ;
if ( db - > affected_rows ( ) ! = 1 ) return ERR_DB_NOT_FOUND ;
2006-03-17 05:54:06 +00:00
return 0 ;
2004-07-22 15:32:30 +00:00
}
2003-06-04 17:21:26 +00:00
void DB_RESULT : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
2006-05-31 17:19:29 +00:00
id = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
create_time = atoi ( r [ i + + ] ) ;
workunitid = atoi ( r [ i + + ] ) ;
server_state = atoi ( r [ i + + ] ) ;
outcome = atoi ( r [ i + + ] ) ;
client_state = atoi ( r [ i + + ] ) ;
hostid = atoi ( r [ i + + ] ) ;
2003-10-16 18:10:56 +00:00
userid = atoi ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
report_deadline = atoi ( r [ i + + ] ) ;
sent_time = atoi ( r [ i + + ] ) ;
received_time = atoi ( r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
cpu_time = atof ( r [ i + + ] ) ;
strcpy2 ( xml_doc_in , r [ i + + ] ) ;
strcpy2 ( xml_doc_out , r [ i + + ] ) ;
strcpy2 ( stderr_out , r [ i + + ] ) ;
batch = atoi ( r [ i + + ] ) ;
file_delete_state = atoi ( r [ i + + ] ) ;
validate_state = atoi ( r [ i + + ] ) ;
claimed_credit = atof ( r [ i + + ] ) ;
granted_credit = atof ( r [ i + + ] ) ;
2003-12-12 21:10:39 +00:00
opaque = atof ( r [ i + + ] ) ;
2003-06-04 17:21:26 +00:00
random = atoi ( r [ i + + ] ) ;
2004-01-14 20:24:24 +00:00
app_version_num = atoi ( r [ i + + ] ) ;
2003-11-11 20:49:07 +00:00
appid = atoi ( r [ i + + ] ) ;
2003-12-23 19:21:52 +00:00
exit_status = atoi ( r [ i + + ] ) ;
2004-01-14 20:24:24 +00:00
teamid = atoi ( r [ i + + ] ) ;
2004-12-06 22:41:19 +00:00
priority = atoi ( r [ i + + ] ) ;
strcpy2 ( mod_time , r [ i + + ] ) ;
2009-09-03 20:26:31 +00:00
elapsed_time = atof ( r [ i + + ] ) ;
flops_estimate = atof ( r [ i + + ] ) ;
app_version_id = atoi ( r [ i + + ] ) ;
2011-09-16 16:43:15 +00:00
runtime_outlier = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2013-04-25 07:27:35 +00:00
size_class = atoi ( r [ i + + ] ) ;
2014-04-03 02:35:59 +00:00
peak_working_set_size = atof ( r [ i + + ] ) ;
peak_swap_size = atof ( r [ i + + ] ) ;
peak_disk_usage = atof ( r [ i + + ] ) ;
2013-04-25 07:27:35 +00:00
}
int DB_RESULT : : get_unsent_counts ( APP & app , int * unsent_count ) {
char query [ 1024 ] ;
MYSQL_RES * rp ;
for ( int i = 0 ; i < app . n_size_classes ; i + + ) {
unsent_count [ i ] = 0 ;
}
sprintf ( query ,
" select size_class, count(size_class) from result where appid=%d and server_state=%d group by size_class " ,
app . id , RESULT_SERVER_STATE_UNSENT
) ;
int retval = db - > do_query ( query ) ;
if ( retval ) return mysql_errno ( db - > mysql ) ;
rp = mysql_store_result ( db - > mysql ) ;
if ( ! rp ) return mysql_errno ( db - > mysql ) ;
while ( 1 ) {
MYSQL_ROW row = mysql_fetch_row ( rp ) ;
if ( ! row ) break ;
int sc = atoi ( row [ 0 ] ) ;
int count = atoi ( row [ 1 ] ) ;
if ( sc > = app . n_size_classes ) {
fprintf ( stderr , " size class %d too large \n " , sc ) ;
retval = - 1 ;
break ;
}
unsent_count [ sc ] = count ;
} ;
mysql_free_result ( rp ) ;
return retval ;
}
int DB_RESULT : : make_unsent (
APP & app , int size_class , int n , const char * order_clause , int & nchanged
) {
char query [ 1024 ] ;
sprintf ( query ,
" update result set server_state=%d where appid=%d and server_state=%d and size_class=%d %s limit %d " ,
RESULT_SERVER_STATE_UNSENT ,
app . id ,
RESULT_SERVER_STATE_INACTIVE ,
size_class ,
order_clause ,
n
) ;
int retval = db - > do_query ( query ) ;
if ( retval ) return mysql_errno ( db - > mysql ) ;
nchanged = db - > affected_rows ( ) ;
return 0 ;
2003-06-04 17:21:26 +00:00
}
2004-06-22 22:56:50 +00:00
void DB_MSG_FROM_HOST : : db_print ( char * buf ) {
2004-04-09 23:33:50 +00:00
ESCAPE ( xml ) ;
2013-03-11 07:02:16 +00:00
ESCAPE ( variety ) ;
2004-01-04 06:48:40 +00:00
sprintf ( buf ,
2004-07-06 04:10:51 +00:00
" create_time=%d, "
" hostid=%d, variety='%s', "
2004-03-17 01:26:44 +00:00
" handled=%d, xml='%s' " ,
2004-06-24 21:00:46 +00:00
2004-07-06 04:10:51 +00:00
create_time ,
2004-06-22 22:56:50 +00:00
hostid , variety ,
2004-03-17 01:26:44 +00:00
handled , xml
2004-06-24 21:00:46 +00:00
2004-01-04 06:48:40 +00:00
) ;
2004-04-09 23:33:50 +00:00
UNESCAPE ( xml ) ;
2013-03-11 07:02:16 +00:00
UNESCAPE ( variety ) ;
2004-01-04 06:48:40 +00:00
}
2004-06-22 22:56:50 +00:00
void DB_MSG_FROM_HOST : : db_parse ( MYSQL_ROW & r ) {
2004-01-04 06:48:40 +00:00
int i = 0 ;
clear ( ) ;
2006-05-31 17:19:29 +00:00
id = atoi ( r [ i + + ] ) ;
create_time = atoi ( r [ i + + ] ) ;
hostid = atoi ( r [ i + + ] ) ;
2004-07-06 04:10:51 +00:00
strcpy2 ( variety , r [ i + + ] ) ;
2004-01-04 06:48:40 +00:00
handled = atoi ( r [ i + + ] ) ;
strcpy2 ( xml , r [ i + + ] ) ;
}
2004-06-22 22:56:50 +00:00
void DB_MSG_TO_HOST : : db_print ( char * buf ) {
2004-04-09 23:33:50 +00:00
ESCAPE ( xml ) ;
2013-03-11 07:02:16 +00:00
ESCAPE ( variety ) ;
2004-03-17 01:26:44 +00:00
sprintf ( buf ,
2004-06-16 19:10:24 +00:00
" create_time=%d, "
2004-07-06 04:10:51 +00:00
" hostid=%d, variety='%s', "
2004-03-17 01:26:44 +00:00
" handled=%d, xml='%s' " ,
2004-06-16 19:10:24 +00:00
create_time ,
2004-06-22 22:56:50 +00:00
hostid , variety ,
2004-03-17 01:26:44 +00:00
handled , xml
) ;
2004-04-09 23:33:50 +00:00
UNESCAPE ( xml ) ;
2013-03-11 07:02:16 +00:00
UNESCAPE ( variety ) ;
2004-03-17 01:26:44 +00:00
}
2004-06-22 22:56:50 +00:00
void DB_MSG_TO_HOST : : db_parse ( MYSQL_ROW & r ) {
2004-03-17 01:26:44 +00:00
int i = 0 ;
clear ( ) ;
2006-05-31 17:19:29 +00:00
id = atoi ( r [ i + + ] ) ;
create_time = atoi ( r [ i + + ] ) ;
hostid = atoi ( r [ i + + ] ) ;
2004-07-06 04:10:51 +00:00
strcpy2 ( variety , r [ i + + ] ) ;
2006-05-31 17:19:29 +00:00
handled = atoi ( r [ i + + ] ) ;
2004-03-17 01:26:44 +00:00
strcpy2 ( xml , r [ i + + ] ) ;
}
2004-07-01 18:43:36 +00:00
2008-02-21 00:47:50 +00:00
void DB_ASSIGNMENT : : db_print ( char * buf ) {
sprintf ( buf ,
" create_time=%d, "
" target_id=%d, "
" target_type=%d, "
" multi=%d, "
" workunitid=%d, "
2011-11-09 07:41:49 +00:00
" resultid=%u " ,
2008-02-21 00:47:50 +00:00
create_time ,
target_id ,
target_type ,
multi ,
workunitid ,
2012-01-30 22:39:13 +00:00
_resultid
2008-02-21 00:47:50 +00:00
) ;
}
void DB_ASSIGNMENT : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
create_time = atoi ( r [ i + + ] ) ;
target_id = atoi ( r [ i + + ] ) ;
target_type = atoi ( r [ i + + ] ) ;
multi = atoi ( r [ i + + ] ) ;
workunitid = atoi ( r [ i + + ] ) ;
2012-01-30 22:39:13 +00:00
_resultid = atoi ( r [ i + + ] ) ;
2008-02-21 00:47:50 +00:00
}
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
int DB_HOST_APP_VERSION : : update_scheduler ( DB_HOST_APP_VERSION & orig ) {
char query [ 1024 ] , clause [ 512 ] ;
2010-04-21 19:33:20 +00:00
if ( consecutive_valid = = orig . consecutive_valid
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
& & max_jobs_per_day = = orig . max_jobs_per_day
& & n_jobs_today = = orig . n_jobs_today
) {
return 0 ;
}
sprintf ( query ,
2010-04-21 19:33:20 +00:00
" consecutive_valid=%d, max_jobs_per_day=%d, n_jobs_today=%d " ,
consecutive_valid ,
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
max_jobs_per_day ,
n_jobs_today
) ;
sprintf ( clause , " host_id=%d and app_version_id=%d " , host_id , app_version_id ) ;
return update_fields_noid ( query , clause ) ;
}
int DB_HOST_APP_VERSION : : update_validator ( DB_HOST_APP_VERSION & orig ) {
2010-04-26 23:12:40 +00:00
char query [ 8192 ] , clause [ 512 ] ;
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
if ( pfc . n = = orig . pfc . n
& & pfc . avg = = orig . pfc . avg
& & et . n = = orig . et . n
& & et . avg = = orig . et . avg
& & et . q = = orig . et . q
& & et . var = = orig . et . var
& & turnaround . n = = orig . turnaround . n
& & turnaround . avg = = orig . turnaround . avg
& & turnaround . q = = orig . turnaround . q
& & turnaround . var = = orig . turnaround . var
2010-04-21 19:33:20 +00:00
& & consecutive_valid = = orig . consecutive_valid
- back end: change "daily result quota" mechanism.
Old: config.xml specifies an initial daily quota (say, 100).
Each host_app_version starts out with this quota.
On the return of a SUCCESS result,
the quota is doubled, up to the initial value.
On the return of an error result, or a timeout,
the quota is decremented down to 1.
Problem:
Doesn't accommodate hosts that can do more than 100 jobs/day.
New: similar, but
- on validation of a job, daily quota is incremented.
- on invalidation of a job, daily quota is decremented.
- on return of an error result, or a timeout,
daily quota is min'd with initial quota, then decremented.
Notes:
- This allows a host to have an unboundedly large quota
as long as it continues to return more valid
than invalid results.
- Even with this change, hosts that return SUCCESS but
invalid results will continue to get the initial daily quota.
It would be desirable to reduce their quota to 1.
svn path=/trunk/boinc/; revision=21675
2010-06-02 00:11:01 +00:00
& & max_jobs_per_day = = orig . max_jobs_per_day
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
) {
return 0 ;
}
sprintf ( query ,
" pfc_n=%.15e, "
" pfc_avg=%.15e, "
" et_n=%.15e, "
" et_avg=%.15e, "
" et_q=%.15e, "
" et_var=%.15e, "
" turnaround_n=%.15e, "
" turnaround_avg=%.15e, "
" turnaround_q=%.15e, "
" turnaround_var=%.15e, "
- back end: change "daily result quota" mechanism.
Old: config.xml specifies an initial daily quota (say, 100).
Each host_app_version starts out with this quota.
On the return of a SUCCESS result,
the quota is doubled, up to the initial value.
On the return of an error result, or a timeout,
the quota is decremented down to 1.
Problem:
Doesn't accommodate hosts that can do more than 100 jobs/day.
New: similar, but
- on validation of a job, daily quota is incremented.
- on invalidation of a job, daily quota is decremented.
- on return of an error result, or a timeout,
daily quota is min'd with initial quota, then decremented.
Notes:
- This allows a host to have an unboundedly large quota
as long as it continues to return more valid
than invalid results.
- Even with this change, hosts that return SUCCESS but
invalid results will continue to get the initial daily quota.
It would be desirable to reduce their quota to 1.
svn path=/trunk/boinc/; revision=21675
2010-06-02 00:11:01 +00:00
" consecutive_valid=%d, "
" max_jobs_per_day=%d " ,
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
pfc . n ,
pfc . avg ,
et . n ,
et . avg ,
et . q ,
et . var ,
turnaround . n ,
turnaround . avg ,
turnaround . q ,
turnaround . var ,
- back end: change "daily result quota" mechanism.
Old: config.xml specifies an initial daily quota (say, 100).
Each host_app_version starts out with this quota.
On the return of a SUCCESS result,
the quota is doubled, up to the initial value.
On the return of an error result, or a timeout,
the quota is decremented down to 1.
Problem:
Doesn't accommodate hosts that can do more than 100 jobs/day.
New: similar, but
- on validation of a job, daily quota is incremented.
- on invalidation of a job, daily quota is decremented.
- on return of an error result, or a timeout,
daily quota is min'd with initial quota, then decremented.
Notes:
- This allows a host to have an unboundedly large quota
as long as it continues to return more valid
than invalid results.
- Even with this change, hosts that return SUCCESS but
invalid results will continue to get the initial daily quota.
It would be desirable to reduce their quota to 1.
svn path=/trunk/boinc/; revision=21675
2010-06-02 00:11:01 +00:00
consecutive_valid ,
max_jobs_per_day
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
) ;
sprintf ( clause ,
" host_id=%d and app_version_id=%d " ,
host_id , app_version_id
) ;
return update_fields_noid ( query , clause ) ;
}
2010-03-29 22:28:20 +00:00
void DB_HOST_APP_VERSION : : db_print ( char * buf ) {
sprintf ( buf ,
" host_id=%d, "
" app_version_id=%d, "
" pfc_n=%.15e, "
" pfc_avg=%.15e, "
" et_n=%.15e, "
" et_avg=%.15e, "
" et_var=%.15e, "
" et_q=%.15e, "
" max_jobs_per_day=%d, "
" n_jobs_today=%d, "
" turnaround_n=%.15e, "
" turnaround_avg=%.15e, "
" turnaround_var=%.15e, "
2010-04-21 19:33:20 +00:00
" turnaround_q=%.15e, "
" consecutive_valid=%d " ,
2010-03-29 22:28:20 +00:00
host_id ,
app_version_id ,
pfc . n ,
pfc . avg ,
et . n ,
et . avg ,
et . var ,
et . q ,
max_jobs_per_day ,
n_jobs_today ,
turnaround . n ,
turnaround . avg ,
turnaround . var ,
2010-04-21 19:33:20 +00:00
turnaround . q ,
consecutive_valid
2010-03-29 22:28:20 +00:00
) ;
}
void DB_HOST_APP_VERSION : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
host_id = atoi ( r [ i + + ] ) ;
app_version_id = atoi ( r [ i + + ] ) ;
pfc . n = atof ( r [ i + + ] ) ;
pfc . avg = atof ( r [ i + + ] ) ;
et . n = atof ( r [ i + + ] ) ;
et . avg = atof ( r [ i + + ] ) ;
et . var = atof ( r [ i + + ] ) ;
et . q = atof ( r [ i + + ] ) ;
max_jobs_per_day = atoi ( r [ i + + ] ) ;
n_jobs_today = atoi ( r [ i + + ] ) ;
turnaround . n = atof ( r [ i + + ] ) ;
turnaround . avg = atof ( r [ i + + ] ) ;
turnaround . var = atof ( r [ i + + ] ) ;
turnaround . q = atof ( r [ i + + ] ) ;
2010-04-21 19:33:20 +00:00
consecutive_valid = atoi ( r [ i + + ] ) ;
2010-03-29 22:28:20 +00:00
}
2012-12-06 07:09:22 +00:00
void DB_USER_SUBMIT : : db_print ( char * buf ) {
sprintf ( buf ,
" user_id=%d, "
" quota=%.15e, "
" logical_start_time=%.15e, "
" submit_all=%d, "
" manage_all=%d " ,
user_id ,
quota ,
logical_start_time ,
submit_all ? 1 : 0 ,
manage_all ? 1 : 0
) ;
}
void DB_USER_SUBMIT : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
user_id = atoi ( r [ i + + ] ) ;
quota = atof ( r [ i + + ] ) ;
logical_start_time = atof ( r [ i + + ] ) ;
submit_all = ( atoi ( r [ i + + ] ) ! = 0 ) ;
manage_all = ( atoi ( r [ i + + ] ) ! = 0 ) ;
}
2009-06-23 21:45:22 +00:00
void DB_STATE_COUNTS : : db_print ( char * buf ) {
sprintf ( buf ,
" appid=%d, "
" last_update_time=%d, "
" result_server_state_2=%d, "
" result_server_state_4=%d, "
" result_file_delete_state_1=%d, "
" result_file_delete_state_2=%d, "
" result_server_state_5_and_file_delete_state_0=%d, "
" workunit_need_validate_1=%d, "
" workunit_assimilate_state_1=%d, "
" workunit_file_delete_state_1=%d, "
" workunit_file_delete_state_2=%d, " ,
appid ,
last_update_time ,
result_server_state_2 ,
result_server_state_4 ,
result_file_delete_state_1 ,
result_file_delete_state_2 ,
result_server_state_5_and_file_delete_state_0 ,
workunit_need_validate_1 ,
workunit_assimilate_state_1 ,
workunit_file_delete_state_1 ,
workunit_file_delete_state_2
) ;
}
void DB_STATE_COUNTS : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
appid = atoi ( r [ i + + ] ) ;
last_update_time = atoi ( r [ i + + ] ) ;
result_server_state_2 = atoi ( r [ i + + ] ) ;
result_server_state_4 = atoi ( r [ i + + ] ) ;
result_file_delete_state_1 = atoi ( r [ i + + ] ) ;
result_file_delete_state_2 = atoi ( r [ i + + ] ) ;
result_server_state_5_and_file_delete_state_0 = atoi ( r [ i + + ] ) ;
workunit_need_validate_1 = atoi ( r [ i + + ] ) ;
workunit_assimilate_state_1 = atoi ( r [ i + + ] ) ;
workunit_file_delete_state_1 = atoi ( r [ i + + ] ) ;
workunit_file_delete_state_2 = atoi ( r [ i + + ] ) ;
}
2004-07-06 18:30:22 +00:00
void TRANSITIONER_ITEM : : parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
appid = atoi ( r [ i + + ] ) ;
min_quorum = atoi ( r [ i + + ] ) ;
2004-12-01 05:03:53 +00:00
need_validate = atoi ( r [ i + + ] ) ;
2004-07-06 18:30:22 +00:00
canonical_resultid = atoi ( r [ i + + ] ) ;
transition_time = atoi ( r [ i + + ] ) ;
delay_bound = atoi ( r [ i + + ] ) ;
error_mask = atoi ( r [ i + + ] ) ;
max_error_results = atoi ( r [ i + + ] ) ;
max_total_results = atoi ( r [ i + + ] ) ;
file_delete_state = atoi ( r [ i + + ] ) ;
assimilate_state = atoi ( r [ i + + ] ) ;
target_nresults = atoi ( r [ i + + ] ) ;
strcpy2 ( result_template_file , r [ i + + ] ) ;
2004-12-06 22:41:19 +00:00
priority = atoi ( r [ i + + ] ) ;
2007-05-29 23:41:31 +00:00
hr_class = atoi ( r [ i + + ] ) ;
2006-01-26 00:19:05 +00:00
batch = atoi ( r [ i + + ] ) ;
2011-06-06 03:40:42 +00:00
app_version_id = atoi ( r [ i + + ] ) ;
2012-01-30 22:39:13 +00:00
transitioner_flags = atoi ( r [ i + + ] ) ;
2013-04-25 07:27:35 +00:00
size_class = atoi ( r [ i + + ] ) ;
2004-12-06 22:41:19 +00:00
// use safe_atoi() from here on cuz they might not be there
//
2004-07-06 18:30:22 +00:00
res_id = safe_atoi ( r [ i + + ] ) ;
strcpy2 ( res_name , r [ i + + ] ) ;
res_report_deadline = safe_atoi ( r [ i + + ] ) ;
res_server_state = safe_atoi ( r [ i + + ] ) ;
res_outcome = safe_atoi ( r [ i + + ] ) ;
res_validate_state = safe_atoi ( r [ i + + ] ) ;
res_file_delete_state = safe_atoi ( r [ i + + ] ) ;
res_sent_time = safe_atoi ( r [ i + + ] ) ;
2004-12-16 21:58:10 +00:00
res_hostid = safe_atoi ( r [ i + + ] ) ;
2007-04-05 17:02:01 +00:00
res_received_time = safe_atoi ( r [ i + + ] ) ;
2010-03-29 22:28:20 +00:00
res_app_version_id = safe_atoi ( r [ i + + ] ) ;
2014-05-23 06:54:56 +00:00
res_exit_status = safe_atoi ( r [ i + + ] ) ;
2004-07-06 18:30:22 +00:00
}
2004-07-01 20:24:00 +00:00
int DB_TRANSITIONER_ITEM_SET : : enumerate (
2004-07-22 17:43:11 +00:00
int transition_time , int nresult_limit ,
2005-08-11 23:53:24 +00:00
int wu_id_modulus , int wu_id_remainder ,
2004-07-01 20:24:00 +00:00
std : : vector < TRANSITIONER_ITEM > & items
) {
2006-01-19 21:46:25 +00:00
int retval ;
2004-12-06 22:41:19 +00:00
char query [ MAX_QUERY_LEN ] ;
2008-03-03 19:33:32 +00:00
char mod_clause [ 256 ] ; ;
2015-03-20 21:49:31 +00:00
char time_clause [ 256 ] ;
2004-12-06 22:41:19 +00:00
MYSQL_ROW row ;
TRANSITIONER_ITEM new_item ;
2004-07-01 18:43:36 +00:00
if ( ! cursor . active ) {
2015-03-20 21:49:31 +00:00
sprintf ( time_clause , " wu.transition_time < %d " , transition_time ) ;
2008-03-03 19:33:32 +00:00
if ( wu_id_modulus ) {
2015-03-18 06:39:19 +00:00
// terrible kludge: if rem >= mod, treat it as a WU ID
// This is to support the --wu_id debugging feature
//
if ( wu_id_remainder < wu_id_modulus ) {
sprintf ( mod_clause ,
" and wu.id %% %d = %d " ,
wu_id_modulus , wu_id_remainder
) ;
} else {
sprintf ( mod_clause , " and wu.id = %u " , wu_id_remainder ) ;
2015-03-20 21:49:31 +00:00
strcpy ( time_clause , " true " ) ;
2015-03-18 06:39:19 +00:00
}
2005-08-11 23:53:24 +00:00
} else {
strcpy ( mod_clause , " " ) ;
}
2004-07-01 18:43:36 +00:00
sprintf ( query ,
2008-03-03 19:33:32 +00:00
" SELECT "
2004-07-01 18:43:36 +00:00
" wu.id, "
" wu.name, "
" wu.appid, "
" wu.min_quorum, "
2004-12-01 05:03:53 +00:00
" wu.need_validate, "
2004-07-01 18:43:36 +00:00
" wu.canonical_resultid, "
" wu.transition_time, "
" wu.delay_bound, "
" wu.error_mask, "
" wu.max_error_results, "
" wu.max_total_results, "
" wu.file_delete_state, "
" wu.assimilate_state, "
" wu.target_nresults, "
2004-07-01 19:01:37 +00:00
" wu.result_template_file, "
2004-12-06 22:41:19 +00:00
" wu.priority, "
2007-05-29 23:41:31 +00:00
" wu.hr_class, "
2006-01-26 00:19:05 +00:00
" wu.batch, "
2011-06-06 03:40:42 +00:00
" wu.app_version_id, "
2012-01-30 22:39:13 +00:00
" wu.transitioner_flags, "
2013-04-25 07:27:35 +00:00
" wu.size_class, "
2004-07-03 03:39:11 +00:00
" res.id, "
" res.name, "
" res.report_deadline, "
" res.server_state, "
" res.outcome, "
" res.validate_state, "
" res.file_delete_state, "
2004-12-16 21:58:10 +00:00
" res.sent_time, "
2007-04-05 17:02:01 +00:00
" res.hostid, "
2010-03-29 22:28:20 +00:00
" res.received_time, "
2014-05-23 06:54:56 +00:00
" res.app_version_id, "
" res.exit_status "
2004-07-01 18:43:36 +00:00
" FROM "
" workunit AS wu "
" LEFT JOIN result AS res ON wu.id = res.workunitid "
" WHERE "
2015-03-20 21:49:31 +00:00
" %s %s and transitioner_flags<>%d "
2004-07-01 18:43:36 +00:00
" LIMIT "
2004-07-02 17:53:31 +00:00
" %d " ,
2015-03-20 21:49:31 +00:00
time_clause , mod_clause , TRANSITION_NONE , nresult_limit
2008-03-03 19:33:32 +00:00
) ;
2004-07-01 18:43:36 +00:00
2006-01-19 21:46:25 +00:00
retval = db - > do_query ( query ) ;
if ( retval ) return mysql_errno ( db - > mysql ) ;
2004-07-01 20:24:00 +00:00
// the following stores the entire result set in memory
2004-12-06 22:41:19 +00:00
//
2004-07-01 18:43:36 +00:00
cursor . rp = mysql_store_result ( db - > mysql ) ;
if ( ! cursor . rp ) return mysql_errno ( db - > mysql ) ;
2004-07-01 20:24:00 +00:00
cursor . active = true ;
2004-07-01 18:43:36 +00:00
2004-07-01 20:24:00 +00:00
row = mysql_fetch_row ( cursor . rp ) ;
if ( ! row ) {
2004-07-04 01:01:56 +00:00
mysql_free_result ( cursor . rp ) ;
2004-07-01 20:24:00 +00:00
cursor . active = false ;
2006-01-19 21:46:25 +00:00
retval = mysql_errno ( db - > mysql ) ;
2008-03-27 18:25:29 +00:00
if ( retval ) return ERR_DB_CONN_LOST ;
2006-01-19 21:46:25 +00:00
return ERR_DB_NOT_FOUND ;
2004-07-01 20:24:00 +00:00
}
last_item . parse ( row ) ;
2004-07-02 23:24:36 +00:00
nitems_this_query = 1 ;
2004-07-01 18:43:36 +00:00
}
2004-07-01 20:24:00 +00:00
items . clear ( ) ;
while ( true ) {
items . push_back ( last_item ) ;
2004-07-01 18:43:36 +00:00
row = mysql_fetch_row ( cursor . rp ) ;
if ( ! row ) {
2004-07-04 01:01:56 +00:00
mysql_free_result ( cursor . rp ) ;
2004-07-01 18:43:36 +00:00
cursor . active = false ;
2004-07-02 23:24:36 +00:00
// if got fewer rows than requested, last group is complete
//
if ( nitems_this_query < nresult_limit ) {
return 0 ;
} else {
2006-01-19 21:46:25 +00:00
return ERR_DB_NOT_FOUND ;
2004-07-02 23:24:36 +00:00
}
2004-07-01 18:43:36 +00:00
}
2004-07-01 20:24:00 +00:00
new_item . parse ( row ) ;
2004-07-02 23:24:36 +00:00
nitems_this_query + + ;
2004-07-01 20:24:00 +00:00
if ( new_item . id ! = last_item . id ) {
last_item = new_item ;
return 0 ;
}
last_item = new_item ;
2004-07-01 18:43:36 +00:00
}
return 0 ;
}
2004-07-02 19:45:33 +00:00
int DB_TRANSITIONER_ITEM_SET : : update_result ( TRANSITIONER_ITEM & ti ) {
char query [ MAX_QUERY_LEN ] ;
sprintf ( query ,
2004-10-08 22:41:33 +00:00
" update result set server_state=%d, outcome=%d, "
2011-11-09 17:27:50 +00:00
" validate_state=%d, file_delete_state=%d where id=%u " ,
2004-07-02 19:45:33 +00:00
ti . res_server_state ,
ti . res_outcome ,
ti . res_validate_state ,
ti . res_file_delete_state ,
ti . res_id
) ;
2009-09-03 20:26:31 +00:00
int retval = db - > do_query ( query ) ;
if ( db - > affected_rows ( ) ! = 1 ) return ERR_DB_NOT_FOUND ;
return retval ;
2004-07-02 19:45:33 +00:00
}
2005-03-30 06:36:11 +00:00
int DB_TRANSITIONER_ITEM_SET : : update_workunit (
TRANSITIONER_ITEM & ti , TRANSITIONER_ITEM & ti_original
) {
2004-07-02 19:45:33 +00:00
char query [ MAX_QUERY_LEN ] ;
2005-03-30 06:36:11 +00:00
char updates [ 4096 ] , buf [ 256 ] ;
2004-07-02 19:45:33 +00:00
2005-03-30 06:36:11 +00:00
strcpy ( updates , " " ) ;
if ( ti . need_validate ! = ti_original . need_validate ) {
sprintf ( buf , " need_validate=%d, " , ti . need_validate ) ;
strcat ( updates , buf ) ;
}
if ( ti . error_mask ! = ti_original . error_mask ) {
sprintf ( buf , " error_mask=%d, " , ti . error_mask ) ;
strcat ( updates , buf ) ;
}
if ( ti . assimilate_state ! = ti_original . assimilate_state ) {
sprintf ( buf , " assimilate_state=%d, " , ti . assimilate_state ) ;
strcat ( updates , buf ) ;
}
if ( ti . file_delete_state ! = ti_original . file_delete_state ) {
sprintf ( buf , " file_delete_state=%d, " , ti . file_delete_state ) ;
strcat ( updates , buf ) ;
}
if ( ti . transition_time ! = ti_original . transition_time ) {
sprintf ( buf , " transition_time=%d, " , ti . transition_time ) ;
strcat ( updates , buf ) ;
}
2007-05-29 23:41:31 +00:00
if ( ti . hr_class ! = ti_original . hr_class ) {
sprintf ( buf , " hr_class=%d, " , ti . hr_class ) ;
strcat ( updates , buf ) ;
}
2011-06-06 03:40:42 +00:00
if ( ti . app_version_id ! = ti_original . app_version_id ) {
sprintf ( buf , " app_version_id=%d, " , ti . app_version_id ) ;
strcat ( updates , buf ) ;
}
2005-03-30 06:36:11 +00:00
int n = strlen ( updates ) ;
if ( n = = 0 ) {
return 0 ;
}
// trim the final comma
//
updates [ n - 1 ] = 0 ;
sprintf ( query , " update workunit set %s where id=%d " , updates , ti . id ) ;
2004-07-03 23:01:29 +00:00
return db - > do_query ( query ) ;
2004-07-02 19:45:33 +00:00
}
2004-07-02 22:48:33 +00:00
2004-10-08 22:41:33 +00:00
void VALIDATOR_ITEM : : parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
2004-10-08 23:07:59 +00:00
wu . id = atoi ( r [ i + + ] ) ;
strcpy2 ( wu . name , r [ i + + ] ) ;
wu . canonical_resultid = atoi ( r [ i + + ] ) ;
wu . canonical_credit = atof ( r [ i + + ] ) ;
wu . min_quorum = atoi ( r [ i + + ] ) ;
wu . assimilate_state = atoi ( r [ i + + ] ) ;
wu . transition_time = atoi ( r [ i + + ] ) ;
2006-07-11 21:49:20 +00:00
wu . opaque = atof ( r [ i + + ] ) ;
2004-10-08 23:07:59 +00:00
wu . batch = atoi ( r [ i + + ] ) ;
2004-12-01 05:46:04 +00:00
wu . target_nresults = atoi ( r [ i + + ] ) ;
2004-10-08 23:07:59 +00:00
wu . max_success_results = atoi ( r [ i + + ] ) ;
wu . error_mask = atoi ( r [ i + + ] ) ;
2006-06-10 12:14:22 +00:00
wu . rsc_fpops_est = atof ( r [ i + + ] ) ;
2010-03-29 22:28:20 +00:00
wu . rsc_fpops_bound = atof ( r [ i + + ] ) ;
2004-10-08 23:07:59 +00:00
res . id = atoi ( r [ i + + ] ) ;
strcpy2 ( res . name , r [ i + + ] ) ;
res . validate_state = atoi ( r [ i + + ] ) ;
res . server_state = atoi ( r [ i + + ] ) ;
res . outcome = atoi ( r [ i + + ] ) ;
res . granted_credit = atof ( r [ i + + ] ) ;
2008-06-05 18:36:31 +00:00
strcpy2 ( res . xml_doc_in , r [ i + + ] ) ;
2006-07-11 21:49:20 +00:00
strcpy2 ( res . xml_doc_out , r [ i + + ] ) ;
strcpy2 ( res . stderr_out , r [ i + + ] ) ;
res . cpu_time = atof ( r [ i + + ] ) ;
2004-10-08 23:07:59 +00:00
res . batch = atoi ( r [ i + + ] ) ;
res . opaque = atof ( r [ i + + ] ) ;
res . exit_status = atoi ( r [ i + + ] ) ;
res . hostid = atoi ( r [ i + + ] ) ;
2008-12-12 17:54:01 +00:00
res . userid = atoi ( r [ i + + ] ) ;
res . teamid = atoi ( r [ i + + ] ) ;
2004-10-08 23:07:59 +00:00
res . sent_time = atoi ( r [ i + + ] ) ;
2004-12-17 19:15:22 +00:00
res . received_time = atoi ( r [ i + + ] ) ;
2007-04-05 17:02:01 +00:00
res . appid = atoi ( r [ i + + ] ) ;
2012-05-09 08:04:21 +00:00
res . app_version_id = atoi ( r [ i + + ] ) ;
res . app_version_num = atoi ( r [ i + + ] ) ;
2010-03-29 22:28:20 +00:00
res . elapsed_time = atof ( r [ i + + ] ) ;
res . flops_estimate = atof ( r [ i + + ] ) ;
res . app_version_id = atoi ( r [ i + + ] ) ;
2011-09-16 16:43:15 +00:00
res . runtime_outlier = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2004-10-08 22:41:33 +00:00
}
int DB_VALIDATOR_ITEM_SET : : enumerate (
int appid , int nresult_limit ,
2005-02-22 20:12:31 +00:00
int wu_id_modulus , int wu_id_remainder ,
2013-05-28 12:42:18 +00:00
int wu_id_min , int wu_id_max ,
2004-10-08 22:41:33 +00:00
std : : vector < VALIDATOR_ITEM > & items
) {
2006-01-19 21:46:25 +00:00
int retval ;
2005-02-22 20:12:31 +00:00
char query [ MAX_QUERY_LEN ] , mod_clause [ 256 ] ;
2004-12-06 22:41:19 +00:00
MYSQL_ROW row ;
VALIDATOR_ITEM new_item ;
2004-10-08 22:41:33 +00:00
if ( ! cursor . active ) {
2005-02-22 20:12:31 +00:00
if ( wu_id_modulus ) {
sprintf ( mod_clause ,
2005-02-23 00:11:17 +00:00
" and wu.id %% %d = %d " ,
2005-02-22 20:12:31 +00:00
wu_id_modulus , wu_id_remainder
) ;
} else {
strcpy ( mod_clause , " " ) ;
}
2013-05-28 12:42:18 +00:00
if ( wu_id_min ) {
sprintf ( mod_clause + ( strlen ( mod_clause ) ) , " and wu.id >= %d " , wu_id_min ) ;
}
if ( wu_id_max ) {
sprintf ( mod_clause + ( strlen ( mod_clause ) ) , " and wu.id <= %d " , wu_id_max ) ;
}
2005-02-22 20:12:31 +00:00
2004-10-08 22:41:33 +00:00
sprintf ( query ,
2008-03-03 19:33:32 +00:00
" SELECT "
2006-07-11 21:49:20 +00:00
" wu.id, "
2004-10-08 22:41:33 +00:00
" wu.name, "
" wu.canonical_resultid, "
" wu.canonical_credit, "
" wu.min_quorum, "
" wu.assimilate_state, "
" wu.transition_time, "
" wu.opaque, "
" wu.batch, "
2004-12-01 05:46:04 +00:00
" wu.target_nresults, "
2006-06-10 12:14:22 +00:00
" wu.max_success_results, "
" wu.error_mask, "
" wu.rsc_fpops_est, "
2010-03-29 22:28:20 +00:00
" wu.rsc_fpops_bound, "
2004-10-08 22:41:33 +00:00
" res.id, "
" res.name, "
" res.validate_state, "
" res.server_state, "
" res.outcome, "
" res.granted_credit, "
2008-06-05 18:36:31 +00:00
" res.xml_doc_in, "
2004-10-08 22:41:33 +00:00
" res.xml_doc_out, "
2004-10-22 22:43:29 +00:00
" res.stderr_out, "
2004-10-08 22:41:33 +00:00
" res.cpu_time, "
" res.batch, "
" res.opaque, "
" res.exit_status, "
" res.hostid, "
2008-12-12 17:54:01 +00:00
" res.userid, "
" res.teamid, "
2004-12-17 19:15:22 +00:00
" res.sent_time, "
2007-04-05 17:02:01 +00:00
" res.received_time, "
2010-03-29 22:28:20 +00:00
" res.appid, "
2012-05-09 08:04:21 +00:00
" res.app_version_id, "
" res.app_version_num, "
2010-03-29 22:28:20 +00:00
" res.elapsed_time, "
" res.flops_estimate, "
2011-09-16 16:43:15 +00:00
" res.app_version_id, "
" res.runtime_outlier "
2004-10-08 23:07:59 +00:00
" FROM "
2006-05-31 17:19:29 +00:00
" workunit AS wu, result AS res where wu.id = res.workunitid "
" and wu.appid = %d and wu.need_validate > 0 %s "
2004-10-08 23:07:59 +00:00
" LIMIT "
" %d " ,
2008-03-03 19:33:32 +00:00
appid , mod_clause , nresult_limit
2004-10-08 23:07:59 +00:00
) ;
2004-10-08 22:41:33 +00:00
2006-01-19 21:46:25 +00:00
retval = db - > do_query ( query ) ;
if ( retval ) return mysql_errno ( db - > mysql ) ;
2004-10-08 22:41:33 +00:00
// the following stores the entire result set in memory
cursor . rp = mysql_store_result ( db - > mysql ) ;
if ( ! cursor . rp ) return mysql_errno ( db - > mysql ) ;
cursor . active = true ;
row = mysql_fetch_row ( cursor . rp ) ;
if ( ! row ) {
mysql_free_result ( cursor . rp ) ;
cursor . active = false ;
2006-01-19 21:46:25 +00:00
retval = mysql_errno ( db - > mysql ) ;
2008-03-27 18:25:29 +00:00
if ( retval ) return ERR_DB_CONN_LOST ;
2006-01-19 21:46:25 +00:00
return ERR_DB_NOT_FOUND ;
2004-10-08 22:41:33 +00:00
}
last_item . parse ( row ) ;
nitems_this_query = 1 ;
}
items . clear ( ) ;
while ( true ) {
items . push_back ( last_item ) ;
row = mysql_fetch_row ( cursor . rp ) ;
if ( ! row ) {
mysql_free_result ( cursor . rp ) ;
cursor . active = false ;
// if got fewer rows than requested, last group is complete
//
if ( nitems_this_query < nresult_limit ) {
return 0 ;
} else {
2006-01-19 21:46:25 +00:00
return ERR_DB_NOT_FOUND ;
2004-10-08 22:41:33 +00:00
}
}
new_item . parse ( row ) ;
nitems_this_query + + ;
2004-10-10 03:16:30 +00:00
if ( new_item . wu . id ! = last_item . wu . id ) {
2004-10-08 22:41:33 +00:00
last_item = new_item ;
return 0 ;
}
last_item = new_item ;
}
return 0 ;
}
int DB_VALIDATOR_ITEM_SET : : update_result ( RESULT & res ) {
char query [ MAX_QUERY_LEN ] ;
sprintf ( query ,
" update result set validate_state=%d, granted_credit=%.15e, "
2012-12-24 20:14:22 +00:00
" server_state=%d, outcome=%d, opaque=%lf, runtime_outlier=%d "
2011-11-09 17:27:50 +00:00
" where id=%u " ,
2004-10-08 22:41:33 +00:00
res . validate_state ,
res . granted_credit ,
res . server_state ,
res . outcome ,
2004-10-22 18:48:26 +00:00
res . opaque ,
2011-09-16 16:43:15 +00:00
res . runtime_outlier ? 1 : 0 ,
2004-10-08 22:41:33 +00:00
res . id
) ;
2009-09-03 20:26:31 +00:00
int retval = db - > do_query ( query ) ;
if ( db - > affected_rows ( ) ! = 1 ) return ERR_DB_NOT_FOUND ;
return retval ;
2004-10-08 22:41:33 +00:00
}
int DB_VALIDATOR_ITEM_SET : : update_workunit ( WORKUNIT & wu ) {
char query [ MAX_QUERY_LEN ] ;
sprintf ( query ,
2004-10-08 23:59:44 +00:00
" update workunit set need_validate=0, error_mask=%d, "
2004-10-08 22:41:33 +00:00
" assimilate_state=%d, transition_time=%d, "
2004-12-01 05:46:04 +00:00
" target_nresults=%d, "
2011-11-09 07:41:49 +00:00
" canonical_resultid=%u, canonical_credit=%.15e "
2004-10-08 22:41:33 +00:00
" where id=%d " ,
2006-07-11 21:49:20 +00:00
wu . error_mask ,
2004-10-08 22:41:33 +00:00
wu . assimilate_state ,
wu . transition_time ,
2004-12-01 05:46:04 +00:00
wu . target_nresults ,
2006-07-11 21:49:20 +00:00
wu . canonical_resultid ,
wu . canonical_credit ,
2004-10-08 22:41:33 +00:00
wu . id
) ;
2009-09-03 20:26:31 +00:00
int retval = db - > do_query ( query ) ;
if ( db - > affected_rows ( ) ! = 1 ) return ERR_DB_NOT_FOUND ;
return retval ;
2004-10-08 22:41:33 +00:00
}
2004-07-02 22:48:33 +00:00
void WORK_ITEM : : parse ( MYSQL_ROW & r ) {
int i = 0 ;
memset ( this , 0 , sizeof ( WORK_ITEM ) ) ;
res_id = atoi ( r [ i + + ] ) ;
2007-04-05 17:02:01 +00:00
res_priority = atoi ( r [ i + + ] ) ;
2009-08-31 19:35:46 +00:00
res_server_state = atoi ( r [ i + + ] ) ;
res_report_deadline = atof ( r [ i + + ] ) ;
2006-05-31 17:19:29 +00:00
wu . id = atoi ( r [ i + + ] ) ;
2004-07-03 17:57:32 +00:00
wu . create_time = atoi ( r [ i + + ] ) ;
wu . appid = atoi ( r [ i + + ] ) ;
strcpy2 ( wu . name , r [ i + + ] ) ;
strcpy2 ( wu . xml_doc , r [ i + + ] ) ;
wu . batch = atoi ( r [ i + + ] ) ;
wu . rsc_fpops_est = atof ( r [ i + + ] ) ;
wu . rsc_fpops_bound = atof ( r [ i + + ] ) ;
wu . rsc_memory_bound = atof ( r [ i + + ] ) ;
wu . rsc_disk_bound = atof ( r [ i + + ] ) ;
wu . need_validate = atoi ( r [ i + + ] ) ;
wu . canonical_resultid = atoi ( r [ i + + ] ) ;
wu . canonical_credit = atof ( r [ i + + ] ) ;
wu . transition_time = atoi ( r [ i + + ] ) ;
wu . delay_bound = atoi ( r [ i + + ] ) ;
wu . error_mask = atoi ( r [ i + + ] ) ;
wu . file_delete_state = atoi ( r [ i + + ] ) ;
wu . assimilate_state = atoi ( r [ i + + ] ) ;
2004-12-06 22:41:19 +00:00
wu . hr_class = atoi ( r [ i + + ] ) ;
2004-07-03 17:57:32 +00:00
wu . opaque = atof ( r [ i + + ] ) ;
wu . min_quorum = atoi ( r [ i + + ] ) ;
wu . target_nresults = atoi ( r [ i + + ] ) ;
wu . max_error_results = atoi ( r [ i + + ] ) ;
wu . max_total_results = atoi ( r [ i + + ] ) ;
wu . max_success_results = atoi ( r [ i + + ] ) ;
strcpy2 ( wu . result_template_file , r [ i + + ] ) ;
2008-03-07 21:13:01 +00:00
wu . priority = atoi ( r [ i + + ] ) ;
strcpy2 ( wu . mod_time , r [ i + + ] ) ;
wu . rsc_bandwidth_bound = atof ( r [ i + + ] ) ;
2010-03-05 22:55:16 +00:00
wu . fileset_id = atoi ( r [ i + + ] ) ;
2011-06-06 03:40:42 +00:00
wu . app_version_id = atoi ( r [ i + + ] ) ;
2013-04-25 07:27:35 +00:00
wu . transitioner_flags = atoi ( r [ i + + ] ) ;
wu . size_class = atoi ( r [ i + + ] ) ;
2004-07-02 22:48:33 +00:00
}
2005-05-26 20:25:00 +00:00
int DB_WORK_ITEM : : enumerate (
2006-05-02 22:33:00 +00:00
int limit , const char * select_clause , const char * order_clause
2005-05-26 20:25:00 +00:00
) {
2004-07-02 22:48:33 +00:00
char query [ MAX_QUERY_LEN ] ;
int retval ;
MYSQL_ROW row ;
if ( ! cursor . active ) {
2007-07-09 20:09:49 +00:00
// use "r1" to refer to the result, since the feeder assumes that
// (historical reasons)
//
2006-05-02 22:33:00 +00:00
sprintf ( query ,
2011-09-07 19:57:46 +00:00
" select high_priority r1.id, r1.priority, r1.server_state, r1.report_deadline, workunit.* from result r1 force index(ind_res_st), workunit, app "
2012-06-29 06:53:48 +00:00
" where r1.server_state=%d "
" and r1.workunitid=workunit.id "
" and workunit.appid=app.id "
" and app.deprecated=0 "
2012-02-22 22:13:08 +00:00
" and workunit.transitioner_flags=0 "
2006-05-02 22:33:00 +00:00
" %s "
" %s "
" limit %d " ,
RESULT_SERVER_STATE_UNSENT ,
select_clause ,
order_clause ,
limit
) ;
2004-07-02 22:48:33 +00:00
retval = db - > do_query ( query ) ;
if ( retval ) return mysql_errno ( db - > mysql ) ;
2004-08-07 01:36:14 +00:00
cursor . rp = mysql_store_result ( db - > mysql ) ;
2004-07-02 22:48:33 +00:00
if ( ! cursor . rp ) return mysql_errno ( db - > mysql ) ;
2004-07-03 19:42:59 +00:00
cursor . active = true ;
2004-07-02 22:48:33 +00:00
}
row = mysql_fetch_row ( cursor . rp ) ;
if ( ! row ) {
mysql_free_result ( cursor . rp ) ;
cursor . active = false ;
2006-01-19 21:46:25 +00:00
retval = mysql_errno ( db - > mysql ) ;
2008-03-27 18:25:29 +00:00
if ( retval ) return ERR_DB_CONN_LOST ;
2006-01-19 21:46:25 +00:00
return ERR_DB_NOT_FOUND ;
2004-07-02 22:48:33 +00:00
} else {
parse ( row ) ;
}
return 0 ;
}
2007-06-22 23:48:37 +00:00
int DB_WORK_ITEM : : enumerate_all (
int limit , const char * select_clause
) {
char query [ MAX_QUERY_LEN ] ;
int retval ;
MYSQL_ROW row ;
if ( ! cursor . active ) {
2007-07-09 20:09:49 +00:00
// use "r1" to refer to the result, since the feeder assumes that
// (historical reasons)
//
2007-06-22 23:48:37 +00:00
sprintf ( query ,
2011-09-07 19:57:46 +00:00
" select high_priority r1.id, r1.priority, r1.server_state, r1.report_deadline, workunit.* from result r1 force index(ind_res_st), workunit force index(primary), app "
2007-07-09 20:09:49 +00:00
" where r1.server_state=%d and r1.workunitid=workunit.id and r1.id>%d "
2011-09-07 19:57:46 +00:00
" and workunit.appid=app.id and app.deprecated=0 "
2012-02-22 22:13:08 +00:00
" and workunit.transitioner_flags=0 "
2007-06-22 23:48:37 +00:00
" %s "
" limit %d " ,
RESULT_SERVER_STATE_UNSENT ,
start_id ,
select_clause ,
limit
) ;
retval = db - > do_query ( query ) ;
if ( retval ) return mysql_errno ( db - > mysql ) ;
cursor . rp = mysql_store_result ( db - > mysql ) ;
if ( ! cursor . rp ) return mysql_errno ( db - > mysql ) ;
// if query gets no rows, start over in ID space
//
if ( mysql_num_rows ( cursor . rp ) = = 0 ) {
mysql_free_result ( cursor . rp ) ;
start_id = 0 ;
return ERR_DB_NOT_FOUND ;
}
cursor . active = true ;
}
row = mysql_fetch_row ( cursor . rp ) ;
if ( ! row ) {
mysql_free_result ( cursor . rp ) ;
cursor . active = false ;
retval = mysql_errno ( db - > mysql ) ;
2008-03-27 18:25:29 +00:00
if ( retval ) return ERR_DB_CONN_LOST ;
2007-06-22 23:48:37 +00:00
return ERR_DB_NOT_FOUND ;
} else {
parse ( row ) ;
start_id = res_id ;
}
return 0 ;
}
2004-12-05 21:53:32 +00:00
2007-04-05 17:02:01 +00:00
void IN_PROGRESS_RESULT : : parse ( MYSQL_ROW & r ) {
int i = 0 ;
memset ( this , 0 , sizeof ( IN_PROGRESS_RESULT ) ) ;
strcpy2 ( result_name , r [ i + + ] ) ;
error_mask = atoi ( r [ i + + ] ) ;
assimilate_state = atoi ( r [ i + + ] ) ;
server_state = atoi ( r [ i + + ] ) ;
outcome = atoi ( r [ i + + ] ) ;
}
int DB_IN_PROGRESS_RESULT : : enumerate ( int hostid , const char * result_names ) {
char query [ MAX_QUERY_LEN ] ;
int retval ;
MYSQL_ROW row ;
if ( ! cursor . active ) {
sprintf ( query ,
" select high_priority result.name, workunit.error_mask, workunit.assimilate_state, result.server_state, result.outcome "
" from result, workunit "
" where result.hostid = %d and workunit.id = result.workunitid "
" and (result.server_state=%d or ( result.server_state = %d and result.outcome = %d ) ) "
" and result.name in (%s) " ,
hostid ,
RESULT_SERVER_STATE_IN_PROGRESS ,
RESULT_SERVER_STATE_OVER ,
RESULT_OUTCOME_NO_REPLY ,
result_names
) ;
retval = db - > do_query ( query ) ;
if ( retval ) return mysql_errno ( db - > mysql ) ;
cursor . rp = mysql_store_result ( db - > mysql ) ;
if ( ! cursor . rp ) return mysql_errno ( db - > mysql ) ;
cursor . active = true ;
}
row = mysql_fetch_row ( cursor . rp ) ;
if ( ! row ) {
mysql_free_result ( cursor . rp ) ;
cursor . active = false ;
retval = mysql_errno ( db - > mysql ) ;
2008-03-27 18:25:29 +00:00
if ( retval ) return ERR_DB_CONN_LOST ;
2007-04-05 17:02:01 +00:00
return ERR_DB_NOT_FOUND ;
} else {
parse ( row ) ;
}
return 0 ;
}
2004-12-05 21:53:32 +00:00
// The items that appear here must agree with those that appear in the
// enumerate method just below!
2005-06-26 19:34:17 +00:00
//
2004-07-06 18:30:22 +00:00
void SCHED_RESULT_ITEM : : parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
workunitid = atoi ( r [ i + + ] ) ;
2008-07-22 23:36:55 +00:00
appid = atoi ( r [ i + + ] ) ;
2004-07-06 18:30:22 +00:00
server_state = atoi ( r [ i + + ] ) ;
hostid = atoi ( r [ i + + ] ) ;
userid = atoi ( r [ i + + ] ) ;
2005-06-26 19:34:17 +00:00
sent_time = atoi ( r [ i + + ] ) ;
2004-07-06 18:30:22 +00:00
received_time = atoi ( r [ i + + ] ) ;
2006-05-31 20:39:32 +00:00
validate_state = atoi ( r [ i + + ] ) ;
2006-05-31 21:50:42 +00:00
outcome = atoi ( r [ i + + ] ) ;
2006-06-03 14:59:22 +00:00
client_state = atoi ( r [ i + + ] ) ;
2006-06-03 16:22:34 +00:00
file_delete_state = atoi ( r [ i + + ] ) ;
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
app_version_id = atoi ( r [ i + + ] ) ;
2004-07-06 18:30:22 +00:00
}
int DB_SCHED_RESULT_ITEM_SET : : add_result ( char * result_name ) {
SCHED_RESULT_ITEM result ;
2005-07-28 08:09:46 +00:00
result . id = 0 ;
2004-07-06 18:30:22 +00:00
strcpy2 ( result . queried_name , result_name ) ;
results . push_back ( result ) ;
return 0 ;
}
int DB_SCHED_RESULT_ITEM_SET : : enumerate ( ) {
2010-09-19 03:42:51 +00:00
string query ;
2004-12-06 22:41:19 +00:00
int retval ;
unsigned int i ;
MYSQL_RES * rp ;
MYSQL_ROW row ;
SCHED_RESULT_ITEM ri ;
2004-07-06 18:30:22 +00:00
2010-09-19 03:42:51 +00:00
query =
2004-07-21 23:48:56 +00:00
" SELECT "
" id, "
" name, "
" workunitid, "
2009-09-03 20:26:31 +00:00
" appid, "
2004-07-21 23:48:56 +00:00
" server_state, "
" hostid, "
" userid, "
2005-06-26 19:34:17 +00:00
" sent_time, "
2006-05-31 20:39:32 +00:00
" received_time, "
2006-05-31 21:50:42 +00:00
" validate_state, "
2006-06-03 14:59:22 +00:00
" outcome, "
2006-06-03 16:22:34 +00:00
" client_state, "
- server: change the following from per-host to per-(host, app version):
- daily quota mechanism
- reliable mechanism (accelerated retries)
- "trusted" mechanism (adaptive replication)
- scheduler: enforce host scale probation only for apps with
host_scale_check set.
- validator: do scale probation on invalid results
(need this in addition to error and timeout cases)
- feeder: update app version scales every 10 min, not 10 sec
- back-end apps: support --foo as well as -foo for options
Notes:
- If you have, say, cuda, cuda23 and cuda_fermi plan classes,
a host will have separate quotas for each one.
That means it could error out on 100 jobs for cuda_fermi,
and when its quota goes to zero,
error out on 100 jobs for cuda23, etc.
This is intentional; there may be cases where one version
works but not the others.
- host.error_rate and host.max_results_day are deprecated
TODO:
- the values in the app table for limits on jobs in progress etc.
should override rather than config.xml.
Implementation notes:
scheduler:
process_request():
read all host_app_versions for host at start;
Compute "reliable" and "trusted" for each one.
write modified records at end
get_app_version():
add "reliable_only" arg; if set, use only reliable versions
skip over-quota versions
Multi-pass scheduling: if have at least one reliable version,
do a pass for jobs that need reliable,
and use only reliable versions.
Then clear best_app_versions cache.
Score-based scheduling: for need-reliable jobs,
it will pick the fastest version,
then give a score bonus if that version happens to be reliable.
When get back a successful result from client:
increase daily quota
When get back an error result from client:
impose scale probation
decrease daily quota if not aborted
Validator:
when handling a WU, create a vector of HOST_APP_VERSION
parallel to vector of RESULT.
Pass it to assign_credit_set().
Make copies of originals so we can update only modified ones
update HOST_APP_VERSION error rates
Transitioner:
decrease quota on timeout
svn path=/trunk/boinc/; revision=21181
2010-04-15 03:13:56 +00:00
" file_delete_state, "
" app_version_id "
2004-07-21 23:48:56 +00:00
" FROM "
" result "
" WHERE "
" name IN ( "
2010-09-19 03:42:51 +00:00
;
2004-07-06 18:30:22 +00:00
2004-07-21 23:48:56 +00:00
for ( i = 0 ; i < results . size ( ) ; i + + ) {
2010-09-19 03:42:51 +00:00
if ( i > 0 ) query + = " , " ;
query + = " ' " ;
query + = results [ i ] . queried_name ;
query + = " ' " ;
2004-07-21 23:48:56 +00:00
}
2010-09-19 03:42:51 +00:00
query + = " ) " ;
2004-07-06 18:30:22 +00:00
2010-09-19 03:42:51 +00:00
retval = db - > do_query ( query . c_str ( ) ) ;
2004-07-21 23:48:56 +00:00
if ( retval ) return retval ;
// the following stores the entire result set in memory
//
rp = mysql_store_result ( db - > mysql ) ;
if ( ! rp ) return mysql_errno ( db - > mysql ) ;
do {
row = mysql_fetch_row ( rp ) ;
if ( ! row ) {
mysql_free_result ( rp ) ;
} else {
ri . parse ( row ) ;
for ( i = 0 ; i < results . size ( ) ; i + + ) {
if ( ! strcmp ( results [ i ] . queried_name , ri . name ) ) {
results [ i ] = ri ;
2004-07-06 18:30:22 +00:00
}
}
2004-07-21 23:48:56 +00:00
}
} while ( row ) ;
2004-07-06 18:30:22 +00:00
return 0 ;
}
2004-07-27 23:29:27 +00:00
int DB_SCHED_RESULT_ITEM_SET : : lookup_result ( char * result_name , SCHED_RESULT_ITEM * * rip ) {
2004-07-06 18:30:22 +00:00
unsigned int i ;
for ( i = 0 ; i < results . size ( ) ; i + + ) {
2004-07-21 23:48:56 +00:00
if ( ! strcmp ( results [ i ] . name , result_name ) ) {
2004-07-27 23:29:27 +00:00
* rip = & results [ i ] ;
2004-07-21 23:48:56 +00:00
return 0 ;
2004-07-06 18:30:22 +00:00
}
}
2004-07-21 23:48:56 +00:00
return - 1 ;
2004-07-06 18:30:22 +00:00
}
int DB_SCHED_RESULT_ITEM_SET : : update_result ( SCHED_RESULT_ITEM & ri ) {
char query [ MAX_QUERY_LEN ] ;
2004-08-11 14:47:35 +00:00
int retval ;
2004-07-06 18:30:22 +00:00
2004-08-11 14:47:35 +00:00
ESCAPE ( ri . xml_doc_out ) ;
ESCAPE ( ri . stderr_out ) ;
2004-07-06 18:30:22 +00:00
sprintf ( query ,
" UPDATE result SET "
" hostid=%d, "
" received_time=%d, "
" client_state=%d, "
" cpu_time=%.15e, "
" exit_status=%d, "
" app_version_num=%d, "
" server_state=%d, "
" outcome=%d, "
" stderr_out='%s', "
" xml_doc_out='%s', "
" validate_state=%d, "
2009-09-03 20:26:31 +00:00
" teamid=%d, "
2014-04-03 02:35:59 +00:00
" elapsed_time=%.15e, "
" peak_working_set_size=%.0f, "
" peak_swap_size=%.0f, "
" peak_disk_usage=%.0f "
2004-07-06 18:30:22 +00:00
" WHERE "
2011-11-09 17:27:50 +00:00
" id=%u " ,
2004-07-06 18:30:22 +00:00
ri . hostid ,
ri . received_time ,
ri . client_state ,
ri . cpu_time ,
ri . exit_status ,
ri . app_version_num ,
ri . server_state ,
ri . outcome ,
ri . stderr_out ,
ri . xml_doc_out ,
ri . validate_state ,
ri . teamid ,
2009-09-03 20:26:31 +00:00
ri . elapsed_time ,
2014-04-03 02:35:59 +00:00
ri . peak_working_set_size ,
ri . peak_swap_size ,
ri . peak_disk_usage ,
2004-07-06 18:30:22 +00:00
ri . id
) ;
2004-08-11 14:47:35 +00:00
retval = db - > do_query ( query ) ;
UNESCAPE ( ri . xml_doc_out ) ;
UNESCAPE ( ri . stderr_out ) ;
2009-09-03 20:26:31 +00:00
if ( db - > affected_rows ( ) ! = 1 ) return ERR_DB_NOT_FOUND ;
2004-08-11 14:47:35 +00:00
return retval ;
2004-07-06 18:30:22 +00:00
}
2005-06-22 02:40:14 +00:00
// set transition times of workunits -
// but only those corresponding to updated results
// (i.e. those that passed "sanity checks")
//
2004-07-21 23:48:56 +00:00
int DB_SCHED_RESULT_ITEM_SET : : update_workunits ( ) {
char query [ MAX_QUERY_LEN ] , buf [ 256 ] ;
unsigned int i ;
2005-06-22 02:40:14 +00:00
bool first = true ;
2004-07-06 18:30:22 +00:00
sprintf ( query ,
2004-07-21 23:48:56 +00:00
" UPDATE workunit SET transition_time=%d WHERE id in ( " ,
2004-08-16 11:31:59 +00:00
( int ) time ( 0 )
2004-07-06 18:30:22 +00:00
) ;
2004-07-21 23:48:56 +00:00
for ( i = 0 ; i < results . size ( ) ; i + + ) {
2010-08-29 08:43:40 +00:00
if ( results [ i ] . id = = 0 ) continue ;
// skip non-updated results
2005-06-22 02:40:14 +00:00
if ( ! first ) strcat ( query , " , " ) ;
first = false ;
2004-07-21 23:48:56 +00:00
sprintf ( buf , " %d " , results [ i ] . workunitid ) ;
strcat ( query , buf ) ;
}
strcat ( query , " ) " ) ;
2005-06-22 06:02:59 +00:00
if ( first ) {
return 0 ;
} else {
return db - > do_query ( query ) ;
}
2004-07-06 18:30:22 +00:00
}
2004-12-08 00:40:19 +00:00
2010-03-05 22:55:16 +00:00
void DB_FILE : : db_print ( char * buf ) {
snprintf ( buf , MAX_QUERY_LEN ,
2010-05-07 20:08:59 +00:00
" name='%s', md5sum='%s', size=%.15e " ,
2010-03-05 22:55:16 +00:00
name , md5sum , size
) ;
}
void DB_FILE : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
strcpy2 ( md5sum , r [ i + + ] ) ;
size = atof ( r [ i + + ] ) ;
}
void DB_FILESET : : db_print ( char * buf ) {
snprintf ( buf , MAX_QUERY_LEN , " name='%s' " , name ) ;
}
void DB_FILESET : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
}
2011-08-10 17:11:08 +00:00
int DB_FILESET : : select_by_name ( const char * _name ) {
2010-03-05 22:55:16 +00:00
char where_clause [ MAX_QUERY_LEN ] = { 0 } ;
// construct where clause and select single record
2011-08-10 17:11:08 +00:00
snprintf ( where_clause , MAX_QUERY_LEN , " WHERE name = '%s' " , _name ) ;
2010-03-05 22:55:16 +00:00
return lookup ( where_clause ) ;
}
void DB_FILESET_FILE : : db_print ( char * buf ) {
snprintf ( buf , MAX_QUERY_LEN ,
" fileset_id=%d, file_id=%d " ,
fileset_id , file_id
) ;
}
void DB_FILESET_FILE : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
fileset_id = atoi ( r [ i + + ] ) ;
file_id = atoi ( r [ i + + ] ) ;
}
void DB_SCHED_TRIGGER : : db_print ( char * buf ) {
snprintf ( buf , MAX_QUERY_LEN ,
" fileset_id=%d, need_work=%d, work_available=%d, no_work_available=%d, working_set_removal=%d " ,
fileset_id , need_work ? 1 : 0 , work_available ? 1 : 0 , no_work_available ? 1 : 0 , working_set_removal ? 1 : 0
) ;
}
void DB_SCHED_TRIGGER : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
fileset_id = atoi ( r [ i + + ] ) ;
need_work = atoi ( r [ i + + ] ) ;
work_available = atoi ( r [ i + + ] ) ;
no_work_available = atoi ( r [ i + + ] ) ;
working_set_removal = atoi ( r [ i + + ] ) ;
}
int DB_SCHED_TRIGGER : : select_unique_by_fileset_name ( const char * fileset_name ) {
char query [ MAX_QUERY_LEN ] ;
int retval ;
2011-08-10 17:11:08 +00:00
int nrows = 0 ;
2010-03-05 22:55:16 +00:00
MYSQL_RES * recordset ;
MYSQL_ROW row ;
2010-06-25 18:54:37 +00:00
//if (!cursor.active) {
2010-03-05 22:55:16 +00:00
// prepare statement
snprintf ( query , MAX_QUERY_LEN ,
" SELECT "
" t.id, "
" t.fileset_id, "
" t.need_work, "
" t.work_available, "
" t.no_work_available, "
" t.working_set_removal "
" FROM "
" fileset fs INNER JOIN sched_trigger t ON fs.id = t.fileset_id "
" WHERE "
" fs.name = '%s' " ,
fileset_name
) ;
retval = db - > do_query ( query ) ;
if ( retval ) return mysql_errno ( db - > mysql ) ;
recordset = mysql_store_result ( db - > mysql ) ;
if ( ! recordset ) return mysql_errno ( db - > mysql ) ;
2010-06-25 18:54:37 +00:00
//}
2010-03-05 22:55:16 +00:00
// determine number of records, fetch first
2011-08-10 17:11:08 +00:00
nrows = mysql_num_rows ( recordset ) ;
2010-03-05 22:55:16 +00:00
row = mysql_fetch_row ( recordset ) ;
2011-08-10 17:11:08 +00:00
if ( ! row | | nrows ! = 1 ) {
2010-03-05 22:55:16 +00:00
// something bad happened
if ( ! row ) {
// no row returned, due to an error?
retval = mysql_errno ( db - > mysql ) ;
mysql_free_result ( recordset ) ;
// yes, probably lost DB connection
if ( retval ) return ERR_DB_CONN_LOST ;
// no, just no record available
return ERR_DB_NOT_FOUND ;
}
else {
// we got more records than expected
mysql_free_result ( recordset ) ;
return ERR_DB_NOT_UNIQUE ;
}
} else {
// all fine, parse single record
db_parse ( row ) ;
mysql_free_result ( recordset ) ;
}
return 0 ;
}
int DB_SCHED_TRIGGER : : update_single_state ( const DB_SCHED_TRIGGER : : STATE state , const bool value ) {
char column_clause [ MAX_QUERY_LEN ] = { 0 } ;
int retval = 0 ;
switch ( state ) {
case DB_SCHED_TRIGGER : : state_need_work :
snprintf ( column_clause , MAX_QUERY_LEN , " need_work = %d " , value ? 1 : 0 ) ;
need_work = value ;
break ;
case DB_SCHED_TRIGGER : : state_work_available :
snprintf ( column_clause , MAX_QUERY_LEN , " work_available = %d " , value ? 1 : 0 ) ;
work_available = value ;
break ;
case DB_SCHED_TRIGGER : : state_no_work_available :
snprintf ( column_clause , MAX_QUERY_LEN , " no_work_available = %d " , value ? 1 : 0 ) ;
no_work_available = value ;
break ;
case DB_SCHED_TRIGGER : : state_working_set_removal :
snprintf ( column_clause , MAX_QUERY_LEN , " working_set_removal = %d " , value ? 1 : 0 ) ;
working_set_removal = value ;
break ;
default :
// unknown state
return - 1 ;
}
// run actual update on current trigger (retrieved earlier)
retval = update_field ( column_clause , NULL ) ;
if ( retval ) return retval ;
return 0 ;
}
void DB_FILESET_SCHED_TRIGGER_ITEM : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
fileset . id = atoi ( r [ i + + ] ) ;
strcpy2 ( fileset . name , r [ i + + ] ) ;
trigger . id = atoi ( r [ i + + ] ) ;
trigger . fileset_id = atoi ( r [ i + + ] ) ;
trigger . need_work = atoi ( r [ i + + ] ) ;
trigger . work_available = atoi ( r [ i + + ] ) ;
trigger . no_work_available = atoi ( r [ i + + ] ) ;
trigger . working_set_removal = atoi ( r [ i + + ] ) ;
}
int DB_FILESET_SCHED_TRIGGER_ITEM_SET : : select_by_name_state (
const char * fileset_name = NULL ,
const bool use_regexp = false ,
const DB_SCHED_TRIGGER : : STATE state = DB_SCHED_TRIGGER : : none ,
const bool state_value = true
) {
char where_clause [ MAX_QUERY_LEN ] = { 0 } ;
char query [ MAX_QUERY_LEN ] = { 0 } ;
int retval = 0 ;
int count = 0 ;
MYSQL_RES * recordset ;
MYSQL_ROW row ;
DB_FILESET_SCHED_TRIGGER_ITEM fileset_trigger ;
// prepare requested compare mode
const char * comparator = use_regexp ? " REGEXP " : " = " ;
// prepare optional state filter
char state_filter [ MAX_QUERY_LEN ] = { 0 } ;
switch ( state ) {
case DB_SCHED_TRIGGER : : state_need_work :
snprintf ( state_filter , MAX_QUERY_LEN , " need_work = %d " , state_value ? 1 : 0 ) ;
break ;
case DB_SCHED_TRIGGER : : state_work_available :
snprintf ( state_filter , MAX_QUERY_LEN , " work_available = %d " , state_value ? 1 : 0 ) ;
break ;
case DB_SCHED_TRIGGER : : state_no_work_available :
snprintf ( state_filter , MAX_QUERY_LEN , " no_work_available = %d " , state_value ? 1 : 0 ) ;
break ;
case DB_SCHED_TRIGGER : : state_working_set_removal :
snprintf ( state_filter , MAX_QUERY_LEN , " working_set_removal = %d " , state_value ? 1 : 0 ) ;
break ;
default :
// none or unknown state (keep empty filter)
break ;
}
// prepare WHERE clause
if ( fileset_name & & ! state ) {
snprintf ( where_clause , MAX_QUERY_LEN , " WHERE fs.name %s '%s' " , comparator , fileset_name ) ;
} else if ( ! fileset_name & & state ) {
snprintf ( where_clause , MAX_QUERY_LEN , " WHERE %s " , state_filter ) ;
} else if ( fileset_name & & state ) {
snprintf ( where_clause , MAX_QUERY_LEN , " WHERE fs.name %s '%s' AND %s " , comparator , fileset_name , state_filter ) ;
}
// prepare final statement
snprintf ( query , MAX_QUERY_LEN ,
" SELECT "
" fs.id, "
" fs.name, "
" t.id, "
" t.fileset_id, "
" t.need_work, "
" t.work_available, "
" t.no_work_available, "
" t.working_set_removal "
" FROM "
" fileset fs INNER JOIN sched_trigger t ON fs.id = t.fileset_id "
" %s " ,
where_clause
) ;
retval = db - > do_query ( query ) ;
if ( retval ) return retval ;
recordset = mysql_store_result ( db - > mysql ) ;
if ( ! recordset ) return mysql_errno ( db - > mysql ) ;
// check if we got at least one record
count = mysql_num_rows ( recordset ) ;
if ( count = = 0 ) {
mysql_free_result ( recordset ) ;
return ERR_DB_NOT_FOUND ;
}
// all fine, iterate over recordset
do {
row = mysql_fetch_row ( recordset ) ;
if ( ! row ) {
// clean up
mysql_free_result ( recordset ) ;
// no row returned, due to an error?
retval = mysql_errno ( db - > mysql ) ;
// yes, probably lost DB connection
if ( retval ) return ERR_DB_CONN_LOST ;
} else {
// parse record, add to vector
fileset_trigger . db_parse ( row ) ;
items . push_back ( fileset_trigger ) ;
}
} while ( row ) ;
return 0 ;
}
2012-02-29 20:58:45 +00:00
int DB_FILESET_SCHED_TRIGGER_ITEM_SET : : contains_trigger (
const char * fileset_name
) {
2010-03-05 22:55:16 +00:00
// iterate over item vector
2012-02-29 20:58:45 +00:00
for ( unsigned int i = 0 ; i < items . size ( ) ; + + i ) {
if ( strcmp ( items [ i ] . fileset . name , fileset_name ) = = 0 ) {
2010-03-05 22:55:16 +00:00
// return 1-indexed position for boolean tests
return i + 1 ;
}
}
return 0 ;
}
2012-01-23 05:03:52 +00:00
void DB_VDA_FILE : : db_print ( char * buf ) {
sprintf ( buf ,
2012-02-24 03:09:56 +00:00
" create_time=%f, "
2012-01-23 05:03:52 +00:00
" dir='%s', "
2012-07-07 19:44:48 +00:00
" file_name='%s', "
2012-01-23 05:03:52 +00:00
" size=%f, "
2012-07-07 19:44:48 +00:00
" chunk_size=%f, "
2012-01-23 21:59:12 +00:00
" need_update=%d, "
2012-02-29 20:58:45 +00:00
" initialized=%d, "
2012-08-17 06:10:25 +00:00
" retrieving=%d, "
2012-08-15 21:27:38 +00:00
" retrieved=%d " ,
2012-02-24 03:09:56 +00:00
create_time ,
2012-01-23 05:03:52 +00:00
dir ,
2012-07-07 19:44:48 +00:00
file_name ,
2012-01-23 05:03:52 +00:00
size ,
2012-07-07 19:44:48 +00:00
chunk_size ,
2012-01-23 21:59:12 +00:00
need_update ? 1 : 0 ,
2012-02-29 20:58:45 +00:00
initialized ? 1 : 0 ,
2012-08-15 21:27:38 +00:00
retrieving ? 1 : 0 ,
retrieved ? 1 : 0
2012-01-23 05:03:52 +00:00
) ;
}
void DB_VDA_FILE : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
2012-02-24 03:09:56 +00:00
create_time = atof ( r [ i + + ] ) ;
2013-06-04 03:24:48 +00:00
strcpy2 ( dir , r [ i + + ] ) ;
strcpy2 ( file_name , r [ i + + ] ) ;
2012-01-23 05:03:52 +00:00
size = atof ( r [ i + + ] ) ;
2012-07-07 19:44:48 +00:00
chunk_size = atof ( r [ i + + ] ) ;
2012-01-23 05:03:52 +00:00
need_update = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2012-02-24 03:09:56 +00:00
initialized = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2012-02-29 20:58:45 +00:00
retrieving = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2012-08-15 21:27:38 +00:00
retrieved = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2012-01-23 05:03:52 +00:00
}
void DB_VDA_CHUNK_HOST : : db_print ( char * buf ) {
sprintf ( buf ,
2012-02-24 03:09:56 +00:00
" create_time=%f, "
2012-01-23 05:03:52 +00:00
" vda_file_id=%d, "
2012-02-24 03:09:56 +00:00
" host_id=%d, "
2012-07-25 21:41:32 +00:00
" physical_file_name='%s', "
2012-01-23 05:03:52 +00:00
" present_on_host=%d, "
" transfer_in_progress=%d, "
" transfer_wait=%d, "
2012-02-24 03:09:56 +00:00
" transfer_request_time=%f, "
" transfer_send_time=%f " ,
create_time ,
2012-01-23 05:03:52 +00:00
vda_file_id ,
2012-02-24 03:09:56 +00:00
host_id ,
2012-07-25 21:41:32 +00:00
physical_file_name ,
2012-01-23 05:03:52 +00:00
present_on_host ,
transfer_in_progress ,
transfer_wait ,
2012-02-24 03:09:56 +00:00
transfer_request_time ,
transfer_send_time
2012-01-23 05:03:52 +00:00
) ;
}
void DB_VDA_CHUNK_HOST : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
2012-02-24 03:09:56 +00:00
create_time = atof ( r [ i + + ] ) ;
2012-01-23 05:03:52 +00:00
vda_file_id = atoi ( r [ i + + ] ) ;
2012-02-24 03:09:56 +00:00
host_id = atoi ( r [ i + + ] ) ;
2013-06-04 03:24:48 +00:00
strcpy2 ( physical_file_name , r [ i + + ] ) ;
2012-01-23 05:03:52 +00:00
present_on_host = ( atoi ( r [ i + + ] ) ! = 0 ) ;
transfer_in_progress = ( atoi ( r [ i + + ] ) ! = 0 ) ;
transfer_wait = ( atoi ( r [ i + + ] ) ! = 0 ) ;
2012-02-24 03:09:56 +00:00
transfer_request_time = atof ( r [ i + + ] ) ;
transfer_send_time = atof ( r [ i + + ] ) ;
2012-01-23 05:03:52 +00:00
}
2014-05-19 02:19:05 +00:00
void DB_BADGE : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
id = atoi ( r [ i + + ] ) ;
create_time = atof ( r [ i + + ] ) ;
type = atoi ( r [ i + + ] ) ;
strcpy2 ( name , r [ i + + ] ) ;
strcpy2 ( title , r [ i + + ] ) ;
strcpy2 ( description , r [ i + + ] ) ;
strcpy2 ( image_url , r [ i + + ] ) ;
strcpy2 ( level , r [ i + + ] ) ;
strcpy2 ( tags , r [ i + + ] ) ;
strcpy2 ( sql_rule , r [ i + + ] ) ;
}
void DB_BADGE_USER : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
badge_id = atoi ( r [ i + + ] ) ;
user_id = atoi ( r [ i + + ] ) ;
create_time = atof ( r [ i + + ] ) ;
reassign_time = atof ( r [ i + + ] ) ;
}
void DB_BADGE_TEAM : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
badge_id = atoi ( r [ i + + ] ) ;
team_id = atoi ( r [ i + + ] ) ;
create_time = atof ( r [ i + + ] ) ;
reassign_time = atof ( r [ i + + ] ) ;
}
2014-08-15 21:01:32 +00:00
void DB_CREDIT_USER : : db_print ( char * buf ) {
sprintf ( buf ,
" userid=%d, "
" appid=%d, "
" njobs=%d, "
" total=%.15e, "
" expavg=%.15e, "
" expavg_time=%.15e, "
" credit_type=%d " ,
userid ,
appid ,
njobs ,
total ,
expavg ,
expavg_time ,
credit_type
) ;
}
void DB_CREDIT_USER : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
userid = atoi ( r [ i + + ] ) ;
appid = atoi ( r [ i + + ] ) ;
njobs = atoi ( r [ i + + ] ) ;
total = atof ( r [ i + + ] ) ;
expavg = atof ( r [ i + + ] ) ;
expavg_time = atof ( r [ i + + ] ) ;
credit_type = atoi ( r [ i + + ] ) ;
}
void DB_CREDIT_TEAM : : db_print ( char * buf ) {
sprintf ( buf ,
" teamid=%d, "
" appid=%d, "
" njobs=%d, "
" total=%.15e, "
" expavg=%.15e, "
" expavg_time=%.15e, "
" credit_type=%d " ,
teamid ,
appid ,
njobs ,
total ,
expavg ,
expavg_time ,
credit_type
) ;
}
void DB_CREDIT_TEAM : : db_parse ( MYSQL_ROW & r ) {
int i = 0 ;
clear ( ) ;
teamid = atoi ( r [ i + + ] ) ;
appid = atoi ( r [ i + + ] ) ;
njobs = atoi ( r [ i + + ] ) ;
total = atof ( r [ i + + ] ) ;
expavg = atof ( r [ i + + ] ) ;
expavg_time = atof ( r [ i + + ] ) ;
credit_type = atoi ( r [ i + + ] ) ;
}
2005-01-02 18:29:53 +00:00
const char * BOINC_RCSID_ac374386c8 = " $Id$ " ;