Search in sources :

Example 6 with LatencyConstraint

use of org.onosproject.net.intent.constraint.LatencyConstraint 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

LatencyConstraint (org.onosproject.net.intent.constraint.LatencyConstraint)6 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)4 Test (org.junit.Test)3 Constraint (org.onosproject.net.intent.Constraint)3 AnnotationConstraint (org.onosproject.net.intent.constraint.AnnotationConstraint)3 ObstacleConstraint (org.onosproject.net.intent.constraint.ObstacleConstraint)3 WaypointConstraint (org.onosproject.net.intent.constraint.WaypointConstraint)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 LinkedList (java.util.LinkedList)2 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)2 AsymmetricPathConstraint (org.onosproject.net.intent.constraint.AsymmetricPathConstraint)2 DomainConstraint (org.onosproject.net.intent.constraint.DomainConstraint)2 LinkTypeConstraint (org.onosproject.net.intent.constraint.LinkTypeConstraint)2 MeteredConstraint (org.onosproject.net.intent.constraint.MeteredConstraint)2 TierConstraint (org.onosproject.net.intent.constraint.TierConstraint)2 HashSet (java.util.HashSet)1 Bandwidth (org.onlab.util.Bandwidth)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DeviceId (org.onosproject.net.DeviceId)1 EncapsulationType (org.onosproject.net.EncapsulationType)1