2008-03-04 23:50:38 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 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
|
2008-05-06 19:53:49 +00:00
|
|
|
|
2008-03-04 23:50:38 +00:00
|
|
|
// assimilator for single jobs.
|
|
|
|
// - if success, move the output file(s) to job directory
|
|
|
|
// - delete job description file
|
|
|
|
// - delete WU template file
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <cstdlib>
|
2008-04-02 19:33:12 +00:00
|
|
|
#include <cstring>
|
2008-03-04 23:50:38 +00:00
|
|
|
|
|
|
|
#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<RESULT>& /*results*/, RESULT& canonical_result
|
|
|
|
) {
|
|
|
|
int retval;
|
|
|
|
char buf[1024], filename[256], job_dir[256];
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
sprintf(filename, "sj_%d", wu.id);
|
|
|
|
dir_hier_path(filename, config.upload_dir, config.uldl_dir_fanout, buf);
|
|
|
|
FILE* f = fopen(buf, "r");
|
|
|
|
if (!f) {
|
|
|
|
log_messages.printf(MSG_CRITICAL, "Can't open job file %s\n", buf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fgets(buf, 1024, f);
|
|
|
|
char* p = strstr(buf, "<job_dir>");
|
|
|
|
if (!p) {
|
|
|
|
log_messages.printf(MSG_CRITICAL, "garbage in job file: %s\n", buf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
strcpy(job_dir, buf+strlen("<job_dir>"));
|
|
|
|
p = strstr(job_dir, "</job_dir>");
|
|
|
|
if (!p) {
|
|
|
|
log_messages.printf(MSG_CRITICAL, "garbage in job file: %s\n", buf);
|
|
|
|
return 0;
|
|
|
|
}
|
2008-03-05 20:16:10 +00:00
|
|
|
*p = 0;
|
2008-03-04 23:50:38 +00:00
|
|
|
if (wu.canonical_resultid) {
|
2008-05-29 20:11:43 +00:00
|
|
|
vector<FILE_INFO> output_files;
|
2008-03-04 23:50:38 +00:00
|
|
|
char copy_path[256];
|
2008-05-29 21:54:18 +00:00
|
|
|
get_output_file_infos(canonical_result, output_files);
|
2008-05-29 20:11:43 +00:00
|
|
|
unsigned int n = output_files.size();
|
2008-03-04 23:50:38 +00:00
|
|
|
for (i=0; i<n; i++) {
|
2008-05-29 20:11:43 +00:00
|
|
|
FILE_INFO& fi = output_files[i];
|
|
|
|
string logical_name;
|
|
|
|
retval = get_logical_name(canonical_result, fi.path, logical_name);
|
2008-03-05 20:16:10 +00:00
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(MSG_CRITICAL,
|
|
|
|
"Couldn't get logical name for %s: %d\n",
|
2008-05-29 20:11:43 +00:00
|
|
|
fi.path.c_str(), retval
|
2008-03-05 20:16:10 +00:00
|
|
|
);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
sprintf(copy_path, "%s/%s", job_dir, logical_name.c_str());
|
2008-05-29 20:11:43 +00:00
|
|
|
retval = boinc_copy(fi.path.c_str() , copy_path);
|
2008-03-04 23:50:38 +00:00
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(MSG_CRITICAL,
|
|
|
|
"couldn't copy file %s to %s\n",
|
2008-05-29 20:11:43 +00:00
|
|
|
fi.path.c_str(), copy_path
|
2008-03-04 23:50:38 +00:00
|
|
|
);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
sprintf(buf, "%s/error_msg", job_dir);
|
|
|
|
f = fopen(buf, "w");
|
|
|
|
fprintf(f, "Error: 0x%x\n", wu.error_mask);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|