Search in sources :

Example 1 with HashedPathSelectionConstraint

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

LinkedList (java.util.LinkedList)1 Bandwidth (org.onlab.util.Bandwidth)1 EncapsulationType (org.onosproject.net.EncapsulationType)1 Constraint (org.onosproject.net.intent.Constraint)1 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)1 DomainConstraint (org.onosproject.net.intent.constraint.DomainConstraint)1 EncapsulationConstraint (org.onosproject.net.intent.constraint.EncapsulationConstraint)1 HashedPathSelectionConstraint (org.onosproject.net.intent.constraint.HashedPathSelectionConstraint)1 LatencyConstraint (org.onosproject.net.intent.constraint.LatencyConstraint)1 PartialFailureConstraint (org.onosproject.net.intent.constraint.PartialFailureConstraint)1