Search in sources :

Example 11 with TopologyCluster

use of org.onosproject.net.topology.TopologyCluster in project onos by opennetworkinglab.

the class ClustersListCommand method doExecute.

@Override
protected void doExecute() {
    init();
    List<TopologyCluster> clusters = Lists.newArrayList(service.getClusters(topology));
    Collections.sort(clusters, Comparators.CLUSTER_COMPARATOR);
    if (outputJson()) {
        print("%s", json(clusters));
    } else {
        for (TopologyCluster cluster : clusters) {
            print(FMT, cluster.id().index(), cluster.deviceCount(), cluster.linkCount());
        }
    }
}
Also used : TopologyCluster(org.onosproject.net.topology.TopologyCluster)

Example 12 with TopologyCluster

use of org.onosproject.net.topology.TopologyCluster in project onos by opennetworkinglab.

the class DefaultTopology method isBroadcastPoint.

/**
 * Indicates whether the given point is part of a broadcast set.
 *
 * @param connectPoint connection point
 * @return true if in broadcast set
 */
public boolean isBroadcastPoint(ConnectPoint connectPoint) {
    if (broadcastFunction != null) {
        return broadcastFunction.apply(connectPoint);
    }
    // Any non-infrastructure, i.e. edge points are assumed to be OK.
    if (!isInfrastructure(connectPoint)) {
        return true;
    }
    // Find the cluster to which the device belongs.
    TopologyCluster cluster = clustersByDevice().get(connectPoint.deviceId());
    checkArgument(cluster != null, "No cluster found for device %s", connectPoint.deviceId());
    // If the broadcast set is null or empty, or if the point explicitly
    // belongs to it, return true.
    Set<ConnectPoint> points = broadcastSets.get().get(cluster.id());
    return isNullOrEmpty(points) || points.contains(connectPoint);
}
Also used : TopologyCluster(org.onosproject.net.topology.TopologyCluster) DefaultTopologyCluster(org.onosproject.net.topology.DefaultTopologyCluster) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 13 with TopologyCluster

use of org.onosproject.net.topology.TopologyCluster in project onos by opennetworkinglab.

the class DefaultTopology method buildIndexes.

// Builds cluster-devices, cluster-links and device-cluster indexes.
private ClusterIndexes buildIndexes() {
    // Prepare the index builders
    ImmutableMap.Builder<DeviceId, TopologyCluster> clusterBuilder = ImmutableMap.builder();
    ImmutableSetMultimap.Builder<TopologyCluster, DeviceId> devicesBuilder = ImmutableSetMultimap.builder();
    ImmutableSetMultimap.Builder<TopologyCluster, Link> linksBuilder = ImmutableSetMultimap.builder();
    // Now scan through all the clusters
    for (TopologyCluster cluster : clusters.get().values()) {
        int i = cluster.id().index();
        // Scan through all the cluster vertexes.
        for (TopologyVertex vertex : clusterResults.get().clusterVertexes().get(i)) {
            devicesBuilder.put(cluster, vertex.deviceId());
            clusterBuilder.put(vertex.deviceId(), cluster);
        }
        // Scan through all the cluster edges.
        for (TopologyEdge edge : clusterResults.get().clusterEdges().get(i)) {
            linksBuilder.put(cluster, edge.link());
        }
    }
    // Finalize all indexes.
    return new ClusterIndexes(clusterBuilder.build(), devicesBuilder.build(), linksBuilder.build());
}
Also used : DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) DeviceId(org.onosproject.net.DeviceId) TopologyCluster(org.onosproject.net.topology.TopologyCluster) DefaultTopologyCluster(org.onosproject.net.topology.DefaultTopologyCluster) TopologyEdge(org.onosproject.net.topology.TopologyEdge) ImmutableMap(com.google.common.collect.ImmutableMap) Link(org.onosproject.net.Link) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 14 with TopologyCluster

use of org.onosproject.net.topology.TopologyCluster in project onos by opennetworkinglab.

the class VirtualNetworkTopologyManagerTest method testGetClusterLinksUsingNullCluster.

/**
 * Test getClusterLinks() methods with a null cluster.
 */
@Test(expected = NullPointerException.class)
public void testGetClusterLinksUsingNullCluster() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    Set<TopologyCluster> clusters = topologyService.getClusters(topology);
    // test the getClusterLinks() method using a null cluster.
    Object[] objects = clusters.stream().toArray();
    assertNotNull("The cluster should not be null.", objects);
    Set<Link> clusterLinks = topologyService.getClusterLinks(topology, null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) Link(org.onosproject.net.Link) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 15 with TopologyCluster

use of org.onosproject.net.topology.TopologyCluster in project onos by opennetworkinglab.

the class VirtualNetworkTopologyManagerTest method testGetClusterDevicesLinks.

/**
 * Test getClusterDevices() and getClusterLinks() methods.
 */
@Test
public void testGetClusterDevicesLinks() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    Set<TopologyCluster> clusters = topologyService.getClusters(topology);
    assertNotNull("The clusters should not be null.", clusters);
    assertEquals("The clusters size did not match.", 2, clusters.size());
    // test the getClusterDevices() method.
    Object[] objects = clusters.stream().toArray();
    assertNotNull("The cluster should not be null.", objects);
    Set<DeviceId> clusterDevices = topologyService.getClusterDevices(topology, (TopologyCluster) objects[0]);
    assertNotNull("The devices should not be null.", clusterDevices);
    assertEquals("The devices size did not match.", 3, clusterDevices.size());
    Set<DeviceId> clusterDevices1 = topologyService.getClusterDevices(topology, (TopologyCluster) objects[1]);
    assertNotNull("The devices should not be null.", clusterDevices1);
    assertEquals("The devices size did not match.", 1, clusterDevices1.size());
    // test the getClusterLinks() method.
    Set<Link> clusterLinks = topologyService.getClusterLinks(topology, (TopologyCluster) objects[0]);
    assertNotNull("The links should not be null.", clusterLinks);
    assertEquals("The links size did not match.", 6, clusterLinks.size());
    Set<Link> clusterLinks1 = topologyService.getClusterLinks(topology, (TopologyCluster) objects[1]);
    assertNotNull("The links should not be null.", clusterLinks1);
    assertEquals("The links size did not match.", 0, clusterLinks1.size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceId(org.onosproject.net.DeviceId) Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) Link(org.onosproject.net.Link) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Aggregations

TopologyCluster (org.onosproject.net.topology.TopologyCluster)19 Topology (org.onosproject.net.topology.Topology)11 TopologyService (org.onosproject.net.topology.TopologyService)10 Test (org.junit.Test)7 DeviceId (org.onosproject.net.DeviceId)6 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)5 Link (org.onosproject.net.Link)5 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 ConnectPoint (org.onosproject.net.ConnectPoint)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 DefaultTopologyCluster (org.onosproject.net.topology.DefaultTopologyCluster)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)2 DefaultTopologyVertex (org.onosproject.net.topology.DefaultTopologyVertex)2 TopologyEdge (org.onosproject.net.topology.TopologyEdge)2 TopologyVertex (org.onosproject.net.topology.TopologyVertex)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1