Search in sources :

Example 1 with ObjectMsg

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;
}
Also used : ABSObject(abs.backend.java.lib.runtime.ABSObject) ObjectMsg(abs.backend.java.lib.net.msg.ObjectMsg)

Example 2 with ObjectMsg

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);
        }
    }
}
Also used : ObjectTargetMsg(abs.backend.java.lib.net.msg.ObjectTargetMsg) COGMsg(abs.backend.java.lib.net.msg.COGMsg) ABSObject(abs.backend.java.lib.runtime.ABSObject) ObjectMsg(abs.backend.java.lib.net.msg.ObjectMsg)

Example 3 with ObjectMsg

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);
}
Also used : ObjectMsg(abs.backend.java.lib.net.msg.ObjectMsg) Test(org.junit.Test)

Example 4 with ObjectMsg

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);
}
Also used : ObjectMsg(abs.backend.java.lib.net.msg.ObjectMsg) Test(org.junit.Test)

Example 5 with ObjectMsg

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);
}
Also used : ObjectMsg(abs.backend.java.lib.net.msg.ObjectMsg) Test(org.junit.Test)

Aggregations

ObjectMsg (abs.backend.java.lib.net.msg.ObjectMsg)6 ABSObject (abs.backend.java.lib.runtime.ABSObject)3 Test (org.junit.Test)3 ObjectTargetMsg (abs.backend.java.lib.net.msg.ObjectTargetMsg)2 COGMsg (abs.backend.java.lib.net.msg.COGMsg)1