use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.
the class ModelCache method addNewHost.
private UiHost addNewHost(Host h) {
UiHost host = new UiHost(uiTopology, h);
uiTopology.add(host);
EdgeLink elink = synthesizeLink(h);
UiLinkId elinkId = uiLinkId(elink);
host.setEdgeLinkId(elinkId);
// add synthesized edge link to the topology
addNewEdgeLink(elinkId);
return host;
}
use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.
the class AbstractPathService method edgeToEdgePath.
// Produces a direct edge-to-edge path.
private Path edgeToEdgePath(EdgeLink srcLink, EdgeLink dstLink, Path path, LinkWeigher weigher) {
List<Link> links = Lists.newArrayListWithCapacity(2);
Weight cost = weigher.getInitialWeight();
// add the infrastructure path only if it is not null.
if (srcLink != NOT_HOST) {
links.add(srcLink);
cost = cost.merge(weigher.weight(new DefaultTopologyEdge(null, null, srcLink)));
}
if (path != null) {
links.addAll(path.links());
cost = cost.merge(path.weight());
}
if (dstLink != NOT_HOST) {
links.add(dstLink);
cost = cost.merge(weigher.weight(new DefaultTopologyEdge(null, null, dstLink)));
}
return new DefaultPath(PID, links, cost);
}
use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.
the class AbstractPathService method getKShortestPaths.
@Override
public Stream<Path> getKShortestPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
checkNotNull(src, ELEMENT_ID_NULL);
checkNotNull(dst, ELEMENT_ID_NULL);
LinkWeigher internalWeigher = weigher != null ? weigher : DEFAULT_WEIGHER;
// Get the source and destination edge locations
EdgeLink srcEdge = getEdgeLink(src, true);
EdgeLink dstEdge = getEdgeLink(dst, false);
// If either edge is null, bail with no paths.
if (srcEdge == null || dstEdge == null) {
return Stream.empty();
}
DeviceId srcDevice = srcEdge != NOT_HOST ? srcEdge.dst().deviceId() : (DeviceId) src;
DeviceId dstDevice = dstEdge != NOT_HOST ? dstEdge.src().deviceId() : (DeviceId) dst;
// is just one path, so build it and return it.
if (srcDevice.equals(dstDevice)) {
return Stream.of(edgeToEdgePath(srcEdge, dstEdge, null, internalWeigher));
}
// Otherwise get all paths between the source and destination edge
// devices.
Topology topology = topologyService.currentTopology();
return topologyService.getKShortestPaths(topology, srcDevice, dstDevice, internalWeigher).map(path -> edgeToEdgePath(srcEdge, dstEdge, path, internalWeigher));
}
use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.
the class PointToPointIntentCompiler method filterInvalidSubIntents.
/**
* Deletes intents from the given list if the ports or links the intent
* relies on are no longer viable. The failover flow rule intent is never
* deleted -- only its contents are updated.
*
* @param oldInstallables list of intents to examine
* @return list of reusable installable intents
*/
private List<Intent> filterInvalidSubIntents(List<Intent> oldInstallables, PointToPointIntent pointIntent) {
List<Intent> intentList = new ArrayList<>();
intentList.addAll(oldInstallables);
Iterator<Intent> iterator = intentList.iterator();
while (iterator.hasNext()) {
Intent intent = iterator.next();
intent.resources().forEach(resource -> {
if (resource instanceof Link) {
Link link = (Link) resource;
if (link.state() == Link.State.INACTIVE) {
setPathsToRemove(intent);
} else if (link instanceof EdgeLink) {
ConnectPoint connectPoint = (link.src().elementId() instanceof DeviceId) ? link.src() : link.dst();
Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port());
if (port == null || !port.isEnabled()) {
setPathsToRemove(intent);
}
} else {
Port port1 = deviceService.getPort(link.src().deviceId(), link.src().port());
Port port2 = deviceService.getPort(link.dst().deviceId(), link.dst().port());
if (port1 == null || !port1.isEnabled() || port2 == null || !port2.isEnabled()) {
setPathsToRemove(intent);
}
}
}
});
}
removeAndUpdateIntents(intentList, pointIntent);
return intentList;
}
Aggregations