use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.
the class OpticalPathProvisioner method createConnectivity.
private OpticalConnectivity createConnectivity(Path path, Bandwidth bandwidth, Duration latency, Set<PacketLinkRealizedByOptical> links) {
OpticalConnectivityId id = OpticalConnectivityId.of(idCounter.getAndIncrement());
OpticalConnectivity connectivity = new OpticalConnectivity(id, path.links(), bandwidth, latency, links, Collections.emptySet());
links.forEach(l -> linkPathMap.put(l, connectivity));
// store connectivity information
connectivityMap.put(connectivity.id(), connectivity);
return connectivity;
}
use of org.onosproject.newoptical.api.OpticalConnectivityId 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);
}
use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.
the class OpticalConnectivityTest method testLinkEstablishedByCircuitIntent.
/**
* Checks that isAllRealizingLink(Not)Established works for OpticalCircuitIntent.
*/
@Test
public void testLinkEstablishedByCircuitIntent() {
// Mock 7-nodes linear topology
ConnectPoint cp12 = createConnectPoint(1, 2);
ConnectPoint cp21 = createConnectPoint(2, 1);
ConnectPoint cp22 = createConnectPoint(2, 2);
ConnectPoint cp31 = createConnectPoint(3, 1);
ConnectPoint cp32 = createConnectPoint(3, 2);
ConnectPoint cp41 = createConnectPoint(4, 1);
ConnectPoint cp42 = createConnectPoint(4, 2);
ConnectPoint cp51 = createConnectPoint(5, 1);
ConnectPoint cp52 = createConnectPoint(5, 2);
ConnectPoint cp61 = createConnectPoint(6, 1);
ConnectPoint cp62 = createConnectPoint(6, 2);
ConnectPoint cp71 = createConnectPoint(7, 1);
Link link1 = createLink(cp12, cp21);
Link link2 = createLink(cp22, cp31);
Link link3 = createLink(cp32, cp41);
Link link4 = createLink(cp42, cp51);
Link link5 = createLink(cp52, cp61);
Link link6 = createLink(cp62, cp71);
List<Link> links = Stream.of(link1, link2, link3, link4, link5, link6).collect(Collectors.toList());
// Mocks 2 intents to create Och connectivity
OpticalCircuitIntent circuitIntent1 = createCircuitIntent(cp21, cp32);
PacketLinkRealizedByOptical ochLink1 = PacketLinkRealizedByOptical.create(cp12, cp41, circuitIntent1);
OpticalCircuitIntent circuitIntent2 = createCircuitIntent(cp51, cp62);
PacketLinkRealizedByOptical ochLink2 = PacketLinkRealizedByOptical.create(cp42, cp71, circuitIntent2);
Set<PacketLinkRealizedByOptical> plinks = ImmutableSet.of(ochLink1, ochLink2);
Bandwidth bandwidth = Bandwidth.bps(100);
Duration latency = Duration.ofMillis(10);
OpticalConnectivityId cid = OpticalConnectivityId.of(1L);
OpticalConnectivity oc1 = new OpticalConnectivity(cid, links, bandwidth, latency, plinks, Collections.emptySet());
assertTrue(oc1.isAllRealizingLinkNotEstablished());
assertFalse(oc1.isAllRealizingLinkEstablished());
// Sets link realized by circuitIntent1 to be established
OpticalConnectivity oc2 = oc1.setLinkEstablished(cp12, cp41, true);
assertFalse(oc2.isAllRealizingLinkNotEstablished());
assertFalse(oc2.isAllRealizingLinkEstablished());
// Sets link realized by circuitIntent2 to be established
OpticalConnectivity oc3 = oc2.setLinkEstablished(cp42, cp71, true);
assertFalse(oc3.isAllRealizingLinkNotEstablished());
assertTrue(oc3.isAllRealizingLinkEstablished());
}
use of org.onosproject.newoptical.api.OpticalConnectivityId 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());
}
use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.
the class OpticalPathProvisionerTest method testRemoveConnectivity.
/**
* Checks removeConnectivity method works.
*/
@Test
public void testRemoveConnectivity() {
Bandwidth bandwidth = Bandwidth.bps(100);
Duration latency = Duration.ofMillis(10);
OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency);
// Checks intents are withdrawn
assertTrue(target.removeConnectivity(cid));
assertEquals(1, intentService.withdrawn.size());
assertEquals(OpticalConnectivityIntent.class, intentService.withdrawn.get(0).getClass());
OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.withdrawn.get(0);
assertEquals(CP31, connIntent.getSrc());
assertEquals(CP52, connIntent.getDst());
}
Aggregations