Search in sources :

Example 91 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class SinglePointToMultiPointIntentCompilerTest method testPartialFailureConstraintSuccess.

/**
 * Tests if all expected links are present when a partial failure
 * constraint is used and one ingress is not present.
 */
@Test
public void testPartialFailureConstraintSuccess() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2)), new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2)));
    final List<Constraint> constraints = Collections.singletonList(new PartialFailureConstraint());
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress, constraints);
    String[] hops = { S3 };
    SinglePointToMultiPointIntentCompiler compiler = makeCompiler(null, new IntentTestsMocks.FixedMP2MPMockPathService(hops), null);
    assertThat(compiler, is(notNullValue()));
    List<Intent> result = compiler.compile(intent, null);
    assertThat(result, is(notNullValue()));
    assertThat(result, hasSize(1));
    Intent resultIntent = result.get(0);
    assertThat(resultIntent, instanceOf(LinkCollectionIntent.class));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(2));
        assertThat(linkIntent.links(), linksHasPath(S1, S3));
        assertThat(linkIntent.links(), linksHasPath(S3, S4));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) IntentTestsMocks(org.onosproject.net.intent.IntentTestsMocks) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 92 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class SinglePointToMultiPointIntentCompilerTest method testSameDeviceCompilation.

/**
 * Tests ingress and egress on the same device.
 */
@Test
public void testSameDeviceCompilation() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    Set<FilteredConnectPoint> egress = Sets.newHashSet(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_2)), new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_3)));
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));
    final String[] hops = {};
    SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
    assertThat(compiler, is(notNullValue()));
    List<Intent> result = compiler.compile(intent, null);
    assertThat(result, is(notNullValue()));
    assertThat(result, hasSize(1));
    Intent resultIntent = result.get(0);
    assertThat(resultIntent, instanceOf(LinkCollectionIntent.class));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(0));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 93 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class SinglePointToMultiPointIntentCompilerTest method testMultiEgressCompilation.

/**
 * Tests multiple egress points that share a common path to the ingress
 * point.
 */
@Test
public void testMultiEgressCompilation() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    FilteredConnectPoint egressOne = new FilteredConnectPoint(new ConnectPoint(DID_3, PORT_2));
    FilteredConnectPoint egressTwo = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
    FilteredConnectPoint egressThree = new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2));
    Set<FilteredConnectPoint> egress = Sets.newHashSet(egressOne, egressTwo, egressThree);
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));
    final String[] hops = { S2 };
    SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
    assertThat(compiler, is(notNullValue()));
    List<Intent> result = compiler.compile(intent, null);
    assertThat(result, is(notNullValue()));
    assertThat(result, hasSize(1));
    Intent resultIntent = result.get(0);
    assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(4));
        assertThat(linkIntent.links(), linksHasPath(S1, S2));
        assertThat(linkIntent.links(), linksHasPath(S2, S3));
        assertThat(linkIntent.links(), linksHasPath(S2, S4));
        assertThat(linkIntent.links(), linksHasPath(S2, S5));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 94 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class OplinkSwitchProtection method getProtectedTransportEndpointState.

/*
     * get protected endpoint state
     */
private ProtectedTransportEndpointState getProtectedTransportEndpointState() {
    List<TransportEndpointState> tess = new ArrayList<>();
    PortNumber portPrimary = PortNumber.portNumber(PRIMARY_PORT);
    PortNumber portSecondary = PortNumber.portNumber(SECONDARY_PORT);
    FilteredConnectPoint fcpPrimary = new FilteredConnectPoint(new ConnectPoint(data().deviceId(), portPrimary));
    FilteredConnectPoint fcpSecondary = new FilteredConnectPoint(new ConnectPoint(data().deviceId(), portSecondary));
    TransportEndpointDescription tedPrimary = TransportEndpointDescription.builder().withOutput(fcpPrimary).build();
    TransportEndpointDescription tedSecondary = TransportEndpointDescription.builder().withOutput(fcpSecondary).build();
    TransportEndpointState tesPrimary = TransportEndpointState.builder().withDescription(tedPrimary).withId(TransportEndpointId.of(PRIMARY_ID)).addAttributes(getProtectionStateAttributes(portPrimary)).build();
    TransportEndpointState tesSecondary = TransportEndpointState.builder().withDescription(tedSecondary).withId(TransportEndpointId.of(SECONDARY_ID)).addAttributes(getProtectionStateAttributes((portSecondary))).build();
    tess.add(tesPrimary);
    tess.add(tesSecondary);
    return ProtectedTransportEndpointState.builder().withDescription(getProtectedTransportEndpointDescription()).withPathStates(tess).withActivePathIndex(getActiveIndex(tess)).build();
}
Also used : ProtectedTransportEndpointState(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointState) TransportEndpointState(org.onosproject.net.behaviour.protection.TransportEndpointState) ProtectedTransportEndpointDescription(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription) TransportEndpointDescription(org.onosproject.net.behaviour.protection.TransportEndpointDescription) ArrayList(java.util.ArrayList) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 95 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class ReactiveRoutingFib method updateExistingMp2pIntent.

@Override
public void updateExistingMp2pIntent(IpPrefix ipPrefix, ConnectPoint ingressConnectPoint) {
    checkNotNull(ipPrefix);
    checkNotNull(ingressConnectPoint);
    MultiPointToSinglePointIntent existingIntent = getExistingMp2pIntent(ipPrefix);
    if (existingIntent != null) {
        Set<FilteredConnectPoint> ingressPoints = existingIntent.filteredIngressPoints();
        // Add host connect point into ingressPoints of the existing intent
        if (ingressPoints.add(new FilteredConnectPoint(ingressConnectPoint))) {
            MultiPointToSinglePointIntent updatedMp2pIntent = MultiPointToSinglePointIntent.builder().appId(appId).key(existingIntent.key()).selector(existingIntent.selector()).treatment(existingIntent.treatment()).filteredIngressPoints(ingressPoints).filteredEgressPoint(existingIntent.filteredEgressPoint()).priority(existingIntent.priority()).constraints(CONSTRAINTS).build();
            log.trace("Update an existing MultiPointToSinglePointIntent " + "to new intent = {} ", updatedMp2pIntent);
            submitReactiveIntent(ipPrefix, updatedMp2pIntent);
        }
    // If adding ingressConnectPoint to ingressPoints failed, it
    // because between the time interval from checking existing intent
    // to generating new intent, onos updated this intent due to other
    // packet-in and the new intent also includes the
    // ingressConnectPoint. This will not affect reactive routing.
    }
}
Also used : MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)161 Test (org.junit.Test)101 Intent (org.onosproject.net.intent.Intent)101 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)92 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)87 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)80 TrafficSelector (org.onosproject.net.flow.TrafficSelector)65 ConnectPoint (org.onosproject.net.ConnectPoint)64 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)53 List (java.util.List)52 Collectors (java.util.stream.Collectors)52 VlanId (org.onlab.packet.VlanId)52 DeviceId (org.onosproject.net.DeviceId)50 FlowRule (org.onosproject.net.flow.FlowRule)50 DomainService (org.onosproject.net.domain.DomainService)48 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)48 ImmutableSet (com.google.common.collect.ImmutableSet)47 LOCAL (org.onosproject.net.domain.DomainId.LOCAL)47 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)47 Before (org.junit.Before)46