Search in sources :

Example 1 with LossMeasurementThreshold

use of org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementThreshold in project onos by opennetworkinglab.

the class LossMeasurementThresholdCodec method decode.

@Override
public LossMeasurementThreshold decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    JsonNode thrNode = json.get("threshold");
    SoamId thresholdId = SoamId.valueOf(nullIsIllegal(thrNode.get("id"), "thresholdId must not be null").asInt());
    LossMeasurementThreshold.LmThresholdBuilder builder = builder(thresholdId);
    if (thrNode.get("thresholds") != null) {
        context.codec(LossMeasurementThreshold.ThresholdOption.class).decode((ArrayNode) (thrNode.get("thresholds")), context).forEach(builder::addToThreshold);
    }
    if (thrNode.get(MEASUREDFLRFORWARD) != null) {
        builder.measuredFlrForward(MilliPct.ofPercent((float) thrNode.get(MEASUREDFLRFORWARD).asDouble()));
    }
    if (thrNode.get(MAXFLRFORWARD) != null) {
        builder.maxFlrForward(MilliPct.ofPercent((float) thrNode.get(MAXFLRFORWARD).asDouble()));
    }
    if (thrNode.get(AVERAGEFLRFORWARD) != null) {
        builder.averageFlrForward(MilliPct.ofPercent((float) thrNode.get(AVERAGEFLRFORWARD).asDouble()));
    }
    if (thrNode.get(MEASUREDFLRBACKWARD) != null) {
        builder.measuredFlrBackward(MilliPct.ofPercent((float) thrNode.get(MEASUREDFLRBACKWARD).asDouble()));
    }
    if (thrNode.get(MAXFLRBACKWARD) != null) {
        builder.maxFlrBackward(MilliPct.ofPercent((float) thrNode.get(MAXFLRBACKWARD).asDouble()));
    }
    if (thrNode.get(AVERAGEFLRBACKWARD) != null) {
        builder.averageFlrBackward(MilliPct.ofPercent((float) thrNode.get(AVERAGEFLRBACKWARD).asDouble()));
    }
    if (thrNode.get(FORWARDHIGHLOSS) != null) {
        builder.forwardHighLoss(thrNode.get(FORWARDHIGHLOSS).asLong());
    }
    if (thrNode.get(FORWARDCONSECUTIVEHIGHLOSS) != null) {
        builder.forwardConsecutiveHighLoss(thrNode.get(FORWARDCONSECUTIVEHIGHLOSS).asLong());
    }
    if (thrNode.get(BACKWARDHIGHLOSS) != null) {
        builder.backwardHighLoss(thrNode.get(BACKWARDHIGHLOSS).asLong());
    }
    if (thrNode.get(BACKWARDCONSECUTIVEHIGHLOSS) != null) {
        builder.backwardConsecutiveHighLoss(thrNode.get(BACKWARDCONSECUTIVEHIGHLOSS).asLong());
    }
    if (thrNode.get(FORWARDUNAVAILABLECOUNT) != null) {
        builder.forwardUnavailableCount(thrNode.get(FORWARDUNAVAILABLECOUNT).asLong());
    }
    if (thrNode.get(FORWARDAVAILABLERATIO) != null) {
        builder.forwardAvailableRatio(MilliPct.ofPercent((float) thrNode.get(FORWARDAVAILABLERATIO).asDouble()));
    }
    if (thrNode.get(BACKWARDUNAVAILABLECOUNT) != null) {
        builder.backwardUnavailableCount(thrNode.get(BACKWARDUNAVAILABLECOUNT).asLong());
    }
    if (thrNode.get(BACKWARDAVAILABLERATIO) != null) {
        builder.backwardAvailableRatio(MilliPct.ofPercent((float) thrNode.get(BACKWARDAVAILABLERATIO).asDouble()));
    }
    return builder.build();
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) LossMeasurementThreshold(org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementThreshold) SoamId(org.onosproject.incubator.net.l2monitoring.soam.SoamId)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 SoamId (org.onosproject.incubator.net.l2monitoring.soam.SoamId)1 LossMeasurementThreshold (org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementThreshold)1