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());
}
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());
}
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());
}
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);
}
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);
}
}
Aggregations