use of abs.backend.java.lib.net.msg.ObjectMsg 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.net.msg.ObjectMsg 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.net.msg.ObjectMsg in project abstools by abstools.
the class DefaultRouterTest method nextNodeBasedOnCOG.
@Test
public void nextNodeBasedOnCOG() {
ObjectMsg msg = createMock(ObjectMsg.class);
currentRouter.replace(cog1, node2, 1);
expect(msg.getCOG()).andReturn(cog1);
replay(msg);
assertEquals("next node must be node2", node2, currentRouter.getNextNode(msg));
verify(msg);
}
use of abs.backend.java.lib.net.msg.ObjectMsg in project abstools by abstools.
the class NodeImplTest method processObjectMsgOnNode.
@Test
public void processObjectMsgOnNode() {
ObjectMsg msg = createMock(ObjectMsg.class);
currentNode.registerCOG(cog);
expect(msg.getObject()).andReturn(object);
expect(msg.getCOG()).andReturn(cog);
currentRouter.replace(object, currentNode, 0);
expectLastCall();
replay(msg);
replay(object);
replay(currentRouter);
currentNode.processMsg(msg);
assertTrue("object must be at node", currentNode.getRegisteredObjects().contains(object));
verify(msg);
verify(cog);
verify(currentRouter);
}
use of abs.backend.java.lib.net.msg.ObjectMsg in project abstools by abstools.
the class NodeImplTest method processObjectMsgNotOnNode.
@Test
public void processObjectMsgNotOnNode() {
ObjectMsg msg = createMock(ObjectMsg.class);
expect(msg.getObject()).andReturn(object);
expect(msg.getCOG()).andReturn(cog);
expect(currentRouter.getNextNode(msg)).andReturn(otherNode);
expect(arc.getQueue()).andReturn(queue);
queue.enqueue(msg);
expectLastCall();
replay(msg);
replay(object);
replay(currentRouter);
replay(arc);
replay(queue);
currentNode.processMsg(msg);
verify(msg);
verify(object);
verify(currentRouter);
verify(arc);
verify(queue);
}
Aggregations