Search in sources :

Example 1 with LmCreateBuilder

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

the class LossMeasurementCreateTest method setUp.

@Before
public void setUp() throws SoamConfigException {
    LossMeasurementThreshold lmt1 = DefaultLmThreshold.builder(SoamId.valueOf(4)).build();
    LmCreateBuilder builder = (LmCreateBuilder) DefaultLmCreate.builder(Version.Y17312008, MepId.valueOf((short) 10), Priority.PRIO3, LmType.LMLMM).addToCountersEnabled(CounterOption.AVAILABILITY_FORWARD_AVERAGE_FLR).addToCountersEnabled(CounterOption.AVAILABILITY_FORWARD_CONSECUTIVE_HIGH_LOSS).availabilityFlrThreshold(MilliPct.ofRatio(0.201f)).availabilityMeasurementInterval(Duration.ofSeconds(5)).availabilityNumberConsecutiveFlrMeasurements(6).availabilityNumberConsecutiveHighFlr((short) 7).availabilityNumberConsecutiveIntervals((short) 8).addToLossMeasurementThreshold(lmt1).frameSize((short) 100).dataPattern(DataPattern.ZEROES).testTlvIncluded(true).testTlvPattern(TestTlvPattern.NULL_SIGNAL_WITHOUT_CRC_32).messagePeriod(Duration.ofMinutes(9)).measurementInterval(Duration.ofMinutes(10)).numberIntervalsStored((short) 11).alignMeasurementIntervals(true).alignMeasurementOffset(Duration.ofSeconds(12)).startTime(StartTime.immediate()).stopTime(StopTime.none()).sessionType(SessionType.PROACTIVE);
    lmc1 = builder.build();
}
Also used : LmCreateBuilder(org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmCreateBuilder) Before(org.junit.Before)

Example 2 with LmCreateBuilder

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

the class LmCreateCodec method decode.

@Override
public LossMeasurementCreate decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    JsonNode lmNode = json.get(LM);
    Version version = Version.Y17312011;
    if (lmNode.get(VERSION) != null) {
        version = Version.valueOf(lmNode.get(VERSION).asText());
    }
    LmType lmCfgType = LmType.LMLMM;
    if (lmNode.get(LM_CFG_TYPE) != null) {
        lmCfgType = LmType.valueOf(lmNode.get(LM_CFG_TYPE).asText(LMLMM));
    }
    MepId remoteMepId = MepId.valueOf(nullIsIllegal(lmNode.get(REMOTE_MEP_ID), REMOTE_MEP_ID + " is required").shortValue());
    Priority prio = Priority.valueOf(nullIsIllegal(lmNode.get(PRIORITY), PRIORITY + " is required in the format 'PRIOn'").asText());
    try {
        LmCreateBuilder builder = DefaultLmCreate.builder(version, remoteMepId, prio, lmCfgType);
        if (lmNode.get(COUNTERS_ENABLED) != null) {
            context.codec(CounterOption.class).decode((ArrayNode) (lmNode.get(COUNTERS_ENABLED)), context).forEach(builder::addToCountersEnabled);
        }
        if (lmNode.get(THRESHOLDS) != null) {
            context.codec(LossMeasurementThreshold.class).decode((ArrayNode) (lmNode.get(THRESHOLDS)), context).forEach(builder::addToLossMeasurementThreshold);
        }
        if (lmNode.get(AVAILABILITY_MEASUREMENT_INTERVAL_MINS) != null) {
            builder = builder.availabilityMeasurementInterval(Duration.ofMinutes(lmNode.get(AVAILABILITY_MEASUREMENT_INTERVAL_MINS).asInt()));
        }
        if (lmNode.get(AVAILABILITY_NUMBER_CONSECUTIVE_FLR_MEASUREMENTS) != null) {
            builder = builder.availabilityNumberConsecutiveFlrMeasurements(lmNode.get(AVAILABILITY_NUMBER_CONSECUTIVE_FLR_MEASUREMENTS).asInt());
        }
        if (lmNode.get(AVAILABILITY_FLR_THRESHOLD_PCT) != null) {
            builder = builder.availabilityFlrThreshold(MilliPct.ofPercent((float) lmNode.get(AVAILABILITY_FLR_THRESHOLD_PCT).asDouble()));
        }
        if (lmNode.get(AVAILABILITY_NUMBER_CONSECUTIVE_INTERVALS) != null) {
            builder = builder.availabilityNumberConsecutiveIntervals((short) lmNode.get(AVAILABILITY_NUMBER_CONSECUTIVE_INTERVALS).asInt());
        }
        if (lmNode.get(AVAILABILITY_NUMBER_CONSECUTIVE_HIGH_FLR) != null) {
            builder = builder.availabilityNumberConsecutiveHighFlr((short) lmNode.get(AVAILABILITY_NUMBER_CONSECUTIVE_HIGH_FLR).asInt());
        }
        if (lmNode.get(FRAME_SIZE) != null) {
            builder = (LmCreateBuilder) builder.frameSize((short) lmNode.get(FRAME_SIZE).asInt());
        }
        if (lmNode.get(MESSAGE_PERIOD_MS) != null) {
            builder = (LmCreateBuilder) builder.messagePeriod(Duration.ofMillis(lmNode.get(MESSAGE_PERIOD_MS).asInt()));
        }
        if (lmNode.get(MEASUREMENT_INTERVAL_MINS) != null) {
            builder = (LmCreateBuilder) builder.measurementInterval(Duration.ofMinutes(lmNode.get(MEASUREMENT_INTERVAL_MINS).asInt()));
        }
        if (lmNode.get(ALIGN_MEASUREMENT_INTERVALS) != null) {
            builder = (LmCreateBuilder) builder.alignMeasurementIntervals(lmNode.get(ALIGN_MEASUREMENT_INTERVALS).asBoolean());
        }
        if (lmNode.get(ALIGN_MEASUREMENT_OFFSET_MINS) != null) {
            builder = (LmCreateBuilder) builder.alignMeasurementOffset(Duration.ofMinutes(lmNode.get(ALIGN_MEASUREMENT_OFFSET_MINS).asInt()));
        }
        if (lmNode.get(START_TIME) != null) {
            builder = (LmCreateBuilder) builder.startTime(context.codec(StartTime.class).decode((ObjectNode) lmNode.get(START_TIME), context));
        }
        if (lmNode.get(STOP_TIME) != null) {
            builder = (LmCreateBuilder) builder.stopTime(context.codec(StopTime.class).decode((ObjectNode) lmNode.get(STOP_TIME), context));
        }
        return builder.build();
    } catch (SoamConfigException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : LmCreateBuilder(org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmCreateBuilder) LmType(org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmType) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Version(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version) Priority(org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority) JsonNode(com.fasterxml.jackson.databind.JsonNode) SoamConfigException(org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)

Aggregations

LmCreateBuilder (org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmCreateBuilder)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Before (org.junit.Before)1 Priority (org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority)1 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)1 SoamConfigException (org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException)1 Version (org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version)1 LmType (org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmType)1