Search in sources :

Example 91 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method testGetIngressLinks.

@Test
public final void testGetIngressLinks() {
    final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
    final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
    LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
    LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1);
    LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3));
    putLink(linkId1, DIRECT);
    putLink(linkId2, DIRECT);
    putLink(linkId3, DIRECT);
    // DID1,P1 => DID2,P2
    // DID2,P2 => DID1,P1
    // DID1,P2 => DID2,P3
    Set<Link> links1 = linkStore.getIngressLinks(d2P2);
    assertEquals(1, links1.size());
    assertLink(linkId1, DIRECT, links1.iterator().next());
    Set<Link> links2 = linkStore.getIngressLinks(d1P1);
    assertEquals(1, links2.size());
    assertLink(linkId2, DIRECT, links2.iterator().next());
}
Also used : LinkKey(org.onosproject.net.LinkKey) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) Test(org.junit.Test)

Example 92 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method testGetLink.

@Test
public final void testGetLink() {
    ConnectPoint src = new ConnectPoint(DID1, P1);
    ConnectPoint dst = new ConnectPoint(DID2, P2);
    LinkKey linkId1 = LinkKey.linkKey(src, dst);
    putLink(linkId1, DIRECT);
    Link link = linkStore.getLink(src, dst);
    assertLink(linkId1, DIRECT, link);
    assertNull("There shouldn't be reverese link", linkStore.getLink(dst, src));
}
Also used : LinkKey(org.onosproject.net.LinkKey) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) Test(org.junit.Test)

Example 93 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class TopologyMutationDriver method repairDevice.

/**
 * Repairs the specified device.
 *
 * @param deviceId device identifier
 */
void repairDevice(DeviceId deviceId) {
    // device IDs are expressed in hexadecimal... (use radix 16)
    int chassisId = Integer.parseInt(deviceId.uri().getSchemeSpecificPart(), 16);
    simulator.createDevice(deviceId, chassisId);
    Set<Link> links = savedLinks.remove(deviceId);
    if (links != null) {
        links.forEach(l -> linkProviderService.linkDetected(new DefaultLinkDescription(l.src(), l.dst(), DIRECT)));
    }
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Example 94 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class OpticalPathProvisioner method updateBandwidthUsage.

/**
 * Updates usage information of bandwidth based on connectivity which is established.
 * @param connectivity Optical connectivity
 */
private void updateBandwidthUsage(OpticalConnectivity connectivity) {
    if (NO_BW_REQUIREMENT.equals(connectivity.bandwidth())) {
        // no bandwidth requirement, nothing to allocate.
        return;
    }
    OpticalConnectivityId connectivityId = connectivity.id();
    List<Link> links = connectivity.links();
    List<Resource> resources = links.stream().flatMap(l -> Stream.of(l.src(), l.dst())).filter(cp -> !isTransportLayer(deviceService.getDevice(cp.deviceId()).type())).map(cp -> Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class).resource(connectivity.bandwidth().bps())).collect(Collectors.toList());
    log.debug("allocating bandwidth for {} : {}", connectivityId, resources);
    List<ResourceAllocation> allocations = resourceService.allocate(connectivityId, resources);
    if (allocations.isEmpty()) {
        log.warn("Failed to allocate bandwidth {} to {}", connectivity.bandwidth().bps(), resources);
    // TODO any recovery?
    }
    log.debug("Done allocating bandwidth for {}", connectivityId);
}
Also used : ConsistentMap(org.onosproject.store.service.ConsistentMap) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) AtomicCounter(org.onosproject.store.service.AtomicCounter) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) TopologyService(org.onosproject.net.topology.TopologyService) Link(org.onosproject.net.Link) ResourceService(org.onosproject.net.resource.ResourceService) ConnectPoint(org.onosproject.net.ConnectPoint) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) StorageService(org.onosproject.store.service.StorageService) Pair(org.apache.commons.lang3.tuple.Pair) MAX_PATHS_DEFAULT(org.onosproject.newoptical.OsgiPropertyConstants.MAX_PATHS_DEFAULT) Port(org.onosproject.net.Port) Duration(java.time.Duration) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) OchPort(org.onosproject.net.optical.OchPort) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) LinkKey(org.onosproject.net.LinkKey) Serializer(org.onosproject.store.service.Serializer) AbstractListenerManager(org.onosproject.event.AbstractListenerManager) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) Bandwidth(org.onlab.util.Bandwidth) Resources(org.onosproject.net.resource.Resources) Collection(java.util.Collection) Set(java.util.Set) Resource(org.onosproject.net.resource.Resource) OpticalPathEvent(org.onosproject.newoptical.api.OpticalPathEvent) Collectors(java.util.stream.Collectors) ResourceAllocation(org.onosproject.net.resource.ResourceAllocation) Objects(java.util.Objects) Versioned(org.onosproject.store.service.Versioned) Key(org.onosproject.net.intent.Key) LinkListener(org.onosproject.net.link.LinkListener) List(java.util.List) OduCltPort(org.onosproject.net.optical.OduCltPort) Stream(java.util.stream.Stream) IntentListener(org.onosproject.net.intent.IntentListener) TopologyVertex(org.onosproject.net.topology.TopologyVertex) Entry(java.util.Map.Entry) ListenerTracker(org.onosproject.event.ListenerTracker) LinkService(org.onosproject.net.link.LinkService) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) TopologyEdge(org.onosproject.net.topology.TopologyEdge) Tools(org.onlab.util.Tools) IntentEvent(org.onosproject.net.intent.IntentEvent) BasicLinkConfig(org.onosproject.net.config.basics.BasicLinkConfig) LinkEvent(org.onosproject.net.link.LinkEvent) ComponentContext(org.osgi.service.component.ComponentContext) HashMap(java.util.HashMap) OpticalPathService(org.onosproject.newoptical.api.OpticalPathService) KryoNamespace(org.onlab.util.KryoNamespace) MapEventListener(org.onosproject.store.service.MapEventListener) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) ImmutableList(com.google.common.collect.ImmutableList) IntentService(org.onosproject.net.intent.IntentService) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) LinkedList(java.util.LinkedList) LinkKey.linkKey(org.onosproject.net.LinkKey.linkKey) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) MAX_PATHS(org.onosproject.newoptical.OsgiPropertyConstants.MAX_PATHS) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Beta(com.google.common.annotations.Beta) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DefaultEdgeWeigher(org.onlab.graph.DefaultEdgeWeigher) OpticalPathListener(org.onosproject.newoptical.api.OpticalPathListener) DistributedSet(org.onosproject.store.service.DistributedSet) Weight(org.onlab.graph.Weight) OpticalDeviceServiceView.opticalView(org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView) MapEvent(org.onosproject.store.service.MapEvent) Modified(org.osgi.service.component.annotations.Modified) BandwidthCapacity(org.onosproject.net.config.basics.BandwidthCapacity) LinkWeigher(org.onosproject.net.topology.LinkWeigher) Reference(org.osgi.service.component.annotations.Reference) ScalarWeight(org.onlab.graph.ScalarWeight) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) ContinuousResource(org.onosproject.net.resource.ContinuousResource) Collections(java.util.Collections) OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) Resource(org.onosproject.net.resource.Resource) ContinuousResource(org.onosproject.net.resource.ContinuousResource) Link(org.onosproject.net.Link) ResourceAllocation(org.onosproject.net.resource.ResourceAllocation)

Example 95 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testSetupPath.

/**
 * Checks setupPath method works.
 */
@Test
public void testSetupPath() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    List<Link> links = Stream.of(LINK1, LINK2, LINK3, LINK4, LINK5, LINK6).collect(Collectors.toList());
    Path path = new DefaultPath(PROVIDER_ID, links, new ScalarWeight(0));
    OpticalConnectivityId cid = target.setupPath(path, bandwidth, latency);
    assertNotNull(cid);
    // Checks intents are installed as expected
    assertEquals(1, intentService.submitted.size());
    assertEquals(OpticalConnectivityIntent.class, intentService.submitted.get(0).getClass());
    OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.submitted.get(0);
    assertEquals(CP31, connIntent.getSrc());
    assertEquals(CP52, connIntent.getDst());
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Duration(java.time.Duration) DefaultPath(org.onosproject.net.DefaultPath) DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link) ScalarWeight(org.onlab.graph.ScalarWeight) Test(org.junit.Test)

Aggregations

Link (org.onosproject.net.Link)172 ConnectPoint (org.onosproject.net.ConnectPoint)75 Test (org.junit.Test)66 DefaultLink (org.onosproject.net.DefaultLink)44 Intent (org.onosproject.net.intent.Intent)40 DeviceId (org.onosproject.net.DeviceId)39 TrafficSelector (org.onosproject.net.flow.TrafficSelector)27 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)26 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)26 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)26 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)26 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)26 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)24 List (java.util.List)23 LinkKey (org.onosproject.net.LinkKey)23 Set (java.util.Set)22 DefaultPath (org.onosproject.net.DefaultPath)20 FlowRule (org.onosproject.net.flow.FlowRule)20 Collectors (java.util.stream.Collectors)19 PathIntent (org.onosproject.net.intent.PathIntent)18