From 9a8151dd638549e316874b86a3b689640a318f63 Mon Sep 17 00:00:00 2001 From: Bruce Allen Date: Fri, 26 Nov 2004 23:33:11 +0000 Subject: [PATCH] - Added a -dont_update_db command-line option to assimilator.C which prevents it from updating the database, and so is useful for testing. svn path=/trunk/boinc/; revision=4668 --- checkin_notes | 6 ++++++ sched/assimilator.C | 39 +++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/checkin_notes b/checkin_notes index 1dccede6b6..1f4ab3b936 100755 --- a/checkin_notes +++ b/checkin_notes @@ -20288,3 +20288,9 @@ Bruce and Reinhard 2004-11-26 Makefile.am test/ boinc_db.inc [removed: this file is autogenerated] + +Bruce 2004-11-27 + - Added a -dont_update_db command-line option to assimilator.C which prevents it from updating + the database, and so is useful for testing. + sched/ + assimilator.C diff --git a/sched/assimilator.C b/sched/assimilator.C index fc1dda6274..8fee11dfa8 100644 --- a/sched/assimilator.C +++ b/sched/assimilator.C @@ -44,7 +44,8 @@ using std::vector; #define PIDFILE "assimilator.pid" SCHED_CONFIG config; -bool noinsert = false; +bool update_db = true; + #define SLEEP_INTERVAL 10 @@ -64,7 +65,10 @@ bool do_pass(APP& app) { sprintf(buf, "where appid=%d and assimilate_state=%d limit 1000", app.id, ASSIMILATE_READY); while (!wu.enumerate(buf)) { vector results; // must be inside while()! - did_something = true; + + // for testing purposes, can pretend we did nothing. + if (update_db) + did_something = true; log_messages.printf(SCHED_MSG_LOG::DEBUG, "[%s] assimilating; state=%d\n", wu.name, wu.assimilate_state @@ -80,17 +84,19 @@ bool do_pass(APP& app) { assimilate_handler(wu, results, canonical_result); - sprintf( - buf, "assimilate_state=%d, transition_time=%d", - ASSIMILATE_DONE, (int)time(0) - ); - retval = wu.update_field(buf); - if (retval) { + if (did_something) { + sprintf( + buf, "assimilate_state=%d, transition_time=%d", + ASSIMILATE_DONE, (int)time(0) + ); + retval = wu.update_field(buf); + if (retval) { log_messages.printf(SCHED_MSG_LOG::CRITICAL, - "[%s] update failed: %d\n", wu.name, retval - ); + "[%s] update failed: %d\n", wu.name, retval + ); exit(1); - } + } + } } if (did_something) { boinc_db.commit_transaction(); @@ -115,10 +121,15 @@ int main(int argc, char** argv) { log_messages.set_debug_level(atoi(argv[++i])); } else if (!strcmp(argv[i], "-app")) { strcpy(app.name, argv[++i]); - } else if (!strcmp(argv[i], "-noinsert")) { - noinsert = true; + } else if (!strcmp(argv[i], "-dont_update_db")) { + // This option is for testing your assimilator. When set, + // it ensures that the assimilator does not actually modify + // the assimilate_state of the workunits, so you can run + // your assimilator over and over again without affecting + // your project. + update_db = false; } else { - log_messages.printf(SCHED_MSG_LOG::CRITICAL, "Unrecognized arg: %s\n", argv[i]); + log_messages.printf(SCHED_MSG_LOG::CRITICAL, "Unrecognized arg: %s\n", argv[i]); } }