when using locality scheduler, have transitioner or backend

lib advertise data file when new result is created.
code organization: create new lib function boinc_touch_file()
      from code that was in locality scheduler module.

svn path=/trunk/boinc/; revision=6456
This commit is contained in:
Bruce Allen 2005-06-27 16:31:49 +00:00
parent f1e75bf4cc
commit 042bfde576
5 changed files with 47 additions and 20 deletions

View File

@ -8568,3 +8568,18 @@ David 26 June 2005
file_names.C file_names.C
html/ops html/ops
cancel_wu_action.php cancel_wu_action.php
Bruce 27 June 2005
- when using locality scheduler, have transitioner or backend
lib advertise data file when new result is created.
- code organization: create new lib function boinc_touch_file()
from code that was in locality scheduler module.
lib/
filesys.C
filesys.h
tools/
backend_lib.C
sched/
transitioner.C
sched_locality.C

View File

@ -392,6 +392,22 @@ bool boinc_file_exists(const char* path) {
return true; return true;
} }
// returns zero on success, nonzero if didn't touch file
//
int boinc_touch_file(const char *path) {
FILE *fp;
if (boinc_file_exists(path)) {
return 0;
}
if ((fp=fopen(path, "w"))) {
fclose(fp);
return 0;
}
return -1;
}
int boinc_copy(const char* orig, const char* newf) { int boinc_copy(const char* orig, const char* newf) {
#ifdef _WIN32 #ifdef _WIN32

View File

@ -60,6 +60,7 @@ typedef DIR *DIRREF;
extern "C" { extern "C" {
#endif #endif
extern int boinc_delete_file(const char*); extern int boinc_delete_file(const char*);
extern int boinc_touch_file(const char *path);
extern int clean_out_dir(const char*); extern int clean_out_dir(const char*);
extern FILE* boinc_fopen(const char* path, const char* mode); extern FILE* boinc_fopen(const char* path, const char* mode);
extern int boinc_copy(const char* orig, const char* newf); extern int boinc_copy(const char* orig, const char* newf);

View File

@ -324,24 +324,6 @@ static bool work_generation_over(char *filename) {
return boinc_file_exists(fullpath); return boinc_file_exists(fullpath);
} }
// returns zero on success, nonzero if didn't touch file
//
int touch_file(char *path) {
FILE *fp;
if (boinc_file_exists(path)) {
return 0;
}
if ((fp=fopen(path, "w"))) {
fclose(fp);
return 0;
}
return -1;
}
// Ask the WU generator to make more WUs for this file. // Ask the WU generator to make more WUs for this file.
// Returns nonzero if can't make more work. // Returns nonzero if can't make more work.
// Returns zero if it *might* have made more work // Returns zero if it *might* have made more work
@ -365,7 +347,7 @@ int make_more_work_for_file(char* filename) {
// If this operation fails, don't worry or tarry! // If this operation fails, don't worry or tarry!
// //
sprintf(fullpath, "../locality_scheduling/need_work/%s", filename); sprintf(fullpath, "../locality_scheduling/need_work/%s", filename);
if (touch_file(fullpath)) { if (boinc_touch_file(fullpath)) {
log_messages.printf( log_messages.printf(
SCHED_MSG_LOG::CRITICAL, SCHED_MSG_LOG::CRITICAL,
"unable to touch %s\n", fullpath "unable to touch %s\n", fullpath
@ -431,7 +413,7 @@ error_exit:
static void flag_for_possible_removal(char* filename) { static void flag_for_possible_removal(char* filename) {
char path[256]; char path[256];
sprintf(path, "../locality_scheduling/working_set_removal/%s", filename); sprintf(path, "../locality_scheduling/working_set_removal/%s", filename);
touch_file(path); boinc_touch_file(path);
return; return;
} }

View File

@ -391,6 +391,19 @@ int create_result(
return retval; return retval;
} }
} }
// if using locality scheduling, advertise data file
// associated with this newly-created result
//
if (config.locality_scheduling) {
char datafilename[512];
char *last=strstr(result.name, "__");
if (result.name<last && last<(result.name+255)) {
sprintf(datafilename, "../locality_scheduling/work_available/");
strncat(datafilename, result.name, last-result.name);
boinc_touch_file(datafilename);
}
}
return 0; return 0;
} }