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