From 8af3a9466ebac3287e47cdc58f9c8dc27567ded4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 26 Jul 2005 11:55:28 +0000 Subject: [PATCH] try file URLs in order svn path=/trunk/boinc/; revision=6805 --- checkin_notes | 15 +++++++++++++++ client/client_state.C | 44 ++++++++++++++++++++++--------------------- client/client_state.h | 1 + client/client_types.C | 17 ++++++++++++----- client/cs_scheduler.C | 3 +++ client/cs_statefile.C | 10 ++++++++-- 6 files changed, 62 insertions(+), 28 deletions(-) diff --git a/checkin_notes b/checkin_notes index 0e6d8bdd54..53a6fa3433 100755 --- a/checkin_notes +++ b/checkin_notes @@ -9576,3 +9576,18 @@ Rom 25 July 2005 wizfailure.gif (Added) wizquestion.bmp (Added) wizsuccess.gif (Added) + +David 26 July 2005 + - Core client: try DL/UL of replicated files + in URL order listed by project, not random order. + Einstein@home orders URLs by proximity to client. + Left in randomization code but commented it out. + - Shorten host info messages, and move to separate function + (don't lengthen functions that are too large already) + - fix small memory leak when using anon platform + + client/ + client_state.C,h + client_types.C + cs_scheduler.C + cs_statefile.C diff --git a/client/client_state.C b/client/client_state.C index 45de262a21..783e348171 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -185,11 +185,32 @@ void CLIENT_STATE::free_mem() { } #endif +void CLIENT_STATE::show_host_info() { + char buf[256], buf2[256]; + msg_printf(NULL, MSG_INFO, + "Processor: %d %s %s", + host_info.p_ncpus, host_info.p_vendor, host_info.p_model + ); + + nbytes_to_string(host_info.m_nbytes, 0, buf, sizeof(buf)); + nbytes_to_string(host_info.m_swap, 0, buf2, sizeof(buf2)); + msg_printf(NULL, MSG_INFO, + "Memory: %s physical, %s virtual", + buf, buf2 + ); + + nbytes_to_string(host_info.d_total, 0, buf, sizeof(buf)); + nbytes_to_string(host_info.d_free, 0, buf2, sizeof(buf2)); + msg_printf(NULL, MSG_INFO, + "Disk: %s total, %s free", + buf, buf2 + ); +} + int CLIENT_STATE::init() { int retval; unsigned int i; char buf[256]; - char buf2[256]; srand((unsigned int)time(0)); now = dtime(); @@ -243,26 +264,7 @@ int CLIENT_STATE::init() { set_ncpus(); - // Display useful diagnostic information in case the user is confused - // about their own system. - msg_printf(NULL, MSG_INFO, - "Processor Inventory: %d %s %s Processor(s)", - host_info.p_ncpus, host_info.p_vendor, host_info.p_model - ); - - nbytes_to_string(host_info.m_nbytes, 0, buf, sizeof(buf)); - nbytes_to_string(host_info.m_swap, 0, buf2, sizeof(buf2)); - msg_printf(NULL, MSG_INFO, - "Memory Inventory: Memory total - %s, Swap total - %s", - buf, buf2 - ); - - nbytes_to_string(host_info.d_total, 0, buf, sizeof(buf)); - nbytes_to_string(host_info.d_free, 0, buf2, sizeof(buf2)); - msg_printf(NULL, MSG_INFO, - "Disk Inventory: Disk total - %s, Disk available - %s", - buf, buf2 - ); + show_host_info(); // Parse various files parse_account_files(); diff --git a/client/client_state.h b/client/client_state.h index 6ae3d1503c..67f60063fd 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -171,6 +171,7 @@ public: // --------------- client_state.C: public: CLIENT_STATE(); + void show_host_info(); int init(); bool do_something(); // Initiates and completes actions (file transfers, process executions) diff --git a/client/client_types.C b/client/client_types.C index 49f29aa1c0..1d8656ddd4 100644 --- a/client/client_types.C +++ b/client/client_types.C @@ -747,21 +747,28 @@ int FILE_INFO::delete_file() { return retval; } -// If a file has multiple replicas, we want to choose -// a random one to try first, and then cycle through others -// if transfers fail. -// Call this to get the initial url, -// // Files may have URLs for both upload and download. +// Call this to get the initial url, // The is_upload arg says which kind you want. // NULL return means there is no URL of the requested type // const char* FILE_INFO::get_init_url(bool is_upload) { + +// if a project supplies multiple URLs, try them in order +// (e.g. in Einstein@home they're ordered by proximity to client). +// The commented-out code tries them starting from random place. +// This is appropriate if replication is for load-balancing. +// TODO: add a flag saying which mode to use. +// +#if 1 + current_url = 0; +#else double temp; temp = rand(); temp *= urls.size(); temp /= RAND_MAX; current_url = (int)temp; +#endif start_url = current_url; while(1) { if (!is_correct_url_type(is_upload, urls[current_url])) { diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index f90ee433b0..5dd6b06fff 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -786,6 +786,9 @@ int CLIENT_STATE::handle_scheduler_reply( } } + // the account file has GUI URLs and project prefs. + // rewrite if either of these has changed + // if (project->gui_urls != old_gui_urls || update_project_prefs) { retval = project->write_account_file(); if (retval) { diff --git a/client/cs_statefile.C b/client/cs_statefile.C index 66c96bd73a..7c6f50d645 100644 --- a/client/cs_statefile.C +++ b/client/cs_statefile.C @@ -102,7 +102,10 @@ int CLIENT_STATE::parse_state_file() { } else if (match_tag(buf, "")) { APP* app = new APP; retval = app->parse(mf); - if (project && project->anonymous_platform) continue; + if (project && project->anonymous_platform) { + delete app; + continue; + } if (retval) { msg_printf(NULL, MSG_ERROR, "Can't parse app in state file"); delete app; @@ -176,7 +179,10 @@ int CLIENT_STATE::parse_state_file() { } else if (match_tag(buf, "")) { APP_VERSION* avp = new APP_VERSION; retval = avp->parse(mf); - if (project && project->anonymous_platform) continue; + if (project && project->anonymous_platform) { + delete avp; + continue; + } if (retval) { msg_printf(NULL, MSG_ERROR, "Can't parse app version in state file"); delete avp;