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 create_batch($r) { xml_start_tag("create_batch"); $app = get_submit_app((string) $r->batch->app_name); list($user, $user_submit) = authenticate_user($r, $app); $now = time(); $batch_name = (string) $r->batch->batch_name; $batch_name = BoincDb::escape_string($batch_name); $expire_time = (double) $r->expire_time; $batch_id = BoincBatch::insert("(user_id, create_time, name, app_id, state, expire_time) values ({$user->id}, {$now}, '{$batch_name}', {$app->id}, " . BATCH_STATE_INIT . ", {$expire_time})"); if (!$batch_id) { xml_error(-1, "BOINC server: Can't create batch: " . BoincDb::error()); } echo "<batch_id>{$batch_id}</batch_id>\n </create_batch>\n "; }
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 submit_batch($r) { $app = get_app($r); list($user, $user_submit) = authenticate_user($r, $app); $template = read_input_template($app); $jobs = xml_get_jobs($r); validate_batch($jobs, $template); stage_files($jobs, $template); $njobs = count($jobs); $now = time(); $batch_name = (string) $r->batch->batch_name; $batch_id = BoincBatch::insert("(user_id, create_time, njobs, name, app_id) values ({$user->id}, {$now}, {$njobs}, '{$batch_name}', {$app->id})"); $i = 0; foreach ($jobs as $job) { submit_job($job, $template, $app, $batch_id, $i++); } $batch = BoincBatch::lookup_id($batch_id); $batch->update("state=" . BATCH_STATE_IN_PROGRESS); echo "<batch_id>{$batch_id}</batch_id>\n"; }