remote job submission: in batch query, getting CPU time is optional

This commit is contained in:
David Anderson 2015-06-29 15:28:51 -07:00
parent 87044507ca
commit 033d67d927
4 changed files with 26 additions and 24 deletions

View File

@ -188,8 +188,12 @@ function boinc_submit_batch($req) {
}
function boinc_query_batches($req) {
$get_cpu_time =
empty($req->get_cpu_time)?" <get_cpu_time>1</get_cpu_time>\n":""
;
$req_xml = "<query_batches>
<authenticator>$req->authenticator</authenticator>
$get_cpu_time
</query_batches>
";
list($reply, $errmsg) = do_http_op($req, $req_xml, "");
@ -203,9 +207,13 @@ function boinc_query_batches($req) {
}
function boinc_query_batch($req) {
$get_cpu_time =
empty($req->get_cpu_time)?" <get_cpu_time>1</get_cpu_time>\n":""
;
$req_xml = "<query_batch>
<authenticator>$req->authenticator</authenticator>
<batch_id>$req->batch_id</batch_id>
$get_cpu_time
</query_batch>
";
list($reply, $errmsg) = do_http_op($req, $req_xml, "");

View File

@ -48,6 +48,14 @@ class BoincBatch {
$db = BoincDb::get();
return $db->update_aux('batch', $clause);
}
function get_cpu_time() {
$db = BoincDb::get();
$x = $db->get_double(
"select sum(result.cpu_time) as total_cpu_time from workunit join result on workunit.id = result.workunitid where workunit.batch=$this->id",
"total_cpu_time"
);
return $x;
}
}
class BoincUserSubmit {
@ -146,19 +154,4 @@ class BoincBatchFileAssoc {
}
}
class BoincBatchTotalCPUTime {
static function get_cpu_time($batch_id) {
$db = BoincDb::get();
$id = (int)$batch_id;
$x = $db->get_double(
"select sum(result.cpu_time) as total_cpu_time from workunit join result on workunit.id = result.workunitid where workunit.batch=$id",
"total_cpu_time"
);
return $x;
}
}
?>

View File

@ -111,14 +111,13 @@ function handle_main() {
$first = false;
echo "<h2>Completed batches</h2>\n";
start_table();
table_header("name", "ID", "# jobs", "submitted", "CPU Time");
table_header("name", "ID", "# jobs", "submitted");
}
table_row(
"<a href=submit_example.php?action=query_batch&batch_id=$batch->id>$batch->name</a>",
"<a href=submit_example.php?action=query_batch&batch_id=$batch->id>$batch->id</a>",
$batch->njobs,
local_time_str($batch->create_time),
BoincBatchTotalCPUTime::get_cpu_time($batch->id)
local_time_str($batch->create_time)
);
}
if ($first) {

View File

@ -354,7 +354,7 @@ function create_batch($r) {
echo "<batch_id>$batch_id</batch_id>\n";
}
function print_batch_params($batch) {
function print_batch_params($batch, $get_cpu_time) {
$app = BoincApp::lookup_id($batch->app_id);
if (!$app) $app->name = "none";
echo "
@ -372,14 +372,15 @@ function print_batch_params($batch) {
<name>$batch->name</name>
<app_name>$app->name</app_name>
";
echo " <total_cpu_time>";
echo BoincBatchTotalCPUTime::get_cpu_time($batch->id);
echo "</total_cpu_time>\n";
if ($get_cpu_time) {
echo " <total_cpu_time>".$batch->get_cpu_time()."</total_cpu_time>\n";
}
}
function query_batches($r) {
list($user, $user_submit) = authenticate_user($r, null);
$batches = BoincBatch::enum("user_id = $user->id");
$get_cpu_time = (int)($r->get_cpu_time);
echo "<batches>\n";
foreach ($batches as $batch) {
if ($batch->state < BATCH_STATE_COMPLETE) {
@ -387,7 +388,7 @@ function query_batches($r) {
$batch = get_batch_params($batch, $wus);
}
echo " <batch>\n";
print_batch_params($batch);
print_batch_params($batch, $get_cpu_time);
echo " </batch>\n";
}
echo "</batches>\n";
@ -426,7 +427,8 @@ function query_batch($r) {
$wus = BoincWorkunit::enum("batch = $batch->id");
$batch = get_batch_params($batch, $wus);
echo "<batch>\n";
print_batch_params($batch);
$get_cpu_time = (int)($r->get_cpu_time);
print_batch_params($batch, $get_cpu_time);
$n_outfiles = n_outfiles($wus[0]);
foreach ($wus as $wu) {
echo " <job>