int handle_remove(const char* name) { DB_VDA_FILE vf; char buf[1024]; sprintf(buf, "where file_name='%s'", name); int retval = vf.lookup(buf); if (retval) return retval; // delete DB records // DB_VDA_CHUNK_HOST ch; sprintf(buf, "vda_file_id=%d", vf.id); ch.delete_from_db_multi(buf); vf.delete_from_db(); // remove symlink from download hier // dir_hier_path(name, config.download_dir, config.uldl_dir_fanout, buf); unlink(buf); // remove encoded data and directories // retval = chdir(vf.dir); if (retval) perror("chdir"); retval = system("/bin/rm -r [0-9]* Coding data.vda"); if (retval) perror("system"); 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:\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 handle_status(const char* name) { DB_VDA_FILE vf; char buf[1024]; sprintf(buf, "where name='%s'", name); int retval = vf.lookup(buf); if (retval) return retval; return 0; }
int handle_update(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; return dvf.update_field("need_update=1"); }
int handle_retrieve(const char* name) { DB_VDA_FILE vf; char buf[1024]; sprintf(buf, "where name='%s'", name); int retval = vf.lookup(buf); if (retval) return retval; retval = vf.update_field("retrieving=1"); return retval; }
// Process a present file; possibilities: // - a download finished // - this host hasn't communicated in a while, and we deleted the // VDA_CHUNK_HOST record // So: // - create a vda_chunk_host record if needed // - set present_on_host flag in vda_chunk_host // - mark our in-memory vda_chunk_host record as "found" // - mark vda_file for update // static void process_present_file(FILE_INFO& fi, CHUNK_LIST& chunks) { char fname[256], chunk_name[256], buf[256]; int hostid, retval; retval = parse_physical_filename(fi.name, hostid, chunk_name, fname); if (retval) { log_messages.printf(MSG_CRITICAL, "Can't parse VDA filename %s\n", fi.name ); return; } DB_VDA_FILE vf; sprintf(buf, "where file_name='%s'", fname); retval = vf.lookup(buf); if (retval) { log_messages.printf(MSG_CRITICAL, "No VDA file %s\n", fname); return; } if (fi.nbytes != vf.chunk_size) { log_messages.printf(MSG_CRITICAL, "wrong chunk size: %.0f != %.0f\n", fi.nbytes, vf.chunk_size ); return; } CHUNK_LIST::iterator cli = chunks.find(string(fi.name)); if (cli == chunks.end()) { // don't have a record of this chunk on this host; make one // DB_VDA_CHUNK_HOST ch; ch.create_time = dtime(); ch.vda_file_id = vf.id; ch.host_id = g_reply->host.id; strcpy(ch.physical_file_name, fi.name); ch.present_on_host = true; ch.transfer_in_progress = false; ch.transfer_wait = false; ch.transfer_request_time = 0; ch.transfer_send_time = 0; retval = ch.insert(); if (retval) { log_messages.printf(MSG_CRITICAL, "ch.insert() failed\n"); return; } } else { // update the existing record // DB_VDA_CHUNK_HOST* chp = &(cli->second); chp->transfer_in_progress = false; chp->transfer_wait = false; chp->present_on_host = true; chp->update(); } mark_for_update(vf.id); }
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; }
// Process a file that's present on client. // A VDA_CHUNK_HOST record may not be in the DB, // e.g. because this host hasn't communicated in a while // and we deleted the VDA_CHUNK_HOST record // So: // - create a vda_chunk_host record if needed // - set present_on_host flag in vda_chunk_host // - mark our in-memory vda_chunk_host record as "found" // - mark vda_file for update // static void process_chunk_present_on_client(FILE_INFO& fi, CHUNK_LIST& chunks) { char fname[256], chunk_name[256], buf[1024]; int hostid, retval; retval = parse_physical_filename(fi.name, hostid, chunk_name, fname); if (retval) { log_messages.printf(MSG_CRITICAL, "Can't parse VDA filename %s\n", fi.name ); return; } DB_VDA_FILE vf; sprintf(buf, "where file_name='%s'", fname); retval = vf.lookup(buf); if (retval) { log_messages.printf(MSG_CRITICAL, "No VDA file for %s, deleting\n", fi.name ); delete_file_xml(fi.name, buf); g_reply->file_transfer_requests.push_back(string(buf)); return; } if (fi.nbytes != vf.chunk_size) { log_messages.printf(MSG_CRITICAL, "wrong chunk size for %s: %.0f != %.0f, deleting\n", fi.name, fi.nbytes, vf.chunk_size ); delete_file_xml(fi.name, buf); g_reply->file_transfer_requests.push_back(string(buf)); return; } CHUNK_LIST::iterator cli = chunks.find(string(fi.name)); if (cli == chunks.end()) { // we don't have a record of this chunk on this host; make one // DB_VDA_CHUNK_HOST ch; ch.create_time = dtime(); ch.vda_file_id = vf.id; ch.host_id = g_reply->host.id; strcpy(ch.physical_file_name, fi.name); ch.present_on_host = true; ch.transfer_in_progress = false; ch.transfer_wait = false; ch.transfer_request_time = 0; ch.transfer_send_time = 0; retval = ch.insert(); if (retval) { log_messages.printf(MSG_CRITICAL, "ch.insert() failed\n"); return; } mark_for_update(vf.id); } else { // we already have a DB record. // If needed, update it and mark file for update // DB_VDA_CHUNK_HOST* chp = &(cli->second); chp->found = true; // if file wasn't previously on host, update the main file // if (!chp->present_on_host) { mark_for_update(vf.id); chp->transfer_in_progress = false; chp->transfer_wait = false; chp->present_on_host = true; sprintf(buf, "host_id=%d and physical_file_name='%s'", chp->host_id, chp->physical_file_name ); chp->update_fields_noid( "transfer_in_progress=0, transfer_wait=0, present_on_host=1", buf ); } } }