X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fsirius%2Findex.php;h=c260926785082a811c47bf7a6a0472779b64ff3f;hb=697e97edba1f53dfdbce4bd96f33fd6fb4190a82;hp=37559f64526e4b4d41a07825bae81eb17994da1d;hpb=0cb2c76e7edefb470f85482b548c313614008da4;p=plewww.git diff --git a/planetlab/sirius/index.php b/planetlab/sirius/index.php index 37559f6..c260926 100644 --- a/planetlab/sirius/index.php +++ b/planetlab/sirius/index.php @@ -28,12 +28,12 @@ include 'plc_header.php'; You can choose to run your experiment at the earliest available time or give a specific time. The number of repetitions has the following meaning: if you want your job re-inserted on the -schedule list (in the earliest slot available) directly after it -gets a priority increase, you can do so (up to 4 times). Currently, -our admission control policy is that we +schedule list (in the earliest slot available) directly after it +gets a priority increase, you can do so (up to 4 times). Currently, +our admission control policy is that we allow only one slice per time slot.

-Currently, +Currently, time slots are only allocated on the granularity of an hour, and only CPU is increased. @@ -62,7 +62,7 @@ function authorizeSlice($sn) { $username = $_SESSION['username']; $password = $_SESSION['password']; - + $_api->setDebug(0); $_api_auth = new xmlrpcval(array( @@ -70,7 +70,7 @@ function authorizeSlice($sn) { "Username" => new xmlrpcval($username), "AuthString" => new xmlrpcval($password), "Role" => new xmlrpcval("user")), "struct"); - + $func = new xmlrpcmsg("SliceInfo"); $func->addParam($_api_auth); @@ -106,9 +106,9 @@ function authorizeSlice($sn) { } } */ - + global $api; - + $slice_list= array(); $result= $api->GetSlices( Null, array( "name" ) ); @@ -116,16 +116,16 @@ function authorizeSlice($sn) { { if ( $slice["name"] == $sn ) return 1; - + } - + return 0; - + } //can a request be satisfied? Currently, answer is yes unless //either this time is taken or you asked for more than one unit -//probably will need to change this. +//probably will need to change this. function validateRequest ($units, $timesOccupied, $requestedTime, $currentTime) { if ($units != 1) return TOO_MANY_UNITS; @@ -144,7 +144,7 @@ function validateRequest ($units, $timesOccupied, $requestedTime, $currentTime) //can a request be satisfied? Currently, answer is yes unless //either this time is taken or you asked for more than one unit -//probably will need to change this. +//probably will need to change this. function validateAndMarkRequest ($units, &$timesOccupied, $requestedTime, $currentTime, $sn, $jobArray) { // buffer so we aren't too close to deadline, if your request is late // OR if it's within 1 minute of deadline, it's too late @@ -176,7 +176,7 @@ function findNextFreeSlot($units, $timesOccupied) { $currMonth = gmdate("m"); $currDate = gmdate("d"); $currHour = gmdate("H") + 1; - $currentTime = gmmktime(); + $currentTime = time(); $reqTime = gmmktime($currHour, 0, 0, $currMonth, $currDate, $currYear); $retVal = 1; while ($retVal != SUCCESS) { @@ -198,7 +198,7 @@ function dumpToFile($fileName, $buffer, $which, $timesOccupied) { //lock in case of concurrent accesses flock($fileHandle, LOCK_EX); - + if ($which == "schedule") { // need to write timestamp in this case $s = gettimeofday(); fwrite($fileHandle, $s[sec]); @@ -208,8 +208,8 @@ function dumpToFile($fileName, $buffer, $which, $timesOccupied) { //do the dump here foreach ($buffer as $value) { $t = ""; - if ($which == "schedule") { - if (strcmp($value["timestamp"], mktime()) > 0) { + if ($which == "schedule") { + if (strcmp($value["timestamp"], time()) > 0) { $numReps = $value["reps"]; $ts = $value["timestamp"]; $t = $value["sliceName"]." ".$value["id"]." ".$value["timestamp"]." ".$value["units"]." ".$value["reps"]." \n"; @@ -243,13 +243,13 @@ function updateSliceFile($name, $units) { $sliceFile = fopen("/var/www/html/planetlab/sirius/slices.txt", "rw"); if (!$sliceFile) { - echo "

Unable to open remote file.

"; - + echo "

Unable to open remote file.

"; + } flock($sliceFile, LOCK_EX); - //we'll construct a new list here, will be current slice file except + //we'll construct a new list here, will be current slice file except //the slice in question will have it's units decreased, if there are any... while (!feof($sliceFile)) { $num = fscanf($sliceFile, "%s %d\n", $sliceName, $unitsAvailable); @@ -280,13 +280,13 @@ function updateSliceFile($name, $units) { //pretty obvious what this does; basically, does the slice exist in -//the slice file yet? (New user of calendar service user may not have +//the slice file yet? (New user of calendar service user may not have //an entry) function isFirstSliceRequest($name) { $sliceFile = fopen("/var/www/html/planetlab/sirius/slices.txt", "r"); if (!$sliceFile) { - echo "

Unable to open remote file.

"; - + echo "

Unable to open remote file.

"; + } flock($sliceFile, LOCK_EX); @@ -347,8 +347,8 @@ function getCurrentSchedule (&$jobArray, &$timesOccupied, &$maxId) { $schedFile = fopen("/var/www/html/planetlab/sirius/schedule.txt", "r"); if (!$schedFile) { - echo "

Unable to open remote file.

"; - + echo "

Unable to open remote file.

"; + } flock($schedFile, LOCK_EX); @@ -393,7 +393,7 @@ function getCurrentSchedule (&$jobArray, &$timesOccupied, &$maxId) { } // Reid: after below function call, you have the current schedule. -// It is stored in $jobArray, which is an array of arrays. +// It is stored in $jobArray, which is an array of arrays. // Layout: each element of $jobArray is an array with // the following fields. // "sliceName": the name of the slice that occupies the slot @@ -434,14 +434,14 @@ if (isset($_POST['action']) && $_POST['action'] == 'submitted') { if (array_key_exists($sname, $jobArray)) { $changeMade = 1; $ts = $jobArray[$sname]["timestamp"]; - if ($ts - mktime() < DELETE_THRESHOLD) + if ($ts - time() < DELETE_THRESHOLD) $requestStatus = TOO_CLOSE_TO_DEADLINE; else { $timesOccupied[$ts]--; unset($jobArray[$sname]); } } - else + else $requestStatus = NO_SUCH_SLICE; } @@ -453,8 +453,8 @@ if (isset($_POST['action']) && $_POST['action'] == 'submitted') { $reps = $_POST['reps']; // $u = $_POST['units']; $u = 1; - - $currentTime = mktime(); + + $currentTime = time(); if ($_POST['whenToRun'] == "asap") { $requestedTime = findNextFreeSlot($u, $timesOccupied); @@ -481,20 +481,20 @@ if (isset($_POST['action']) && $_POST['action'] == 'submitted') { $requestedTime = gmmktime($hour, 0, 0, $currMonth, $currDate, $currYear); } } - + $id = $maxId + 1; - + $requestStatus = validateAndMarkRequest($u, $timesOccupied, $requestedTime, $currentTime, $sname, $jobArray); if ($requestStatus == SUCCESS) { // ignore below, it is for future work anyways. if (isFirstSliceRequest($sname)) { $sliceFile = fopen("/var/www/html/planetlab/sirius/slices.txt", "a"); if ($sliceFile == 0) { - echo "

Unable to open file.

"; - + echo "

Unable to open file.

"; + } flock($sliceFile, LOCK_EX); - + // should be max number of units, not 5 // why is this 6? fwrite($sliceFile, $sname." "."6"); @@ -504,9 +504,9 @@ if (isset($_POST['action']) && $_POST['action'] == 'submitted') { // if (updateSliceFile($sname, 1) < 0) // temporarily not looking at units... if (0) - $requestStatus = NO_UNITS_LEFT; + $requestStatus = NO_UNITS_LEFT; else { - // here, pretty simple, just stick all data into + // here, pretty simple, just stick all data into // array element, then stick array into $jobArray. $newArray["sliceName"] = $sname; $newArray["id"] = $id; @@ -521,7 +521,7 @@ if (isset($_POST['action']) && $_POST['action'] == 'submitted') { } //sort job array by earliest time first ("cmp" function does this) -usort($jobArray, "cmp"); +usort($jobArray, "cmp"); // Reid: after this above line, $jobArray holds a sorted list that // you can output as the queue. @@ -549,7 +549,7 @@ $deletedExpiredJob = 0; $arr= array(); $n= 0; foreach ($jobArray as $value) { - if (strcmp($value["timestamp"], mktime()) > 0) { + if (strcmp($value["timestamp"], time()) > 0) { printf("\n"); printf(" %s %d %s \n", $value["sliceName"], $value["reps"], gmdate("r", $value["timestamp"])); $arr[$n]= $value["sliceName"]; @@ -565,7 +565,7 @@ echo "
\n"; // Reid: end of current printing of the schedule. // Reid: here is where we put the data back to the schedule file. -// It's already a function, +// It's already a function, function findNextQueue($units, $timesOccupied, $arr) { @@ -573,16 +573,16 @@ function findNextQueue($units, $timesOccupied, $arr) { $currMonth = gmdate("m"); $currDate = gmdate("d"); $currHour = gmdate("H") + 1; - $currentTime = gmmktime(); + $currentTime = time(); $reqTime = gmmktime($currHour, 0, 0, $currMonth, $currDate, $currYear); $retVal = 1; $i = 0; - + // DAVE // outputting table to display the queue // green background will mean slot is open, and red will mean the slot is used - // + // echo "\n"; echo "\n"; echo "
24 hour Queue: Choose the GMT time slot you desire (green slots are open, red are taken)

\n"; @@ -595,7 +595,7 @@ function findNextQueue($units, $timesOccupied, $arr) { while ($i < 12) { $retVal = validateRequest($units, $timesOccupied, $reqTime, $currentTime); if ($retVal == SUCCESS) { // advance timestamp one hour (3600 seconds) - + echo "\n"; } else { @@ -633,7 +633,7 @@ function sliceDropDown() { $username = $_SESSION['username']; $password = $_SESSION['password']; - + $_api->setDebug(0); $_api_auth = new xmlrpcval(array( @@ -641,12 +641,12 @@ function sliceDropDown() { "Username" => new xmlrpcval($username), "AuthString" => new xmlrpcval($password), "Role" => new xmlrpcval("user")), "struct"); - + $func = new xmlrpcmsg("SliceInfo"); $func->addParam($_api_auth); $result = $_api->send($func, 15, 'https'); - + if( $result == 0 ) { // printf("problem: %s\n", $_api->errstring); return 0; @@ -670,7 +670,7 @@ function sliceDropDown() { $i = 0; while ($i < $numElements) { echo "\n"; - + $i++; } return 0; @@ -678,7 +678,7 @@ function sliceDropDown() { } */ global $api; - + $slice_list= array(); $result= $api->GetSlices( Null, array( "name" ) ); @@ -691,9 +691,9 @@ function sliceDropDown() { foreach ( $result AS $slice ) { echo "
" . gmdate("H:i:s", $reqTime) . "