Search in sources :

Example 1 with ABSObject

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

Example 2 with ABSObject

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);
        }
    }
}
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 ABSObject

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

Example 4 with ABSObject

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

Example 5 with ABSObject

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];
}
Also used : VariableValuePair(org.absmodels.abs.plugin.debug.model.VariableValuePair) ArrayList(java.util.ArrayList) ABSObject(abs.backend.java.lib.runtime.ABSObject) ABSObject(abs.backend.java.lib.runtime.ABSObject) TaskStackFrameView(abs.backend.java.observing.TaskStackFrameView) ObjectView(abs.backend.java.observing.ObjectView)

Aggregations

ABSObject (abs.backend.java.lib.runtime.ABSObject)5 ObjectMsg (abs.backend.java.lib.net.msg.ObjectMsg)3 ObjectTargetMsg (abs.backend.java.lib.net.msg.ObjectTargetMsg)2 COGMsg (abs.backend.java.lib.net.msg.COGMsg)1 ObjectView (abs.backend.java.observing.ObjectView)1 TaskStackFrameView (abs.backend.java.observing.TaskStackFrameView)1 ArrayList (java.util.ArrayList)1 VariableValuePair (org.absmodels.abs.plugin.debug.model.VariableValuePair)1