use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class MultiPointToSinglePointIntentCompiler method compile.
@Override
public List<Intent> compile(MultiPointToSinglePointIntent intent, List<Intent> installable) {
Map<DeviceId, Link> links = new HashMap<>();
ConnectPoint egressPoint = intent.egressPoint();
final boolean allowMissingPaths = intentAllowsPartialFailure(intent);
boolean hasPaths = false;
boolean missingSomePaths = false;
for (ConnectPoint ingressPoint : intent.ingressPoints()) {
if (ingressPoint.deviceId().equals(egressPoint.deviceId())) {
if (deviceService.isAvailable(ingressPoint.deviceId())) {
hasPaths = true;
} else {
missingSomePaths = true;
}
continue;
}
Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId());
if (path != null) {
hasPaths = true;
for (Link link : path.links()) {
if (links.containsKey(link.dst().deviceId())) {
// We've already reached the existing tree with the first
// part of this path. Add the merging point with different
// incoming port, but don't add the remainder of the path
// in case it differs from the path we already have.
links.put(link.src().deviceId(), link);
break;
}
links.put(link.src().deviceId(), link);
}
} else {
missingSomePaths = true;
}
}
// Allocate bandwidth on existing paths if a bandwidth constraint is set
List<ConnectPoint> ingressCPs = intent.filteredIngressPoints().stream().map(fcp -> fcp.connectPoint()).collect(Collectors.toList());
ConnectPoint egressCP = intent.filteredEgressPoint().connectPoint();
List<ConnectPoint> pathCPs = links.values().stream().flatMap(l -> Stream.of(l.src(), l.dst())).collect(Collectors.toList());
pathCPs.addAll(ingressCPs);
pathCPs.add(egressCP);
allocateBandwidth(intent, pathCPs);
if (!hasPaths) {
throw new IntentException("Cannot find any path between ingress and egress points.");
} else if (!allowMissingPaths && missingSomePaths) {
throw new IntentException("Missing some paths between ingress and egress points.");
}
Intent result = LinkCollectionIntent.builder().appId(intent.appId()).key(intent.key()).treatment(intent.treatment()).selector(intent.selector()).links(Sets.newHashSet(links.values())).filteredIngressPoints(intent.filteredIngressPoints()).filteredEgressPoints(ImmutableSet.of(intent.filteredEgressPoint())).priority(intent.priority()).constraints(intent.constraints()).resourceGroup(intent.resourceGroup()).build();
return Collections.singletonList(result);
}
use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class PointToPointIntentCompiler method compile.
@Override
public List<Intent> compile(PointToPointIntent intent, List<Intent> installable) {
log.trace("compiling {} {}", intent, installable);
ConnectPoint ingressPoint = intent.filteredIngressPoint().connectPoint();
ConnectPoint egressPoint = intent.filteredEgressPoint().connectPoint();
// Idea: use suggested path as primary and another path from path service as protection
if (intent.suggestedPath() != null && intent.suggestedPath().size() > 0) {
Path path = new DefaultPath(PID, intent.suggestedPath(), new ScalarWeight(1));
// Check intent constraints against suggested path and suggested path availability
if (checkPath(path, intent.constraints()) && pathAvailable(intent)) {
allocateIntentBandwidth(intent, path);
return asList(createLinkCollectionIntent(ImmutableSet.copyOf(intent.suggestedPath()), DEFAULT_COST, intent));
}
}
if (ingressPoint.deviceId().equals(egressPoint.deviceId())) {
return createZeroHopLinkCollectionIntent(intent);
}
// proceed with no protected paths
if (!ProtectionConstraint.requireProtectedPath(intent)) {
return createUnprotectedLinkCollectionIntent(intent);
}
try {
// attempt to compute and implement backup path
return createProtectedIntent(ingressPoint, egressPoint, intent, installable);
} catch (PathNotFoundException e) {
log.warn("Could not find disjoint Path for {}", intent);
// no disjoint path extant -- maximum one path exists between devices
return createSinglePathIntent(ingressPoint, egressPoint, intent, installable);
}
}
use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class PointToPointIntentCompiler method allocateIntentBandwidth.
private void allocateIntentBandwidth(PointToPointIntent intent, Path path) {
ConnectPoint ingressCP = intent.filteredIngressPoint().connectPoint();
ConnectPoint egressCP = intent.filteredEgressPoint().connectPoint();
List<ConnectPoint> pathCPs = path.links().stream().flatMap(l -> Stream.of(l.src(), l.dst())).collect(Collectors.toList());
pathCPs.add(ingressCP);
pathCPs.add(egressCP);
allocateBandwidth(intent, pathCPs);
}
use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class DefaultVirtualNetworkProvider method isTraversable.
@Override
public boolean isTraversable(ConnectPoint src, ConnectPoint dst) {
final boolean[] foundSrc = new boolean[1];
final boolean[] foundDst = new boolean[1];
Topology topology = topologyService.currentTopology();
Set<Path> paths = topologyService.getPaths(topology, src.deviceId(), dst.deviceId());
paths.forEach(path -> {
foundDst[0] = false;
foundSrc[0] = false;
// Traverse the links in each path to determine if both the src and dst connection
// point are in the path, if so then this src/dst pair are traversable.
path.links().forEach(link -> {
if (link.src().equals(src)) {
foundSrc[0] = true;
}
if (link.dst().equals(dst)) {
foundDst[0] = true;
}
});
if (foundSrc[0] && foundDst[0]) {
return;
}
});
return foundSrc[0] && foundDst[0];
}
use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class PathManagerTest method infraToEdge.
@Test
public void infraToEdge() {
DeviceId src = did("src");
HostId dst = hid("12:34:56:78:90:ab/1");
fakeTopoMgr.paths.add(createPath("src", "middle", "edge"));
fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ab/1", "edge"));
Set<Path> paths = service.getPaths(src, dst);
validatePaths(paths, 1, 3, src, dst);
}
Aggregations