Ejemplo n.º 1
0
function revalidate($clause)
{
    $nwus = 0;
    $nresults = 0;
    $wus = BoincWorkunit::enum($clause);
    foreach ($wus as $wu) {
        $results = BoincResult::enum("workunitid={$wu->id}");
        $n = 0;
        foreach ($results as $result) {
            if ($result->server_state != 5) {
                continue;
            }
            if ($result->outcome != 1) {
                continue;
            }
            if ($result->validate_state < 2) {
                continue;
            }
            $result->update("validate_state=0");
            echo "<br>updated result {$result->id}\n";
            $n++;
            $nresults++;
        }
        if ($n) {
            $wu->update("need_validate=1");
            echo "<br>updated wu {$wu->id}\n";
            $nwus++;
        }
    }
    echo "Examined " . count($wus) . " jobs.\n";
    echo "{$nwus} jobs and {$nresults} instances were marked for revalidation";
}
Ejemplo n.º 2
0
function get_batch_output_files($batch_id, $auth_str)
{
    $batch = BoincBatch::lookup_id($batch_id);
    if (!$batch) {
        die("no batch {$batch_id}");
    }
    $user = BoincUser::lookup_id($batch->user_id);
    if (!$user) {
        die("no user {$batch->user_id}");
    }
    $x = md5($user->authenticator . $batch_id);
    if ($x != $auth_str) {
        die("bad auth str");
    }
    $zip_basename = tempnam("/tmp", "boinc_batch_");
    $zip_filename = $zip_basename . ".zip";
    $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
    $upload_dir = parse_config(get_config(), "<upload_dir>");
    $wus = BoincWorkunit::enum("batch={$batch_id}");
    foreach ($wus as $wu) {
        if (!$wu->canonical_resultid) {
            continue;
        }
        $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);
}
Ejemplo n.º 3
0
function catchup()
{
    while (1) {
        $now = time();
        $wus = BoincWorkunit::enum("transition_time<{$now} limit 1");
        if (count($wus) == 0) {
            break;
        }
        echo "There are " . count($wus) . " WUs needing transition.\n";
        system("bin/transitioner --one_pass");
    }
    echo "Transitioner is caught up.\n";
}
Ejemplo n.º 4
0
function catchup()
{
    while (1) {
        $now = time();
        $wus = BoincWorkunit::enum("transition_time<{$now} limit 1");
        if (count($wus) == 0) {
            break;
        }
        echo "Some WUs need transition - running transitioner.\n";
        $ret = system("bin/transitioner --one_pass");
        echo "ret: {$ret}\n";
        sleep(1);
    }
    echo "Transitioner is caught up.\n";
}
Ejemplo n.º 5
0
function query_batch2($r)
{
    xml_start_tag("query_batch2");
    list($user, $user_submit) = authenticate_user($r, null);
    $batch_names = $r->batch_name;
    $batches = array();
    foreach ($batch_names as $b) {
        $batch_name = (string) $b;
        $batch_name = BoincDb::escape_string($batch_name);
        $batch = BoincBatch::lookup_name($batch_name);
        if (!$batch) {
            xml_error(-1, "no batch named {$batch_name}");
        }
        if ($batch->user_id != $user->id) {
            xml_error(-1, "not owner of {$batch_name}");
        }
        $batches[] = $batch;
    }
    $min_mod_time = (double) $r->min_mod_time;
    if ($min_mod_time) {
        $mod_time_clause = "and mod_time > FROM_UNIXTIME({$min_mod_time})";
    } else {
        $mod_time_clause = "";
    }
    $t = dtime();
    echo "<server_time>{$t}</server_time>\n";
    foreach ($batches as $batch) {
        $wus = BoincWorkunit::enum("batch = {$batch->id} {$mod_time_clause}");
        echo "   <batch_size>" . count($wus) . "</batch_size>\n";
        foreach ($wus as $wu) {
            if ($wu->canonical_resultid) {
                $status = "DONE";
            } else {
                if ($wu->error_mask) {
                    $status = "ERROR";
                } else {
                    $status = "IN_PROGRESS";
                }
            }
            echo "    <job>\n        <job_name>{$wu->name}</job_name>\n        <status>{$status}</status>\n    </job>\n";
        }
    }
    echo "</query_batch2>\n";
}
Ejemplo n.º 6
0
function handle_query_batch($user)
{
    $batch_id = get_int('batch_id');
    $batch = BoincBatch::lookup_id($batch_id);
    $app = BoincApp::lookup_id($batch->app_id);
    $wus = BoincWorkunit::enum("batch = {$batch->id}");
    $batch = get_batch_params($batch, $wus);
    page_head("Batch {$batch_id}");
    start_table();
    row2("name", $batch->name);
    row2("application", $app->name);
    row2("state", batch_state_string($batch->state));
    row2("# jobs", $batch->njobs);
    row2("# error jobs", $batch->nerror_jobs);
    //row2("logical end time", time_str($batch->logical_end_time));
    row2("expiration time", time_str($batch->expire_time));
    row2("progress", sprintf("%.0f%%", $batch->fraction_done * 100));
    if ($batch->completion_time) {
        row2("completed", local_time_str($batch->completion_time));
    }
    row2("GFLOP/hours, estimated", number_format(credit_to_gflop_hours($batch->credit_estimate), 2));
    row2("GFLOP/hours, actual", number_format(credit_to_gflop_hours($batch->credit_canonical), 2));
    row2("Output File Size (MB)", number_format(batch_output_file_size($batch->id) / 1000000.0, 2));
    end_table();
    if (batch_output_file_size($batch->id) <= 100000000.0) {
        $url = boinc_get_output_files_url($user, $batch_id);
        show_button($url, "Get zipped output files");
    } else {
        echo "<br/>The output file size of this batch is too big, it will be uploaded by FTP<br/>";
    }
    switch ($batch->state) {
        case BATCH_STATE_IN_PROGRESS:
            echo "<br>";
            show_button("submit.php?action=abort_batch_confirm&batch_id={$batch_id}", "Abort batch");
            break;
        case BATCH_STATE_COMPLETE:
        case BATCH_STATE_ABORTED:
            echo "<br>";
            show_button("submit.php?action=retire_batch_confirm&batch_id={$batch_id}", "Retire batch");
            break;
    }
    echo "<h2>Jobs</h2>\n";
    start_table();
    table_header("Job ID and name<br><p class=\"text-muted\">click for details or to get output files</p>", "status", "Canonical instance<br><p class=\"text-muted\">click to see result page on BOINC server</p>", "Download Results");
    foreach ($wus as $wu) {
        $resultid = $wu->canonical_resultid;
        $durl = boinc_get_wu_output_files_url($user, $wu->id);
        if ($resultid) {
            $x = "<a href=result.php?resultid={$resultid}>{$resultid}</a>";
            $y = '<font color="green">completed</font>';
            $text = "<a href={$durl}> Download Result Files</a>";
        } else {
            $x = "---";
            $text = "---";
            if ($batch->state == BATCH_STATE_COMPLETE) {
                $y = '<font color="red">failed</font>';
            } else {
                $y = "in progress";
            }
        }
        echo "<tr>\n                <td><a href=submit.php?action=query_job&wuid={$wu->id}>{$wu->id} &middot; {$wu->name}</a></td>\n                <td>{$y}</td>\n                <td>{$x}</td>\n                <td>{$text}</td>\n            </tr>\n        ";
    }
    end_table();
    echo "<p><a href=submit.php>Return to job control page</a>\n";
    page_tail();
}
Ejemplo n.º 7
0
function query_batch($r)
{
    list($user, $user_submit) = authenticate_user($r, null);
    $batch_id = (int) $r->batch_id;
    $batch = BoincBatch::lookup_id($batch_id);
    if (!$batch) {
        error("no such batch");
    }
    if ($batch->user_id != $user->id) {
        error("not owner");
    }
    $wus = BoincWorkunit::enum("batch = {$batch_id}");
    $batch = get_batch_params($batch, $wus);
    echo "<batch>\n";
    print_batch_params($batch);
    $n_outfiles = n_outfiles($wus[0]);
    foreach ($wus as $wu) {
        echo "    <job>\n        <id>{$wu->id}</id>\n        <canonical_instance_id>{$wu->canonical_resultid}</canonical_instance_id>\n        <n_outfiles>{$n_outfiles}</n_outfiles>\n        </job>\n";
    }
    echo "</batch>\n";
}