Search in sources :

Example 16 with BandwidthConstraint

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

the class ConstraintCodecTest method bandwidthConstraint.

/**
 * Tests bandwidth constraint.
 */
@Test
public void bandwidthConstraint() {
    Constraint constraint = getConstraint("BandwidthConstraint.json");
    assertThat(constraint, instanceOf(BandwidthConstraint.class));
    BandwidthConstraint bandwidthConstraint = (BandwidthConstraint) constraint;
    assertThat(bandwidthConstraint.bandwidth().bps(), is(345.678D));
}
Also used : WaypointConstraint(org.onosproject.net.intent.constraint.WaypointConstraint) AsymmetricPathConstraint(org.onosproject.net.intent.constraint.AsymmetricPathConstraint) DomainConstraint(org.onosproject.net.intent.constraint.DomainConstraint) MeteredConstraint(org.onosproject.net.intent.constraint.MeteredConstraint) ObstacleConstraint(org.onosproject.net.intent.constraint.ObstacleConstraint) Constraint(org.onosproject.net.intent.Constraint) TierConstraint(org.onosproject.net.intent.constraint.TierConstraint) AnnotationConstraint(org.onosproject.net.intent.constraint.AnnotationConstraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) LinkTypeConstraint(org.onosproject.net.intent.constraint.LinkTypeConstraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) Test(org.junit.Test)

Example 17 with BandwidthConstraint

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

the class ConnectivityIntentCommand method buildConstraints.

/**
 * Builds the constraint list for this command based on the command line
 * parameters.
 *
 * @return List of constraint objects describing the constraints requested
 */
protected List<Constraint> buildConstraints() {
    final List<Constraint> constraints = new LinkedList<>();
    // Check for a bandwidth specification
    if (!isNullOrEmpty(bandwidthString)) {
        Bandwidth bandwidth;
        try {
            bandwidth = Bandwidth.bps(Long.parseLong(bandwidthString));
        // when the string can't be parsed as long, then try to parse as double
        } catch (NumberFormatException e) {
            bandwidth = Bandwidth.bps(Double.parseDouble(bandwidthString));
        }
        constraints.add(new BandwidthConstraint(bandwidth));
    }
    // Check for partial failure specification
    if (partial) {
        constraints.add(new PartialFailureConstraint());
    }
    // Check for encapsulation specification
    if (!isNullOrEmpty(encapsulationString)) {
        final EncapsulationType encapType = EncapsulationType.valueOf(encapsulationString);
        constraints.add(new EncapsulationConstraint(encapType));
    }
    // Check for hashed path selection
    if (hashedPathSelection) {
        constraints.add(new HashedPathSelectionConstraint());
    }
    // Check for domain processing
    if (domains) {
        constraints.add(DomainConstraint.domain());
    }
    // Check for a latency specification
    if (!isNullOrEmpty(latConstraint)) {
        try {
            long lat = Long.parseLong(latConstraint);
            constraints.add(new LatencyConstraint(Duration.of(lat, ChronoUnit.NANOS)));
        } catch (NumberFormatException e) {
            double lat = Double.parseDouble(latConstraint);
            constraints.add(new LatencyConstraint(Duration.of((long) lat, ChronoUnit.NANOS)));
        }
    }
    return constraints;
}
Also used : EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) EncapsulationType(org.onosproject.net.EncapsulationType) HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) DomainConstraint(org.onosproject.net.intent.constraint.DomainConstraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) Bandwidth(org.onlab.util.Bandwidth) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) LinkedList(java.util.LinkedList) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint)

Aggregations

BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)17 Constraint (org.onosproject.net.intent.Constraint)15 Test (org.junit.Test)13 ConnectPoint (org.onosproject.net.ConnectPoint)12 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)12 ResourceService (org.onosproject.net.resource.ResourceService)12 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)11 MockResourceService (org.onosproject.net.resource.MockResourceService)11 PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)9 ResourceAllocation (org.onosproject.net.resource.ResourceAllocation)8 Key (org.onosproject.net.intent.Key)6 Bandwidth (org.onlab.util.Bandwidth)5 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 TrafficSelector (org.onosproject.net.flow.TrafficSelector)3 LatencyConstraint (org.onosproject.net.intent.constraint.LatencyConstraint)3 PartialFailureConstraint (org.onosproject.net.intent.constraint.PartialFailureConstraint)3 PathNotFoundException (org.onosproject.net.intent.impl.PathNotFoundException)3 ContinuousResource (org.onosproject.net.resource.ContinuousResource)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 DeviceId (org.onosproject.net.DeviceId)2