From 09d0878732425e92d4e79b3adfb239305f013f98 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 29 Jan 2005 23:29:54 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=5244 --- checkin_notes | 31 +++++++++ sched/db_purge.C | 1 + sched/file_deleter.C | 2 + sched/make_work.C | 147 +++++++++++++++++++++++------------------- tools/dir_hier_path.C | 7 +- 5 files changed, 122 insertions(+), 66 deletions(-) diff --git a/checkin_notes b/checkin_notes index f5c55a6075..e1e8b40be2 100755 --- a/checkin_notes +++ b/checkin_notes @@ -23447,3 +23447,34 @@ Rom 29 Jan 2005 lib/ gui_rpc_client.C + +David 29 Jan 2005 + - make_work: fixed a basic design problem. + Its main loop creates workunits until the number of + sendable results reaches the "cushion" level. + This worked OK in the old days when creating a workunit + created its results; but these days the transitioner does that. + So make_work would end up creating way more workunits + than it's supposed to. + + The fix: estimate how many WUs to create + (based on wu.target_nresults). + Make that many, then sleep for 10 seconds + (give the transitioner a chance to create the results). + + - Another problem: the "master WU" used by make_work could + get deleted by file_deleter and db_purge. + Kludgy but effective solution: + change file_deleter and db_purge to ignore WUs whose + name includes "nodelete". + Call your master WU "wu_nodelete". + + - change dir_hier_path so that it just prints the pathname of the file, + so you can use it in scripts + + sched/ + db_purge.C + file_deleter.C + make_work.C + tools/ + dir_hier_path.C diff --git a/sched/db_purge.C b/sched/db_purge.C index 13ec29b54c..69c90e9af1 100644 --- a/sched/db_purge.C +++ b/sched/db_purge.C @@ -470,6 +470,7 @@ bool do_pass() { int n=0; while (!wu.enumerate(buf)) { + if (strstr(wu.name, "nodelete")) continue; did_something = true; // if archives have not already been opened, then open them. diff --git a/sched/file_deleter.C b/sched/file_deleter.C index 27786afa78..2dd157bfeb 100644 --- a/sched/file_deleter.C +++ b/sched/file_deleter.C @@ -68,6 +68,8 @@ int wu_delete_files(WORKUNIT& wu) { bool no_delete=false; int count_deleted = 0, retval; + if (strstr(wu.name, "nodelete")) return 0; + safe_strcpy(buf, wu.xml_doc); p = strtok(buf, "\n"); diff --git a/sched/make_work.C b/sched/make_work.C index 679674c544..9bf09ffcf2 100644 --- a/sched/make_work.C +++ b/sched/make_work.C @@ -111,14 +111,84 @@ int count_workunits(const char* query="") { return n; } -void make_work() { - SCHED_CONFIG config; - char * p; - int retval, start_time=time(0); - char keypath[256]; +void make_new_wu( + DB_WORKUNIT& wu, char* starting_xml, int start_time, int& seqno, + SCHED_CONFIG& config +) { char file_name[256], buf[LARGE_BLOB_SIZE], pathname[256]; char new_file_name[256], new_pathname[256], command[256]; - char starting_xml[LARGE_BLOB_SIZE], new_buf[LARGE_BLOB_SIZE]; + char new_buf[LARGE_BLOB_SIZE]; + char * p; + int retval; + + strcpy(buf, starting_xml); + p = strtok(buf, "\n"); + strcpy(file_name, ""); + + // make new hard links to the WU's input files + // (don't actually copy files) + // + while (p) { + if (parse_str(p, "", file_name, sizeof(file_name))) { + sprintf( + new_file_name, "%s__%d_%d", file_name, start_time, seqno++ + ); + dir_hier_path( + file_name, config.download_dir, config.uldl_dir_fanout, true, + pathname + ); + dir_hier_path( + new_file_name, config.download_dir, config.uldl_dir_fanout, true, + new_pathname, true + ); + sprintf(command,"ln %s %s", pathname, new_pathname); + log_messages.printf(SCHED_MSG_LOG::DEBUG, "executing command: %s\n", command); + retval = system(command); + if (retval) { + log_messages.printf( + SCHED_MSG_LOG::CRITICAL, "system() error %d\n", retval + ); + perror(command); + exit(1); + } + strcpy(new_buf, starting_xml); + replace_file_name( + new_buf, file_name, new_file_name, config.download_url + ); + strcpy(wu.xml_doc, new_buf); + } + p = strtok(0, "\n"); + } + + // set various fields for new WU (all others are copied) + // + wu.id = 0; + wu.create_time = time(0); + sprintf(wu.name, "wu_%d_%d", start_time, seqno++); + wu.need_validate = false; + wu.canonical_resultid = 0; + wu.canonical_credit = 0; + wu.transition_time = time(0); + wu.error_mask = 0; + wu.file_delete_state = FILE_DELETE_INIT; + wu.assimilate_state = ASSIMILATE_INIT; + retval = wu.insert(); + if (retval) { + log_messages.printf(SCHED_MSG_LOG::CRITICAL, + "Failed to created WU, error %d; exiting\n", retval + ); + exit(retval); + } + wu.id = boinc_db.insert_id(); + log_messages.printf(SCHED_MSG_LOG::DEBUG, "[%s] Created new WU\n", wu.name); +} + +void make_work() { + SCHED_CONFIG config; + int retval, start_time=time(0); + char keypath[256]; + char buf[LARGE_BLOB_SIZE]; + char starting_xml[LARGE_BLOB_SIZE]; R_RSA_PRIVATE_KEY key; DB_WORKUNIT wu; int seqno = 0; @@ -169,70 +239,17 @@ void make_work() { unsent_results, cushion ); if (unsent_results > cushion) { - sleep(1); + sleep(10); continue; } - strcpy(buf, starting_xml); - p = strtok(buf, "\n"); - strcpy(file_name, ""); - - // make new hard links to the WU's input files - // (don't actually copy files) - // - while (p) { - if (parse_str(p, "", file_name, sizeof(file_name))) { - sprintf( - new_file_name, "%s__%d_%d", file_name, start_time, seqno++ - ); - dir_hier_path( - file_name, config.download_dir, config.uldl_dir_fanout, true, - pathname - ); - dir_hier_path( - new_file_name, config.download_dir, config.uldl_dir_fanout, true, - new_pathname, true - ); - sprintf(command,"ln %s %s", pathname, new_pathname); - log_messages.printf(SCHED_MSG_LOG::DEBUG, "executing command: %s\n", command); - retval = system(command); - if (retval) { - log_messages.printf( - SCHED_MSG_LOG::CRITICAL, "system() error %d\n", retval - ); - perror(command); - exit(1); - } - strcpy(new_buf, starting_xml); - replace_file_name( - new_buf, file_name, new_file_name, config.download_url - ); - strcpy(wu.xml_doc, new_buf); - } - p = strtok(0, "\n"); + int nwus = (cushion-unsent_results)/wu.target_nresults+1; + for (int i=0; i #include "util.h" @@ -35,7 +40,7 @@ int main(int argc, char** argv) { } dir_hier_path(argv[1], "", config.uldl_dir_fanout, true, path); - printf("path: %s%s\n", config.download_dir, path); + printf("%s%s\n", config.download_dir, path); } const char *BOINC_RCSID_c683969ea8 = "$Id$";