use of abs.backend.java.lib.runtime.ABSObject in project abstools by abstools.
the class NodeImpl method migrateObject.
private synchronized boolean migrateObject() {
for (ABSObject o : objects) {
NetCOG cog = (NetCOG) o.getCOG();
if (!cogs.contains(cog)) {
NetNode node = router.getRouteEntry(cog).getNextNode();
objects.remove(o);
outArcs.get(node).getQueue().enqueue(new ObjectMsg(o));
return true;
}
}
return false;
}
use of abs.backend.java.lib.runtime.ABSObject in project abstools by abstools.
the class NodeImpl method processMsg.
@Override
public synchronized void processMsg(Msg m) {
if (m instanceof ObjectTargetMsg) {
ObjectTargetMsg otm = (ObjectTargetMsg) m;
if (objects.contains(otm.getTarget())) {
NetCOG cog = (NetCOG) otm.getTarget().getCOG();
cog.processMsg(m);
} else {
routeAway(m);
}
} else if (m instanceof COGMsg) {
COGMsg cm = (COGMsg) m;
NetCOG cog = cm.getCOG();
cog.setNode(this);
cogs.add(cog);
} else if (m instanceof ObjectMsg) {
ObjectMsg om = (ObjectMsg) m;
ABSObject object = om.getObject();
NetCOG cog = (NetCOG) object.getCOG();
if (cogs.contains(cog)) {
objects.add(object);
} else {
routeAway(m);
}
}
}
use of abs.backend.java.lib.runtime.ABSObject in project abstools by abstools.
the class DefaultRouter method update.
@Override
public void update(NetNode adjacentNode, Router adjacentNodeRouter) {
for (ABSObject object : adjacentNodeRouter.getRegisteredObjects()) {
RouteEntry otherEntry = adjacentNodeRouter.getRouteEntry(object);
DefaultRouteEntry newEntry = new DefaultRouteEntry(adjacentNode, otherEntry.getHops() + 1, adjacentNode);
if (routeForObject.containsKey(object)) {
DefaultRouteEntry currentEntry = routeForObject.get(object);
if (newEntry.getSourceNode() == currentEntry.getSourceNode() || newEntry.compareTo(currentEntry) < 0) {
routeForObject.put(object, newEntry);
}
} else {
routeForObject.put(object, newEntry);
}
}
for (NetCOG cog : adjacentNodeRouter.getRegisteredCOGs()) {
RouteEntry otherEntry = adjacentNodeRouter.getRouteEntry(cog);
DefaultRouteEntry newEntry = new DefaultRouteEntry(adjacentNode, otherEntry.getHops() + 1, adjacentNode);
if (routeForCOG.containsKey(cog)) {
DefaultRouteEntry currentEntry = routeForCOG.get(cog);
if (newEntry.getSourceNode() == currentEntry.getSourceNode() || newEntry.compareTo(currentEntry) < 0) {
routeForCOG.put(cog, newEntry);
}
} else {
routeForCOG.put(cog, newEntry);
}
}
}
use of abs.backend.java.lib.runtime.ABSObject in project abstools by abstools.
the class DefaultRouter method getNextNode.
@Override
public NetNode getNextNode(Msg m) {
if (m instanceof ObjectTargetMsg) {
ObjectTargetMsg om = (ObjectTargetMsg) m;
ABSObject target = om.getTarget();
if (routeForObject.containsKey(target)) {
return routeForObject.get(target).getNextNode();
} else {
return node.defaultRoute();
}
} else if (m instanceof ObjectMsg) {
ObjectMsg om = (ObjectMsg) m;
NetCOG target = om.getCOG();
if (routeForCOG.containsKey(target)) {
return routeForCOG.get(target).getNextNode();
} else {
return node.defaultRoute();
}
} else {
return node.defaultRoute();
}
}
use of abs.backend.java.lib.runtime.ABSObject in project abstools by abstools.
the class VariableContentProvider method getChildren.
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement != null) {
if (parentElement instanceof TaskStackFrameView) {
TaskStackFrameView stackFrame = (TaskStackFrameView) parentElement;
ArrayList<VariableValuePair> children = new ArrayList<VariableValuePair>();
for (String variableName : stackFrame.getVariableNames()) {
children.add(new VariableValuePair(variableName, stackFrame.getValue(variableName)));
}
return children.toArray();
} else if (parentElement instanceof ObjectView) {
ObjectView obj = (ObjectView) parentElement;
ArrayList<VariableValuePair> children = new ArrayList<VariableValuePair>();
for (String fieldName : obj.getFieldNames()) {
try {
children.add(new VariableValuePair(fieldName, obj.getFieldValue(fieldName)));
} catch (NoSuchFieldException e) {
// can never happen. Since we iterate over the field names, the field is guaranteed
// to exist as long as the objectView is implemented correctly.
}
}
return children.toArray();
} else if (parentElement instanceof VariableValuePair) {
return getChildren(((VariableValuePair) parentElement).getValue());
} else if (parentElement instanceof ABSObject) {
return getChildren(((ABSObject) parentElement).getView());
}
}
// single (or unknown) value - no children
return new Object[0];
}
Aggregations