Commit 7b355473 authored by Jonathon Duerig's avatar Jonathon Duerig

Robustness improvements. Merging with other changes.

parent 729b7fe7
......@@ -316,16 +316,38 @@ package
return result;
}
public function changeState(cmIndex : int, newState : int) : void
public function changeState(cmIndex : int, oldState : int,
newState : int) : void
{
var i : int = 0;
for (; i < nodes.length; ++i)
{
if (nodes[i].calculateState() == oldState)
{
nodes[i].changeState(cmIndex, newState);
}
}
updateSelectText();
}
public function revertState(cmIndex : int) : void
{
var i : int = 0;
for (; i < nodes.length; ++i)
{
nodes[i].revertState(cmIndex);
}
}
public function commitState(cmIndex : int) : void
{
var i : int = 0;
for (; i < nodes.length; ++i)
{
nodes[i].commitState(cmIndex);
}
}
public function existsState(cmIndex : int, newState : int) : Boolean
{
var result : Boolean = false;
......@@ -354,15 +376,13 @@ package
static var NO_SELECTION : int = -1;
public static var PLANNED : int = 0;
public static var PENDING : int = 1;
public static var CREATED : int = 2;
public static var BOOTED : int = 3;
public static var FAILED : int = 4;
public static var CREATED : int = 1;
public static var BOOTED : int = 2;
public static var PENDING : int = 3;
public static var statusText = new Array("Planned",
"Pending",
"Created",
"Booted",
"Failed");
"Pending");
}
}
......@@ -104,7 +104,7 @@ package
if (newRequest != null)
{
queue.push(newRequest);
nodes.changeState(i, ActiveNodes.PENDING);
// nodes.changeState(i, ActiveNodes.PENDING);
if (! working)
{
start();
......
......@@ -49,7 +49,9 @@ package
renumber(newNumber);
links = new Array();
changeState(cmIndex, ActiveNodes.PLANNED);
oldState = ActiveNodes.PLANNED;
newState = ActiveNodes.PLANNED;
updateState();
}
public function cleanup() : void
......@@ -140,15 +142,50 @@ package
return cmIndex;
}
public function changeState(index : int, newState : int) : void
public function changeState(index : int, state : int) : void
{
if (index == cmIndex)
{
clip.node.nameField.backgroundColor = stateColor[newState];
state = newState;
newState = state;
updateState();
}
}
public function commitState(index : int) : void
{
if (index == cmIndex)
{
oldState = newState;
updateState();
}
}
public function revertState(index : int) : void
{
if (index == cmIndex)
{
newState = oldState;
updateState();
}
}
public function calculateState() : int
{
var state : int = newState;
if (newState != oldState)
{
state = ActiveNodes.PENDING;
}
return state;
}
public function updateState() : void
{
var state : int = calculateState();
clip.node.nameField.backgroundColor = stateColor[state];
}
public function getXml(targetIndex : int) : XML
{
var result : XML = null;
......@@ -165,11 +202,13 @@ package
public function isState(index : int, exemplar : int) : Boolean
{
var state : int = calculateState();
return index == cmIndex && state == exemplar;
}
public function getStatusText() : String
{
var state : int = calculateState();
var result : String = "";
result += "<font color=\"#7777ff\">Name:</font> " + name + "\n";
result += "<font color=\"#7777ff\">UUID:</font> " + id + "\n";
......@@ -179,6 +218,11 @@ package
{
result += "<font color=\"#7777ff\">Status:</font> "
+ ActiveNodes.statusText[state];
if (state == ActiveNodes.PENDING)
{
result += ": " + ActiveNodes.statusText[oldState] + " -> "
+ ActiveNodes.statusText[newState];
}
}
return result;
}
......@@ -192,7 +236,8 @@ package
var links : Array;
var mouseDownNode : Function;
var mouseDownLink : Function;
var state : int;
var oldState : int;
var newState : int;
static var virtType = "emulab-vnode";
......@@ -203,9 +248,9 @@ package
public static var CENTER_Y : int = Math.floor(HEIGHT/2);
static var stateColor = new Array(0xaaaaff,
0xaaaaaa,
0xaaffaa,
0xaaffff,
0xffaaaa);
0xaaaaaa);
// 0xffaaaa);
}
}
......@@ -36,6 +36,7 @@ package
{
if (cm.getTicket(cmIndex) == null)
{
nodes.changeState(cmIndex, ActiveNodes.PLANNED, ActiveNodes.CREATED);
opName = "Getting Ticket";
op.reset(Geni.getTicket);
op.addField("credential", credential.slice);
......@@ -68,21 +69,26 @@ package
}
else
{
nodes.changeState(cmIndex, ActiveNodes.CREATED);
nodes.commitState(cmIndex);
credential.slivers[cmIndex] = response.value;
cm.setTicket(cmIndex, null);
}
}
else
{
nodes.changeState(cmIndex, ActiveNodes.FAILED);
if (cm.getTicket(cmIndex) != null)
{
// TODO: DeleteTicket
}
nodes.revertState(cmIndex);
}
return result;
}
override public function fail() : void
{
nodes.changeState(cmIndex, ActiveNodes.FAILED);
// TODO: DeleteTicket
nodes.revertState(cmIndex);
}
var cmIndex : int;
......
......@@ -34,6 +34,8 @@ package
{
// TODO: Check to make sure that credential.slivers[cmIndex]
// exists and perform a no-op if it doesn't.
nodes.changeState(cmIndex, ActiveNodes.CREATED, ActiveNodes.PLANNED);
nodes.changeState(cmIndex, ActiveNodes.BOOTED, ActiveNodes.PLANNED);
opName = "Deleting Sliver";
op.reset(Geni.deleteSliver);
op.addField("credential", credential.slivers[cmIndex]);
......@@ -47,11 +49,11 @@ package
{
if (code == 0)
{
nodes.changeState(cmIndex, ActiveNodes.PLANNED);
nodes.commitState(cmIndex);
}
else
{
nodes.changeState(cmIndex, ActiveNodes.FAILED);
nodes.revertState(cmIndex);
}
credential.slivers[cmIndex] = null;
return null;
......
......@@ -32,6 +32,7 @@ package
override public function start(credential : Credential) : Operation
{
nodes.changeState(cmIndex, ActiveNodes.CREATED, ActiveNodes.BOOTED);
opName = "Booting Sliver";
op.reset(Geni.startSliver);
op.addField("credential", credential.slivers[cmIndex]);
......@@ -45,11 +46,11 @@ package
{
if (code == 0)
{
nodes.changeState(cmIndex, ActiveNodes.BOOTED);
nodes.commitState(cmIndex);
}
else
{
nodes.changeState(cmIndex, ActiveNodes.FAILED);
nodes.revertState(cmIndex);
}
return null;
}
......
......@@ -34,6 +34,7 @@ package
override public function start(credential : Credential) : Operation
{
nodes.changeState(cmIndex, ActiveNodes.PLANNED, ActiveNodes.CREATED);
opName = "Updating Sliver";
op.reset(Geni.updateSliver);
op.addField("credential", credential.slivers[cmIndex]);
......@@ -48,11 +49,11 @@ package
{
if (code == 0)
{
nodes.changeState(cmIndex, ActiveNodes.CREATED);
nodes.commitState(cmIndex);
}
else
{
nodes.changeState(cmIndex, ActiveNodes.FAILED);
nodes.revertState(cmIndex);
}
return null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment