Search in sources :

Example 6 with OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testSetupConnectivity.

/**
 * Checks setupConnectivity method works.
 */
@Test
public void testSetupConnectivity() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency);
    assertNotNull(cid);
    // Checks path computation is called as expected
    assertEquals(1, topologyService.edges.size());
    assertEquals(CP12.deviceId(), topologyService.edges.get(0).getKey());
    assertEquals(CP71.deviceId(), topologyService.edges.get(0).getValue());
    // 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 : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Duration(java.time.Duration) Test(org.junit.Test)

Example 7 with OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testRemovedEventLocal.

/**
 * Checks if PATH_REMOVED event comes up after packet link is removed.
 */
@Test
public void testRemovedEventLocal() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency);
    // notify all intents are installed
    intentService.notifyInstalled();
    target.removeConnectivity(cid);
    // notify all intents are withdrawn
    intentService.notifyWithdrawn();
    // must have received "INSTALLED" and "REMOVED" events
    assertEquals(2, listener.events.size());
    assertEquals(OpticalPathEvent.Type.PATH_INSTALLED, listener.events.get(0).type());
    assertEquals(cid, listener.events.get(0).subject());
    assertEquals(OpticalPathEvent.Type.PATH_REMOVED, listener.events.get(1).type());
    assertEquals(cid, listener.events.get(1).subject());
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) Duration(java.time.Duration) Test(org.junit.Test)

Example 8 with OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testGetPath.

/**
 * Checks getPath method works.
 */
@Test
public void testGetPath() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    List<Link> links = Stream.of(LINK1, LINK2, LINK3, LINK4, LINK5, LINK6).collect(Collectors.toList());
    OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency);
    Optional<List<Link>> path = target.getPath(cid);
    // Checks returned path is as expected
    assertTrue(path.isPresent());
    assertEquals(links, path.get());
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) Duration(java.time.Duration) ArrayList(java.util.ArrayList) List(java.util.List) DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link) Test(org.junit.Test)

Example 9 with OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.

the class OpticalPathProvisioner method setupConnectivity.

/*
     * Request packet-layer connectivity between specified ports,
     * over packet-optical multi-layer infrastructure.
     *
     * Functionality-wise this is effectively submitting Packet-Optical
     * multi-layer P2P Intent.
     *
     * It computes multi-layer path meeting specified constraint,
     * and calls setupPath.
     */
@Override
public OpticalConnectivityId setupConnectivity(ConnectPoint ingress, ConnectPoint egress, Bandwidth bandwidth, Duration latency) {
    checkNotNull(ingress);
    checkNotNull(egress);
    log.info("setupConnectivity({}, {}, {}, {})", ingress, egress, bandwidth, latency);
    Bandwidth bw = (bandwidth == null) ? NO_BW_REQUIREMENT : bandwidth;
    Stream<Path> paths = topologyService.getKShortestPaths(topologyService.currentTopology(), ingress.deviceId(), egress.deviceId(), new BandwidthLinkWeight(bandwidth));
    // Path service calculates from node to node, we're only interested in port to port
    Optional<OpticalConnectivityId> id = paths.filter(p -> p.src().equals(ingress) && p.dst().equals(egress)).limit(maxPaths).map(p -> setupPath(p, bw, latency)).filter(Objects::nonNull).findFirst();
    if (id.isPresent()) {
        log.info("Assigned OpticalConnectivityId: {}", id);
    } else {
        log.error("setupConnectivity({}, {}, {}, {}) failed.", ingress, egress, bandwidth, latency);
    }
    return id.orElse(null);
}
Also used : Path(org.onosproject.net.Path) OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth)

Example 10 with OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.

the class OpticalPathProvisioner method releaseBandwidthUsage.

/**
 * Release bandwidth allocated by given connectivity.
 * @param connectivity Optical connectivity
 */
private void releaseBandwidthUsage(OpticalConnectivity connectivity) {
    if (connectivity.links().isEmpty()) {
        return;
    }
    if (NO_BW_REQUIREMENT.equals(connectivity.bandwidth())) {
        // no bandwidth requirement, nothing to release.
        return;
    }
    // release resource only if this node is the master for link head device
    if (mastershipService.isLocalMaster(connectivity.links().get(0).src().deviceId())) {
        OpticalConnectivityId connectivityId = connectivity.id();
        log.debug("releasing bandwidth allocated to {}", connectivityId);
        if (!resourceService.release(connectivityId)) {
            log.warn("Failed to release bandwidth allocated to {}", connectivityId);
        // TODO any recovery?
        }
        log.debug("DONE releasing bandwidth for {}", connectivityId);
    }
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId)

Aggregations

OpticalConnectivityId (org.onosproject.newoptical.api.OpticalConnectivityId)17 Bandwidth (org.onlab.util.Bandwidth)14 Duration (java.time.Duration)12 Test (org.junit.Test)11 Link (org.onosproject.net.Link)6 ConnectPoint (org.onosproject.net.ConnectPoint)5 DefaultLink (org.onosproject.net.DefaultLink)5 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)5 Path (org.onosproject.net.Path)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ScalarWeight (org.onlab.graph.ScalarWeight)2 OpticalCircuitIntent (org.onosproject.net.intent.OpticalCircuitIntent)2 OpticalPathService (org.onosproject.newoptical.api.OpticalPathService)2 Beta (com.google.common.annotations.Beta)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableList (com.google.common.collect.ImmutableList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1