Ejemplo n.º 1
0
Archivo: index.php Proyecto: hisapi/his
             $trigger_wait_message = true;
         }
     }
     // END IF
 }
 // END IF
 if ($APP['ms']->kind != "no-messaging" && !$messaging_complete) {
     // WAIT FOR MESSAGE QUEUE RESPONSE
     $message = $new_job_id->receive("replyfrom_" . $selected_job_server_name);
     $all_messages .= $message . "<br/>\n";
     if (($message . "" == "NULL" || strlen($message . "") == 0) && $cnt < 15) {
         sleep(1);
         continue;
     }
     $message_xml = xmlToArray(simplexml_load_string($message));
     $collected_job_id = new job_id_user();
     $collected_job_id->fromobjectxml($message_xml);
     if ($collected_job_id->id == $id_submitted_job) {
         $new_job_id->fromobjectxml($message_xml);
         $messaging_complete = True;
     } else {
         $all_messages .= "received a wrong message: " . htmlspecialchars($message);
         // we collected a message from anoth/er job - re-post the message to the queue so we don't end up stealing other jobs' responses
         $collected_job_id->send("replyfrom_" . $selected_job_server_name, $message);
     }
 } else {
     $new_job_id->get_from_hashrange($u->id_user, $new_job_id->id);
 }
 if ($new_job_id->id_status != 'running' && $new_job_id->id_status != 'new' && $new_job_id->id_status != 'paused') {
     // JOB IS DONE
     break;
Ejemplo n.º 2
0
Archivo: get.php Proyecto: hisapi/his
<?php

if ((!isset($_GET['uid']) && !isset($_GET['secret']) || !isset($_POST['uid']) && !isset($_POST['secret'])) && !isset($_COOKIE["hisdata"])) {
    echo trim(iconv('UTF-8', 'ASCII//IGNORE', "ERROR: GET parameters 'uid' and 'secret' must be defined"));
    exit;
}
if (!isset($_GET['job'])) {
    echo trim(iconv('UTF-8', 'ASCII//IGNORE', "ERROR: GET parameter 'job' must be defined"));
    exit;
}
if (!isset($_GET['return'])) {
    echo trim(iconv('UTF-8', 'ASCII//IGNORE', "ERROR: GET parameter 'return' must be defined"));
    exit;
}
include "version.php";
include "demos.php";
include "controller.guard.php";
$find_job = new job_id_user();
$find_job->get_from_hashrange($u->id_user, $_GET['job']);
if ($find_job->id != "undefined") {
    if ($_GET['return'] == "status") {
        echo trim(iconv('UTF-8', 'ASCII//IGNORE', $find_job->id_status));
    }
    if ($_GET['return'] == "output") {
        $find_job->build(array("obj_rqdata", "obj_response", "obj_ad", "obj_hf", "obj_user"));
        // 302
        header("Location: " . $find_job->obj_output->val);
    }
} else {
    echo trim(iconv('UTF-8', 'ASCII//IGNORE', "undefined"));
}
Ejemplo n.º 3
0
 public function reassign_auto()
 {
     global $mode_server;
     $user_servers = array();
     $user_server = new user_server();
     // LIST OF ALL JOB SERVERS
     $user_servers = $user_server->get_from_hashrange($this->id_user);
     // HOW MANY NON-BUSY JOB SERVERS
     $not_busy_servers = array();
     foreach ($user_servers as $user_server) {
         if (isset($user_server['is_busy'])) {
             if ($user_server['is_busy'] . "" != "1" && $user_server['int_online'] . "" == "1") {
                 $not_busy_servers[] = $user_server;
             }
         }
     }
     // HOW MANY OTHER NON-BUSY JOB SERVERS (INC. THIS ONE) WERE LAST SEEN IN THE PAST 30 SECONDS
     $server_second_timerange = 30;
     $current_not_busy_servers = array();
     foreach ($not_busy_servers as $not_busy_server) {
         $timespan = intval(get_time()) - intval($not_busy_server['last_ping']);
         if ($timespan < $server_second_timerange) {
             $current_not_busy_servers[] = $not_busy_server;
         }
     }
     //   SORT THIS LIST
     usort($current_not_busy_servers, "nameindexordersort");
     usort($current_not_busy_servers, "lastpingordersort");
     $current_not_busy_servers_by_name = array();
     foreach ($current_not_busy_servers as $current_not_busy_server) {
         $current_not_busy_servers_by_name[$current_not_busy_server['name']] = $current_not_busy_server;
     }
     //echo "CURRENT NOT BUSY SERVERS:";print_r($current_not_busy_servers_by_name);
     //echo "FIRST SERVER:".$current_not_busy_servers[0]['name'];
     //   IS THIS SERVER THE FIRST IN THE LIST?
     //if ( count($current_not_busy_servers)>0 ) //&& $INSTANCE_NAME==$current_not_busy_servers[0]['name'] )
     //{
     $assigned_servers = array();
     $assignable_hf = new assign_hf();
     //echo "SEARCHING FOR ASSIGNABILITY:".$job_assign_hf;
     $job_reassignability = $assignable_hf->get_from_hashrange($this->id_user, $this->id_hf, "BEGINS_WITH");
     //echo "ASSIGNABILITY:";
     //print_r($job_reassignability);
     $find_id_prefix = $this->id_hf . "@";
     $eligible_servers = array();
     foreach ($job_reassignability as $job_reassign_hf) {
         //echo "ADDING ELIGIBLE SERVER:".str_replace($find_id_prefix,"",$job_reassign_hf['hf_server'])."\n";
         $eligible_servers[] = str_replace($find_id_prefix, "", $job_reassign_hf['hf_server']);
     }
     $eligible_not_busy_servers = array();
     foreach ($eligible_servers as $eligible_server) {
         if (in_array($eligible_server, array_keys($current_not_busy_servers_by_name)) && !in_array($eligible_server, $assigned_servers)) {
             $eligible_not_busy_servers[] = $eligible_server;
         }
     }
     if (count($eligible_not_busy_servers) == 0) {
         foreach ($eligible_servers as $eligible_server) {
             $eligible_not_busy_servers[] = $eligible_server;
         }
     }
     //echo "ELIGIBLE JOB SERVERS (NOT BUSY):";print_r($eligible_not_busy_servers);
     $a_job_has_been_reassigned = false;
     if (count($eligible_not_busy_servers) > 0) {
         $eligible_not_busy_server = $eligible_not_busy_servers[rand(0, count($eligible_not_busy_servers) - 1)];
         $new_assigned_server = $eligible_not_busy_server;
         $assigned_servers[] = $new_assigned_server;
         $old_full_job_id = $this->id;
         $old_full_split = explode("@", $old_full_job_id);
         $old_server_name = $old_full_split[0];
         $old_job_id = $old_full_split[1];
         $new_full_job_id = $new_assigned_server . "@" . $old_job_id;
         if ($new_assigned_server != $old_server_name) {
             if ($mode_server) {
                 logger("REASSIGNING JOB " . $old_job_id . " TO:\n\t" . $new_assigned_server . "\n");
             } else {
                 echo "<div align='center' style='background-color:green;color:white;'>";
                 echo "REASSIGNING JOB " . $old_job_id . " TO:\n\t" . $new_assigned_server . "\n";
                 echo "</div>";
             }
             // UPDATE JOB ASSIGNMENT
             $job_obj = new job_id_user();
             $job_obj->get_from_hashrange($this->id_user, $old_full_job_id);
             if ($job_obj->id_status == "undefined") {
                 if ($mode_server) {
                     logger("\tJOB HAS ALREADY BEEN RE-ASSIGNED\n");
                     return;
                 } else {
                     echo "<div align='center' style='background-color:green;color:white;'>";
                     echo "\tJOB HAS ALREADY BEEN RE-ASSIGNED\n";
                     echo "</div>";
                 }
                 break;
             }
             $job_obj->delete_job_new();
             $job_obj->update(array("id" => $new_full_job_id, "dt_modified" => get_time()));
             $job_obj->delete_job_flags();
             //$job_obj->set($new_job);
             // UPDATE ANY PH_CHILD AND PH_PARENT ENTRIES
             // IF THIS JOB HAS CHANGED NAME (ASSIGNED TO A DIFFERENT SERVER), IT COULD
             // ONLY BE A CHILD NODE BEING RENAMED
             // UPDATE THE PH_CHILD ENTRY AND THEN THE PH_PARENT ENTRY THAT GOES ALONG WITH IT
             $find_ph_child = new ph_child();
             $find_ph_child->get_from_hashrange($old_full_job_id);
             if ($find_ph_child->id_child_job != "undefined") {
                 //echo "REASSIGNING CHILD";
                 // FIND ITS ASSOCIATED PARENT AND UPDATE
                 $find_ph_parent = new ph_parent();
                 $find_ph_parent->get_from_hashrange($find_ph_child->id_parent_job, $old_full_job_id);
                 if ($find_ph_parent->id_parent_job != "undefined") {
                     //echo "REASSIGNING parent";
                     // FIND ITS ASSOCIATED PARENT AND UPDATE
                     $find_ph_parent->update(array("id_child_job" => $new_full_job_id));
                 }
                 $find_ph_child->update(array("id_child_job" => $new_full_job_id));
             }
             // CREATE JOB_NEW TABLE ENTRY FOR JOBS TO BE FOUND
             if ($job_obj->id_status == "new") {
                 $job_obj->status_new();
             }
             $member_list = $this->member_list($this);
             foreach ($member_list as $member) {
                 $this->{$member} = $job_obj->{$member};
             }
             $a_job_has_been_reassigned = true;
             //break;
         }
         // END IF (OLD SERVER NAME != NEW SERVER NAME)
     }
     // END IF (COUNT OF ELIGIBLE NOT BUSY SERVERS > 0)
     if ($a_job_has_been_reassigned) {
         // A JOB HAS ALREADY BEEN SUCCESSFULLY RE-ASSIGNED, NOW EXIT LOOP TO GET TO THE CONTINUE STATEMENT BELOW
     }
     // END IF
     return $a_job_has_been_reassigned;
 }
Ejemplo n.º 4
0
            $PAGE->title = $PAGE->title . " " . $version_content . " ";
            $PAGE->title = $PAGE->title . getTranslation("update package", $settings);
            $PAGE->title = $PAGE->title . "</h1>";
            $PAGE->generate_headers_footers();
            $PAGE->body = $PAGE->body . "<p>";
            $PAGE->body = $PAGE->body . getTranslation("Update package was downloaded, extracted, and installed successfully.", $settings);
            $PAGE->body = $PAGE->body . "</p>";
            echo $PAGE->content();
            exit;
        }
    }
    // END IF (ACTION)
}
if (isset($_GET['action'])) {
    if ($_GET['action'] == "reassign-job") {
        if (isset($_POST['id'])) {
            $REASSIGN_JOB = new job_id_user();
            $REASSIGN_JOB->get_from_hashrange($u->id_user, $_POST['id']);
            if ($REASSIGN_JOB->id != "undefined") {
                $was_reassigned = $REASSIGN_JOB->reassign_auto();
                if (!$was_reassigned) {
                    echo "<div align='center' style='background-color:red;color:white;'>";
                    echo "Job was not reassigned.";
                    echo "</div>";
                }
            }
        }
        // END IF (ID SET)
    }
    // END IF (ACTION IS DELETE-JOB)
}
Ejemplo n.º 5
0
             logger("\t\t\t\tUpload failure\n");
         }
         // MOVED PARENT JOB = DONE TO BE AFTER PLACEHOLDER REPLACEMENTS
         $this_time_epoch = get_time();
         logger("\t\tDELETING ALL DESCENDANT CHILD JOBS\n");
         $PARENT_JOB->update(array("id_status" => "done", "dt_done" => $this_time_epoch, "dt_modified" => $this_time_epoch));
         $THIS_JOB->update(array("id_status" => "done"));
         $PARENT_JOB->delete_ph_decendants();
         $JID_MERGE_CHECK = $PARENT_JID;
     } else {
         $JID_MERGE_CHECK = "undefined";
         logger("\t\t\t" . "THERE ARE STILL OTHER JOBS THAT NEED TO BE COMPLETED\n");
         break;
     }
 } else {
     $THIS_JOB = new job_id_user();
     $THIS_JOB->get_from_hashrange($JOB->id_user, $JID_MERGE_CHECK);
     // THIS JOB WAS *NOT* RUN TO FILL A PLACEHOLDER IN AN OUTPUT ENTRY FROM ANOTHER JOB
     logger("\t\t" . "THIS JOB WAS *NOT* RUN TO FILL A PLACEHOLDER IN AN OUTPUT ENTRY FROM ANOTHER JOB\n");
     if ($THIS_JOB) {
         if ($THIS_JOB->id_status == 'done') {
             // this will be the case on direct runs
             // and also this will be the ending point on nested subjobs after having
             // traced up to the completed root of the job tree
             // $STDOUT = is the value that is posted to the output expression url
             $OUTPUT_STRING = new strings();
             $OUTPUT_STRING->get_from_hashrange($THIS_JOB->str_output);
             $OUTPUT_STRING->build();
             if (isset($OUTPUT_STRING->body)) {
                 if (strlen($OUTPUT_STRING->body) > 0) {
                     // in edit mode, this won't get hit
Ejemplo n.º 6
0
     echo "</table>";
 }
 // END IF (ANY UNFINISHED JOBS)
 if (count($unfinished_jobs) == 0) {
     echo getTranslation("No unfinished jobs found.", $settings);
 }
 echo "</ul>";
 echo "<form action='?v=job-servers' method='post'><input style='background-color:" . rcolor() . ";display:inline;' type='submit' value='";
 echo getTranslation("Refresh", $settings);
 echo "'/></form>";
 echo "</pre>";
 echo "</ul>";
 echo "</a>";
 foreach ($unfinished_jobs as &$unfinished_job) {
     $job_id = explode("#", $unfinished_job['id_status_job'])[1];
     $job_obj = new job_id_user();
     $job_obj->get_from_hashrange($u->id_user, $job_id);
     $check_is_child = new ph_child();
     $check_is_child->get_from_hashrange($job_obj->id);
     if ($check_is_child->id_child_job != "undefined") {
         $unfinished_job['id_parent_job'] = $check_is_child->id_parent_job;
     } else {
         $unfinished_job['id_parent_job'] = false;
     }
 }
 $new = array();
 foreach ($unfinished_jobs as $a) {
     $new[$a['id_parent_job']][] = $a;
 }
 $tree = array();
 if (count($new) > 0) {