// Berkeley Open Infrastructure for Network Computing // http://boinc.berkeley.edu // Copyright (C) 2007 University of California // // This 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 2.1 of the License, or (at your option) any later version. // // This software 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. // // To view the GNU Lesser General Public License visit // http://www.gnu.org/copyleft/lesser.html // or write to the Free Software Foundation, Inc., // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // A sample assimilator that: // 1) if success, copy the output file(s) to a directory // 2) if failure, append a message to an error log // #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 "assimilate_handler.h" using std::vector; using std::string; int assimilate_handler( WORKUNIT& wu, vector& /*results*/, RESULT& canonical_result ) { SCOPE_MSG_LOG scope_messages(log_messages, SCHED_MSG_LOG::MSG_NORMAL); // Parse pym_dir string pymw_dir(""); for (int i=1; i output_file_paths; scope_messages.printf("[%s] Found canonical result\n", wu.name); char copy_path[256]; get_output_file_paths(canonical_result, output_file_paths); unsigned int n = output_file_paths.size(); for (i = 0; i < n; i++) { string s = string(canonical_result.xml_doc_in); string::size_type start = s.find("", 0); string::size_type end = s.find("", 0); string name = string(s, start+11, end - start - 11); // absoulte path to copy result to string target(pymw_dir); target = target.append(name); string source = output_file_paths[i]; retval = boinc_copy(source.c_str() , target.c_str()); if (retval) { scope_messages.printf("[%s] An error occured, while copying result to %s\n", wu.name, target.c_str()); return retval; } } } else { scope_messages.printf("[%s] Workunit failed 0x%x\n", wu.name, wu.error_mask); return -1; } return 0; }