int handle_status(const char* name) { DB_VDA_FILE dvf; char buf[1024]; sprintf(buf, "where file_name='%s'", name); int retval = dvf.lookup(buf); if (retval) return retval; VDA_FILE_AUX vf = dvf; sprintf(buf, "%s/boinc_meta.txt", vf.dir); retval = vf.policy.parse(buf); if (retval) { log_messages.printf(MSG_CRITICAL, "Can't parse policy file %s\n", buf); return retval; } retval = vf.get_state(); if (retval) { log_messages.printf(MSG_CRITICAL, "Can't get file state: %d\n", retval); return retval; } printf("status for file %s:\n", vf.file_name); vf.meta_chunk->recovery_plan(); vf.meta_chunk->compute_min_failures(); vf.meta_chunk->print_status(0); printf("fault tolerance level: %d\n", vf.meta_chunk->min_failures-1); if (vf.retrieving) { if (vf.retrieved) { printf("Retrieving: completed\n"); } else { printf("Retrieving: in progress\n"); } } return 0; }
int CHUNK::recovery_action(double now) { int retval; char buf[256]; VDA_FILE_AUX* fp = parent->dfile; if (data_now_present) { present_on_server = true; #if 0 fp->disk_usage.sample_inc( size, fp->collecting_stats(), now, "recovery_action: now present" ); #endif status = PRESENT; } if (status == PRESENT && (int)(hosts.size()) < fp->policy.replication) { retval = assign(); if (retval) return retval; keep_present = true; } if (download_in_progress()) { keep_present = true; } if (debug_status) { printf(" chunk %s: data_needed %d present_on_server %d keep_present %d\n", name, data_needed, present_on_server, keep_present ); } if (present_on_server) { if (!keep_present) { sprintf(buf, " chunk %s: not needed, removing from server\n", name ); show_msg(buf); retval = delete_file(); if (retval) return retval; present_on_server = false; status = RECOVERABLE; min_failures = fp->policy.replication; parent->dfile->disk_usage.sample_inc( -size, fp->collecting_stats(), now, "recovery_action: don't need" ); } } else { if (data_needed) { retval = start_upload(); if (retval) return retval; } } return 0; }
int CHUNK::recovery_action(double now) { int retval; char buf[256]; VDA_FILE_AUX* fp = parent->dfile; if (data_now_present) { present_on_server = true; fp->disk_usage.sample_inc( size, fp->collecting_stats(), now ); status = PRESENT; } if (status == PRESENT && (int)(hosts.size()) < fp->policy.replication) { retval = assign(); if (retval) return retval; } if (download_in_progress()) { data_needed = true; } #ifdef DEBUG_RECOVERY printf("chunk action: %s data_needed %d present_on_server %d\n", name, data_needed, present_on_server ); #endif if (data_needed) { if (!present_on_server) { retval = start_upload(); if (retval) return retval; } } else { if (present_on_server) { present_on_server = false; status = RECOVERABLE; min_failures = fp->policy.replication; sprintf(buf, "%s replicated, removing from server\n", name); show_msg(buf); parent->dfile->disk_usage.sample_inc( -size, fp->collecting_stats(), now ); } } return 0; }
int handle_file(VDA_FILE_AUX& vf, DB_VDA_FILE& dvf) { int retval; char buf[1024]; log_messages.printf(MSG_NORMAL, "processing file %s\n", vf.file_name); // read the policy file // sprintf(buf, "%s/boinc_meta.txt", vf.dir); retval = vf.policy.parse(buf); if (retval) { log_messages.printf(MSG_CRITICAL, "Can't parse policy file %s\n", buf); return retval; } if (vf.initialized) { retval = vf.get_state(); if (retval) { log_messages.printf(MSG_CRITICAL, "vf.get_state failed %d\n", retval); return retval; } } else { retval = vf.init(); if (retval) { log_messages.printf(MSG_CRITICAL, "vf.init failed %d\n", retval); return retval; } sprintf(buf, "initialized=1, chunk_size=%.0f", vf.policy.chunk_size()); dvf.update_field(buf); } retval = vf.meta_chunk->recovery_plan(); if (retval) { log_messages.printf(MSG_CRITICAL, "vf.recovery_plan failed %d\n", retval); return retval; } retval = vf.meta_chunk->recovery_action(dtime()); if (retval) { log_messages.printf(MSG_CRITICAL, "vf.recovery_action failed %d\n", retval); return retval; } return 0; }
int handle_status(const char* name) { DB_VDA_FILE dvf; char buf[1024]; sprintf(buf, "where file_name='%s'", name); int retval = dvf.lookup(buf); if (retval) return retval; VDA_FILE_AUX vf = dvf; sprintf(buf, "%s/boinc_meta.txt", vf.dir); retval = vf.policy.parse(buf); if (retval) { log_messages.printf(MSG_CRITICAL, "Can't parse policy file %s\n", buf); return retval; } retval = vf.get_state(); if (retval) { log_messages.printf(MSG_CRITICAL, "Can't get file state: %d\n", retval); return retval; } printf("status for file %s:", vf.file_name); vf.meta_chunk->print_status(0); return 0; }