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. <p>
-Currently,
+Currently,
time slots are only allocated on the granularity
of an hour, and
only CPU is increased.
$username = $_SESSION['username'];
$password = $_SESSION['password'];
-
+
$_api->setDebug(0);
$_api_auth = new xmlrpcval(array(
"Username" => new xmlrpcval($username),
"AuthString" => new xmlrpcval($password),
"Role" => new xmlrpcval("user")), "struct");
-
+
$func = new xmlrpcmsg("SliceInfo");
$func->addParam($_api_auth);
}
}
*/
-
+
global $api;
-
+
$slice_list= array();
$result= $api->GetSlices( Null, array( "name" ) );
{
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;
//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
$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) {
//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]);
//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";
$sliceFile = fopen("/var/www/html/planetlab/sirius/slices.txt", "rw");
if (!$sliceFile) {
- echo "<p>Unable to open remote file.</p>";
-
+ echo "<p>Unable to open remote file.</p>";
+
}
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);
//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 "<p>Unable to open remote file.</p>";
-
+ echo "<p>Unable to open remote file.</p>";
+
}
flock($sliceFile, LOCK_EX);
$schedFile = fopen("/var/www/html/planetlab/sirius/schedule.txt", "r");
if (!$schedFile) {
- echo "<p>Unable to open remote file.</p>";
-
+ echo "<p>Unable to open remote file.</p>";
+
}
flock($schedFile, LOCK_EX);
}
// 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
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;
}
$reps = $_POST['reps'];
// $u = $_POST['units'];
$u = 1;
-
- $currentTime = mktime();
+
+ $currentTime = time();
if ($_POST['whenToRun'] == "asap") {
$requestedTime = findNextFreeSlot($u, $timesOccupied);
$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 "<p>Unable to open file.</p>";
-
+ echo "<p>Unable to open file.</p>";
+
}
flock($sliceFile, LOCK_EX);
-
+
// should be max number of units, not 5
// why is this 6?
fwrite($sliceFile, $sname." "."6");
// 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;
}
//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.
$arr= array();
$n= 0;
foreach ($jobArray as $value) {
- if (strcmp($value["timestamp"], mktime()) > 0) {
+ if (strcmp($value["timestamp"], time()) > 0) {
printf("<tr>\n");
printf("<td> %s </td><td align=center> %d </td><td> %s </td>\n", $value["sliceName"], $value["reps"], gmdate("r", $value["timestamp"]));
$arr[$n]= $value["sliceName"];
// 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) {
$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 "<table cellspacing=\"2\" cellpadding=\"1\" border=\"0\" width=550>\n";
echo "<tr><td colspan=\"3\"><span class='bold'>24 hour Queue:</span> Choose the GMT time slot you desire (<font color=\"#339933\">green</font> slots are open, <font color=\"#CC3333\">red</font> are taken) <p></td></tr>\n";
echo "<tr><td width=\"47%\" align=\"right\"><table cellspacing=1 cellpadding=1 border=0 width=130>\n";
while ($i < 12) {
$retVal = validateRequest($units, $timesOccupied, $reqTime, $currentTime);
if ($retVal == SUCCESS) { // advance timestamp one hour (3600 seconds)
-
+
echo "<tr bgcolor=\"#339933\"><td><input type=\"radio\" name=\"queue_time\" value=\"" . gmdate("H:i:s", $reqTime) . "\"> " . gmdate("H:i:s", $reqTime) . " </td></tr>\n";
}
else {
$username = $_SESSION['username'];
$password = $_SESSION['password'];
-
+
$_api->setDebug(0);
$_api_auth = new xmlrpcval(array(
"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;
$i = 0;
while ($i < $numElements) {
echo "<option value='" . $arr[$i][name] . "'>" . $arr[$i][name] . "</option>\n";
-
+
$i++;
}
return 0;
}
*/
global $api;
-
+
$slice_list= array();
$result= $api->GetSlices( Null, array( "name" ) );
foreach ( $result AS $slice )
{
echo "<option value='" . $slice["name"] . "'>" . $slice["name"] . "\n";
-
+
}
-
+
}
//reopen schedule file, and dump newly sorted job list into it
//note that current timestamp is put in at beginning
// hack here...the problem is that the file might not be sorted
// when it should, because of the stupid way it was designed. this
- // happens when reps is not 0, and the next entry should go after
+ // happens when reps is not 0, and the next entry should go after
// another entry. what does happen is that it goes before, which is
// fine for displaying, but the sirius service code expects it to
// always be sorted, "it" being the schedule file
$hackArray = array();
getCurrentSchedule ($hackArray, $timesOccupied, $maxId);
- usort($hackArray, "cmp");
+ usort($hackArray, "cmp");
dumpToFile("/var/www/html/planetlab/sirius/schedule.txt", $hackArray, "schedule", $timesOccupied);
}
<p>
Only enter a time/date here if your request is for a time more than 24 hours from now.<br>
-Year (two digits) <input type=text maxlength=2 size=2 name="year"/>
-Month (1-12) <input type=text maxlength=2 size=2 name="month"/>
-Date (1-31) <input type=text maxlength=2 size=2 name="date"/>
-Hour (0-23) <input type=text maxlength=2 size=2 name="hour"/>
+Year (two digits) <input type=text maxlength=2 size=2 name="year"/>
+Month (1-12) <input type=text maxlength=2 size=2 name="month"/>
+Date (1-31) <input type=text maxlength=2 size=2 name="date"/>
+Hour (0-23) <input type=text maxlength=2 size=2 name="hour"/>
<p>
<!--Units <input type=text maxlength=2 size=2 name="units"/>-->
<!--<p>-->