Search in sources :

Example 1 with MeteredConstraint

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

the class EncodeConstraintCodecHelper method encodeMeteredConstraint.

private ObjectNode encodeMeteredConstraint() {
    checkNotNull(constraint, "Metered constraint cannot be null");
    final MeteredConstraint meteredConstraint = (MeteredConstraint) constraint;
    return context.mapper().createObjectNode().put("metered", meteredConstraint.isUseMetered());
}
Also used : MeteredConstraint(org.onosproject.net.intent.constraint.MeteredConstraint)

Example 2 with MeteredConstraint

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

the class ConstraintCodecTest method meteredConstraint.

/**
 * Tests metered constraint.
 */
@Test
public void meteredConstraint() {
    Constraint constraint = getConstraint("MeteredConstraint.json");
    assertThat(constraint, instanceOf(MeteredConstraint.class));
    MeteredConstraint meteredConstraint = (MeteredConstraint) constraint;
    assertThat(meteredConstraint.isUseMetered(), is(true));
}
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) MeteredConstraint(org.onosproject.net.intent.constraint.MeteredConstraint) Test(org.junit.Test)

Example 3 with MeteredConstraint

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

the class EncodeConstraintCodecHelper method encode.

/**
 * Encodes the constraint in JSON.
 *
 * @return JSON node
 */
public ObjectNode encode() {
    final ObjectNode result;
    if (constraint instanceof BandwidthConstraint) {
        result = encodeBandwidthConstraint();
    } else if (constraint instanceof LinkTypeConstraint) {
        result = encodeLinkTypeConstraint();
    } else if (constraint instanceof AnnotationConstraint) {
        result = encodeAnnotationConstraint();
    } else if (constraint instanceof LatencyConstraint) {
        result = encodeLatencyConstraint();
    } else if (constraint instanceof ObstacleConstraint) {
        result = encodeObstacleConstraint();
    } else if (constraint instanceof WaypointConstraint) {
        result = encodeWaypointConstraint();
    } else if (constraint instanceof MeteredConstraint) {
        result = encodeMeteredConstraint();
    } else if (constraint instanceof TierConstraint) {
        result = encodeTierConstraint();
    } else {
        result = context.mapper().createObjectNode();
    }
    result.put(ConstraintCodec.TYPE, constraint.getClass().getSimpleName());
    return result;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObstacleConstraint(org.onosproject.net.intent.constraint.ObstacleConstraint) TierConstraint(org.onosproject.net.intent.constraint.TierConstraint) WaypointConstraint(org.onosproject.net.intent.constraint.WaypointConstraint) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) MeteredConstraint(org.onosproject.net.intent.constraint.MeteredConstraint) LinkTypeConstraint(org.onosproject.net.intent.constraint.LinkTypeConstraint) AnnotationConstraint(org.onosproject.net.intent.constraint.AnnotationConstraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint)

Aggregations

MeteredConstraint (org.onosproject.net.intent.constraint.MeteredConstraint)3 AnnotationConstraint (org.onosproject.net.intent.constraint.AnnotationConstraint)2 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)2 LatencyConstraint (org.onosproject.net.intent.constraint.LatencyConstraint)2 LinkTypeConstraint (org.onosproject.net.intent.constraint.LinkTypeConstraint)2 ObstacleConstraint (org.onosproject.net.intent.constraint.ObstacleConstraint)2 TierConstraint (org.onosproject.net.intent.constraint.TierConstraint)2 WaypointConstraint (org.onosproject.net.intent.constraint.WaypointConstraint)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Test (org.junit.Test)1 Constraint (org.onosproject.net.intent.Constraint)1 AsymmetricPathConstraint (org.onosproject.net.intent.constraint.AsymmetricPathConstraint)1 DomainConstraint (org.onosproject.net.intent.constraint.DomainConstraint)1