- web: new page to manage job submission

svn path=/trunk/boinc/; revision=24959
This commit is contained in:
David Anderson 2011-12-31 08:57:53 +00:00
parent 1eff1601d2
commit 2b4e6c2f65
5 changed files with 61 additions and 61 deletions

View File

@ -9763,3 +9763,14 @@ David 31 Dec 2011
html/user/
lammps.php
David 31 Dec 2011
- web: new page to manage job submission
html/
inc/
submit.inc
submit_util.inc
user/
submit_rpc_handler.php
submit_example.php

View File

@ -30,9 +30,6 @@
// Functions:
// boinc_abort_batch(): abort a batch
// boinc_estimate_batch(); estimate completion time of a batch
// boinc_file_delete(): delete a file on server
// boinc_file_get_list(): get list of this user's files on server
// boinc_file_upload(): upload a file to the server
// boinc_get_output_file(): get the URL for an output file
// boinc_get_output_files(): get the URL for zipped batch output
// boinc_query_batch(): get detaills of a batch
@ -84,7 +81,7 @@ function validate_request($req) {
}
function do_http_op($project, $xml) {
$ch = curl_init("$project/submit.php");
$ch = curl_init("$project/submit_rpc_handler.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "request=$xml");
@ -252,27 +249,6 @@ function boinc_retire_batch($req) {
return null;
}
function boinc_file_delete($req) {
$req_xml = "<file_delete>
<authenticator>$req->authenticator</authenticator>
<file_name>$req->file_name</file_name>
</file_delete>
";
list($reply, $errmsg) = do_http_op($req->project, $req_xml);
if ($errmsg) return $errmsg;
$name = $reply->getName();
if ($name == 'error') {
return (string)($reply->message);
}
return null;
}
function boinc_file_get_list() {
}
function boinc_file_upload() {
}
//// example usage follows
$req->project = "http://isaac.ssl.berkeley.edu/test/";

View File

@ -21,6 +21,42 @@
require_once("../inc/submit_db.inc");
// given its WUs, compute params of a batch
// NOTE: eventually this should be done by server components
// (transitioner, validator etc.) as jobs complete or time out
//
// TODO: update est_completion_time
//
function get_batch_params($batch, $wus) {
$fp_total = 0;
$fp_done = 0;
$completed = true;
$batch->nerror_jobs = 0;
$batch->credit_canonical = 0;
foreach ($wus as $wu) {
$fp_total += $wu->rsc_fpops_est;
if ($wu->canonical_resultid) {
$fp_done += $wu->rsc_fpops_est;
$batch->credit_canonical += $wu->canonical_credit;
} else if ($wu->error_mask) {
$batch->nerror_jobs++;
} else {
$completed = false;
}
}
if ($fp_total) {
$batch->fraction_done = $fp_done / $fp_total;
}
if ($completed && $batch->state < BATCH_STATE_COMPLETE) {
$batch->state = BATCH_STATE_COMPLETE;
$batch->completion_time = time();
}
$batch->update("fraction_done = $batch->fraction_done, nerror_jobs = $batch->nerror_jobs, state=$batch->state, completion_time = $batch->completion_time, credit_canonical = $batch->credit_canonical");
$batch->credit_estimate = flops_to_credit($fp_total);
return $batch;
}
function get_outfile_names($result) {
$names = array();
$xml = "<a>".$result->xml_doc_out."</a>";
@ -83,4 +119,15 @@ function batch_state_string($state) {
return "unknown state $state";
}
function boinc_get_output_file_url($user, $result, $i) {
$name = $result->name;
$auth_str = md5($user->authenticator.$name);
return "get_output.php?instance_name=$name&file_num=$i&auth_str=$auth_str";
}
function boinc_get_output_files_url($user, $batch_id) {
$auth_str = md5($user->authenticator.$batch_id);
return "get_output.php?batch_id=$batch_id&auth_str=$auth_str";
}
?>

View File

@ -31,6 +31,7 @@
// you can strip out this stuff if the web site doesn't use BOINC
require_once("../inc/submit.inc");
require_once("../inc/submit_util.inc");
require_once("../inc/submit_db.inc");
require_once("../inc/util.inc");
require_once("../project/project.inc");

View File

@ -190,44 +190,9 @@ function submit_batch($r) {
echo "<batch_id>$batch_id</batch_id>\n";
}
// given its WUs, compute params of a batch
// NOTE: eventually this should be done by server components
// (transitioner, validator etc.) as jobs complete or time out
//
// TODO: update est_completion_time
//
function get_batch_params($batch, $wus) {
$fp_total = 0;
$fp_done = 0;
$completed = true;
$batch->nerror_jobs = 0;
$batch->credit_canonical = 0;
foreach ($wus as $wu) {
$fp_total += $wu->rsc_fpops_est;
if ($wu->canonical_resultid) {
$fp_done += $wu->rsc_fpops_est;
$batch->credit_canonical += $wu->canonical_credit;
} else if ($wu->error_mask) {
$batch->nerror_jobs++;
} else {
$completed = false;
}
}
if ($fp_total) {
$batch->fraction_done = $fp_done / $fp_total;
}
if ($completed && $batch->state < BATCH_STATE_COMPLETE) {
$batch->state = BATCH_STATE_COMPLETE;
$batch->completion_time = time();
}
$batch->update("fraction_done = $batch->fraction_done, nerror_jobs = $batch->nerror_jobs, state=$batch->state, completion_time = $batch->completion_time, credit_canonical = $batch->credit_canonical");
$batch->credit_estimate = flops_to_credit($fp_total);
return $batch;
}
function print_batch_params($batch) {
$app = BoincApp::lookup_id($batch->app_id);
if (!$app) $app->name = "none";
echo "
<id>$batch->id</id>
<create_time>$batch->create_time</create_time>