svn path=/trunk/boinc/; revision=388
This commit is contained in:
David Anderson 2002-08-28 21:50:51 +00:00
parent ff7205e11b
commit a095225083
30 changed files with 430 additions and 237 deletions

View File

@ -188,8 +188,8 @@ double boinc_cpu_time() {
static DWORD last_count = 0;
if (first) {
last_count = GetTickCount();
first = true;
last_count = GetTickCount();
first = true;
}
DWORD cur = GetTickCount();
double x = (cur - last_count)/1000.;
@ -355,46 +355,20 @@ int write_fd_init_file(FILE* f, char *file_name, int fdesc, int input_file ) {
//
int parse_fd_init_file(FILE* f) {
char buf[256],filename[256];
int filedesc,fd,retval;
int filedesc;
while (fgets(buf, 256, f)) {
if (parse_str(buf, "<fdesc_dup_infile>", filename)) {
if (fgets(buf, 256, f)) {
if (parse_int(buf, "<fdesc_dup_innum>", filedesc)) {
#if 1
freopen(filename, "r", stdin);
#else
fd = open(filename, O_RDONLY);
if (fd < 0) return ERR_OPEN;
if (fd != filedesc) {
retval = dup2(fd, filedesc);
if (retval < 0) {
fprintf(stderr, "dup2 %d %d returned %d\n", fd, filedesc, retval);
return ERR_DUP2;
}
close(fd);
}
#endif
fprintf(stderr, "opened input file %s\n", filename);
freopen(filename, "r", stdin);
fprintf(stderr, "opened input file %s\n", filename);
}
}
} else if (parse_str(buf, "<fdesc_dup_outfile>", filename)) {
if (fgets(buf, 256, f)) {
if (parse_int(buf, "<fdesc_dup_outnum>", filedesc)) {
#if 1
freopen(filename, "w", stdout);
#else
fd = open(filename, O_WRONLY|O_CREAT, 0660);
if (fd < 0) return ERR_OPEN;
if (fd != filedesc) {
retval = dup2(fd, filedesc);
if (retval < 0) {
fprintf(stderr, "dup2 %d %d returned %d\n", fd, filedesc, retval);
return ERR_DUP2;
}
close(fd);
}
#endif
fprintf(stderr, "opened output file %s\n", filename);
freopen(filename, "w", stdout);
fprintf(stderr, "opened output file %s\n", filename);
}
}
} else fprintf(stderr, "parse_fd_init_file: unrecognized %s", buf);

View File

@ -1758,3 +1758,50 @@ David August 26, 2002
init.inc
master.html
test_uc.php
David August 28, 2002
- added DB fields to keep track of credit for hosts and result
- added utility program "grant_credit" to grant credit for a result
- removed some extraneous printfs
- file upload handler error messages have user name
- added a "poll_debug" flag; turn this on in case of infinite
poll loop, to see what's causing the problem
- added a "libboinc.a" target to lib/ Makefile.
We might want to consider using a random library
instead of referring to explicit .o files everywhere
api/
boinc_api.h
client/
Makefile.in
app.C
client_state.C
cs_apps.C
cs_files.C
cs_scheduler.C
file_xfer.C
log_flags.C,h
net_xfer.C
pers_file_xfer.C
db/
db.h
db_mysql.C
schema.sql
html_ops/
db.inc
db.php
html_user/
index.html
lib/
Makefile.in
sched/
feeder.C
file_upload_handler.C
handle_request.C
test/
master.html
test_uc.php
tools/
Makefile.in
backend_lib.C,h
grant_credit.C (new)

View File

@ -35,7 +35,6 @@ OBJS = \
cs_scheduler.o \
file_names.o \
file_xfer.o \
filesys.o \
hostinfo.o \
hostinfo_unix.o \
http.o \
@ -47,21 +46,22 @@ OBJS = \
scheduler_op.o \
speed_stats.o \
time_stats.o \
util.o \
../lib/filesys.o \
../lib/parse.o \
../lib/md5_file.o \
../lib/md5.o \
../lib/crypt.o \
../lib/util.o \
../RSAEuro/source/rsaeuro.a \
../api/boinc_api.o
TEST_NET_XFER_OBJS = \
filesys.o \
http.o \
log_flags.o \
../lib/parse.o \
net_xfer.o \
util.o
../lib/filesys.o \
../lib/parse.o \
../lib/util.o
TEST_HTTP_OBJS = $(TEST_NET_XFER_OBJS)

View File

@ -421,7 +421,6 @@ bool ACTIVE_TASK_SET::poll() {
}
}
if (log_flags.task_debug && found) printf("ACTIVE_TASK_SET::poll\n");
return found;
#endif
@ -472,7 +471,6 @@ bool ACTIVE_TASK_SET::poll() {
clean_out_dir(atp->slot_dir);
if (log_flags.task_debug) printf("ACTIVE_TASK_SET::poll\n");
return true;
}
@ -613,9 +611,9 @@ bool ACTIVE_TASK::check_app_status_files() {
retval = file_delete(path);
if (retval) {
fprintf(stderr,
"ACTIVE_TASK.check_app_status_files: could not delete %s: %d\n",
path, retval
);
"ACTIVE_TASK.check_app_status_files: could not delete %s: %d\n",
path, retval
);
}
}
@ -630,9 +628,9 @@ bool ACTIVE_TASK::check_app_status_files() {
retval = file_delete(path);
if (retval) {
fprintf(stderr,
"ACTIVE_TASK.check_app_status_files: could not delete %s: %d\n",
path, retval
);
"ACTIVE_TASK.check_app_status_files: could not delete %s: %d\n",
path, retval
);
}
}
return found;
@ -650,7 +648,6 @@ bool ACTIVE_TASK_SET::poll_time() {
updated |= atp->check_app_status_files();
}
if (log_flags.task_debug && updated) printf("ACTIVE_TASK_SET::poll_time\n");
return updated;
}

View File

@ -183,6 +183,12 @@ int CLIENT_STATE::check_suspend_activities() {
return 0;
}
static void print_log(char* p) {
if (log_flags.poll_debug) {
printf(p);
}
}
// do_something is where all the action happens. This is part of the
// finite state machine abstraction of the client. Each of the key
// elements of the client is given a chance to perform work here.
@ -195,32 +201,45 @@ bool CLIENT_STATE::do_something() {
check_suspend_activities();
if (!activities_suspended) {
// Call these functions in bottom to top order in
// respect to the FSMs hierarchy
// Call these functions in bottom to top order with
// respect to the FSM hierarchy
net_xfers->poll(999999, nbytes);
if (nbytes) { printf("net_xfers\n"); action = true; }
if (nbytes) { action=true; print_log("net_xfers\n"); }
x = http_ops->poll();
if (x) {action=true; printf("http_ops::poll\n"); }
if (x) {action=true; print_log("http_ops::poll\n"); }
x = file_xfers->poll();
if (x) {action=true; printf("file_xfers::poll\n"); }
if (x) {action=true; print_log("file_xfers::poll\n"); }
x = active_tasks.poll();
if (x) {action=true; printf("active_tasks::poll\n"); }
if (x) {action=true; print_log("active_tasks::poll\n"); }
x = active_tasks.poll_time();
if (x) {action=true; printf("active_tasks::poll_time\n"); }
if (x) {action=true; print_log("active_tasks::poll_time\n"); }
x = scheduler_rpc_poll();
if (x) {action=true; printf("scheduler_rpc_poll\n"); }
if (x) {action=true; print_log("scheduler_rpc_poll\n"); }
x = start_apps();
if (x) {action=true; printf("start_apps\n"); }
if (x) {action=true; print_log("start_apps\n"); }
x = pers_xfers->poll();
if (x) {action=true; printf("pers_xfers->poll\n"); }
if (x) {action=true; print_log("pers_xfers->poll\n"); }
x = handle_running_apps();
if (x) {action=true; printf("handle_running_apps\n"); }
if (x) {action=true; print_log("handle_running_apps\n"); }
x = handle_pers_file_xfers();
if (x) {action=true; printf("handle_pers_file_xfers\n"); }
if (x) {action=true; print_log("handle_pers_file_xfers\n"); }
x = garbage_collect();
if (x) {action=true; printf("garbage_collect\n"); }
if (x) {action=true; print_log("garbage_collect\n"); }
x = update_results();
if (x) {action=true; printf("update_results\n"); }
if (x) {action=true; print_log("update_results\n"); }
write_state_file_if_needed();
}
if (!action) time_stats.update(true, !activities_suspended);

View File

@ -119,7 +119,6 @@ bool CLIENT_STATE::handle_running_apps() {
action = true;
}
}
if (log_flags.task_debug && action) printf("CS::handle_running_apps\n");
return action;
}
@ -154,10 +153,10 @@ bool CLIENT_STATE::start_apps() {
int open_slot;
for (i=0; i<results.size(); i++) {
// If all the app slots are already used, we can't start
// a new app
// If all the app slots are already used, we can't start a new app
//
open_slot = active_tasks.get_free_slot(nslots);
if (open_slot < 0) {
if (log_flags.task_debug) {
printf("start_apps(): all slots full\n");
@ -165,10 +164,12 @@ bool CLIENT_STATE::start_apps() {
return false;
}
rp = results[i];
// Start the application to compute a result if the result
// isn't done yet, the application isn't currently computing
// the result, and all the input files for the result are
// locally available
// Start the application to compute a result if:
// 1) the result isn't done yet;
// 2) the application isn't currently computing the result;
// 3) all the input files for the result are locally available
//
if (rp->state == RESULT_FILES_DOWNLOADED && !rp->is_active ) {
if (log_flags.task_debug) {
printf("starting application for result %s\n", rp->name);
@ -180,10 +181,9 @@ bool CLIENT_STATE::start_apps() {
active_tasks.insert(atp);
action = true;
set_client_state_dirty("start_apps");
app_started = time(0);
app_started = time(0);
}
}
if (log_flags.task_debug && action) printf("CS::start_apps\n");
return action;
}

View File

@ -94,21 +94,21 @@ bool CLIENT_STATE::handle_pers_file_xfers() {
for (i=0; i<file_infos.size(); i++) {
fip = file_infos[i];
pfx = fip->pers_file_xfer;
if (pfx) continue;
if (pfx) continue;
if (!fip->generated_locally && fip->status == FILE_NOT_PRESENT) {
// Set up the persistent file transfer object.
// This will start the download when there is available bandwidth
// This will start the download when there is available bandwidth
//
pfx = new PERS_FILE_XFER;
pfx->init(fip, false);
fip->pers_file_xfer = pfx;
pers_xfers->insert( fip->pers_file_xfer );
pers_xfers->insert( fip->pers_file_xfer );
action = true;
} else if (fip->upload_when_present && fip->status == FILE_PRESENT && !fip->uploaded) {
// Set up the persistent file transfer object.
// This will start the upload when there is available bandwidth
// This will start the upload when there is available bandwidth
//
pfx = new PERS_FILE_XFER;
pfx->init(fip, true);
@ -123,7 +123,7 @@ bool CLIENT_STATE::handle_pers_file_xfers() {
// If the transfer finished, remove the PERS_FILE_XFER object
// from the set and delete it
//
//
if (pfx->xfer_done) {
pfx->fip->pers_file_xfer = NULL;
pers_xfers->remove(pfx);
@ -132,6 +132,5 @@ bool CLIENT_STATE::handle_pers_file_xfers() {
}
}
if (log_flags.file_xfer_debug && action) printf("CS::handle_pers_file_xfers\n");
return action;
}

View File

@ -125,9 +125,10 @@ PROJECT* CLIENT_STATE::next_project(PROJECT* old) {
return pbest;
}
// Compute the "resource debt" of each project. This is used
// to determine what project we will focus on next, based on
// the user specified resource share
// Compute the "resource debt" of each project.
// This is used to determine what project we will focus on next,
// based on the user-specified resource share.
// TODO: this counts only CPU time. Should reflect disk/network usage too.
//
void CLIENT_STATE::compute_resource_debts() {
unsigned int i, j;
@ -278,7 +279,6 @@ bool CLIENT_STATE::scheduler_rpc_poll() {
}
break;
}
if (log_flags.sched_op_debug && action) printf("CS::scheduler_rpc_poll\n");
return action;
}
@ -322,6 +322,11 @@ void CLIENT_STATE::handle_scheduler_reply(
if (strlen(sr.project_name)) {
strcpy(project->project_name, sr.project_name);
}
if (strlen(sr.user_name)) {
strcpy(project->user_name, sr.user_name);
}
project->total_credit = sr.total_credit;
project->expavg_credit = sr.expavg_credit;
if (strlen(sr.message)) {
show_message(sr.message, sr.message_priority);
}

View File

@ -221,8 +221,5 @@ bool FILE_XFER_SET::poll() {
}
}
}
if (log_flags.file_xfer_debug) {
if (action) printf("FILE_XFER_SET poll true\n");
}
return action;
}

View File

@ -83,6 +83,10 @@ int LOG_FLAGS::parse(FILE* in) {
net_xfer_debug = true;
continue;
}
else if (match_tag(buf, "<poll_debug/>")) {
poll_debug = true;
continue;
}
else fprintf(stderr, "LOG_FLAGS::parse: unrecognized: %s\n", buf);
}
return ERR_XML_PARSE;

View File

@ -42,6 +42,7 @@ public:
bool http_debug;
bool time_debug; // print message on sleep
bool net_xfer_debug;
bool poll_debug; // show what polls are responding
LOG_FLAGS();
int parse(FILE*);

View File

@ -189,9 +189,6 @@ int NET_XFER_SET::poll(int max_bytes, int& bytes_transferred) {
bytes_transferred += n;
if (max_bytes < 0) break;
}
if (log_flags.net_xfer_debug && bytes_transferred) {
printf("NET_XFER_SET::poll bytes_transferred %d\n", bytes_transferred);
}
return 0;
}

View File

@ -120,8 +120,10 @@ bool PERS_FILE_XFER::poll(unsigned int now) {
if (fxp->file_xfer_done) {
if (log_flags.file_xfer) {
printf( "file transfer done for %s; retval %d\n",
fip->get_url(), fxp->file_xfer_retval );
printf(
"file transfer done for %s; retval %d\n",
fip->get_url(), fxp->file_xfer_retval
);
}
if (fxp->file_xfer_retval == 0) {
// The transfer finished with no errors.
@ -260,7 +262,6 @@ bool PERS_FILE_XFER_SET::poll() {
if (action) gstate.set_client_state_dirty("pers_file_xfer_set poll");
if (log_flags.file_xfer_debug && action) printf("PERS_FILE_XFER_SET::poll\n");
return action;
}

View File

@ -335,7 +335,6 @@ bool SCHEDULER_OP::poll() {
default:
break;
}
if (log_flags.sched_op_debug && action) printf("SCHEDULER_OP::poll\n");
return action;
}
@ -378,6 +377,12 @@ int SCHEDULER_REPLY::parse(FILE* in) {
return 0;
} else if (parse_str(buf, "<project_name>", project_name)) {
continue;
} else if (parse_str(buf, "<user_name>", user_name)) {
continue;
} else if (parse_double(buf, "<total_credit>", total_credit)) {
continue;
} else if (parse_double(buf, "<expavg_credit>", expavg_credit)) {
continue;
} else if (parse_int(buf, "<hostid>", hostid)) {
continue;
} else if (parse_int(buf, "<request_delay>", request_delay)) {

View File

@ -148,6 +148,9 @@ struct HOST {
int userid; // ID of user running this host
int rpc_seqno; // last seqno received from client
unsigned int rpc_time; // time of last scheduler RPC
double total_credit;
double expavg_credit;
double expavg_time;
// all remaining items are assigned by the client
int timezone;
@ -236,6 +239,7 @@ struct RESULT {
int batch;
int project_state;
bool validated;
double granted_credit;
// the following not used in the DB
char wu_name[256];
@ -290,6 +294,7 @@ extern int db_workunit_lookup_name(WORKUNIT&);
extern int db_workunit_enum_dynamic_to_send(WORKUNIT&, int);
extern int db_result_new(RESULT& p);
extern int db_result(int id, RESULT&);
extern int db_result_update(RESULT& p);
extern int db_result_lookup_name(RESULT& p);
extern int db_result_enum_to_send(RESULT&, int);

View File

@ -162,6 +162,7 @@ void struct_to_str(void* vp, char* q, int type) {
sprintf(q,
"id=%d, create_time=%d, userid=%d, "
"rpc_seqno=%d, rpc_time=%d, "
"total_credit=%f, expavg_credit=%f, expavg_time=%f, "
"timezone=%d, domain_name='%s', serialnum='%s', "
"last_ip_addr='%s', nsame_ip_addr=%d, "
"on_frac=%f, connected_frac=%f, active_frac=%f, "
@ -173,6 +174,7 @@ void struct_to_str(void* vp, char* q, int type) {
"n_bwup=%f, n_bwdown=%f",
hp->id, hp->create_time, hp->userid,
hp->rpc_seqno, hp->rpc_time,
hp->total_credit, hp->expavg_credit, hp->expavg_time,
hp->timezone, hp->domain_name, hp->serialnum,
hp->last_ip_addr, hp->nsame_ip_addr,
hp->on_frac, hp->connected_frac, hp->active_frac,
@ -208,12 +210,12 @@ void struct_to_str(void* vp, char* q, int type) {
"hostid=%d, report_deadline=%d, sent_time=%d, received_time=%d, "
"name='%s', exit_status=%d, cpu_time=%f, "
"xml_doc_in='%s', xml_doc_out='%s', stderr_out='%s', "
"batch=%d, project_state=%d, validated=%d",
"batch=%d, project_state=%d, validated=%d, granted_credit=%f",
rp->id, rp->create_time, rp->workunitid, rp->state,
rp->hostid, rp->report_deadline, rp->sent_time, rp->received_time,
rp->name, rp->exit_status, rp->cpu_time,
rp->xml_doc_in, rp->xml_doc_out, rp->stderr_out,
rp->batch, rp->project_state, rp->validated
rp->batch, rp->project_state, rp->validated, rp->granted_credit
);
break;
}
@ -307,6 +309,9 @@ void row_to_struct(MYSQL_ROW& r, void* vp, int type) {
hp->userid = atoi(r[i++]);
hp->rpc_seqno = atoi(r[i++]);
hp->rpc_time = atoi(r[i++]);
hp->total_credit = atof(r[i++]);
hp->expavg_credit = atof(r[i++]);
hp->expavg_time = atof(r[i++]);
hp->timezone = atoi(r[i++]);
strcpy(hp->domain_name, r[i++]);
strcpy(hp->serialnum, r[i++]);
@ -373,6 +378,7 @@ void row_to_struct(MYSQL_ROW& r, void* vp, int type) {
rp->batch = atoi(r[i++]);
rp->project_state = atoi(r[i++]);
rp->validated = atoi(r[i++]);
rp->granted_credit = atof(r[i++]);
break;
}
}
@ -570,6 +576,10 @@ int db_result_new(RESULT& p) {
return db_new(&p, TYPE_RESULT);
}
int db_result(int i, RESULT& p) {
return db_lookup_id(i, &p, TYPE_RESULT);
}
int db_result_update(RESULT& p) {
return db_update(&p, TYPE_RESULT);
}

View File

@ -74,6 +74,9 @@ create table host (
userid integer not null,
rpc_seqno integer not null,
rpc_time integer not null,
total_credit float not null,
expavg_credit float not null,
expavg_time float not null,
timezone integer not null,
domain_name varchar(254),
@ -148,5 +151,6 @@ create table result (
batch integer not null,
project_state integer not null,
validated smallint not null,
granted_credit float not null,
primary key (id)
);

View File

@ -74,42 +74,41 @@ function show_app_version($app_version,$show_xml_docs) {
}
function show_host($host) {
start_table();
echo TABLE2."\n";
echo "<tr>";
echo "<p>";
echo "<tr>".TD2.LG_FONT."<b>Host Information:</b></font></td></tr>\n";
row("<b>IP address: </b>", "$host->last_ip_addr<br>(same the last $host->nsame_ip_addr times)");
row("<b>Domain name: <b>", $host->domain_name);
row("Created", time_str($host->create_time));
row("Total credit", $host->total_credit);
row("Average credit", $host->expavg_credit);
row("Average update time", time_str($host->expavg_time));
row("IP address", "$host->last_ip_addr<br>(same the last $host->nsame_ip_addr times)");
row("Domain name", $host->domain_name);
$x = $host->timezone/3600;
row("<b>Time zone: </b>", "UTC - $x hours");
row("<b>Created: </b>", time_str($host->create_time));
row("<b>CPU: </b>", "$host->p_vendor $host->p_model");
row("<b>Number of CPUs: </b>", $host->p_ncpus);
row("<b>Operating System: </b>", "$host->os_name $host->os_version");
row("Time zone", "UTC - $x hours");
row("CPU", "$host->p_vendor $host->p_model");
row("Number of CPUs", $host->p_ncpus);
row("Operating System", "$host->os_name $host->os_version");
$x = $host->m_nbytes/(1024*1024);
$y = round($x, 2);
row("<b>Memory: </b>", "$y MB");
row("Memory", "$y MB");
$x = $host->m_cache/1024;
$y = round($x, 2);
row("<b>Cache: </b>", "$y KB");
row("Cache", "$y KB");
$x = $host->m_swap/(1024*1024);
$y = round($x, 2);
row("<b>Swap Space: </b>", "$y MB");
row("Swap Space", "$y MB");
$x = $host->d_total/(1024*1024*1024);
$y = round($x, 2);
row("<b>Total Disk Space: </b>", "$y GB");
row("Total Disk Space", "$y GB");
$x = $host->d_free/(1024*1024*1024);
$y = round($x, 2);
row("<b>Free Disk Space: </b>", "$y GB");
row("<b>Avg network bandwidth:<br>(upstream) </b>", "$host->n_bwup bytes/sec");
row("<b>Avg network bandwidth:<br>(downstream) </b>", "$host->n_bwdown bytes/sec");
row("<b>Number of times client has contacted server: </b>", $host->rpc_seqno);
row("<b>Last time contacted server: </b>", time_str($host->rpc_time));
row("<b>% of time client on: </b>", 100*$host->on_frac." %");
row("<b>% of time host connected: </b>", 100*$host->connected_frac." %");
row("<b>% of time user active: </b>", 100*$host->active_frac." %");
row("","<a href=result.php?host_id=$host->id>Results Assigned to Host</a>");
row("Free Disk Space", "$y GB");
row("Avg network bandwidth (upstream)", "$host->n_bwup bytes/sec");
row("Avg network bandwidth (downstream)", "$host->n_bwdown bytes/sec");
row("Number of RPCs", $host->rpc_seqno);
row("Last RPC", time_str($host->rpc_time));
row("% of time client on", 100*$host->on_frac." %");
row("% of time host connected", 100*$host->connected_frac." %");
row("% of time user active", 100*$host->active_frac." %");
end_table();
}
@ -171,15 +170,16 @@ function show_result($result,$show_xml_docs,$show_stderr,$show_times) {
function show_user($user) {
start_table();
row("Created", time_str($user->create_time));
row("Total Credit", $user->total_credit);
row("Recent Averaged Credit:", $user->expavg_credit);
row("Name", $user->name);
row("Email Address", $user->email_addr);
row("Country", $user->country);
row("Postal Code", $user->postal_code);
row("Team", ($user->teamid == 0 ? "None" : "<a href=team.php?id=$user->teamid>" . team_name_by_id($user->teamid) . "</a>" ));
row("", "<a href=host.php?user_id=$user->id>User Hosts</a>");
row("created", time_str($user->create_time));
row("total credit", $user->total_credit);
row("recent averaged credit:", $user->expavg_credit);
row("name", $user->name);
row("email address", $user->email_addr);
row("country", $user->country);
row("postal code", $user->postal_code);
row("total credit", $user->total_credit);
row("average credit", $user->expavg_credit);
row("last average time", time_str($user->expavg_time));
end_table();
}

View File

@ -4,40 +4,84 @@
db_init();
echo "<hr>Platforms";
$result = mysql_query("select * from platform");
while ($platform = mysql_fetch_object($result)) {
show_platform($platform);
function show_platform_table() {
echo "<hr>Platforms";
$result = mysql_query("select * from platform");
while ($platform = mysql_fetch_object($result)) {
show_platform($platform);
}
}
echo "<hr>Apps";
$result = mysql_query("select * from app");
while ($app = mysql_fetch_object($result)) {
show_app($app);
function show_app_table() {
echo "<hr>Apps";
$result = mysql_query("select * from app");
while ($app = mysql_fetch_object($result)) {
show_app($app);
}
}
echo "<hr>App versions";
$result = mysql_query("select * from app_version");
while ($app_version = mysql_fetch_object($result)) {
show_app_version($app_version);
function show_app_version_table() {
echo "<hr>App versions";
$result = mysql_query("select * from app_version");
while ($app_version = mysql_fetch_object($result)) {
show_app_version($app_version);
}
}
echo "<hr>Hosts";
$result = mysql_query("select * from host");
while ($host = mysql_fetch_object($result)) {
show_host($host);
function show_host_table() {
echo "<hr>Hosts";
$result = mysql_query("select * from host");
while ($host = mysql_fetch_object($result)) {
show_host($host);
}
}
echo "<hr>Workunits";
$result = mysql_query("select * from workunit");
while ($workunit = mysql_fetch_object($result)) {
show_workunit($workunit);
function show_workunit_table() {
echo "<hr>Workunits";
$result = mysql_query("select * from workunit");
while ($workunit = mysql_fetch_object($result)) {
show_workunit($workunit);
}
}
echo "<hr>Results";
$result = mysql_query("select * from result");
while ($res = mysql_fetch_object($result)) {
show_result($res);
function show_result_table() {
echo "<hr>Results";
$result = mysql_query("select * from result");
while ($res = mysql_fetch_object($result)) {
show_result($res);
}
}
echo "<hr>Users";
$result = mysql_query("select * from user");
while ($user = mysql_fetch_object($result)) {
show_user($user);
function show_user_table() {
echo "<hr>Users";
$result = mysql_query("select * from user");
while ($user = mysql_fetch_object($result)) {
show_user($user);
}
}
parse_str(getenv("QUERY_STRING"));
if ($show=="platform") {
show_platform_table();
} else if ($show=="app") {
show_app_table();
} else if ($show=="app_version") {
show_app_version_table();
} else if ($show=="host") {
show_host_table();
} else if ($show=="workunit") {
show_workunit_table();
} else if ($show=="result") {
show_result_table();
} else if ($show=="user") {
show_user_table();
} else {
echo "<br><a href=db.php?show=platform>Platform</a>";
echo "<br><a href=db.php?show=app>App</a>";
echo "<br><a href=db.php?show=app_version>App Version</a>";
echo "<br><a href=db.php?show=host>Host</a>";
echo "<br><a href=db.php?show=workunit>Workunit</a>";
echo "<br><a href=db.php?show=result>Result</a>";
echo "<br><a href=db.php?show=user>User</a>";
}
?>

View File

@ -1,28 +1,14 @@
<head>
<title>BOINC - Berkeley Open Infrastructure for Network Computing</title>
</head>
<body text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000>
<h1>BOINC - Berkeley Open Infrastructure for Network Computing</h1>
<title>BOINC Test Project</title>
<h1>BOINC Test Project</h1>
<p>
BOINC is a software platform for public-participation
distributed computing projects.
Users are allowed to simultaneously participate in multiple projects
and to choose how to allocate their resources
for each project.
This is a placeholder for the main page of the project's web site.
<p>
First download the core client by clicking on the below link.
Then create a BOINC account,
setting your preferences to specify how much your computer should
be working on each project.
You may view your user page to see how much credit
you have accumulated as your participation proceeds.
In addition, you may modify your preferences through your user page
at anytime to reallocate your resources
among the different projects you may be involved in.
To participate in this project,
create an account, then download the BOINC client.
<ul>
<li><a href=download.php>Download core client</a></li>
<li><a href=login.php>Log in or create account</a></li>
<li><a href=download.php>Download BOINC client</a></li>
<li><a href=login.php>Log in or create account on this project</a></li>
<li><a href=home.php>User page</a></li>
<li><a href=team.php>Teams</a></li>
</ul>

View File

@ -38,6 +38,9 @@ all: $(PROGS) $(OBJS) $(MD5_OBJS) $(CRYPT_OBJS)
.c.o:
$(CC) -c -o $*.o $<
libboinc.a: $(OBJS) $(MD5_OBJS)
ar cr libboinc.a $(OBJS) $(MD5_OBJS); ranlib libboinc.a
md5_test: md5_test.o $(MD5_OBJS)
$(CC) md5_test.o $(MD5_OBJS) -o md5_test

View File

@ -73,6 +73,7 @@ int check_trigger(SCHED_SHMEM* ssp) {
ssp->scan_tables();
} else {
fprintf(stderr, "feeder: unknown command in trigger file: %s\n", buf);
exit(0);
}
unlink(TRIGGER_FILENAME);
return 0;

View File

@ -78,11 +78,13 @@ int FILE_INFO::parse(FILE* in) {
int print_status(int status, char* message) {
printf("Content-type: text/plain\n\n<status>%d</status>\n", status);
if (message) printf("<error>%s</error>\n", message);
fprintf(stderr,
"file_upload_handler (%s): status %d: %s>\n",
BOINC_USER, status, message
);
if (message) {
printf("<error>%s</error>\n", message);
fprintf(stderr,
"file_upload_handler (%s): status %d: %s>\n",
BOINC_USER, status, message
);
}
return 0;
}
@ -145,12 +147,12 @@ int handle_request(FILE* in, R_RSA_PUBLIC_KEY& key) {
if (match_tag(buf, "<file_info>")) {
retval = file_info.parse(in);
if (retval) {
fprintf(stderr,
"file_upload_handler (%s): FILE_INFO.parse\n",
BOINC_USER
);
return retval;
}
fprintf(stderr,
"file_upload_handler (%s): FILE_INFO.parse\n",
BOINC_USER
);
return retval;
}
retval = verify_string(
file_info.signed_xml, file_info.xml_signature, key, is_valid
);
@ -163,14 +165,23 @@ int handle_request(FILE* in, R_RSA_PUBLIC_KEY& key) {
// Handle a file size request
else if (parse_str(buf, "<file_size_req>", file_name)) {
struct stat sbuf;
// TODO: put checking here to ensure path doesn't point somewhere bad
// TODO: check to ensure path doesn't point somewhere bad
//
sprintf( path, "%s/%s", BOINC_UPLOAD_DIR, file_name );
retval = stat( path, &sbuf );
if (retval && errno != ENOENT) print_status( -1, "cannot open file" );
else if (retval) printf("Content-type: text/plain\n\n<nbytes>0</nbytes>\n"
"<status>0</status>\n");
else printf("Content-type: text/plain\n\n<nbytes>%d</nbytes>\n"
"<status>0</status>\n", (int)sbuf.st_size);
if (retval && errno != ENOENT) {
print_status( -1, "cannot open file" );
} else if (retval) {
printf(
"Content-type: text/plain\n\n<nbytes>0</nbytes>\n"
"<status>0</status>\n"
);
} else {
printf(
"Content-type: text/plain\n\n<nbytes>%d</nbytes>\n"
"<status>0</status>\n", (int)sbuf.st_size
);
}
exit(0);
}
else if (parse_double(buf, "<offset>", offset)) continue;
@ -193,12 +204,12 @@ int handle_request(FILE* in, R_RSA_PUBLIC_KEY& key) {
sprintf(path, "%s/%s", BOINC_UPLOAD_DIR, file_info.name);
retval = copy_socket_to_file(in, path, offset, nbytes);
if (retval) {
fprintf(stderr,
"file_upload_handler (%s): copy_socket_to_file %d %s\n",
BOINC_USER, retval, path
);
}
if (retval) {
fprintf(stderr,
"file_upload_handler (%s): copy_socket_to_file %d %s\n",
BOINC_USER, retval, path
);
}
break;
}
}
@ -233,7 +244,6 @@ int main() {
if (retval) {
fprintf(stderr, "file_upload_handler: handle_request: %d\n", retval);
} else {
//fprintf(stderr, "file_upload_handler: handle_request: %d\n", retval);
print_status(0, 0);
}
return 0;

View File

@ -52,10 +52,10 @@ int insert_time_tag(WORKUNIT& wu, double seconds) {
location = strstr(wu.xml_doc, "</workunit>");
if ((location - wu.xml_doc) > (MAX_BLOB_SIZE - 64)) {
return -1; //not enough space to include time info
return -1; //not enough space to include time info
}
sprintf(location,
" <seconds_to_complete>%lf</seconds_to_complete>\n"
" <seconds_to_complete>%f</seconds_to_complete>\n"
"</workunit>\n",
seconds
);
@ -140,8 +140,8 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
return -1;
}
new_host:
// reply.user is filled in and valid at this point
//
// reply.user is filled in and valid at this point
//
reply.host = sreq.host;
reply.host.id = 0;
reply.host.create_time = time(0);
@ -156,8 +156,8 @@ new_host:
return -1;
}
reply.host.id = db_insert_id();
reply.hostid = reply.host.id;
// this tells client to updates its host ID
reply.hostid = reply.host.id;
// this tells client to updates its host ID
}
return 0;
}
@ -300,18 +300,18 @@ int send_work(
if (!ss.wu_results[i].present ||
!wu_is_feasible(ss.wu_results[i].workunit, reply.host)
) {
continue;
}
continue;
}
wu = ss.wu_results[i].workunit;
result = ss.wu_results[i].result;
ss.wu_results[i].present = false;
retval = add_wu_to_reply(wu, reply, platform, ss,
estimate_duration(wu, reply.host)
estimate_duration(wu, reply.host)
);
if (retval) continue;
reply.insert_result(result);
seconds_to_fill -= (int)estimate_duration(wu, reply.host);
seconds_to_fill -= (int)estimate_duration(wu, reply.host);
nresults++;
result.state = RESULT_STATE_IN_PROGRESS;

View File

@ -1,28 +1,14 @@
<head>
<title>BOINC - Berkeley Open Infrastructure for Network Computing</title>
</head>
<body text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000>
<h1>BOINC - Berkeley Open Infrastructure for Network Computing</h1>
<title>BOINC Test Project</title>
<h1>BOINC Test Project</h1>
<p>
BOINC is a software platform for public-participation
distributed computing projects.
Users are allowed to simultaneously participate in multiple projects
and to choose how to allocate their resources
for each project.
This is a placeholder for the main page of the project's web site.
<p>
First download the core client by clicking on the below link.
Then create a BOINC account,
setting your preferences to specify how much your computer should
be working on each project.
You may view your user page to see how much credit
you have accumulated as your participation proceeds.
In addition, you may modify your preferences through your user page
at anytime to reallocate your resources
among the different projects you may be involved in.
To participate in this project,
create an account, then download the BOINC client.
<ul>
<li><a href=download.php>Download core client</a></li>
<li><a href=login.php>Log in or create account</a></li>
<li><a href=download.php>Download BOINC client</a></li>
<li><a href=login.php>Log in or create account on this project</a></li>
<li><a href=home.php>User page</a></li>
<li><a href=team.php>Teams</a></li>
</ul>

View File

@ -9,10 +9,10 @@
check_env_vars();
clear_db();
if (true) {
clear_server_dirs(false);
clear_server_dirs(false);
} else {
clear_server_dirs(true);
create_keys();
clear_server_dirs(true);
create_keys();
}
clear_client_dirs();
init_client_dirs("prefs1.xml");
@ -21,10 +21,11 @@
add_platform(null);
add_user("prefs.xml");
add_app("upper_case", null, null);
add_core_client(null);
create_work("-appname upper_case -rsc_iops 180000000000.0 -rsc_fpops 0.0 -wu_name uc_wu -wu_template uc_wu -result_template uc_result -nresults 2 input input input input input");
start_feeder();
run_client("-exit_after 10");
//run_client("-exit_when_idle");
//run_client("-exit_after 10");
run_client("-exit_when_idle");
stop_feeder();
check_results_done();
compare_file("uc_wu_0_0", "uc_correct_output");

View File

@ -15,7 +15,8 @@ CFLAGS = -g -Wall @DEFS@ \
-I @top_srcdir@/lib \
-I @top_srcdir@/RSAEuro/source \
-I @top_srcdir@/db \
-I $(MYSQL_INC)
-I $(MYSQL_INC) \
-L../lib
CC = @CC@ $(CFLAGS)
@ -27,7 +28,7 @@ OBJS = \
backend_lib.o \
process_result_template.o
PROGS = create_work add country_select
PROGS = create_work add country_select grant_credit
all: $(PROGS) $(OBJS)
MYSQL_DIR = /usr/local/mysql/lib
@ -56,6 +57,9 @@ create_work: create_work.o $(CLIBS) $(LIBS) $(CRYPTO_LIBS)
add: add.o $(CLIBS) $(LIBS) $(CRYPTO_LIBS)
$(CC) add.o $(CLIBS) $(LIBS) $(CRYPTO_LIBS) $(MYSQL_LIBS) -o add
grant_credit: grant_credit.o
$(CC) grant_credit.o $(LIBS) $(CRYPTO_LIBS) $(MYSQL_LIBS) $(CLIBS) -o grant_credit;
country_select: country_select.o ../lib/countries.o
$(CC) country_select.o ../lib/countries.o -o country_select

View File

@ -202,3 +202,16 @@ int create_work(
}
return 0;
}
// not finished!
int grant_credit(int resultid, double credit) {
RESULT result;
int retval;
retval = db_result(resultid, result);
if (retval) return retval;
result.granted_credit = credit;
result.validated = true;
retval = db_result_update(result);
return retval;
}

View File

@ -38,3 +38,5 @@ extern int create_work(
int ninfiles,
R_RSA_PRIVATE_KEY&
);
extern int grant_credit(int resultid, double cobblestones);

78
tools/grant_credit.C Normal file
View File

@ -0,0 +1,78 @@
// grant_credit result_name
//
// grant credit for the given result, based on its reported CPU time
//
// TODO: redundancy checking
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include "db.h"
#define EXP_DECAY_RATE (1./(3600*24*7))
int main(int argc, char** argv) {
RESULT result;
HOST host;
USER user;
int retval;
double host_speed, credit, deltat;
time_t now;
retval = db_open(getenv("BOINC_DB_NAME"), getenv("BOINC_DB_PASSWD"));
if (retval) exit(1);
strcpy(result.name, argv[1]);
retval = db_result_lookup_name(result);
if (retval) {
printf("can't find result\n");
exit(1);
}
if (result.state != RESULT_STATE_DONE) {
printf("result is not done\n");
exit(1);
}
retval = db_host(result.hostid, host);
if (retval) {
printf("can't find host\n");
exit(1);
}
retval = db_user(host.userid, user);
if (retval) {
printf("can't find user\n");
exit(1);
}
host_speed = host.p_fpops + host.p_iops + host.p_membw/10;
credit = result.cpu_time*host_speed;
result.granted_credit = credit;
retval = db_result_update(result);
if (retval) {
printf("can't update result\n");
}
now = time(0);
if (user.expavg_time) {
deltat = now - user.expavg_time;
user.expavg_credit *= exp(deltat*EXP_DECAY_RATE);
}
user.expavg_credit += credit;
user.expavg_time = now;
retval = db_user_update(user);
if (retval) {
printf("can't update user\n");
}
if (host.expavg_time) {
deltat = now - host.expavg_time;
host.expavg_credit *= exp(deltat*EXP_DECAY_RATE);
}
host.expavg_credit += credit;
host.expavg_time = now;
retval = db_host_update(host);
if (retval) {
printf("can't update host\n");
}
}