function reset_all() { BoincUserSubmit::update_aux("logical_start_time=0"); BoincBatch::update_aux("logical_start_time=0, logical_end_time=0"); BoincWorkunit::update_aux("priority=0"); BoincResult::update_aux("priority=0"); }
function show_batches($user) { $batches = BoincBatch::enum("user_id={$user->id}"); page_head("Batches"); start_table(); table_header("Batch ID", "Submitted", "# jobs"); foreach ($batches as $batch) { echo "<tr>\n <td><a href=submit_status.php?action=show_batch&batch_id={$batch->id}>{$batch->id}</a></td>\n <td>" . time_str($batch->create_time) . "</td>\n <td>{$batch->njobs}</td>\n </tr>\n "; } end_table(); page_tail(); }
function handle_submit($r, $user, $app) { global $app_name, $log; $timestamp = date("Y-m-d H:i", time()); // read the list of template filenames // $files = file("../../tree_threader_template_files"); if ($files === false) { fwrite($log, "{$timestamp}\ttemplate file tree_threader_template_files\n"); error("no templates file"); } $njobs = sizeof($files); $now = time(); $batch_id = BoincBatch::insert("(user_id, create_time, njobs, name, app_id, state) values ({$user->id}, {$now}, {$njobs}, 'tree_threader batch', {$app->id}, " . BATCH_STATE_IN_PROGRESS . ")"); if (!$batch_id) { $log_msg = "{$timestamp}\tfailed to create batch for user {$user->id}\n"; fwrite($log, $log_msg); die("couldn't create batch\n"); } else { $log_msg = "{$timestamp}\tcreated batch {$batch_id} for user {$user->id}\n"; fwrite($log, $log_msg); } // move the sequence file to the download hier // $config = simplexml_load_string(file_get_contents("../../config.xml")); $fanout = (int) $config->config->uldl_dir_fanout; $download_dir = trim((string) $config->config->download_dir); $seq_fname = "treeThreader_sequence_{$batch_id}.tar.gz"; $seq_path = dir_hier_path($seq_fname, $download_dir, $fanout); $tmp_name = $_FILES['seq_file']['tmp_name']; $ret = rename($tmp_name, $seq_path); if ($ret === false) { error("couldn't rename sequence file"); } $i = 1; foreach ($files as $file) { $file = trim($file); $wu_name = "ICT_" . $batch_id . "_{$i}"; $cmd = "cd ../..; ./bin/create_work --appname {$app_name} --batch {$batch_id} --wu_name {$wu_name} --wu_template templates/ICT_in --result_template templates/ICT_out {$seq_fname} {$file}"; fwrite($log, "{$timestamp}\t{$cmd}\n"); system($cmd, $ret); if ($ret != 0) { fwrite($log, "can not creat job {$wu_name}\n"); error("can't create job"); } $i++; } echo "<tt_reply>\n<batch_id>{$batch_id}</batch_id>\n</tt_reply>\n"; }
function batches_action($app) { $batches = BoincBatch::enum("app_id={$app->id}"); $abort_all = get_str("abort_all", true); foreach ($batches as $batch) { if ($abort_all || get_str("abort_{$batch->id}", true)) { abort_batch($batch); } } page_head("Update successful"); echo "\n <a href=manage_app.php?app_id={$app->id}>Return to application management page</a>\n "; page_tail(); }
function get_wu_output_files($wu_id, $auth_str) { $wu = BoincWorkunit::lookup_id($wu_id); if (!$wu) { die("no workunit {$wu_id}"); } $batch = BoincBatch::lookup_id($wu->batch); if (!$batch) { die("no batch {$wu->batch}"); } $user = BoincUser::lookup_id($batch->user_id); if (!$user) { die("no user {$batch->user_id}"); } $x = md5($user->authenticator . $wu_id); echo "user authenticator= {$user->authenticator}, wu_id={$wu_id}<br/>"; if ($x != $auth_str) { die("bad auth str: x={$x}, auth_str={$auth_str}"); } $zip_basename = tempnam("/tmp", "boinc_wu_" . $wu->name . "_"); $zip_filename = $zip_basename . ".zip"; $fanout = parse_config(get_config(), "<uldl_dir_fanout>"); $upload_dir = parse_config(get_config(), "<upload_dir>"); if (!$wu->canonical_resultid) { die("no canonical result for wu {$wu->name}"); } $result = BoincResult::lookup_id($wu->canonical_resultid); $names = get_outfile_names($result); foreach ($names as $name) { $path = dir_hier_path($name, $upload_dir, $fanout); if (is_file($path)) { system("nice -9 zip -jq {$zip_basename} {$path}"); } } do_download($zip_filename); unlink($zip_filename); unlink($zip_basename); }
function handle_abort_jobs($r) { xml_start_tag("abort_jobs"); list($user, $user_submit) = authenticate_user($r, null); $batch = null; foreach ($r->job_name as $job_name) { $job_name = BoincDb::escape_string($job_name); $wu = BoincWorkunit::lookup("name='{$job_name}'"); if (!$wu) { xml_error(-1, "No job {$job_name}"); } if (!$wu->batch) { xml_error(-1, "Job {$job_name} is not part of a batch"); } if (!$batch || $wu->batch != $batch->id) { $batch = BoincBatch::lookup_id($wu->batch); } if (!$batch || $batch->user_id != $user->id) { xml_error(-1, "not owner"); } echo "<aborted {$job_name}>\n"; abort_workunit($wu); } echo "<success>1</success>\n </abort_jobs>\n "; }
function handle_show_all($user) { $userid = get_int("userid"); $appid = get_int("appid"); $state = get_int("state"); if ($userid) { // user looking at their own batches // if ($userid != $user->id) { error_page("wrong user"); } $batches = BoincBatch::enum("user_id = {$user->id} and state={$state} order by id desc"); fill_in_app_and_user_names($batches); show_batches_in_state($batches, $state); } else { // admin looking at batches // check_admin_access($user, $appid); if ($appid) { $app = BoincApp::lookup_id($appid); if (!$app) { error_page("no such app"); } $batches = BoincBatch::enum("app_id = {$appid} and state={$state} order by id desc"); } else { $batches = BoincBatch::enum("state={$state} order by id desc"); } fill_in_app_and_user_names($batches); show_batches_in_state($batches, $state); } }
function submit_batch($user, $app) { $tmpfile = get_str('tmpfile'); $x = file_get_contents("{$tmpfile}"); $info = unserialize($x); $njobs = 0; $cmdlines = file($info->cmdline_file_path); foreach ($cmdlines as $cmdline) { if (preg_match("/^\\s*-var/", $cmdline)) { $njobs++; } } $now = time(); $batch_name = $info->area . "_" . date("Y-M-d D H:i:s"); $batch_id = BoincBatch::insert("(user_id, create_time, njobs, name, app_id, state) values ({$user->id}, {$now}, {$njobs}, '{$batch_name}', {$app->id}, " . BATCH_STATE_IN_PROGRESS . ")"); // $batch_id=99; $i = 0; foreach ($cmdlines as $cmdline) { if (preg_match("/^\\s*-var/", $cmdline)) { submit_job($app, $batch_id, $info, $cmdline, $i); $i++; } } }
function handle_retire_batch($user) { $batch_id = get_int('batch_id'); $batch = BoincBatch::lookup_id($batch_id); if (!$batch) { error_page("no such batch"); } check_access($user, $batch); retire_batch($batch); page_head("Batch retired"); echo "<p><a href=submit.php>Return to job control page</a>\n"; page_tail(); }
function handle_retire_batch($r) { list($user, $user_submit) = authenticate_user($r, null); $batch_id = (int) $r->batch_id; $batch = BoincBatch::lookup_id($batch_id); if ($batch->user_id != $user->id) { error("not owner"); } retire_batch($batch); echo "<success>1</success>"; }