mirror of https://github.com/BOINC/boinc.git
- client emulator: implement project availability feature
This commit is contained in:
parent
1f2f32f115
commit
89c9e49bc6
|
@ -302,6 +302,12 @@ int PROJECT::parse_state(XML_PARSER& xp) {
|
|||
continue;
|
||||
}
|
||||
if (xp.parse_double("desired_disk_usage", desired_disk_usage)) continue;
|
||||
#ifdef SIM
|
||||
if (xp.match_tag("available")) {
|
||||
available.parse(xp, "/available");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (log_flags.unparsed_xml) {
|
||||
msg_printf(0, MSG_INFO,
|
||||
"[unparsed_xml] PROJECT::parse_state(): unrecognized: %s",
|
||||
|
|
|
@ -343,6 +343,21 @@ bool CLIENT_STATE::simulate_rpc(PROJECT* p) {
|
|||
int infeasible_count = 0;
|
||||
vector<RESULT*> new_results;
|
||||
|
||||
bool avail;
|
||||
if (p->last_rpc_time) {
|
||||
double delta = now - p->last_rpc_time;
|
||||
avail = p->available.sample(delta);
|
||||
} else {
|
||||
avail = p->available.sample(0);
|
||||
}
|
||||
p->last_rpc_time = now;
|
||||
if (!avail) {
|
||||
sprintf(buf, "RPC to %s skipped - project down<br>", p->project_name);
|
||||
html_msg += buf;
|
||||
msg_printf(p, MSG_INFO, "RPC skipped: project down");
|
||||
return false;
|
||||
}
|
||||
|
||||
// save request params for WORK_FETCH::handle_reply
|
||||
//
|
||||
double save_cpu_req_secs = rsc_work_fetch[0].req_secs;
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
double lambda;
|
||||
bool sample(double dt);
|
||||
void init(double f, double l);
|
||||
int parse(XML_PARSER&, const char*);
|
||||
RANDOM_PROCESS();
|
||||
};
|
||||
|
||||
|
|
|
@ -175,8 +175,7 @@ bool RANDOM_PROCESS::sample(double diff) {
|
|||
}
|
||||
#if 0
|
||||
msg_printf(0, MSG_INFO,
|
||||
"value: %d lambda: %f time_left %f",
|
||||
value, lambda, time_left
|
||||
"value: %d lambda: %f time_left %f", value, lambda, time_left
|
||||
);
|
||||
#endif
|
||||
return value;
|
||||
|
@ -191,9 +190,30 @@ void RANDOM_PROCESS::init(double f, double l) {
|
|||
frac = f;
|
||||
lambda = l;
|
||||
last_time = 0;
|
||||
value = true;
|
||||
time_left = exponential(lambda);
|
||||
off_lambda = lambda/frac - lambda;
|
||||
if (drand() > frac) {
|
||||
value = false;
|
||||
time_left = exponential(off_lambda);
|
||||
} else {
|
||||
value = true;
|
||||
time_left = exponential(lambda);
|
||||
}
|
||||
}
|
||||
|
||||
int RANDOM_PROCESS::parse(XML_PARSER& xp, const char* end_tag) {
|
||||
while (!xp.get_tag()) {
|
||||
if (!xp.is_tag) return ERR_XML_PARSE;
|
||||
if (xp.parse_double("lambda", lambda)) continue;
|
||||
else if (xp.parse_double("frac", frac)) continue;
|
||||
else if (xp.match_tag(end_tag)) {
|
||||
init(frac, lambda);
|
||||
return 0;
|
||||
} else {
|
||||
printf("unrecognized: %s\n", xp.parsed_tag);
|
||||
return ERR_XML_PARSE;
|
||||
}
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
}
|
||||
|
||||
int UNIFORM_DIST::parse(XML_PARSER& xp, const char* end_tag) {
|
||||
|
|
Loading…
Reference in New Issue