mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=2922
This commit is contained in:
parent
f05ed0cdd7
commit
18983d42e1
|
@ -9499,3 +9499,22 @@ David Jan 22 2004
|
|||
lib/
|
||||
util.C,h
|
||||
xml_util.C,h
|
||||
|
||||
David Jan 22 2004
|
||||
- change the GUI RPC protocol so that there's a single
|
||||
<get_state/> request that returns the entire state
|
||||
(same contents as the client state file)
|
||||
- add fraction_done, current_cpu_time to <active_task> output
|
||||
- factored out CLIENT_STATE::write_state(FILE*)
|
||||
(used for both state file write and GUI RPC)
|
||||
- always copy team name from scheduler reply
|
||||
(so that we'll learn if user quits team)
|
||||
|
||||
client/
|
||||
app.C
|
||||
client_state.h
|
||||
cs_scheduler.C
|
||||
cs_statefile.C
|
||||
gui_rpc_client.C,h
|
||||
gui_rpc_server.C
|
||||
gui_test.C
|
||||
|
|
|
@ -1256,12 +1256,16 @@ int ACTIVE_TASK::write(FILE* fout) {
|
|||
" <app_version_num>%d</app_version_num>\n"
|
||||
" <slot>%d</slot>\n"
|
||||
" <checkpoint_cpu_time>%f</checkpoint_cpu_time>\n"
|
||||
" <fraction_done>%f</fraction_done>\n"
|
||||
" <current_cpu_time>%f</current_cpu_time>\n"
|
||||
"</active_task>\n",
|
||||
result->project->master_url,
|
||||
result->name,
|
||||
app_version->version_num,
|
||||
slot,
|
||||
checkpoint_cpu_time
|
||||
checkpoint_cpu_time,
|
||||
fraction_done,
|
||||
current_cpu_time
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1324,6 +1328,8 @@ int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) {
|
|||
else if (parse_int(buf, "<app_version_num>", app_version_num)) continue;
|
||||
else if (parse_int(buf, "<slot>", slot)) continue;
|
||||
else if (parse_double(buf, "<checkpoint_cpu_time>", checkpoint_cpu_time)) continue;
|
||||
else if (parse_double(buf, "<fraction_done>", fraction_done)) continue;
|
||||
else if (parse_double(buf, "<current_cpu_time>", current_cpu_time)) continue;
|
||||
else msg_printf(NULL, MSG_ERROR, "ACTIVE_TASK::parse(): unrecognized %s\n", buf);
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
|
|
|
@ -258,6 +258,7 @@ private:
|
|||
public:
|
||||
void set_client_state_dirty(char*);
|
||||
int parse_state_file();
|
||||
int write_state(FILE*);
|
||||
int write_state_file();
|
||||
int write_state_file_if_needed();
|
||||
int parse_venue();
|
||||
|
|
|
@ -485,9 +485,7 @@ int CLIENT_STATE::handle_scheduler_reply(
|
|||
if (strlen(sr.user_name)) {
|
||||
safe_strcpy(project->user_name, sr.user_name);
|
||||
}
|
||||
if (strlen(sr.team_name)) {
|
||||
safe_strcpy(project->team_name, sr.team_name);
|
||||
}
|
||||
safe_strcpy(project->team_name, sr.team_name);
|
||||
project->user_total_credit = sr.user_total_credit;
|
||||
project->user_expavg_credit = sr.user_expavg_credit;
|
||||
project->user_create_time = sr.user_create_time;
|
||||
|
|
|
@ -185,7 +185,6 @@ int CLIENT_STATE::parse_venue() {
|
|||
// Write the client_state.xml file
|
||||
//
|
||||
int CLIENT_STATE::write_state_file() {
|
||||
unsigned int i, j;
|
||||
FILE* f = boinc_fopen(STATE_FILE_TEMP, "w");
|
||||
int retval;
|
||||
|
||||
|
@ -195,6 +194,19 @@ int CLIENT_STATE::write_state_file() {
|
|||
msg_printf(0, MSG_ERROR, "Can't open temp state file: %s\n", STATE_FILE_TEMP);
|
||||
return ERR_FOPEN;
|
||||
}
|
||||
retval = write_state(f);
|
||||
fclose(f);
|
||||
if (retval) return retval;
|
||||
retval = boinc_rename(STATE_FILE_TEMP, STATE_FILE_NAME);
|
||||
scope_messages.printf("CLIENT_STATE::write_state_file(): Done writing state file\n");
|
||||
if (retval) return ERR_RENAME;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLIENT_STATE::write_state(FILE* f) {
|
||||
unsigned int i, j;
|
||||
int retval;
|
||||
|
||||
fprintf(f, "<client_state>\n");
|
||||
retval = host_info.write(f);
|
||||
if (retval) return retval;
|
||||
|
@ -261,10 +273,6 @@ int CLIENT_STATE::write_state_file() {
|
|||
fprintf(f, "<host_venue>%s</host_venue>\n", host_venue);
|
||||
}
|
||||
fprintf(f, "</client_state>\n");
|
||||
fclose(f);
|
||||
retval = boinc_rename(STATE_FILE_TEMP, STATE_FILE_NAME);
|
||||
scope_messages.printf("CLIENT_STATE::write_state_file(): Done writing state file\n");
|
||||
if (retval) return ERR_RENAME;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,116 +29,15 @@ RPC_CLIENT::~RPC_CLIENT() {
|
|||
fclose(fout);
|
||||
}
|
||||
|
||||
int RPC_CLIENT::get_projects(vector<PROJECT>& projects) {
|
||||
int RPC_CLIENT::get_state() {
|
||||
char buf[256];
|
||||
int retval;
|
||||
|
||||
fprintf(fout, "<get_projects>\n");
|
||||
fprintf(fout, "<get_state/>\n");
|
||||
fflush(fout);
|
||||
while (fgets(buf, 256, fin)) {
|
||||
if (match_tag(buf, "<projects>")) continue;
|
||||
else if (match_tag(buf, "</projects>")) return 0;
|
||||
else if (match_tag(buf, "<project>")) {
|
||||
PROJECT project;
|
||||
retval = project.parse_state(fin);
|
||||
if (!retval) {
|
||||
projects.push_back(project);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "unrecognized: %s", buf);
|
||||
}
|
||||
printf(buf);
|
||||
if (match_tag(buf, "</client_state>")) break;
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PROJECT::parse_state(FILE* in) {
|
||||
char buf[256];
|
||||
STRING256 string;
|
||||
|
||||
strcpy(project_name, "");
|
||||
strcpy(user_name, "");
|
||||
strcpy(team_name, "");
|
||||
resource_share = 100;
|
||||
exp_avg_cpu = 0;
|
||||
exp_avg_mod_time = 0;
|
||||
min_rpc_time = 0;
|
||||
min_report_min_rpc_time = 0;
|
||||
nrpc_failures = 0;
|
||||
master_url_fetch_pending = false;
|
||||
sched_rpc_pending = false;
|
||||
scheduler_urls.clear();
|
||||
while (fgets(buf, 256, in)) {
|
||||
if (match_tag(buf, "</project>")) return 0;
|
||||
else if (parse_str(buf, "<scheduler_url>", string.text, sizeof(string.text))) {
|
||||
scheduler_urls.push_back(string);
|
||||
continue;
|
||||
}
|
||||
else if (parse_str(buf, "<master_url>", master_url, sizeof(master_url))) continue;
|
||||
else if (parse_str(buf, "<project_name>", project_name, sizeof(project_name))) continue;
|
||||
else if (parse_str(buf, "<user_name>", user_name, sizeof(user_name))) continue;
|
||||
else if (parse_str(buf, "<team_name>", team_name, sizeof(team_name))) continue;
|
||||
else if (parse_double(buf, "<user_total_credit>", user_total_credit)) continue;
|
||||
else if (parse_double(buf, "<user_expavg_credit>", user_expavg_credit)) continue;
|
||||
else if (parse_int(buf, "<user_create_time>", (int &)user_create_time)) continue;
|
||||
else if (parse_int(buf, "<rpc_seqno>", rpc_seqno)) continue;
|
||||
else if (parse_int(buf, "<hostid>", hostid)) continue;
|
||||
else if (parse_double(buf, "<host_total_credit>", host_total_credit)) continue;
|
||||
else if (parse_double(buf, "<host_expavg_credit>", host_expavg_credit)) continue;
|
||||
else if (parse_int(buf, "<host_create_time>", (int &)host_create_time)) continue;
|
||||
else if (parse_double(buf, "<exp_avg_cpu>", exp_avg_cpu)) continue;
|
||||
else if (parse_int(buf, "<exp_avg_mod_time>", exp_avg_mod_time)) continue;
|
||||
else if (match_tag(buf, "<code_sign_key>")) {
|
||||
copy_element_contents(
|
||||
in,
|
||||
"</code_sign_key>",
|
||||
code_sign_key,
|
||||
sizeof(code_sign_key)
|
||||
);
|
||||
}
|
||||
else if (parse_int(buf, "<nrpc_failures>", nrpc_failures)) continue;
|
||||
else if (parse_int(buf, "<master_fetch_failures>", master_fetch_failures)) continue;
|
||||
else if (parse_int(buf, "<min_rpc_time>", (int&)min_rpc_time)) continue;
|
||||
else if (match_tag(buf, "<master_url_fetch_pending/>")) master_url_fetch_pending = true;
|
||||
else if (match_tag(buf, "<sched_rpc_pending/>")) sched_rpc_pending = true;
|
||||
else printf("PROJECT::parse_state(): unrecognized: %s\n", buf);
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
}
|
||||
|
||||
PROJECT::PROJECT() {
|
||||
init();
|
||||
}
|
||||
|
||||
void PROJECT::init() {
|
||||
strcpy(master_url, "");
|
||||
strcpy(authenticator, "");
|
||||
project_specific_prefs = "";
|
||||
resource_share = 100;
|
||||
strcpy(project_name, "");
|
||||
strcpy(user_name, "");
|
||||
strcpy(team_name, "");
|
||||
user_total_credit = 0;
|
||||
user_expavg_credit = 0;
|
||||
user_create_time = 0;
|
||||
rpc_seqno = 0;
|
||||
hostid = 0;
|
||||
host_total_credit = 0;
|
||||
host_expavg_credit = 0;
|
||||
host_create_time = 0;
|
||||
exp_avg_cpu = 0;
|
||||
exp_avg_mod_time = 0;
|
||||
strcpy(code_sign_key, "");
|
||||
nrpc_failures = 0;
|
||||
min_rpc_time = 0;
|
||||
min_report_min_rpc_time = 0;
|
||||
master_fetch_failures = 0;
|
||||
resource_debt = 0;
|
||||
debt_order = 0;
|
||||
master_url_fetch_pending = false;
|
||||
sched_rpc_pending = false;
|
||||
tentative = false;
|
||||
}
|
||||
|
||||
PROJECT::~PROJECT() {
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "client_types.h"
|
||||
|
||||
class RPC_CLIENT {
|
||||
int sock;
|
||||
FILE* fin;
|
||||
|
@ -9,6 +7,6 @@ class RPC_CLIENT {
|
|||
public:
|
||||
~RPC_CLIENT();
|
||||
int init(char*);
|
||||
int get_projects(vector<PROJECT>&);
|
||||
int get_state();
|
||||
};
|
||||
|
||||
|
|
|
@ -34,19 +34,8 @@ int GUI_RPC_CONN::handle_rpc() {
|
|||
if (n <= 0) return -1;
|
||||
buf[n] = 0;
|
||||
printf("got %s\n", buf);
|
||||
if (match_tag(buf, "<get_projects")) {
|
||||
fprintf(fout, "<projects>\n");
|
||||
for (i=0; i<gstate.projects.size(); i++) {
|
||||
PROJECT* p = gstate.projects[i];
|
||||
p->write_state(fout);
|
||||
}
|
||||
fprintf(fout, "</projects>\n");
|
||||
} else if match_tag(buf, "<get_results">)) {
|
||||
fprintf(fout, "<results>\n");
|
||||
for (i=0; i<gstate.projects.size(); i++) {
|
||||
PROJECT* p = gstate.projects[i];
|
||||
p->write_state(fout);
|
||||
}
|
||||
if (match_tag(buf, "<get_state")) {
|
||||
gstate.write_state(fout);
|
||||
} else {
|
||||
fprintf(fout, "<unrecognized/>\n");
|
||||
}
|
||||
|
|
|
@ -4,13 +4,8 @@
|
|||
|
||||
main() {
|
||||
RPC_CLIENT rpc;
|
||||
vector<PROJECT>projects;
|
||||
unsigned int i;
|
||||
|
||||
rpc.init("gui_rpc");
|
||||
rpc.get_projects(projects);
|
||||
for (i=0; i<projects.size(); i++) {
|
||||
PROJECT& project = projects[i];
|
||||
printf("%s: %s\n", project.master_url, project.project_name);
|
||||
}
|
||||
rpc.get_state();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue