Search in sources :

Example 36 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent 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);
}
Also used : DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) ListIterator(java.util.ListIterator) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) TimeoutException(java.util.concurrent.TimeoutException) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) GroupListener(org.onosproject.net.group.GroupListener) Arrays.asList(java.util.Arrays.asList) PathNotFoundException(org.onosproject.net.intent.impl.PathNotFoundException) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) FlowRule(org.onosproject.net.flow.FlowRule) GroupBuckets(org.onosproject.net.group.GroupBuckets) LinkService(org.onosproject.net.link.LinkService) Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) IntStream(java.util.stream.IntStream) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) CompletableFuture(java.util.concurrent.CompletableFuture) GroupBucket(org.onosproject.net.group.GroupBucket) GroupKey(org.onosproject.net.group.GroupKey) Group(org.onosproject.net.group.Group) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultPath(org.onosproject.net.DefaultPath) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) EdgeLink(org.onosproject.net.EdgeLink) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IntentId(org.onosproject.net.intent.IntentId) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PathIntent(org.onosproject.net.intent.PathIntent) Instructions(org.onosproject.net.flow.instructions.Instructions) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupService(org.onosproject.net.group.GroupService) ProtectionConstraint(org.onosproject.net.intent.constraint.ProtectionConstraint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ProviderId(org.onosproject.net.provider.ProviderId) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) ScalarWeight(org.onlab.graph.ScalarWeight) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) DisjointPath(org.onosproject.net.DisjointPath) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 37 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.

the class PointToPointIntentCompiler method removeAndUpdateIntents.

/**
 * Removes intents from installables list, depending on the values
 * of instance variables erasePrimary and eraseBackup. Flow rule intents
 * that contain the manufactured fast failover flow rules are never deleted.
 * The contents are simply modified as necessary. If cleanUpIntents size
 * is greater than 1 (failover intent), then one whole path from previous
 * installables must be still viable.
 *
 * @param cleanUpIntents   list of installable intents
 */
private void removeAndUpdateIntents(List<Intent> cleanUpIntents, PointToPointIntent pointIntent) {
    ListIterator<Intent> iterator = cleanUpIntents.listIterator();
    while (iterator.hasNext()) {
        Intent cIntent = iterator.next();
        if (cIntent instanceof FlowRuleIntent) {
            FlowRuleIntent fIntent = (FlowRuleIntent) cIntent;
            if (fIntent.type() == PathIntent.ProtectionType.PRIMARY && erasePrimary) {
                // remove primary path's flow rule intents
                iterator.remove();
            } else if (fIntent.type() == PathIntent.ProtectionType.BACKUP && eraseBackup) {
                // remove backup path's flow rule intents
                iterator.remove();
            } else if (fIntent.type() == PathIntent.ProtectionType.BACKUP && erasePrimary) {
                // promote backup path's flow rule intents to primary
                iterator.set(new FlowRuleIntent(fIntent, PathIntent.ProtectionType.PRIMARY));
            }
        }
    }
    // remove buckets whose watchports are disabled if the failover group exists
    Group group = groupService.getGroup(pointIntent.filteredIngressPoint().connectPoint().deviceId(), makeGroupKey(pointIntent.id()));
    if (group != null) {
        updateFailoverGroup(pointIntent);
    }
}
Also used : Group(org.onosproject.net.group.Group) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent)

Example 38 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.

the class PointToPointIntentCompilerTest method testBandwidthConstrainedIntentSuccess.

/**
 * Tests that requests with sufficient available bandwidth succeed.
 */
@Test
public void testBandwidthConstrainedIntentSuccess() {
    final double bpsTotal = 1000.0;
    final double bpsToReserve = 100.0;
    final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
    final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(bpsToReserve)));
    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);
    final List<Intent> compiledIntents = compiler.compile(intent, null);
    assertThat(compiledIntents, Matchers.notNullValue());
    assertThat(compiledIntents, hasSize(1));
    assertThat("key is inherited", compiledIntents.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
}
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) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) 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 39 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.

the class PointToPointIntentCompilerTest method testSuggestedPath.

/**
 * Test if a suggested path is correctly applied.
 */
@Test
public void testSuggestedPath() {
    String[] suggestedPathHops = { S1, S3, S4, S5, S6, S8 };
    List<Link> suggestedPath = NetTestTools.createPath(suggestedPathHops).links();
    PointToPointIntent intent = makeIntentSuggestedPath(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_8, PORT_2), suggestedPath);
    String[][] paths = { { S1, S2, S8 }, suggestedPathHops };
    PointToPointIntentCompiler compiler = makeCompilerSuggestedPath(paths);
    List<Intent> result = compiler.compile(intent, null);
    assertThat(result, is(Matchers.notNullValue()));
    assertThat(result, hasSize(1));
    Intent resultIntent = result.get(0);
    assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent resultLinkIntent = (LinkCollectionIntent) resultIntent;
        FilteredConnectPoint ingressPoint = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
        FilteredConnectPoint egressPoint = new FilteredConnectPoint(new ConnectPoint(DID_8, PORT_2));
        // 5 links for the hops, plus one default link on ingress and egress
        assertThat(resultLinkIntent.links(), hasSize(suggestedPathHops.length - 1));
        assertThat(resultLinkIntent.links(), linksHasPath(S1, S3));
        assertThat(resultLinkIntent.links(), linksHasPath(S3, S4));
        assertThat(resultLinkIntent.links(), linksHasPath(S4, S5));
        assertThat(resultLinkIntent.links(), linksHasPath(S5, S6));
        assertThat(resultLinkIntent.links(), linksHasPath(S6, S8));
        assertThat(resultLinkIntent.filteredIngressPoints(), is(ImmutableSet.of(ingressPoint)));
        assertThat(resultLinkIntent.filteredEgressPoints(), is(ImmutableSet.of(egressPoint)));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Link(org.onosproject.net.Link) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 40 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent 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)

Aggregations

PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)48 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)28 ConnectPoint (org.onosproject.net.ConnectPoint)24 Intent (org.onosproject.net.intent.Intent)19 Test (org.junit.Test)18 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)16 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)16 TrafficSelector (org.onosproject.net.flow.TrafficSelector)13 Key (org.onosproject.net.intent.Key)13 ArrayList (java.util.ArrayList)12 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)12 Link (org.onosproject.net.Link)11 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)11 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)11 Constraint (org.onosproject.net.intent.Constraint)11 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)10 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)10 PathIntent (org.onosproject.net.intent.PathIntent)8 MockResourceService (org.onosproject.net.resource.MockResourceService)8 ResourceService (org.onosproject.net.resource.ResourceService)8