Search in sources :

Example 1 with UiClusterMember

use of org.onosproject.ui.model.topo.UiClusterMember in project onos by opennetworkinglab.

the class ModelCache method addOrUpdateClusterMember.

// invoked from UiSharedTopologyModel cluster event listener
void addOrUpdateClusterMember(ControllerNode cnode) {
    NodeId id = cnode.id();
    String memo = MEMO_UPDATED;
    UiClusterMember member = uiTopology.findClusterMember(id);
    if (member == null) {
        member = addNewClusterMember(cnode);
        memo = MEMO_ADDED;
    }
    updateClusterMember(member);
    postEvent(CLUSTER_MEMBER_ADDED_OR_UPDATED, member, memo);
}
Also used : NodeId(org.onosproject.cluster.NodeId) UiClusterMember(org.onosproject.ui.model.topo.UiClusterMember)

Example 2 with UiClusterMember

use of org.onosproject.ui.model.topo.UiClusterMember in project onos by opennetworkinglab.

the class ModelCache method removeClusterMember.

// invoked from UiSharedTopologyModel cluster event listener
void removeClusterMember(ControllerNode cnode) {
    NodeId id = cnode.id();
    UiClusterMember member = uiTopology.findClusterMember(id);
    if (member != null) {
        uiTopology.remove(member);
        postEvent(CLUSTER_MEMBER_REMOVED, member, MEMO_REMOVED);
    } else {
        log.warn(E_NO_ELEMENT, "cluster node", id);
    }
}
Also used : NodeId(org.onosproject.cluster.NodeId) UiClusterMember(org.onosproject.ui.model.topo.UiClusterMember)

Example 3 with UiClusterMember

use of org.onosproject.ui.model.topo.UiClusterMember in project onos by opennetworkinglab.

the class Topo2Jsonifier method instances.

/**
 * Returns a JSON representation of the cluster members (ONOS instances).
 *
 * @param instances the instance model objects
 * @return a JSON representation of the data
 */
ObjectNode instances(List<UiClusterMember> instances) {
    NodeId local = clusterService.getLocalNode().id();
    ObjectNode payload = objectNode();
    ArrayNode members = arrayNode();
    payload.set("members", members);
    for (UiClusterMember member : instances) {
        members.add(json(member, member.id().equals(local)));
    }
    return payload;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) NodeId(org.onosproject.cluster.NodeId) UiClusterMember(org.onosproject.ui.model.topo.UiClusterMember) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 4 with UiClusterMember

use of org.onosproject.ui.model.topo.UiClusterMember in project onos by opennetworkinglab.

the class ModelCacheTest method addNodeThenExamineIt.

@Test
public void addNodeThenExamineIt() {
    title("addNodeThenExamineIt");
    cache.addOrUpdateClusterMember(CNODE_1);
    dispatcher.assertLast(Type.CLUSTER_MEMBER_ADDED_OR_UPDATED, C1);
    UiClusterMember member = cache.accessClusterMember(nodeId(C1));
    print(member);
    // see AbstractUiImplTest Mock Environment for expected values...
    assertEquals("wrong id str", C1, member.idAsString());
    assertEquals("wrong id", nodeId(C1), member.id());
// TODO make assertions through the cluster service; state no longer
// cached in the UiModel...
// assertEquals("not online", true, member.isOnline());
// assertEquals("not ready", true, member.isReady());
}
Also used : UiClusterMember(org.onosproject.ui.model.topo.UiClusterMember) Test(org.junit.Test)

Example 5 with UiClusterMember

use of org.onosproject.ui.model.topo.UiClusterMember in project onos by opennetworkinglab.

the class ModelCache method addNewClusterMember.

// === CLUSTER MEMBERS
private UiClusterMember addNewClusterMember(ControllerNode n) {
    UiClusterMember member = new UiClusterMember(uiTopology, n);
    uiTopology.add(member);
    return member;
}
Also used : UiClusterMember(org.onosproject.ui.model.topo.UiClusterMember)

Aggregations

UiClusterMember (org.onosproject.ui.model.topo.UiClusterMember)6 NodeId (org.onosproject.cluster.NodeId)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Test (org.junit.Test)1 ControllerNode (org.onosproject.cluster.ControllerNode)1