mirror of https://github.com/BOINC/boinc.git
- client: associate a PROJECT with HTTP_OP where applicable,
so that if you use <http_debug> and filter by project you don't see other projects' HTTP stuff - client simulator: cc_config.xml is part of the scenario; log flags are part of the simulation svn path=/trunk/boinc/; revision=24410
This commit is contained in:
parent
b0c0daa8ce
commit
54311606e3
|
@ -7348,3 +7348,18 @@ David 17 Oct 2011
|
|||
sim.cpp,h
|
||||
work_fetch.cpp
|
||||
sim_util.cpp
|
||||
|
||||
David 17 Oct 2011
|
||||
- client: associate a PROJECT with HTTP_OP where applicable,
|
||||
so that if you use <http_debug> and filter by project
|
||||
you don't see other projects' HTTP stuff
|
||||
- client simulator: cc_config.xml is part of the scenario;
|
||||
log flags are part of the simulation
|
||||
|
||||
client/
|
||||
http_curl.cpp,h
|
||||
sim.cpp
|
||||
work_fetch.cpp
|
||||
file_xfer.cpp
|
||||
gui_http.cpp
|
||||
scheduler_op.cpp
|
||||
|
|
|
@ -65,7 +65,7 @@ int FILE_XFER::init_download(FILE_INFO& file_info) {
|
|||
const char* url = fip->download_urls.get_current_url(file_info);
|
||||
if (!url) return ERR_INVALID_URL;
|
||||
return HTTP_OP::init_get(
|
||||
url, pathname, false, (int)starting_size
|
||||
file_info.project, url, pathname, false, (int)starting_size
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,9 @@ int FILE_XFER::init_upload(FILE_INFO& file_info) {
|
|||
file_size_query = true;
|
||||
const char* url = fip->upload_urls.get_current_url(file_info);
|
||||
if (!url) return ERR_INVALID_URL;
|
||||
return HTTP_OP::init_post2(url, header, sizeof(header), NULL, 0);
|
||||
return HTTP_OP::init_post2(
|
||||
file_info.project, url, header, sizeof(header), NULL, 0
|
||||
);
|
||||
} else {
|
||||
bytes_xferred = file_info.upload_offset;
|
||||
sprintf(header,
|
||||
|
@ -140,7 +142,8 @@ int FILE_XFER::init_upload(FILE_INFO& file_info) {
|
|||
const char* url = fip->upload_urls.get_current_url(file_info);
|
||||
if (!url) return ERR_INVALID_URL;
|
||||
return HTTP_OP::init_post2(
|
||||
url, header, sizeof(header), pathname, fip->upload_offset
|
||||
file_info.project, url, header, sizeof(header),
|
||||
pathname, fip->upload_offset
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ int GUI_HTTP::do_rpc(
|
|||
}
|
||||
|
||||
boinc_delete_file(output_file);
|
||||
retval = http_op.init_get(url, output_file, true);
|
||||
retval = http_op.init_get(0, url, output_file, true);
|
||||
if (retval) return retval;
|
||||
gstate.http_ops->insert(&http_op);
|
||||
gui_http_op = op;
|
||||
|
@ -64,7 +64,7 @@ int GUI_HTTP::do_rpc_post(
|
|||
}
|
||||
|
||||
boinc_delete_file(output_file);
|
||||
retval = http_op.init_post(url, input_file, output_file);
|
||||
retval = http_op.init_post(0, url, input_file, output_file);
|
||||
if (retval) return retval;
|
||||
gstate.http_ops->insert(&http_op);
|
||||
gui_http_op = op;
|
||||
|
@ -77,7 +77,7 @@ int GUI_HTTP::do_rpc_post_str(GUI_HTTP_OP* op, char* url, char* req_buf, int len
|
|||
if (gui_http_state != GUI_HTTP_STATE_IDLE) {
|
||||
return ERR_RETRY;
|
||||
}
|
||||
int retval = http_op.init_post2(url, req_buf, len, NULL, 0);
|
||||
int retval = http_op.init_post2(0, url, req_buf, len, NULL, 0);
|
||||
if (retval) return retval;
|
||||
gstate.http_ops->insert(&http_op);
|
||||
gui_http_op = op;
|
||||
|
|
|
@ -217,10 +217,11 @@ int libcurl_debugfunction(
|
|||
return 0;
|
||||
}
|
||||
|
||||
void HTTP_OP::init() {
|
||||
void HTTP_OP::init(PROJECT* p) {
|
||||
reset();
|
||||
start_time = gstate.now;
|
||||
start_bytes_xferred = 0;
|
||||
project = p;
|
||||
}
|
||||
|
||||
void HTTP_OP::reset() {
|
||||
|
@ -237,6 +238,7 @@ void HTTP_OP::reset() {
|
|||
connect_error = 0;
|
||||
bytes_xferred = 0;
|
||||
bSentHeader = false;
|
||||
project = 0;
|
||||
close_socket();
|
||||
}
|
||||
|
||||
|
@ -271,14 +273,14 @@ HTTP_OP::~HTTP_OP() {
|
|||
// output goes to the given file, starting at given offset
|
||||
//
|
||||
int HTTP_OP::init_get(
|
||||
const char* url, const char* out, bool del_old_file, double off
|
||||
PROJECT* p, const char* url, const char* out, bool del_old_file, double off
|
||||
) {
|
||||
if (del_old_file) {
|
||||
unlink(out);
|
||||
}
|
||||
req1 = NULL; // not using req1, but init_post2 uses it
|
||||
file_offset = off;
|
||||
HTTP_OP::init();
|
||||
HTTP_OP::init(p);
|
||||
// usually have an outfile on a get
|
||||
if (off != 0) {
|
||||
bytes_xferred = off;
|
||||
|
@ -298,7 +300,7 @@ int HTTP_OP::init_get(
|
|||
// This is used for scheduler requests and account mgr RPCs.
|
||||
//
|
||||
int HTTP_OP::init_post(
|
||||
const char* url, const char* in, const char* out
|
||||
PROJECT* p, const char* url, const char* in, const char* out
|
||||
) {
|
||||
int retval;
|
||||
double size;
|
||||
|
@ -311,7 +313,7 @@ int HTTP_OP::init_post(
|
|||
if (retval) return retval; // this will return 0 or ERR_NOT_FOUND
|
||||
content_length = (int)size;
|
||||
}
|
||||
HTTP_OP::init();
|
||||
HTTP_OP::init(p);
|
||||
http_op_type = HTTP_OP_POST;
|
||||
http_op_state = HTTP_STATE_CONNECTING;
|
||||
if (log_flags.http_debug) {
|
||||
|
@ -327,12 +329,12 @@ int HTTP_OP::init_post(
|
|||
// This is used for file upload (both get_file_size and file_upload)
|
||||
//
|
||||
int HTTP_OP::init_post2(
|
||||
const char* url, char* r1, int r1_len, const char* in, double offset
|
||||
PROJECT* p, const char* url, char* r1, int r1_len, const char* in, double offset
|
||||
) {
|
||||
int retval;
|
||||
double size;
|
||||
|
||||
init();
|
||||
init(p);
|
||||
req1 = r1;
|
||||
req1_len = r1_len;
|
||||
content_length = 0;
|
||||
|
|
|
@ -47,12 +47,15 @@ extern int curl_cleanup();
|
|||
#define HTTP_STATE_CONNECTING 1
|
||||
#define HTTP_STATE_DONE 2
|
||||
|
||||
struct PROJECT;
|
||||
|
||||
class HTTP_OP {
|
||||
public:
|
||||
HTTP_OP();
|
||||
~HTTP_OP();
|
||||
|
||||
PROXY_INFO pi;
|
||||
PROJECT* project; // associated project, if any
|
||||
|
||||
char m_url[256];
|
||||
char m_curl_ca_bundle_location[256];
|
||||
|
@ -144,7 +147,7 @@ public:
|
|||
// For example: notice RSS feed fetches
|
||||
|
||||
void reset();
|
||||
void init();
|
||||
void init(PROJECT*);
|
||||
int get_ip_addr(int &ip_addr);
|
||||
void close_socket();
|
||||
void close_file();
|
||||
|
@ -153,9 +156,15 @@ public:
|
|||
void handle_messages(CURLMsg*);
|
||||
|
||||
//int init_head(const char* url);
|
||||
int init_get(const char* url, const char* outfile, bool del_old_file, double offset=0);
|
||||
int init_post(const char* url, const char* infile, const char* outfile);
|
||||
int init_get(
|
||||
PROJECT*, const char* url, const char* outfile,
|
||||
bool del_old_file, double offset=0
|
||||
);
|
||||
int init_post(
|
||||
PROJECT*, const char* url, const char* infile, const char* outfile
|
||||
);
|
||||
int init_post2(
|
||||
PROJECT*,
|
||||
const char* url,
|
||||
char* req1, // first part of request. ALSO USED FOR REPLY
|
||||
int req1_len,
|
||||
|
|
|
@ -275,7 +275,7 @@ int SCHEDULER_OP::start_rpc(PROJECT* p) {
|
|||
get_sched_reply_filename(*p, reply_file, sizeof(reply_file));
|
||||
|
||||
cur_proj = p;
|
||||
retval = http_op.init_post(scheduler_url, request_file, reply_file);
|
||||
retval = http_op.init_post(p, scheduler_url, request_file, reply_file);
|
||||
if (retval) {
|
||||
if (log_flags.sched_ops) {
|
||||
msg_printf(p, MSG_INFO,
|
||||
|
@ -303,7 +303,7 @@ int SCHEDULER_OP::init_master_fetch(PROJECT* p) {
|
|||
msg_printf(p, MSG_INFO, "[sched_op] Fetching master file");
|
||||
}
|
||||
cur_proj = p;
|
||||
retval = http_op.init_get(p->master_url, master_filename, true);
|
||||
retval = http_op.init_get(p, p->master_url, master_filename, true);
|
||||
if (retval) {
|
||||
if (log_flags.sched_ops) {
|
||||
msg_printf(p, MSG_INFO,
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
// client_state.xml
|
||||
// global_prefs.xml
|
||||
// global_prefs_override.xml
|
||||
// [--config_prefix dir/]
|
||||
// Prefix of cc_config.xml
|
||||
// [--outfile_prefix X]
|
||||
// Prefix of output filenames; default is blank.
|
||||
// Output files are:
|
||||
|
@ -73,7 +71,6 @@
|
|||
#define SCHED_RETRY_DELAY_MAX (60*60*4) // 4 hours
|
||||
|
||||
const char* infile_prefix = "./";
|
||||
const char* config_prefix = "./";
|
||||
const char* outfile_prefix = "./";
|
||||
|
||||
#define TIMELINE_FNAME "timeline.html"
|
||||
|
@ -115,7 +112,6 @@ int njobs;
|
|||
void usage(char* prog) {
|
||||
fprintf(stderr, "usage: %s\n"
|
||||
"[--infile_prefix F]\n"
|
||||
"[--config_prefix F]\n"
|
||||
"[--outfile_prefix F]\n"
|
||||
"[--existing_jobs_only]\n"
|
||||
"[--duration X]\n"
|
||||
|
@ -1314,11 +1310,24 @@ void cull_projects() {
|
|||
void do_client_simulation() {
|
||||
char buf[256], buf2[256];
|
||||
int retval;
|
||||
FILE* f;
|
||||
|
||||
sprintf(buf, "%s%s", config_prefix, CONFIG_FILE);
|
||||
sprintf(buf, "%s%s", infile_prefix, CONFIG_FILE);
|
||||
config.defaults();
|
||||
read_config_file(true, buf);
|
||||
|
||||
log_flags.init();
|
||||
sprintf(buf, "%s%s", outfile_prefix, "log_flags.xml");
|
||||
f = fopen(buf, "r");
|
||||
if (f) {
|
||||
MIOFILE mf;
|
||||
mf.init_file(f);
|
||||
XML_PARSER xp(&mf);
|
||||
xp.get_tag(); // skip open tag
|
||||
log_flags.parse(xp);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
gstate.add_platform("client simulator");
|
||||
sprintf(buf, "%s%s", infile_prefix, STATE_FILE_NAME);
|
||||
if (!boinc_file_exists(buf)) {
|
||||
|
@ -1378,7 +1387,7 @@ void do_client_simulation() {
|
|||
sim_results.compute_figures_of_merit();
|
||||
|
||||
sprintf(buf, "%s%s", outfile_prefix, RESULTS_DAT_FNAME);
|
||||
FILE* f = fopen(buf, "w");
|
||||
f = fopen(buf, "w");
|
||||
sim_results.print(f);
|
||||
fclose(f);
|
||||
sprintf(buf, "%s%s", outfile_prefix, RESULTS_TXT_FNAME);
|
||||
|
@ -1422,8 +1431,6 @@ int main(int argc, char** argv) {
|
|||
char* opt = argv[i++];
|
||||
if (!strcmp(opt, "--infile_prefix")) {
|
||||
infile_prefix = argv[i++];
|
||||
} else if (!strcmp(opt, "--config_prefix")) {
|
||||
config_prefix = argv[i++];
|
||||
} else if (!strcmp(opt, "--outfile_prefix")) {
|
||||
outfile_prefix = argv[i++];
|
||||
} else if (!strcmp(opt, "--existing_jobs_only")) {
|
||||
|
|
|
@ -625,7 +625,7 @@ PROJECT* WORK_FETCH::choose_project() {
|
|||
}
|
||||
for (unsigned int i=0; i<gstate.results.size(); i++) {
|
||||
RESULT* rp = gstate.results[i];
|
||||
PROJECT* p = rp->project;
|
||||
p = rp->project;
|
||||
p->sched_priority -= CURRENT_QUEUE_WEIGHT * rp->estimated_flops_remaining()/total_flops_remaining;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class RESULT {
|
|||
|
||||
// do a simulation
|
||||
//
|
||||
function do_sim($in, $out, $policy, $config_prefix=null) {
|
||||
function do_sim($in, $out, $policy) {
|
||||
$args = "";
|
||||
if ($policy->existing_jobs_only) $args .= " --existing_jobs_only";
|
||||
if ($policy->use_hyst_fetch) $args .= " --use_hyst_fetch";
|
||||
|
@ -84,8 +84,7 @@ function do_sim($in, $out, $policy, $config_prefix=null) {
|
|||
$args .= " --delta $policy->delta";
|
||||
$args .= " --rec_half_life $policy->rec_half_life";
|
||||
|
||||
$c = $config_prefix?"--config_prefix $config_prefix/":"";
|
||||
$cmd = "./sim $args --infile_prefix $in/ --outfile_prefix $out/ $c";
|
||||
$cmd = "./sim $args --infile_prefix $in/ --outfile_prefix $out/";
|
||||
//echo "cmd: $cmd\n"; die;
|
||||
system($cmd, $ret);
|
||||
if ($ret) {
|
||||
|
|
|
@ -116,7 +116,7 @@ function show_scenarios() {
|
|||
<li>Whether to use Hysteresis-based work fetch
|
||||
(the proposed policy for the 6.14 client)
|
||||
</ul>
|
||||
<li> <b>cc_config.xml</b>: client configuration (optional).
|
||||
<li> log flags
|
||||
</ul>
|
||||
The outputs of a simulation include
|
||||
<ul>
|
||||
|
@ -194,6 +194,7 @@ function create_scenario_form() {
|
|||
row2("* client_state.xml", "<input name=client_state type=file>");
|
||||
row2("global_prefs.xml", "<input name=global_prefs type=file>");
|
||||
row2("global_prefs_override.xml", "<input name=global_prefs_override type=file>");
|
||||
row2("cc_config.xml", "<input name=cc_config type=file>");
|
||||
row2("* Description", "<textarea name=description cols=40></textarea>");
|
||||
row2("", "<input type=submit value=OK>");
|
||||
echo "
|
||||
|
@ -250,6 +251,10 @@ function create_scenario() {
|
|||
if (is_uploaded_file($gpo)) {
|
||||
move_uploaded_file($gpo, "$d/global_prefs_override.xml");
|
||||
}
|
||||
$ccc = $_FILES['cc_config']['tmp_name'];
|
||||
if (is_uploaded_file($ccc)) {
|
||||
move_uploaded_file($ccc, "$d/cc_config.xml");
|
||||
}
|
||||
file_put_contents("$d/userid", "$user->id");
|
||||
file_put_contents("$d/description", $desc);
|
||||
mkdir("$d/simulations");
|
||||
|
@ -330,6 +335,14 @@ function show_scenario() {
|
|||
page_tail();
|
||||
}
|
||||
|
||||
function log_flag_boxes() {
|
||||
return "
|
||||
<input type=checkbox name=cpu_sched_debug> CPU scheduling debug
|
||||
<br> <input type=checkbox name=rr_simulation> Round-robin simulation info
|
||||
<br> <input type=checkbox name=work_fetch_debug> Work fetch debug
|
||||
";
|
||||
}
|
||||
|
||||
function simulation_form_short() {
|
||||
$scen = get_str("scen");
|
||||
page_head("Do simulation");
|
||||
|
@ -346,7 +359,7 @@ function simulation_form_short() {
|
|||
";
|
||||
row2("Duration", "<input name=duration value=86400> seconds");
|
||||
row2("Time step", "<input name=delta value=60> seconds");
|
||||
row2("cc_config.xml", "<input type=file name=cc_config>");
|
||||
row2("Log flags", log_flag_boxes());
|
||||
row2("", "<input type=submit value=OK>");
|
||||
echo "</form>\n";
|
||||
end_table();
|
||||
|
@ -419,12 +432,21 @@ function simulation_action() {
|
|||
$policy->cpu_sched_rr_only = post_str("cpu_sched_rr_only", true);
|
||||
$policy->server_uses_workload = post_str("server_uses_workload", true);
|
||||
file_put_contents("$sim_path/userid", "$user->id");
|
||||
$cc = $_FILES['cc_config']['tmp_name'];
|
||||
if (is_uploaded_file($cc)) {
|
||||
move_uploaded_file($cc, "$sim_path/cc_config.xml");
|
||||
}
|
||||
|
||||
do_sim("scenarios/$scen", $sim_path, $policy, $sim_path);
|
||||
$x = "<log_flags>\n";
|
||||
if (post_str("cpu_sched_debug", true)) {
|
||||
$x .= "<cpu_sched_debug/>\n";
|
||||
}
|
||||
if (post_str("rr_simulation", true)) {
|
||||
$x .= "<rr_simulation/>\n";
|
||||
}
|
||||
if (post_str("work_fetch_debug", true)) {
|
||||
$x .= "<work_fetch_debug/>\n";
|
||||
}
|
||||
$x .= "</log_flags>\n";
|
||||
file_put_contents("$sim_path/log_flags.xml", $x);
|
||||
|
||||
do_sim("scenarios/$scen", $sim_path, $policy);
|
||||
header("Location: sim_web.php?action=show_simulation&scen=$scen&sim=$sim_name");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue