From 9ec90c409e05db7dcfe8580de8086085dbae2b74 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 7 Jul 2009 22:58:58 +0000 Subject: [PATCH] - GUI RPC: add get_message_seqno() RPC. fixes #931 svn path=/trunk/boinc/; revision=18576 --- checkin_notes | 11 +++++++++++ client/boinc_cmd.cpp | 7 +++++++ client/gui_rpc_server_ops.cpp | 10 ++++++++++ client/work_fetch.cpp | 16 +++++++++++++--- lib/gui_rpc_client.h | 1 + lib/gui_rpc_client_ops.cpp | 19 +++++++++++++++++++ 6 files changed, 61 insertions(+), 3 deletions(-) diff --git a/checkin_notes b/checkin_notes index 89dcd1f314..eccff31498 100644 --- a/checkin_notes +++ b/checkin_notes @@ -6196,3 +6196,14 @@ Charlie 7 July 2009 mac_installer/ PostInstall.cpp + +David 7 July 2009 + - GUI RPC: add get_message_seqno() RPC. fixes #931 + + client/ + work_fetch.cpp + boinc_cmd.cpp + gui_rpc_server_ops.cpp + lib/ + gui_rpc_client_ops.cpp + gui_rpc_client.h diff --git a/client/boinc_cmd.cpp b/client/boinc_cmd.cpp index ff69518c90..02858c386a 100644 --- a/client/boinc_cmd.cpp +++ b/client/boinc_cmd.cpp @@ -68,6 +68,7 @@ Commands:\n\ --get_disk_usage show disk usage\n\ --get_proxy_settings\n\ --get_messages [ seqno ] show messages > seqno\n\ + --get_message_count show largest message seqno\n\ --get_host_info\n\ --version, -V show core client version\n\ --result url result_name op job operation\n\ @@ -361,6 +362,12 @@ int main(int argc, char** argv) { if (pi.http_user_name.size()) pi.use_http_authentication = true; if (pi.socks_server_name.size()) pi.use_socks_proxy = true; retval = rpc.set_proxy_settings(pi); + } else if (!strcmp(cmd, "--get_message_count")) { + int seqno; + retval = rpc.get_message_count(seqno); + if (!retval) { + printf("Greatest message sequence number: %d\n", seqno); + } } else if (!strcmp(cmd, "--get_messages")) { int seqno; if (i == argc) { diff --git a/client/gui_rpc_server_ops.cpp b/client/gui_rpc_server_ops.cpp index dc384aaa56..78ba4e5622 100644 --- a/client/gui_rpc_server_ops.cpp +++ b/client/gui_rpc_server_ops.cpp @@ -405,6 +405,14 @@ static void handle_get_messages(char* buf, MIOFILE& fout) { fout.printf("\n"); } +static void handle_get_message_count(char*, MIOFILE& fout) { + if (message_descs.size() == 0) { + fout.printf("0\n"); + } else { + fout.printf("%d\n", message_descs[0]->seqno); + } +} + // // XXX // XXX @@ -1124,6 +1132,8 @@ int GUI_RPC_CONN::handle_rpc() { handle_get_disk_usage(mf); } else if (match_tag(request_msg, "= 1) return 0; double wu_est = result->estimated_duration(for_work_fetch); if (fraction_done <= 0) return wu_est; double frac_est = (elapsed_time / fraction_done) - elapsed_time; +#if 0 + // commenting this out for now - could cause big discontinuity + // + if (elapsed_time >= wu_est) { + // if the job has already run longer than static estimate, + // just use the dynamic estimate. + // + return frac_est; + } +#endif double fraction_left = 1-fraction_done; double wu_weight = fraction_left * fraction_left; double fd_weight = 1 - wu_weight; diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index de146aad66..bd5f8075f5 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -615,6 +615,7 @@ public: int set_proxy_settings(GR_PROXY_INFO&); int get_proxy_settings(GR_PROXY_INFO&); int get_messages(int seqno, MESSAGES&); + int get_message_count(int& seqno); int file_transfer_op(FILE_TRANSFER&, const char*); int result_op(RESULT&, const char*); int get_host_info(HOST_INFO&); diff --git a/lib/gui_rpc_client_ops.cpp b/lib/gui_rpc_client_ops.cpp index 0cf4ad6d10..a05b2f2bd6 100644 --- a/lib/gui_rpc_client_ops.cpp +++ b/lib/gui_rpc_client_ops.cpp @@ -1717,6 +1717,25 @@ int RPC_CLIENT::get_proxy_settings(GR_PROXY_INFO& p) { return retval; } +int RPC_CLIENT::get_message_count(int& seqno) { + int retval; + SET_LOCALE sl; + char buf[256]; + RPC rpc(this); + + sprintf(buf, + "\n" + ); + retval = rpc.do_rpc(buf); + if (retval) return retval; + while (rpc.fin.fgets(buf, 256)) { + if (parse_int(buf, "", seqno)) { + return 0; + } + } + return ERR_XML_PARSE; +} + int RPC_CLIENT::get_messages(int seqno, MESSAGES& msgs) { int retval; SET_LOCALE sl;