use of org.onosproject.net.intent.impl.PathNotFoundException in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testBandwidthConstrainedIntentFailure.
/**
* Tests that requests with insufficient available bandwidth fail.
*/
@Test
public void testBandwidthConstrainedIntentFailure() {
final double bpsTotal = 10.0;
final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(BPS_TO_RESERVE)));
try {
final PointToPointIntent intent = makeIntent(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), constraints);
String[] hops = { S1, S2, S3 };
final PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);
compiler.compile(intent, null);
fail("Point to Point compilation with insufficient bandwidth does " + "not throw exception.");
} catch (PathNotFoundException noPath) {
assertThat(noPath.getMessage(), containsString("No path"));
}
}
use of org.onosproject.net.intent.impl.PathNotFoundException in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testSuggestedPathBandwidthConstrainedIntentFailure.
/**
* Tests that requests with insufficient available bandwidth fail.
*/
@Test
public void testSuggestedPathBandwidthConstrainedIntentFailure() {
final double bpsTotal = 10.0;
final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(BPS_TO_RESERVE)));
String[] suggestedPathHops = { S1, S4, S5, S3 };
List<Link> suggestedPath = NetTestTools.createPath(suggestedPathHops).links();
try {
final PointToPointIntent intent = makeIntentSuggestedPath(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), suggestedPath, constraints);
String[][] paths = { { S1, S2, S3 }, suggestedPathHops };
final PointToPointIntentCompiler compiler = makeCompilerSuggestedPath(paths, resourceService);
compiler.compile(intent, null);
fail("Point to Point compilation with insufficient bandwidth does " + "not throw exception.");
} catch (PathNotFoundException noPath) {
assertThat(noPath.getMessage(), containsString("No path"));
}
}
use of org.onosproject.net.intent.impl.PathNotFoundException 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);
}
}
Aggregations