// The contents of this file are subject to the BOINC Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://boinc.berkeley.edu/license_1.0.txt // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations // under the License. // // The Original Code is the Berkeley Open Infrastructure for Network Computing. // // The Initial Developer of the Original Code is the SETI@home project. // Portions created by the SETI@home project are Copyright (C) 2002 // University of California at Berkeley. All Rights Reserved. // // Contributor(s): // // transitioner - handle transitions in the state of a WU // - a result has become DONE (via timeout or client reply) // - the WU error mask is set (e.g. by validater) // - assimilation is finished // // cmdline: // [ -asynch ] be asynchronous // [ -one_pass ] do one pass, then exit // [ -d x ] debug level x using namespace std; #include #include #include #include #include "boinc_db.h" #include "util.h" #include "backend_lib.h" #include "sched_config.h" #include "sched_util.h" #define LOCKFILE "transitioner.out" #define PIDFILE "transitioner.pid" int startup_time; CONFIG config; R_RSA_PRIVATE_KEY key; void handle_wu(DB_WORKUNIT& wu) { vector results; DB_RESULT result; DB_RESULT canonical_result; int nerrors, retval, ninprogress, nsuccess; int nunsent, ncouldnt_send, nover; unsigned int i, n; char buf[256], suffix[256], result_template[MAX_BLOB_SIZE]; time_t now = time(0), x; bool all_over, have_result_to_validate, do_delete; log_messages.printf(SchedMessages::DEBUG, "[WU#%d %s] handling WU\n", wu.id, wu.name); ScopeMessages scope_messages(log_messages, SchedMessages::NORMAL); // scan the results for the WU // sprintf(buf, "where workunitid=%d", wu.id); while (!result.enumerate(buf)) { results.push_back(result); } // if (results.size() == 0) { // log_messages.printf( // SchedMessages::NORMAL, "[WU#%d %s] No results\n", // wu.id, wu.name // ); // return; // } log_messages.printf(SchedMessages::DEBUG, "[WU#%d %s] enumerated %d results\n", wu.id, wu.name, (int)results.size() ); // count up the number of results in various states, // and check for timed-out results // nunsent = 0; ninprogress = 0; nerrors = 0; nsuccess = 0; ncouldnt_send = 0; have_result_to_validate = false; for (i=0; i= wu.min_quorum && have_result_to_validate) { wu.need_validate = true; } // check for WU error conditions // NOTE: check on max # of success results is done in validater // if (ncouldnt_send > 0) { wu.error_mask |= WU_ERROR_COULDNT_SEND_RESULT; } if (nerrors > wu.max_error_results) { log_messages.printf( SchedMessages::NORMAL, "[WU#%d %s] WU has too many errors (%d errors for %d results)\n", wu.id, wu.name, nerrors, (int)results.size() ); wu.error_mask |= WU_ERROR_TOO_MANY_ERROR_RESULTS; } if ((int)results.size() > wu.max_total_results) { log_messages.printf( SchedMessages::NORMAL, "[WU#%d %s] WU has too many total results (%d)\n", wu.id, wu.name, (int)results.size() ); wu.error_mask |= WU_ERROR_TOO_MANY_TOTAL_RESULTS; } // if this WU had an error, don't send any unsent results, // and trigger assimilation if needed // if (wu.error_mask) { for (i=0; i 0) { log_messages.printf( SchedMessages::NORMAL, "[WU#%d %s] Generating %d more results (%d target - %d unsent - %d in progress - %d success)\n", wu.id, wu.name, n, wu.target_nresults, nunsent, ninprogress, nsuccess ); for (i=0; i setting FILE_DELETE_READY\n", wu.id, wu.name ); // can delete canonical result outputs // if all successful results have been validated // if (canonical_result.id && canonical_result.file_delete_state == FILE_DELETE_INIT) { canonical_result.file_delete_state = FILE_DELETE_READY; canonical_result.update(); } } // output of error results can be deleted immediately; // output of success results can be deleted if validated // for (i=0; i