// This file is part of BOINC. // http://boinc.berkeley.edu // Copyright (C) 2008 University of California // // 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. // // BOINC is distributed in the hope that it will be useful, // 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. // // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . // assimilator for single jobs. // - if success, move the output file(s) to job directory // - delete job description file // - delete WU template file #include #include #include #include #include #include "boinc_db.h" #include "error_numbers.h" #include "filesys.h" #include "sched_msgs.h" #include "validate_util.h" #include "sched_config.h" #include "sched_util.h" using std::vector; using std::string; int assimilate_handler( WORKUNIT& wu, vector& /*results*/, RESULT& canonical_result ) { int retval; char buf[1024], filename[256], job_dir[256], job_dir_file[256]; unsigned int i; // delete the template files // unlink(config.project_path("templates/sj_wu_template_%d", wu.id)); unlink(config.project_path("templates/sj_result_template_%d", wu.id)); // read and delete the job directory file // sprintf(filename, "sj_%d", wu.id); dir_hier_path( filename, config.upload_dir, config.uldl_dir_fanout, job_dir_file ); FILE* f = fopen(job_dir_file, "r"); if (!f) { log_messages.printf(MSG_CRITICAL, "Can't open job file %s\n", buf); return 0; } if (!fgets(buf, 1024, f)) { log_messages.printf(MSG_CRITICAL, "Can't read job file %s\n", buf); fclose(f); return 0; } fclose(f); unlink(job_dir_file); // parse the job directory file // char* p = strstr(buf, ""); if (!p) { log_messages.printf(MSG_CRITICAL, "garbage in job file: %s\n", buf); return 0; } strcpy(job_dir, buf+strlen("")); p = strstr(job_dir, ""); if (!p) { log_messages.printf(MSG_CRITICAL, "garbage in job file: %s\n", buf); return 0; } *p = 0; // Create a job summary file // sprintf(filename, "%s/job_summary_%d", job_dir, wu.id); f = fopen(filename, "w"); // If job was successful, copy the output files // if (wu.canonical_resultid) { fprintf(f, "Job was completed by host %d.\n" "CPU time: %f seconds\n", canonical_result.hostid, canonical_result.cpu_time ); vector output_files; char copy_path[MAXPATHLEN]; get_output_file_infos(canonical_result, output_files); unsigned int n = output_files.size(); for (i=0; i