Search in sources :

Example 1 with PathNotFoundException

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"));
    }
}
Also used : Constraint(org.onosproject.net.intent.Constraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) ResourceService(org.onosproject.net.resource.ResourceService) MockResourceService(org.onosproject.net.resource.MockResourceService) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) PathNotFoundException(org.onosproject.net.intent.impl.PathNotFoundException) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 2 with PathNotFoundException

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"));
    }
}
Also used : Constraint(org.onosproject.net.intent.Constraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) ResourceService(org.onosproject.net.resource.ResourceService) MockResourceService(org.onosproject.net.resource.MockResourceService) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) PathNotFoundException(org.onosproject.net.intent.impl.PathNotFoundException) Link(org.onosproject.net.Link) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 3 with PathNotFoundException

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);
    }
}
Also used : Path(org.onosproject.net.Path) DefaultPath(org.onosproject.net.DefaultPath) DisjointPath(org.onosproject.net.DisjointPath) DefaultPath(org.onosproject.net.DefaultPath) PathNotFoundException(org.onosproject.net.intent.impl.PathNotFoundException) ConnectPoint(org.onosproject.net.ConnectPoint) ScalarWeight(org.onlab.graph.ScalarWeight)

Aggregations

ConnectPoint (org.onosproject.net.ConnectPoint)3 PathNotFoundException (org.onosproject.net.intent.impl.PathNotFoundException)3 Test (org.junit.Test)2 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)2 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)2 Constraint (org.onosproject.net.intent.Constraint)2 PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)2 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)2 MockResourceService (org.onosproject.net.resource.MockResourceService)2 ResourceService (org.onosproject.net.resource.ResourceService)2 ScalarWeight (org.onlab.graph.ScalarWeight)1 DefaultPath (org.onosproject.net.DefaultPath)1 DisjointPath (org.onosproject.net.DisjointPath)1 Link (org.onosproject.net.Link)1 Path (org.onosproject.net.Path)1