Initial import of CFM and SOAM api
Change-Id: Icf5cc2d5fb34b75460e80e8cced0d70265bcd33b
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/DefaultMeasurementCreateBase.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/DefaultMeasurementCreateBase.java
new file mode 100644
index 0000000..62b9e3a
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/DefaultMeasurementCreateBase.java
@@ -0,0 +1,287 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.soam.StartTime.StartTimeOption;
+import org.onosproject.incubator.net.l2monitoring.soam.StopTime.StopTimeOption;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DataPattern;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.TestTlvPattern;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version;
+
+/**
+ * Abstract implementation of {@link org.onosproject.incubator.net.l2monitoring.soam.MeasurementCreateBase}.
+ */
+public abstract class DefaultMeasurementCreateBase
+ implements MeasurementCreateBase {
+ protected final Version version;
+
+ protected final MepId remoteMepId;
+ protected final Duration messagePeriod;
+ protected final Priority priority;
+ protected final Short frameSize;
+ protected final DataPattern dataPattern;
+ protected final boolean testTlvIncluded;
+ protected final TestTlvPattern testTlvPattern;
+ protected final Duration measurementInterval;
+ protected final Short numberIntervalsStored;
+ protected final boolean alignMeasurementIntervals;
+ protected final Duration alignMeasurementOffset;
+ protected final SessionType sessionType;
+ protected final StartTime startTime;
+ protected final StopTime stopTime;
+
+ protected DefaultMeasurementCreateBase(DefaultMeasCreateBaseBuilder builder) {
+ this.version = builder.version;
+
+ this.remoteMepId = builder.remoteMepId;
+ this.messagePeriod = builder.messagePeriod;
+ this.priority = builder.priority;
+ this.frameSize = builder.frameSize;
+ this.dataPattern = builder.dataPattern;
+ this.testTlvIncluded = builder.testTlvIncluded;
+ this.testTlvPattern = builder.testTlvPattern;
+ this.measurementInterval = builder.measurementInterval;
+ this.numberIntervalsStored = builder.numberIntervalsStored;
+ this.alignMeasurementIntervals = builder.alignMeasurementIntervals;
+ this.alignMeasurementOffset = builder.alignMeasurementOffset;
+ this.sessionType = builder.sessionType;
+ this.startTime = builder.startTime;
+ this.stopTime = builder.stopTime;
+ }
+
+ @Override
+ public Version version() {
+ return version;
+ }
+
+ @Override
+ public MepId remoteMepId() {
+ return remoteMepId;
+ }
+
+ @Override
+ public Duration messagePeriod() {
+ return messagePeriod;
+ }
+
+ @Override
+ public Priority priority() {
+ return priority;
+ }
+
+ @Override
+ public Short frameSize() {
+ return frameSize;
+ }
+
+ @Override
+ public DataPattern dataPattern() {
+ return dataPattern;
+ }
+
+ @Override
+ public boolean testTlvIncluded() {
+ return testTlvIncluded;
+ }
+
+ @Override
+ public TestTlvPattern testTlvPattern() {
+ return testTlvPattern;
+ }
+
+ @Override
+ public Duration measurementInterval() {
+ return measurementInterval;
+ }
+
+ @Override
+ public Short numberIntervalsStored() {
+ return numberIntervalsStored;
+ }
+
+ @Override
+ public boolean alignMeasurementIntervals() {
+ return alignMeasurementIntervals;
+ }
+
+ @Override
+ public Duration alignMeasurementOffset() {
+ return alignMeasurementOffset;
+ }
+
+ @Override
+ public SessionType sessionType() {
+ return sessionType;
+ }
+
+ @Override
+ public StartTime startTime() {
+ return startTime;
+ }
+
+ @Override
+ public StopTime stopTime() {
+ return stopTime;
+ }
+
+ /**
+ * Abstract Builder class for building.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.MeasurementCreateBase}.
+ */
+ protected abstract static class DefaultMeasCreateBaseBuilder implements MeasCreateBaseBuilder {
+ protected final Version version;
+ protected final MepId remoteMepId;
+ protected final Priority priority;
+
+ protected Duration messagePeriod;
+ protected Short frameSize;
+ protected DataPattern dataPattern;
+ protected boolean testTlvIncluded;
+ protected TestTlvPattern testTlvPattern;
+ protected Duration measurementInterval;
+ protected Short numberIntervalsStored;
+ protected boolean alignMeasurementIntervals;
+ protected Duration alignMeasurementOffset;
+ protected SessionType sessionType;
+ protected StartTime startTime;
+ protected StopTime stopTime;
+
+ protected DefaultMeasCreateBaseBuilder(Version version,
+ MepId remoteMepId, Priority priority)
+ throws SoamConfigException {
+ super();
+ if (remoteMepId == null) {
+ throw new SoamConfigException("RemoteMepId is null");
+ }
+ this.remoteMepId = remoteMepId;
+ this.version = version;
+ this.priority = priority;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder messagePeriod(Duration messagePeriod) throws SoamConfigException {
+ if (messagePeriod.toMillis() < 3 || messagePeriod.toMillis() > 3600000) {
+ throw new SoamConfigException("Message Period must be between 3-3600000ms. Rejecting: "
+ + messagePeriod);
+ }
+ this.messagePeriod = messagePeriod;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder frameSize(Short frameSize) throws SoamConfigException {
+ if (frameSize < 64 || frameSize > 9600) {
+ throw new SoamConfigException("Frame Size must be between 64-9600 bytes."
+ + " Rejecting: " + frameSize);
+ }
+ this.frameSize = frameSize;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder dataPattern(DataPattern dataPattern) {
+ this.dataPattern = dataPattern;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder testTlvIncluded(boolean testTlvIncluded) {
+ this.testTlvIncluded = testTlvIncluded;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder testTlvPattern(TestTlvPattern testTlvPattern) {
+ this.testTlvPattern = testTlvPattern;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder measurementInterval(Duration measurementInterval) throws SoamConfigException {
+ if (measurementInterval.toMinutes() < 1 || measurementInterval.toMinutes() > 525600) {
+ throw new SoamConfigException(
+ "Measurement Interval must be between 1..525600 minutes. Rejecting: " + measurementInterval);
+ }
+ this.measurementInterval = measurementInterval;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder numberIntervalsStored(Short numberIntervalsStored)
+ throws SoamConfigException {
+ if (numberIntervalsStored < 2 || numberIntervalsStored > 1000) {
+ throw new SoamConfigException(
+ "Number Intervals Stored must be between 2-1000. "
+ + "Rejecting: " + numberIntervalsStored);
+ }
+ this.numberIntervalsStored = numberIntervalsStored;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder alignMeasurementIntervals(boolean alignMeasurementIntervals) {
+ this.alignMeasurementIntervals = alignMeasurementIntervals;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder alignMeasurementOffset(
+ Duration alignMeasurementOffset) throws SoamConfigException {
+ if (alignMeasurementOffset.toMinutes() < 0 || alignMeasurementOffset.toMinutes() > 525600) {
+ throw new SoamConfigException(
+ "Align Measurement Offset must be between 0..525600 minutes. Rejecting: " +
+ alignMeasurementOffset);
+ }
+ this.alignMeasurementOffset = alignMeasurementOffset;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder sessionType(SessionType sessionType) {
+ this.sessionType = sessionType;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder startTime(StartTime startTime) throws SoamConfigException {
+ if (startTime.option() == StartTimeOption.ABSOLUTE &&
+ startTime.absoluteTime().isBefore(Instant.now())) {
+ throw new SoamConfigException(
+ "Start Time must be not be in the past. Rejecting: " + startTime);
+ }
+ this.startTime = startTime;
+ return this;
+ }
+
+ @Override
+ public MeasCreateBaseBuilder stopTime(StopTime stopTime) throws SoamConfigException {
+ if (stopTime.option() == StopTimeOption.ABSOLUTE &&
+ stopTime.absoluteTime().isBefore(Instant.now())) {
+ throw new SoamConfigException(
+ "Stop Time must be not be in the past. Rejecting: " + stopTime);
+ }
+ this.stopTime = stopTime;
+ return this;
+ }
+
+
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/MeasurementCreateBase.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/MeasurementCreateBase.java
new file mode 100644
index 0000000..89428b0
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/MeasurementCreateBase.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import java.time.Duration;
+
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DataPattern;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.TestTlvPattern;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version;
+
+/**
+ * A base interface with attributes that are common to both Delay and Loss Measurements.
+ */
+public interface MeasurementCreateBase {
+ /**
+ * The version of the PDUs used to perform Loss or Delay Measurement.
+ * The exact PDUs to use are specified by this object in combination with measurement-type
+ * @return The version of the PDUs
+ */
+ Version version();
+
+ /**
+ * The remote MEP to perform the tests against.
+ * @return An ID of a MEP
+ */
+ MepId remoteMepId();
+
+ /**
+ * The interval between Loss or Delay Measurement OAM message transmission.
+ * For Loss Measurement monitoring applications the default value is 1 sec.
+ * This object is not applicable if measurement-type is set to 'ccm' and is ignored for that Loss Measurement Type
+ * @return A java Duration
+ */
+ Duration messagePeriod();
+
+ /**
+ * The priority of frames with Performance Monitoring OAM message information.
+ * @return A priority enumerated value 0-7
+ */
+ Priority priority();
+
+ /**
+ * The Loss Measurement frame size between 64 bytes and the maximum transmission unit of the EVC.
+ * The range of frame sizes from 64 through 2000 octets need to be supported,
+ * and the range of frame sizes from 2001 through 9600 octets is suggested be supported.
+ * The adjustment to the frame size of the standard frame size is accomplished
+ * by the addition of a Data or Test TLV. A Data or Test TLV is only added to
+ * the frame if the frame size is greater than 64 bytes
+ * @return frame size in bytes
+ */
+ Short frameSize();
+
+ /**
+ * The LM data pattern included in a Data TLV.
+ * when the size of the LM frame is determined by the frame-size object and test-tlv-included is 'false'.
+ * If the frame size object does not define the LM frame size or
+ * test-tlv-included is 'true' the value of this object is ignored
+ * @return The data pattern - ones or zeroes
+ */
+ DataPattern dataPattern();
+
+ /**
+ * Whether a Test TLV or Data TLV is included when the size of the LM frame is determined by the frame-size object.
+ * If the frame-size object does not define the LM frame size the value of
+ * this object is ignored.
+ * @return true indicates that the Test TLV is to be included, false indicates it is not
+ */
+ boolean testTlvIncluded();
+
+ /**
+ * The type of test pattern to be sent in the LM frame Test TLV.
+ * when the size of LM PDU is determined by the frame-size object and
+ * test-tlv-included is 'true'.
+ * If the frame size object does not define the LM frame size or
+ * test-tlv-included is 'false' the value of this object is ignored
+ * @return A TLV pattern enum
+ */
+ TestTlvPattern testTlvPattern();
+
+ /**
+ * The Measurement Interval for FLR statistics.
+ * A Measurement Interval of 15 minutes needs to be supported, other
+ * intervals may be supported.
+ * @return A java Duration
+ */
+ Duration measurementInterval();
+
+ /**
+ * The number of completed measurement intervals to store in the history statistic table.
+ * At least 32 completed measurement intervals are to be stored.
+ * 96 measurement intervals are recommended to be stored
+ * @return The number to be stored.
+ */
+ Short numberIntervalsStored();
+
+ /**
+ * Whether the measurement intervals for the Loss Measurement session are aligned with a zero offset to real time.
+ * The value 'true' indicates that each Measurement Interval starts at a time
+ * which is aligned to NE time source hour if the interval is a factor of an
+ * hour, i.e. 60min/15min = 4. For instance, a measurement time interval of
+ * 15 minutes would stop/start the measurement interval at 0, 15, 30, and 45
+ * minutes of an hour. A measurement interval of 7 minutes would not align to
+ * the hour since 7 minutes is NOT a factor of an hour, i.e. 60min/7min = 8.6,
+ * and the behavior is the same as if the object is set to 'false'.
+ * The value 'false' indicates that each Measurement Interval starts at a time
+ * which is indicated by repetition-period.
+ * One side effect of the usage of this parameter is that if the value is true
+ * and the repetition-period is not a factor of an hour then the start of the
+ * next Measurement Interval will be delayed until the next factor of an hour.
+ * @return See above for the meaning of true and false
+ */
+ boolean alignMeasurementIntervals();
+
+ /**
+ * The offset in minutes from the time of day value.
+ * if align-measurement-intervals is 'true' and the repetition time is a factor
+ * of 60 minutes. If not, the value of this object is ignored.
+ * If the Measurement Interval is 15 minutes and align-measurement-intervals
+ * is true and if this object was set to 5 minutes, the Measurement Intervals
+ * would start at 5, 20, 35, 50 minutes past each hour
+ * @return A java Duration
+ */
+ Duration alignMeasurementOffset();
+
+ /**
+ * Defines the session start time.
+ * @return An object with the start time type and optionally an instant
+ */
+ StartTime startTime();
+
+ /**
+ * Defines the session stop time.
+ * @return An object with the stop time type and optionally an instant
+ */
+ StopTime stopTime();
+
+ /**
+ * Indicates whether the current session is defined to be 'proactive' or 'on-demand.
+ * @return An enumerated value
+ */
+ SessionType sessionType();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.MeasurementCreateBase}.
+ */
+ public interface MeasCreateBaseBuilder {
+ MeasCreateBaseBuilder messagePeriod(
+ Duration messagePeriod) throws SoamConfigException;
+
+ MeasCreateBaseBuilder frameSize(Short frameSize) throws SoamConfigException;
+
+ MeasCreateBaseBuilder dataPattern(DataPattern dataPattern);
+
+ MeasCreateBaseBuilder testTlvIncluded(boolean testTlvIncluded);
+
+ MeasCreateBaseBuilder testTlvPattern(TestTlvPattern testTlvPattern);
+
+ MeasCreateBaseBuilder measurementInterval(
+ Duration measurementInterval) throws SoamConfigException;
+
+ MeasCreateBaseBuilder numberIntervalsStored(
+ Short numberIntervalsStored) throws SoamConfigException;
+
+ MeasCreateBaseBuilder alignMeasurementIntervals(
+ boolean alignMeasurementIntervals);
+
+ MeasCreateBaseBuilder alignMeasurementOffset(
+ Duration alignMeasurementOffset) throws SoamConfigException;
+
+ MeasCreateBaseBuilder startTime(StartTime startTime) throws SoamConfigException;
+
+ MeasCreateBaseBuilder stopTime(StopTime stopTime) throws SoamConfigException;
+
+ MeasCreateBaseBuilder sessionType(SessionType sessionType);
+
+ }
+
+ /**
+ * Supported session types.
+ * reference [MEF SOAM IA] R3
+ */
+ public enum SessionType {
+ /**
+ * The current session is 'proactive'.
+ */
+ PROACTIVE,
+ /**
+ * The current session is 'on-demand'.
+ */
+ ONDEMAND;
+ }
+
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/MilliPct.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/MilliPct.java
new file mode 100644
index 0000000..0c6dd88
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/MilliPct.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+/**
+ * A representation of a ratio in milli-percent.
+ */
+public final class MilliPct extends Number {
+
+ private static final long serialVersionUID = 1476288484705687568L;
+ private static NumberFormat pf = DecimalFormat.getPercentInstance();
+
+ private int value;
+
+ private MilliPct(int value) {
+ this.value = value;
+ pf.setMaximumFractionDigits(3);
+ }
+
+ public static MilliPct ofMilliPct(int value) {
+ return new MilliPct(value);
+ }
+
+ public static MilliPct ofPercent(float value) {
+ return new MilliPct(Float.valueOf(value * 1000f).intValue());
+ }
+
+ public static MilliPct ofRatio(float value) {
+ return new MilliPct(Float.valueOf(value * 100000f).intValue());
+ }
+
+ @Override
+ public int intValue() {
+ return value;
+ }
+
+ @Override
+ public long longValue() {
+ return value;
+ }
+
+ @Override
+ public float floatValue() {
+ return value;
+ }
+
+ @Override
+ public double doubleValue() {
+ return value;
+ }
+
+ public float percentValue() {
+ return value / 1000f;
+ }
+
+ public float ratioValue() {
+ return value / 100000f;
+ }
+
+ @Override
+ public String toString() {
+ return pf.format(ratioValue());
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamConfigException.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamConfigException.java
new file mode 100644
index 0000000..6ca9994
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamConfigException.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+/**
+ * Exception for configuration related to Service OAM.
+ */
+public class SoamConfigException extends Throwable {
+
+ private static final long serialVersionUID = 1L;
+
+ public SoamConfigException(String message) {
+ super(message);
+ }
+
+ public SoamConfigException(Throwable t) {
+ super(t);
+ }
+
+ public SoamConfigException(String message, Throwable t) {
+ super(message, t);
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamDmProgrammable.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamDmProgrammable.java
new file mode 100644
index 0000000..77582e9
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamDmProgrammable.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import org.onosproject.net.driver.HandlerBehaviour;
+
+/**
+ * Behaviour that allows Layer 2 SOAM PM in the form of Delay Measurement to be implemented by devices.
+ *
+ * Has all of the same methods as {@link org.onosproject.incubator.net.l2monitoring.soam.SoamService},
+ * so we don't repeat them here
+ */
+public interface SoamDmProgrammable extends HandlerBehaviour, SoamService {
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamId.java
new file mode 100644
index 0000000..a4434d9
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamId.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import org.onlab.util.Identifier;
+
+/**
+ * Identifier for SOAM objects.
+ */
+public class SoamId extends Identifier<Integer> {
+ protected SoamId(int id) {
+ super(id);
+ }
+
+ /**
+ * Creates a dm ID from a int value.
+ *
+ * @param id int value
+ * @return dm ID
+ */
+ public static SoamId valueOf(int id) {
+ if (id < 0) {
+ throw new IllegalArgumentException("SOAM Value must be unsigned."
+ + "Rejecting: " + id);
+ }
+ return new SoamId(id);
+ }
+
+ /**
+ * Gets the dm ID value.
+ *
+ * @return dm ID value as int
+ */
+ public int value() {
+ return this.identifier;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(identifier);
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamService.java
new file mode 100644
index 0000000..fc777cb
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamService.java
@@ -0,0 +1,334 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import java.util.Collection;
+import java.util.Optional;
+
+import org.onosproject.incubator.net.l2monitoring.cfm.MepTsCreate;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatCurrent;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatHistory;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementEntry;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatCurrent;
+
+/**
+ * Methods callable on MEPs to implement SOAM functionality.
+ * Most of the methods have been derived from the MEF 38 and MEF 39 standards
+ *
+ */
+public interface SoamService {
+ /**
+ * Get all of the Delay Measurements on a particular MEP.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @return A collection of Delay Measurements and their children
+ * @throws CfmConfigException If there's a problem with Cfm attributes
+ * @throws SoamConfigException If there's a problem with Soam attributes
+ */
+ Collection<DelayMeasurementEntry> getAllDms(MdId mdName, MaIdShort maName, MepId mepId)
+ throws CfmConfigException, SoamConfigException;
+
+ /**
+ * Get a named Delay Measurements on a particular MEP.
+ * While devices are not required to have named delay measurement objects
+ * so do. The getAllDms() method may have produced a list of DM Ids that can
+ * be used here to retrieve one DM at a time
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param dmId The id of the Delay Measurement
+ * @return A collection of Delay Measurements and their children
+ * @throws CfmConfigException If there's a problem with Cfm attributes
+ * @throws SoamConfigException If there's a problem with Soam attributes
+ */
+ DelayMeasurementEntry getDm(MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId)
+ throws CfmConfigException, SoamConfigException;
+
+ /**
+ * Get only the current stats of a named Delay Measurements on a particular MEP.
+ * It may be useful to retrieve the current stats on their own to retrieve
+ * values between Delay Measurement intervals
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param dmId The id of the Delay Measurement
+ * @throws CfmConfigException If there's a problem with Cfm attributes
+ * @throws SoamConfigException If there's a problem with Soam attributes
+ * @return A collection of Delay Measurements and their children
+ */
+ DelayMeasurementStatCurrent getDmCurrentStat(
+ MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId)
+ throws CfmConfigException, SoamConfigException;
+
+ /**
+ * Get only the history stats of a named Delay Measurements on a particular MEP.
+ * It may be useful to retrieve the history stats on their own to retrieve
+ * values before they have been overwritten
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param dmId The id of the Delay Measurement
+ * @throws CfmConfigException If there's a problem with Cfm attributes
+ * @throws SoamConfigException If there's a problem with Soam attributes
+ * @return A collection of Delay Measurements and their children
+ */
+ Collection<DelayMeasurementStatHistory> getDmHistoricalStats(
+ MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId)
+ throws CfmConfigException, SoamConfigException;
+
+ /**
+ * Create a Delay Measurement on a particular MEP.
+ * MEF 39 defines a delay measurement as an ephemeral object and does not
+ * require the supporting device to persist it. It runs as an action until
+ * stopped with the corresponding abort action below.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param dm The parameters of the Delay Measurement
+ * @return The id of the newly created DM if available
+ * @throws CfmConfigException If there's a problem with Cfm attributes
+ * @throws SoamConfigException If there's a problem with Soam attributes
+ */
+ Optional<SoamId> createDm(MdId mdName, MaIdShort maName, MepId mepId,
+ DelayMeasurementCreate dm) throws CfmConfigException, SoamConfigException;
+
+ /**
+ * Stop all Delay Measurements on a particular MEP.
+ * This stops the Delay Measurement activity started through the
+ * createDm action above. It is up to the individual device how to implement
+ * it. It does not necessarily mean delete the DM.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void abortDm(MdId mdName, MaIdShort maName, MepId mepId)
+ throws CfmConfigException;
+
+ /**
+ * Stop a particular named Delay Measurement on a particular MEP.
+ * This stops the Delay Measurement activity started through the
+ * createDm action above. It is up to the individual device how to implement
+ * it. It does not necessarily mean delete the DM.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param dmId The id of the DM
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void abortDm(MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId)
+ throws CfmConfigException;
+
+ /**
+ * Clear the history stats on all Delay Measurements on a particular MEP.
+ * This removes any historical stats stored on a device for one MEP
+ * It does NOT require that the Delay Measurement test is aborted.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void clearDelayHistoryStats(MdId mdName, MaIdShort maName, MepId mepId)
+ throws CfmConfigException;
+
+ /**
+ * Clear the history stats on a named Delay Measurement on a particular MEP.
+ * This removes any historical stats stored on a device for one DM on one MEP
+ * It does NOT require that the Delay Measurement test is aborted.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param dmId The id of the DM
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void clearDelayHistoryStats(MdId mdName, MaIdShort maName, MepId mepId,
+ SoamId dmId) throws CfmConfigException;
+
+ /**
+ * Get all of the Loss Measurements on a particular MEP.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @return A collection of Loss Measurements and their children
+ * @throws CfmConfigException When the command cannot be completed
+ * @throws SoamConfigException When the command cannot be completed
+ */
+ Collection<LossMeasurementEntry> getAllLms(MdId mdName, MaIdShort maName, MepId mepId)
+ throws CfmConfigException, SoamConfigException;
+
+ /**
+ * Get a named Loss Measurements on a particular MEP.
+ * While devices are not required to have named Loss measurement objects
+ * some do. The getAllLms() method may have produced a list of LM Ids that
+ * can be used here to retrieve one LM at a time
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param lmId The id of the Loss Measurement
+ * @return A collection of Loss Measurements and their children
+ * @throws CfmConfigException When the command cannot be completed
+ * @throws SoamConfigException When the command cannot be completed
+ */
+ LossMeasurementEntry getLm(MdId mdName, MaIdShort maName, MepId mepId,
+ SoamId lmId) throws CfmConfigException, SoamConfigException;
+
+ /**
+ * Get only the current stats of a named Loss Measurements on a particular MEP.
+ * It may be useful to retrieve the current stats on their own to retrieve
+ * values between Loss Measurement intervals
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param lmId The id of the Loss Measurement
+ * @return A collection of Loss Measurements and their children
+ */
+ LossMeasurementStatCurrent getLmCurrentStat(
+ MdId mdName, MaIdShort maName, MepId mepId, SoamId lmId);
+
+ /**
+ * Get only the history stats of a named Loss Measurements on a particular MEP.
+ * It may be useful to retrieve the history stats on their own to retrieve
+ * values before they have been overwritten
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param lmId The id of the Loss Measurement
+ * @return A collection of Loss Measurements and their children
+ */
+ Collection<LossMeasurementStatCurrent> getLmHistoricalStats(
+ MdId mdName, MaIdShort maName, MepId mepId, SoamId lmId);
+
+ /**
+ * Create a Loss Measurement on a particular MEP.
+ * MEF 39 defines a Loss measurement as an ephemeral object and does not
+ * require the supporting device to persist it. It runs as an action until
+ * stopped with the corresponding abort action below.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param lm The parameters of the Loss Measurement
+ * @return The id of the newly created LM if available
+ * @throws CfmConfigException When the command cannot be completed
+ * @throws SoamConfigException When the command cannot be completed
+ */
+ Optional<SoamId> createLm(MdId mdName, MaIdShort maName, MepId mepId,
+ LossMeasurementCreate lm) throws CfmConfigException, SoamConfigException;
+
+ /**
+ * Stop all Loss Measurements on a particular MEP.
+ * This stops the Loss Measurement activity started through the
+ * createLm action above. It is up to the individual device how to implement
+ * it. It does not necessarily mean delete the LM.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void abortLm(MdId mdName, MaIdShort maName, MepId mepId)
+ throws CfmConfigException;
+
+ /**
+ * Stop a particular named Loss Measurement on a particular MEP.
+ * This stops the Loss Measurement activity started through the
+ * createLm action above. It is up to the individual device how to implement
+ * it. It does not necessarily mean delete the LM.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param lmId The id of the LM
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void abortLm(MdId mdName, MaIdShort maName, MepId mepId, SoamId lmId)
+ throws CfmConfigException;
+
+ /**
+ * Clear the history stats on all Loss Measurements on a particular MEP.
+ * This removes any historical stats stored on a device for one MEP
+ * It does NOT require that the Loss Measurement test is aborted.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void clearLossHistoryStats(MdId mdName, MaIdShort maName, MepId mepId)
+ throws CfmConfigException;
+
+ /**
+ * Clear the history stats on a named Loss Measurement on a particular MEP.
+ * This removes any historical stats stored on a device for one LM on one MEP
+ * It does NOT require that the Loss Measurement test is aborted.
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param lmId The id of the LM
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void clearLossHistoryStats(MdId mdName, MaIdShort maName, MepId mepId,
+ SoamId lmId) throws CfmConfigException;
+
+ /**
+ * Create a Test Signal operation on a particular MEP.
+ * MEF39 defines the Test Signal as an ephemeral operation that is not
+ * required to be persisted by a device. Only one Test Signal is active
+ * on a MEP at a time
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @param tsCreate The parameters the Test Signal is created with
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void createTestSignal(MdId mdName, MaIdShort maName, MepId mepId,
+ MepTsCreate tsCreate) throws CfmConfigException;
+
+ /**
+ * Abort a Test Signal operation on a particular MEP.
+ * Abort a Test Signal operation on a Mep
+ *
+ * @param mdName The Maintenance Domain of the MEP
+ * @param maName The Maintenance Association of the MEP
+ * @param mepId The id of the MEP itself
+ * @throws CfmConfigException When the command cannot be completed
+ */
+ void abortTestSignal(MdId mdName, MaIdShort maName, MepId mepId)
+ throws CfmConfigException;
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamTime.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamTime.java
new file mode 100644
index 0000000..d8e5924
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/SoamTime.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import java.time.Duration;
+import java.time.Instant;
+
+/**
+ * A base class with common attributes of StartTime and StopTime.
+ */
+public abstract class SoamTime {
+ protected final TimeOption option;
+ protected final Duration relativeTime;
+ protected final Instant absoluteTime;
+
+ public TimeOption option() {
+ return option;
+ }
+
+ public Duration relativeTime() {
+ return relativeTime;
+ }
+
+ public Instant absoluteTime() {
+ return absoluteTime;
+ }
+
+ protected SoamTime(TimeOption option, Duration relativeStart, Instant absoluteStart) {
+ this.option = option;
+ this.relativeTime = relativeStart;
+ this.absoluteTime = absoluteStart;
+ }
+
+ /**
+ * Abstract interface for TimeOptions on SoamTime concrete classes.
+ */
+ public interface TimeOption {
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/StartTime.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/StartTime.java
new file mode 100644
index 0000000..02fa765
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/StartTime.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * A utility class for specifying a Start Time for Delay and Loss Measurements.
+ */
+public final class StartTime extends SoamTime {
+
+ protected StartTime(TimeOption option, Duration relativeStart, Instant absoluteStart) {
+ super(option, relativeStart, absoluteStart);
+ }
+
+ public static final StartTime immediate() {
+ return new StartTime(StartTimeOption.IMMEDIATE, null, null);
+ }
+
+ public static final StartTime relative(Duration relativeStart) {
+ return new StartTime(StartTimeOption.RELATIVE, relativeStart, null);
+ }
+
+ public static final StartTime absolute(Instant absoluteStart) {
+ return new StartTime(StartTimeOption.ABSOLUTE, null, absoluteStart);
+ }
+
+ @Override
+ public String toString() {
+ if (option == StartTimeOption.IMMEDIATE) {
+ return "immediate";
+ } else if (option == StartTimeOption.ABSOLUTE) {
+ return MoreObjects.toStringHelper(getClass()).add("absolute", absoluteTime).toString();
+ } else if (option == StartTimeOption.RELATIVE) {
+ return MoreObjects.toStringHelper(getClass()).add("relative", relativeTime).toString();
+ }
+ return "unknown";
+ }
+
+ /**
+ * Options for Start Time.
+ */
+ public enum StartTimeOption implements TimeOption {
+ IMMEDIATE,
+ RELATIVE,
+ ABSOLUTE;
+ }
+}
\ No newline at end of file
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/StopTime.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/StopTime.java
new file mode 100644
index 0000000..b581036
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/StopTime.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * A utility class for specifying a Stop Time for Delay and Loss Measurements.
+ */
+public final class StopTime extends SoamTime {
+
+ private StopTime(TimeOption option, Duration relativeStart, Instant absoluteStart) {
+ super(option, relativeStart, absoluteStart);
+ }
+
+ public static final StopTime none() {
+ return new StopTime(StopTimeOption.NONE, null, null);
+ }
+
+ public static final StopTime relative(Duration relativeStop) {
+ return new StopTime(StopTimeOption.RELATIVE, relativeStop, null);
+ }
+
+ public static final StopTime absolute(Instant absoluteStop) {
+ return new StopTime(StopTimeOption.ABSOLUTE, null, absoluteStop);
+ }
+
+ @Override
+ public String toString() {
+ if (option == StopTimeOption.NONE) {
+ return "none";
+ } else if (option == StopTimeOption.ABSOLUTE) {
+ return MoreObjects.toStringHelper(getClass()).add("absolute", absoluteTime).toString();
+ } else if (option == StopTimeOption.RELATIVE) {
+ return MoreObjects.toStringHelper(getClass()).add("relative", relativeTime).toString();
+ }
+ return "unknown";
+ }
+
+ /**
+ * Options for Stop Time.
+ */
+ public enum StopTimeOption implements TimeOption {
+ NONE,
+ RELATIVE,
+ ABSOLUTE;
+ }
+}
\ No newline at end of file
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementCreate.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementCreate.java
new file mode 100644
index 0000000..f74ff04
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementCreate.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.soam.DefaultMeasurementCreateBase;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+
+/**
+ * The default implementation of {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate}.
+ */
+public class DefaultDelayMeasurementCreate extends DefaultMeasurementCreateBase
+ implements DelayMeasurementCreate {
+
+ protected final DmType dmCfgType;
+ protected final Collection<MeasurementOption> measurementsEnabled;
+ protected final Short binsPerFdInterval;
+ protected final Short binsPerIfdvInterval;
+ protected final Short ifdvSelectionOffset;
+ protected final Short binsPerFdrInterval;
+ protected final Collection<DelayMeasurementThreshold> thresholds;
+
+ protected DefaultDelayMeasurementCreate(DefaultDmCreateBuilder builder) {
+ super(builder);
+ this.dmCfgType = builder.dmCfgType;
+ this.measurementsEnabled = builder.measurementsEnabled;
+ this.binsPerFdInterval = builder.binsPerFdInterval;
+ this.binsPerIfdvInterval = builder.binsPerIfdvInterval;
+ this.ifdvSelectionOffset = builder.ifdvSelectionOffset;
+ this.binsPerFdrInterval = builder.binsPerFdrInterval;
+ this.thresholds = builder.thresholds;
+ }
+
+ @Override
+ public DmType dmCfgType() {
+ return dmCfgType;
+ }
+
+ @Override
+ public Collection<MeasurementOption> measurementsEnabled() {
+ return measurementsEnabled;
+ }
+
+ @Override
+ public Short binsPerFdInterval() {
+ return binsPerFdInterval;
+ }
+
+ @Override
+ public Short binsPerIfdvInterval() {
+ return binsPerIfdvInterval;
+ }
+
+ @Override
+ public Short ifdvSelectionOffset() {
+ return ifdvSelectionOffset;
+ }
+
+ @Override
+ public Short binsPerFdrInterval() {
+ return binsPerFdrInterval;
+ }
+
+ @Override
+ public Collection<DelayMeasurementThreshold> thresholds() {
+ return thresholds;
+ }
+
+ public static DmCreateBuilder builder(DmType dmCfgType,
+ Version version, MepId remoteMepId, Priority priority)
+ throws SoamConfigException {
+ return new DefaultDmCreateBuilder(dmCfgType, version, remoteMepId, priority);
+ }
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate}.
+ */
+ protected static class DefaultDmCreateBuilder extends DefaultMeasCreateBaseBuilder
+ implements DmCreateBuilder {
+ protected final DmType dmCfgType;
+
+ protected Collection<MeasurementOption> measurementsEnabled;
+ protected Short binsPerFdInterval;
+ protected Short binsPerIfdvInterval;
+ protected Short ifdvSelectionOffset;
+ protected Short binsPerFdrInterval;
+ protected Collection<DelayMeasurementThreshold> thresholds;
+
+ protected DefaultDmCreateBuilder(DmType dmCfgType, Version version,
+ MepId remoteMepId, Priority priority)
+ throws SoamConfigException {
+ super(version, remoteMepId, priority);
+ this.dmCfgType = dmCfgType;
+ measurementsEnabled = new ArrayList<>();
+ thresholds = new ArrayList<>();
+ }
+
+ @Override
+ public DmCreateBuilder addToMeasurementsEnabled(
+ MeasurementOption measurementEnabled) {
+ this.measurementsEnabled.add(measurementEnabled);
+ return this;
+ }
+
+ @Override
+ public DmCreateBuilder binsPerFdInterval(Short binsPerFdInterval)
+ throws SoamConfigException {
+ if (binsPerFdInterval < 2 || binsPerFdInterval > 100) {
+ throw new SoamConfigException(
+ "Bins Per Fd Interval must be between 2..100. Rejecting: " +
+ binsPerFdInterval);
+ }
+ this.binsPerFdInterval = binsPerFdInterval;
+ return this;
+ }
+
+ @Override
+ public DmCreateBuilder binsPerIfdvInterval(Short binsPerIfdvInterval)
+ throws SoamConfigException {
+ if (binsPerIfdvInterval < 2 || binsPerIfdvInterval > 100) {
+ throw new SoamConfigException(
+ "Bins Per Ifdv Interval must be between 2..100. Rejecting: " +
+ binsPerIfdvInterval);
+ }
+ this.binsPerIfdvInterval = binsPerIfdvInterval;
+ return this;
+ }
+
+ @Override
+ public DmCreateBuilder ifdvSelectionOffset(Short ifdvSelectionOffset)
+ throws SoamConfigException {
+ if (ifdvSelectionOffset < 2 || ifdvSelectionOffset > 100) {
+ throw new SoamConfigException(
+ "IFDV Selection Offset must be between 2..100. Rejecting: " +
+ ifdvSelectionOffset);
+ }
+ this.ifdvSelectionOffset = ifdvSelectionOffset;
+ return this;
+ }
+
+ @Override
+ public DmCreateBuilder binsPerFdrInterval(Short binsPerFdrInterval)
+ throws SoamConfigException {
+ if (binsPerFdrInterval < 2 || binsPerFdrInterval > 100) {
+ throw new SoamConfigException(
+ "Bins Per Fd Interval must be between 2..100. Rejecting: " +
+ binsPerFdrInterval);
+ }
+ this.binsPerFdrInterval = binsPerFdrInterval;
+ return this;
+ }
+
+ @Override
+ public DmCreateBuilder addToThresholds(
+ DelayMeasurementThreshold threshold) {
+ this.thresholds.add(threshold);
+ return this;
+ }
+
+ @Override
+ public DelayMeasurementCreate build() {
+ return new DefaultDelayMeasurementCreate(this);
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementEntry.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementEntry.java
new file mode 100644
index 0000000..c53c63b
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementEntry.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+import com.google.common.collect.Lists;
+
+/**
+ * The default implementation of {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry}.
+ */
+public final class DefaultDelayMeasurementEntry
+ extends DefaultDelayMeasurementCreate implements DelayMeasurementEntry {
+
+ private final SoamId dmId;
+ private final SessionStatus sessionStatus;
+ private final Duration frameDelayTwoWay;
+ private final Duration frameDelayForward;
+ private final Duration frameDelayBackward;
+ private final Duration interFrameDelayVariationTwoWay;
+ private final Duration interFrameDelayVariationForward;
+ private final Duration interFrameDelayVariationBackward;
+ private final DelayMeasurementStatCurrent currentResult;
+ private final Collection<DelayMeasurementStatHistory> historicalResults;
+
+ private DefaultDelayMeasurementEntry(DefaultDmEntryBuilder builder) {
+ super(builder);
+ this.dmId = builder.dmId;
+ this.currentResult = builder.currentResult;
+ this.historicalResults = builder.historicalResults;
+
+ this.sessionStatus = builder.sessionStatus;
+ this.frameDelayTwoWay = builder.frameDelayTwoWay;
+ this.frameDelayForward = builder.frameDelayForward;
+ this.frameDelayBackward = builder.frameDelayBackward;
+ this.interFrameDelayVariationTwoWay = builder.interFrameDelayVariationTwoWay;
+ this.interFrameDelayVariationForward = builder.interFrameDelayVariationForward;
+ this.interFrameDelayVariationBackward = builder.interFrameDelayVariationBackward;
+ }
+
+ @Override
+ public SoamId dmId() {
+ return dmId;
+ }
+
+ @Override
+ public SessionStatus sessionStatus() {
+ return sessionStatus;
+ }
+
+ @Override
+ public Duration frameDelayTwoWay() {
+ return frameDelayTwoWay;
+ }
+
+ @Override
+ public Duration frameDelayForward() {
+ return frameDelayForward;
+ }
+
+ @Override
+ public Duration frameDelayBackward() {
+ return frameDelayBackward;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationTwoWay() {
+ return interFrameDelayVariationTwoWay;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationForward() {
+ return interFrameDelayVariationForward;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationBackward() {
+ return interFrameDelayVariationBackward;
+ }
+
+ @Override
+ public DelayMeasurementStatCurrent currentResult() {
+ return currentResult;
+ }
+
+ @Override
+ public Collection<DelayMeasurementStatHistory> historicalResults() {
+ if (historicalResults != null) {
+ return Lists.newArrayList(historicalResults);
+ }
+ return null;
+ }
+
+ public static DmEntryBuilder builder(SoamId dmId, DmType dmCfgType,
+ Version version, MepId remoteMepId, Priority priority)
+ throws SoamConfigException {
+ return new DefaultDmEntryBuilder(dmId, dmCfgType, version,
+ remoteMepId, priority);
+ }
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry}.
+ */
+ private static final class DefaultDmEntryBuilder extends DefaultDmCreateBuilder
+ implements DmEntryBuilder {
+ private final SoamId dmId;
+ private SessionStatus sessionStatus;
+ private Duration frameDelayTwoWay;
+ private Duration frameDelayForward;
+ private Duration frameDelayBackward;
+ private Duration interFrameDelayVariationTwoWay;
+ private Duration interFrameDelayVariationForward;
+ private Duration interFrameDelayVariationBackward;
+ private DelayMeasurementStatCurrent currentResult;
+ private Collection<DelayMeasurementStatHistory> historicalResults;
+
+ private DefaultDmEntryBuilder(SoamId dmId, DmType dmCfgType,
+ Version version, MepId remoteMepId, Priority priority)
+ throws SoamConfigException {
+ super(dmCfgType, version, remoteMepId, priority);
+ if (dmId == null) {
+ throw new SoamConfigException("DmId is null");
+ }
+ this.dmId = dmId;
+ historicalResults = new ArrayList<>();
+ }
+
+ @Override
+ public DmEntryBuilder sessionStatus(SessionStatus sessionStatus) {
+ this.sessionStatus = sessionStatus;
+ return this;
+ }
+
+ @Override
+ public DmEntryBuilder frameDelayTwoWay(Duration frameDelayTwoWay) {
+ this.frameDelayTwoWay = frameDelayTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmEntryBuilder frameDelayForward(Duration frameDelayForward) {
+ this.frameDelayForward = frameDelayForward;
+ return this;
+ }
+
+ @Override
+ public DmEntryBuilder frameDelayBackward(Duration frameDelayBackward) {
+ this.frameDelayBackward = frameDelayBackward;
+ return this;
+ }
+
+ @Override
+ public DmEntryBuilder interFrameDelayVariationTwoWay(
+ Duration interFrameDelayVariationTwoWay) {
+ this.interFrameDelayVariationTwoWay = interFrameDelayVariationTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmEntryBuilder interFrameDelayVariationForward(
+ Duration interFrameDelayVariationForward) {
+ this.interFrameDelayVariationForward = interFrameDelayVariationForward;
+ return this;
+ }
+
+ @Override
+ public DmEntryBuilder interFrameDelayVariationBackward(
+ Duration interFrameDelayVariationBackward) {
+ this.interFrameDelayVariationBackward = interFrameDelayVariationBackward;
+ return this;
+ }
+
+ @Override
+ public DmEntryBuilder currentResult(DelayMeasurementStatCurrent currentResult) {
+ this.currentResult = currentResult;
+ return this;
+ }
+
+ @Override
+ public DmEntryBuilder addToHistoricalResults(
+ DelayMeasurementStatHistory historicalResult) {
+ this.historicalResults.add(historicalResult);
+ return this;
+ }
+
+ @Override
+ public DelayMeasurementEntry build() {
+ return new DefaultDelayMeasurementEntry(this);
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementStat.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementStat.java
new file mode 100644
index 0000000..01f0bc4
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementStat.java
@@ -0,0 +1,589 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Duration;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+/**
+ * Abstract default implementation of DelayMeasurementStat.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStat}.
+ */
+public abstract class DefaultDelayMeasurementStat implements DelayMeasurementStat {
+
+ private final Duration elapsedTime;
+ private final boolean suspectStatus;
+ private final Duration frameDelayTwoWayMin;
+ private final Duration frameDelayTwoWayMax;
+ private final Duration frameDelayTwoWayAvg;
+ private final Duration frameDelayForwardMin;
+ private final Duration frameDelayForwardMax;
+ private final Duration frameDelayForwardAvg;
+ private final Duration frameDelayBackwardMin;
+ private final Duration frameDelayBackwardMax;
+ private final Duration frameDelayBackwardAvg;
+ private final Duration interFrameDelayVariationTwoWayMin;
+ private final Duration interFrameDelayVariationTwoWayMax;
+ private final Duration interFrameDelayVariationTwoWayAvg;
+ private final Duration interFrameDelayVariationForwardMin;
+ private final Duration interFrameDelayVariationForwardMax;
+ private final Duration interFrameDelayVariationForwardAvg;
+ private final Duration interFrameDelayVariationBackwardMin;
+ private final Duration interFrameDelayVariationBackwardMax;
+ private final Duration interFrameDelayVariationBackwardAvg;
+ private final Duration frameDelayRangeTwoWayMax;
+ private final Duration frameDelayRangeTwoWayAvg;
+ private final Duration frameDelayRangeForwardMax;
+ private final Duration frameDelayRangeForwardAvg;
+ private final Duration frameDelayRangeBackwardMax;
+ private final Duration frameDelayRangeBackwardAvg;
+ private final Integer soamPdusSent;
+ private final Integer soamPdusReceived;
+ private final Map<Duration, Integer> frameDelayTwoWayBins;
+ private final Map<Duration, Integer> frameDelayForwardBins;
+ private final Map<Duration, Integer> frameDelayBackwardBins;
+ private final Map<Duration, Integer> interFrameDelayVariationTwoWayBins;
+ private final Map<Duration, Integer> interFrameDelayVariationForwardBins;
+ private final Map<Duration, Integer> interFrameDelayVariationBackwardBins;
+ private final Map<Duration, Integer> frameDelayRangeTwoWayBins;
+ private final Map<Duration, Integer> frameDelayRangeForwardBins;
+ private final Map<Duration, Integer> frameDelayRangeBackwardBins;
+
+ protected DefaultDelayMeasurementStat(DefaultDmStatBuilder builder) {
+ this.elapsedTime = builder.elapsedTime;
+ this.suspectStatus = builder.suspectStatus;
+ this.frameDelayTwoWayMin = builder.frameDelayTwoWayMin;
+ this.frameDelayTwoWayMax = builder.frameDelayTwoWayMax;
+ this.frameDelayTwoWayAvg = builder.frameDelayTwoWayAvg;
+ this.frameDelayForwardMin = builder.frameDelayForwardMin;
+ this.frameDelayForwardMax = builder.frameDelayForwardMax;
+ this.frameDelayForwardAvg = builder.frameDelayForwardAvg;
+ this.frameDelayBackwardMin = builder.frameDelayBackwardMin;
+ this.frameDelayBackwardMax = builder.frameDelayBackwardMax;
+ this.frameDelayBackwardAvg = builder.frameDelayBackwardAvg;
+ this.interFrameDelayVariationTwoWayMin = builder.interFrameDelayVariationTwoWayMin;
+ this.interFrameDelayVariationTwoWayMax = builder.interFrameDelayVariationTwoWayMax;
+ this.interFrameDelayVariationTwoWayAvg = builder.interFrameDelayVariationTwoWayAvg;
+ this.interFrameDelayVariationForwardMin = builder.interFrameDelayVariationForwardMin;
+ this.interFrameDelayVariationForwardMax = builder.interFrameDelayVariationForwardMax;
+ this.interFrameDelayVariationForwardAvg = builder.interFrameDelayVariationForwardAvg;
+ this.interFrameDelayVariationBackwardMin = builder.interFrameDelayVariationBackwardMin;
+ this.interFrameDelayVariationBackwardMax = builder.interFrameDelayVariationBackwardMax;
+ this.interFrameDelayVariationBackwardAvg = builder.interFrameDelayVariationBackwardAvg;
+ this.frameDelayRangeTwoWayMax = builder.frameDelayRangeTwoWayMax;
+ this.frameDelayRangeTwoWayAvg = builder.frameDelayRangeTwoWayAvg;
+ this.frameDelayRangeForwardMax = builder.frameDelayRangeForwardMax;
+ this.frameDelayRangeForwardAvg = builder.frameDelayRangeForwardAvg;
+ this.frameDelayRangeBackwardMax = builder.frameDelayRangeBackwardMax;
+ this.frameDelayRangeBackwardAvg = builder.frameDelayRangeBackwardAvg;
+ this.soamPdusSent = builder.soamPdusSent;
+ this.soamPdusReceived = builder.soamPdusReceived;
+ this.frameDelayTwoWayBins = builder.frameDelayTwoWayBins;
+ this.frameDelayForwardBins = builder.frameDelayForwardBins;
+ this.frameDelayBackwardBins = builder.frameDelayBackwardBins;
+ this.interFrameDelayVariationTwoWayBins = builder.interFrameDelayVariationTwoWayBins;
+ this.interFrameDelayVariationForwardBins = builder.interFrameDelayVariationForwardBins;
+ this.interFrameDelayVariationBackwardBins = builder.interFrameDelayVariationBackwardBins;
+ this.frameDelayRangeTwoWayBins = builder.frameDelayRangeTwoWayBins;
+ this.frameDelayRangeForwardBins = builder.frameDelayRangeForwardBins;
+ this.frameDelayRangeBackwardBins = builder.frameDelayRangeBackwardBins;
+ }
+
+ @Override
+ public Duration elapsedTime() {
+ return elapsedTime;
+ }
+
+ @Override
+ public boolean suspectStatus() {
+ return suspectStatus;
+ }
+
+ @Override
+ public Duration frameDelayTwoWayMin() {
+ return frameDelayTwoWayMin;
+ }
+
+ @Override
+ public Duration frameDelayTwoWayMax() {
+ return frameDelayTwoWayMax;
+ }
+
+ @Override
+ public Duration frameDelayTwoWayAvg() {
+ return frameDelayTwoWayAvg;
+ }
+
+ @Override
+ public Duration frameDelayForwardMin() {
+ return frameDelayForwardMin;
+ }
+
+ @Override
+ public Duration frameDelayForwardMax() {
+ return frameDelayForwardMax;
+ }
+
+ @Override
+ public Duration frameDelayForwardAvg() {
+ return frameDelayForwardAvg;
+ }
+
+ @Override
+ public Duration frameDelayBackwardMin() {
+ return frameDelayBackwardMin;
+ }
+
+ @Override
+ public Duration frameDelayBackwardMax() {
+ return frameDelayBackwardMax;
+ }
+
+ @Override
+ public Duration frameDelayBackwardAvg() {
+ return frameDelayBackwardAvg;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationTwoWayMin() {
+ return interFrameDelayVariationTwoWayMin;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationTwoWayMax() {
+ return interFrameDelayVariationTwoWayMax;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationTwoWayAvg() {
+ return interFrameDelayVariationTwoWayAvg;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationForwardMin() {
+ return interFrameDelayVariationForwardMin;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationForwardMax() {
+ return interFrameDelayVariationForwardMax;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationForwardAvg() {
+ return interFrameDelayVariationForwardAvg;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationBackwardMin() {
+ return interFrameDelayVariationBackwardMin;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationBackwardMax() {
+ return interFrameDelayVariationBackwardMax;
+ }
+
+ @Override
+ public Duration interFrameDelayVariationBackwardAvg() {
+ return interFrameDelayVariationBackwardAvg;
+ }
+
+ @Override
+ public Duration frameDelayRangeTwoWayMax() {
+ return frameDelayRangeTwoWayMax;
+ }
+
+ @Override
+ public Duration frameDelayRangeTwoWayAvg() {
+ return frameDelayRangeTwoWayAvg;
+ }
+
+ @Override
+ public Duration frameDelayRangeForwardMax() {
+ return frameDelayRangeForwardMax;
+ }
+
+ @Override
+ public Duration frameDelayRangeForwardAvg() {
+ return frameDelayRangeForwardAvg;
+ }
+
+ @Override
+ public Duration frameDelayRangeBackwardMax() {
+ return frameDelayRangeBackwardMax;
+ }
+
+ @Override
+ public Duration frameDelayRangeBackwardAvg() {
+ return frameDelayRangeBackwardAvg;
+ }
+
+ @Override
+ public Integer soamPdusSent() {
+ return soamPdusSent;
+ }
+
+ @Override
+ public Integer soamPdusReceived() {
+ return soamPdusReceived;
+ }
+
+ @Override
+ public Map<Duration, Integer> frameDelayTwoWayBins() {
+ if (frameDelayTwoWayBins != null) {
+ return Maps.newHashMap(frameDelayTwoWayBins);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Map<Duration, Integer> frameDelayForwardBins() {
+ if (frameDelayForwardBins != null) {
+ return Maps.newHashMap(frameDelayForwardBins);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Map<Duration, Integer> frameDelayBackwardBins() {
+ if (frameDelayBackwardBins != null) {
+ return Maps.newHashMap(frameDelayBackwardBins);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Map<Duration, Integer> interFrameDelayVariationTwoWayBins() {
+ if (interFrameDelayVariationTwoWayBins != null) {
+ return Maps.newHashMap(interFrameDelayVariationTwoWayBins);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Map<Duration, Integer> interFrameDelayVariationForwardBins() {
+ if (interFrameDelayVariationForwardBins != null) {
+ return Maps.newHashMap(interFrameDelayVariationForwardBins);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Map<Duration, Integer> interFrameDelayVariationBackwardBins() {
+ if (interFrameDelayVariationBackwardBins != null) {
+ return Maps.newHashMap(interFrameDelayVariationBackwardBins);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Map<Duration, Integer> frameDelayRangeTwoWayBins() {
+ if (frameDelayRangeTwoWayBins != null) {
+ return Maps.newHashMap(frameDelayRangeTwoWayBins);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Map<Duration, Integer> frameDelayRangeForwardBins() {
+ if (frameDelayRangeForwardBins != null) {
+ return Maps.newHashMap(frameDelayRangeForwardBins);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Map<Duration, Integer> frameDelayRangeBackwardBins() {
+ if (frameDelayRangeBackwardBins != null) {
+ return Maps.newHashMap(frameDelayRangeBackwardBins);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Abstract builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStat}.
+ */
+ protected abstract static class DefaultDmStatBuilder implements DmStatBuilder {
+
+ private final Duration elapsedTime;
+ private final boolean suspectStatus;
+ private Duration frameDelayTwoWayMin;
+ private Duration frameDelayTwoWayMax;
+ private Duration frameDelayTwoWayAvg;
+ private Duration frameDelayForwardMin;
+ private Duration frameDelayForwardMax;
+ private Duration frameDelayForwardAvg;
+ private Duration frameDelayBackwardMin;
+ private Duration frameDelayBackwardMax;
+ private Duration frameDelayBackwardAvg;
+ private Duration interFrameDelayVariationTwoWayMin;
+ private Duration interFrameDelayVariationTwoWayMax;
+ private Duration interFrameDelayVariationTwoWayAvg;
+ private Duration interFrameDelayVariationForwardMin;
+ private Duration interFrameDelayVariationForwardMax;
+ private Duration interFrameDelayVariationForwardAvg;
+ private Duration interFrameDelayVariationBackwardMin;
+ private Duration interFrameDelayVariationBackwardMax;
+ private Duration interFrameDelayVariationBackwardAvg;
+ private Duration frameDelayRangeTwoWayMax;
+ private Duration frameDelayRangeTwoWayAvg;
+ private Duration frameDelayRangeForwardMax;
+ private Duration frameDelayRangeForwardAvg;
+ private Duration frameDelayRangeBackwardMax;
+ private Duration frameDelayRangeBackwardAvg;
+ private Integer soamPdusSent;
+ private Integer soamPdusReceived;
+ private Map<Duration, Integer> frameDelayTwoWayBins;
+ private Map<Duration, Integer> frameDelayForwardBins;
+ private Map<Duration, Integer> frameDelayBackwardBins;
+ private Map<Duration, Integer> interFrameDelayVariationTwoWayBins;
+ private Map<Duration, Integer> interFrameDelayVariationForwardBins;
+ private Map<Duration, Integer> interFrameDelayVariationBackwardBins;
+ private Map<Duration, Integer> frameDelayRangeTwoWayBins;
+ private Map<Duration, Integer> frameDelayRangeForwardBins;
+ private Map<Duration, Integer> frameDelayRangeBackwardBins;
+
+ protected DefaultDmStatBuilder(Duration elapsedTime, boolean suspectStatus) {
+ this.elapsedTime = elapsedTime;
+ this.suspectStatus = suspectStatus;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayTwoWayMin(Duration frameDelayTwoWayMin) {
+ this.frameDelayTwoWayMin = frameDelayTwoWayMin;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayTwoWayMax(Duration frameDelayTwoWayMax) {
+ this.frameDelayTwoWayMax = frameDelayTwoWayMax;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayTwoWayAvg(Duration frameDelayTwoWayAvg) {
+ this.frameDelayTwoWayAvg = frameDelayTwoWayAvg;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayForwardMin(Duration frameDelayForwardMin) {
+ this.frameDelayForwardMin = frameDelayForwardMin;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayForwardMax(Duration frameDelayForwardMax) {
+ this.frameDelayForwardMax = frameDelayForwardMax;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayForwardAvg(Duration frameDelayForwardAvg) {
+ this.frameDelayForwardAvg = frameDelayForwardAvg;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayBackwardMin(Duration frameDelayBackwardMin) {
+ this.frameDelayBackwardMin = frameDelayBackwardMin;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayBackwardMax(Duration frameDelayBackwardMax) {
+ this.frameDelayBackwardMax = frameDelayBackwardMax;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayBackwardAvg(Duration frameDelayBackwardAvg) {
+ this.frameDelayBackwardAvg = frameDelayBackwardAvg;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationTwoWayMin(Duration interFrameDelayVariationTwoWayMin) {
+ this.interFrameDelayVariationTwoWayMin = interFrameDelayVariationTwoWayMin;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationTwoWayMax(Duration interFrameDelayVariationTwoWayMax) {
+ this.interFrameDelayVariationTwoWayMax = interFrameDelayVariationTwoWayMax;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationTwoWayAvg(Duration interFrameDelayVariationTwoWayAvg) {
+ this.interFrameDelayVariationTwoWayAvg = interFrameDelayVariationTwoWayAvg;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationForwardMin(Duration interFrameDelayVariationForwardMin) {
+ this.interFrameDelayVariationForwardMin = interFrameDelayVariationForwardMin;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationForwardMax(Duration interFrameDelayVariationForwardMax) {
+ this.interFrameDelayVariationForwardMax = interFrameDelayVariationForwardMax;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationForwardAvg(Duration interFrameDelayVariationForwardAvg) {
+ this.interFrameDelayVariationForwardAvg = interFrameDelayVariationForwardAvg;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationBackwardMin(Duration interFrameDelayVariationBackwardMin) {
+ this.interFrameDelayVariationBackwardMin = interFrameDelayVariationBackwardMin;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationBackwardMax(Duration interFrameDelayVariationBackwardMax) {
+ this.interFrameDelayVariationBackwardMax = interFrameDelayVariationBackwardMax;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationBackwardAvg(Duration interFrameDelayVariationBackwardAvg) {
+ this.interFrameDelayVariationBackwardAvg = interFrameDelayVariationBackwardAvg;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayRangeTwoWayMax(Duration frameDelayRangeTwoWayMax) {
+ this.frameDelayRangeTwoWayMax = frameDelayRangeTwoWayMax;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayRangeTwoWayAvg(Duration frameDelayRangeTwoWayAvg) {
+ this.frameDelayRangeTwoWayAvg = frameDelayRangeTwoWayAvg;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayRangeForwardMax(Duration frameDelayRangeForwardMax) {
+ this.frameDelayRangeForwardMax = frameDelayRangeForwardMax;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayRangeForwardAvg(Duration frameDelayRangeForwardAvg) {
+ this.frameDelayRangeForwardAvg = frameDelayRangeForwardAvg;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayRangeBackwardMax(Duration frameDelayRangeBackwardMax) {
+ this.frameDelayRangeBackwardMax = frameDelayRangeBackwardMax;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayRangeBackwardAvg(Duration frameDelayRangeBackwardAvg) {
+ this.frameDelayRangeBackwardAvg = frameDelayRangeBackwardAvg;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder soamPdusSent(Integer soamPdusSent) {
+ this.soamPdusSent = soamPdusSent;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder soamPdusReceived(Integer soamPdusReceived) {
+ this.soamPdusReceived = soamPdusReceived;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayTwoWayBins(Map<Duration, Integer> frameDelayTwoWayBins) {
+ this.frameDelayTwoWayBins = frameDelayTwoWayBins;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayForwardBins(Map<Duration, Integer> frameDelayForwardBins) {
+ this.frameDelayForwardBins = frameDelayForwardBins;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayBackwardBins(Map<Duration, Integer> frameDelayBackwardBins) {
+ this.frameDelayBackwardBins = frameDelayBackwardBins;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationTwoWayBins(
+ Map<Duration, Integer> interFrameDelayVariationTwoWayBins) {
+ this.interFrameDelayVariationTwoWayBins = interFrameDelayVariationTwoWayBins;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationForwardBins(
+ Map<Duration, Integer> interFrameDelayVariationForwardBins) {
+ this.interFrameDelayVariationForwardBins = interFrameDelayVariationForwardBins;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder interFrameDelayVariationBackwardBins(
+ Map<Duration, Integer> interFrameDelayVariationBackwardBins) {
+ this.interFrameDelayVariationBackwardBins = interFrameDelayVariationBackwardBins;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayRangeTwoWayBins(Map<Duration, Integer> frameDelayRangeTwoWayBins) {
+ this.frameDelayRangeTwoWayBins = frameDelayRangeTwoWayBins;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayRangeForwardBins(Map<Duration, Integer> frameDelayRangeForwardBins) {
+ this.frameDelayRangeForwardBins = frameDelayRangeForwardBins;
+ return this;
+ }
+
+ @Override
+ public DmStatBuilder frameDelayRangeBackwardBins(Map<Duration, Integer> frameDelayRangeBackwardBins) {
+ this.frameDelayRangeBackwardBins = frameDelayRangeBackwardBins;
+ return this;
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementStatCurrent.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementStatCurrent.java
new file mode 100644
index 0000000..7263134
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementStatCurrent.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Duration;
+import java.time.Instant;
+
+/**
+ * The default implementation of DelayMeasurementStatCurrent.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatCurrent}.
+ */
+public final class DefaultDelayMeasurementStatCurrent
+ extends DefaultDelayMeasurementStat
+ implements DelayMeasurementStatCurrent {
+
+ private final Instant startTime;
+
+ protected DefaultDelayMeasurementStatCurrent(DefaultDmStatCurrentBuilder builder) {
+ super(builder);
+ this.startTime = builder.startTime;
+ }
+
+ @Override
+ public Instant startTime() {
+ return startTime;
+ }
+
+ public static DmStatCurrentBuilder builder(Duration elapsedTime, boolean suspectStatus) {
+ return new DefaultDmStatCurrentBuilder(elapsedTime, suspectStatus);
+ }
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatCurrent}.
+ */
+ private static final class DefaultDmStatCurrentBuilder extends DefaultDmStatBuilder
+ implements DmStatCurrentBuilder {
+
+ private Instant startTime;
+
+ private DefaultDmStatCurrentBuilder(Duration elapsedTime, boolean suspectStatus) {
+ super(elapsedTime, suspectStatus);
+ }
+
+ @Override
+ public DmStatCurrentBuilder startTime(Instant startTime) {
+ this.startTime = startTime;
+ return this;
+ }
+
+ @Override
+ public DelayMeasurementStat build() {
+ return new DefaultDelayMeasurementStatCurrent(this);
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementStatHistory.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementStatHistory.java
new file mode 100644
index 0000000..4db3683
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementStatHistory.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * The default implementation of DelayMeasurementStatHistory.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatHistory}.
+ */
+public class DefaultDelayMeasurementStatHistory extends DefaultDelayMeasurementStat
+ implements DelayMeasurementStatHistory {
+
+ private final SoamId historyStatsId;
+ private final Instant endTime;
+
+ protected DefaultDelayMeasurementStatHistory(DefaultDmStatHistoryBuilder builder) {
+ super(builder);
+ this.historyStatsId = builder.historyStatsId;
+ this.endTime = builder.endTime;
+ }
+
+ @Override
+ public SoamId historyStatsId() {
+ return historyStatsId;
+ }
+
+ @Override
+ public Instant endTime() {
+ return endTime;
+ }
+
+ public static DmStatHistoryBuilder builder(SoamId historyStatsId,
+ Duration elapsedTime, boolean suspectStatus) {
+ return new DefaultDmStatHistoryBuilder(
+ historyStatsId, elapsedTime, suspectStatus);
+ }
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatHistory}.
+ */
+ private static final class DefaultDmStatHistoryBuilder
+ extends DefaultDmStatBuilder implements DmStatHistoryBuilder {
+ private final SoamId historyStatsId;
+ private Instant endTime;
+
+ private DefaultDmStatHistoryBuilder(SoamId historyStatsId,
+ Duration elapsedTime, boolean suspectStatus) {
+ super(elapsedTime, suspectStatus);
+ this.historyStatsId = historyStatsId;
+ }
+
+ @Override
+ public DmStatHistoryBuilder endTime(Instant endTime) {
+ this.endTime = endTime;
+ return this;
+ }
+
+ @Override
+ public DelayMeasurementStat build() {
+ return new DefaultDelayMeasurementStatHistory(this);
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementThreshold.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementThreshold.java
new file mode 100644
index 0000000..90a8c25
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DefaultDelayMeasurementThreshold.java
@@ -0,0 +1,458 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * The default implementation of DelayMeasurementThreshold.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementThreshold}.
+ */
+public final class DefaultDelayMeasurementThreshold
+ implements DelayMeasurementThreshold {
+
+ private final SoamId threshId;
+ private final Collection<ThresholdOption> thresholdsEnabled;
+ private final Duration measuredFrameDelayTwoWay;
+ private final Duration maxFrameDelayTwoWay;
+ private final Duration averageFrameDelayTwoWay;
+ private final Duration measuredInterFrameDelayVariationTwoWay;
+ private final Duration maxInterFrameDelayVariationTwoWay;
+ private final Duration averageInterFrameDelayVariationTwoWay;
+ private final Duration maxFrameDelayRangeTwoWay;
+ private final Duration averageFrameDelayRangeTwoWay;
+ private final Duration measuredFrameDelayForward;
+ private final Duration maxFrameDelayForward;
+ private final Duration averageFrameDelayForward;
+ private final Duration measuredInterFrameDelayVariationForward;
+ private final Duration maxInterFrameDelayVariationForward;
+ private final Duration averageInterFrameDelayVariationForward;
+ private final Duration maxFrameDelayRangeForward;
+ private final Duration averageFrameDelayRangeForward;
+ private final Duration measuredFrameDelayBackward;
+ private final Duration maxFrameDelayBackward;
+ private final Duration averageFrameDelayBackward;
+ private final Duration measuredInterFrameDelayVariationBackward;
+ private final Duration maxInterFrameDelayVariationBackward;
+ private final Duration averageInterFrameDelayVariationBackward;
+ private final Duration maxFrameDelayRangeBackward;
+ private final Duration averageFrameDelayRangeBackward;
+
+ private DefaultDelayMeasurementThreshold(DefaultDmThresholdBuilder builder) {
+ this.threshId = builder.threshId;
+ this.thresholdsEnabled = builder.thresholdsEnabled;
+ this.measuredFrameDelayTwoWay = builder.measuredFrameDelayTwoWay;
+ this.maxFrameDelayTwoWay = builder.maxFrameDelayTwoWay;
+ this.averageFrameDelayTwoWay = builder.averageFrameDelayTwoWay;
+ this.measuredInterFrameDelayVariationTwoWay =
+ builder.measuredInterFrameDelayVariationTwoWay;
+ this.maxInterFrameDelayVariationTwoWay =
+ builder.maxInterFrameDelayVariationTwoWay;
+ this.averageInterFrameDelayVariationTwoWay =
+ builder.averageInterFrameDelayVariationTwoWay;
+ this.maxFrameDelayRangeTwoWay = builder.maxFrameDelayRangeTwoWay;
+ this.averageFrameDelayRangeTwoWay = builder.averageFrameDelayRangeTwoWay;
+ this.measuredFrameDelayForward = builder.measuredFrameDelayForward;
+ this.maxFrameDelayForward = builder.maxFrameDelayForward;
+ this.averageFrameDelayForward = builder.averageFrameDelayForward;
+ this.measuredInterFrameDelayVariationForward =
+ builder.measuredInterFrameDelayVariationForward;
+ this.maxInterFrameDelayVariationForward =
+ builder.maxInterFrameDelayVariationForward;
+ this.averageInterFrameDelayVariationForward =
+ builder.averageInterFrameDelayVariationForward;
+ this.maxFrameDelayRangeForward = builder.maxFrameDelayRangeForward;
+ this.averageFrameDelayRangeForward = builder.averageFrameDelayRangeForward;
+ this.measuredFrameDelayBackward = builder.measuredFrameDelayBackward;
+ this.maxFrameDelayBackward = builder.maxFrameDelayBackward;
+ this.averageFrameDelayBackward = builder.averageFrameDelayBackward;
+ this.measuredInterFrameDelayVariationBackward =
+ builder.measuredInterFrameDelayVariationBackward;
+ this.maxInterFrameDelayVariationBackward =
+ builder.maxInterFrameDelayVariationBackward;
+ this.averageInterFrameDelayVariationBackward =
+ builder.averageInterFrameDelayVariationBackward;
+ this.maxFrameDelayRangeBackward =
+ builder.maxFrameDelayRangeBackward;
+ this.averageFrameDelayRangeBackward =
+ builder.averageFrameDelayRangeBackward;
+ }
+
+ @Override
+ public SoamId threshId() {
+ return threshId;
+ }
+
+ @Override
+ public Collection<ThresholdOption> thresholdsEnabled() {
+ return thresholdsEnabled;
+ }
+
+ @Override
+ public Duration measuredFrameDelayTwoWay() {
+ return measuredFrameDelayTwoWay;
+ }
+
+ @Override
+ public Duration maxFrameDelayTwoWay() {
+ return maxFrameDelayTwoWay;
+ }
+
+ @Override
+ public Duration averageFrameDelayTwoWay() {
+ return averageFrameDelayTwoWay;
+ }
+
+ @Override
+ public Duration measuredInterFrameDelayVariationTwoWay() {
+ return measuredInterFrameDelayVariationTwoWay;
+ }
+
+ @Override
+ public Duration maxInterFrameDelayVariationTwoWay() {
+ return maxInterFrameDelayVariationTwoWay;
+ }
+
+ @Override
+ public Duration averageInterFrameDelayVariationTwoWay() {
+ return averageInterFrameDelayVariationTwoWay;
+ }
+
+ @Override
+ public Duration maxFrameDelayRangeTwoWay() {
+ return maxFrameDelayRangeTwoWay;
+ }
+
+ @Override
+ public Duration averageFrameDelayRangeTwoWay() {
+ return averageFrameDelayRangeTwoWay;
+ }
+
+ @Override
+ public Duration measuredFrameDelayForward() {
+ return measuredFrameDelayForward;
+ }
+
+ @Override
+ public Duration maxFrameDelayForward() {
+ return maxFrameDelayForward;
+ }
+
+ @Override
+ public Duration averageFrameDelayForward() {
+ return averageFrameDelayForward;
+ }
+
+ @Override
+ public Duration measuredInterFrameDelayVariationForward() {
+ return measuredInterFrameDelayVariationForward;
+ }
+
+ @Override
+ public Duration maxInterFrameDelayVariationForward() {
+ return maxInterFrameDelayVariationForward;
+ }
+
+ @Override
+ public Duration averageInterFrameDelayVariationForward() {
+ return averageInterFrameDelayVariationForward;
+ }
+
+ @Override
+ public Duration maxFrameDelayRangeForward() {
+ return maxFrameDelayRangeForward;
+ }
+
+ @Override
+ public Duration averageFrameDelayRangeForward() {
+ return averageFrameDelayRangeForward;
+ }
+
+ @Override
+ public Duration measuredFrameDelayBackward() {
+ return measuredFrameDelayBackward;
+ }
+
+ @Override
+ public Duration maxFrameDelayBackward() {
+ return maxFrameDelayBackward;
+ }
+
+ @Override
+ public Duration averageFrameDelayBackward() {
+ return averageFrameDelayBackward;
+ }
+
+ @Override
+ public Duration measuredInterFrameDelayVariationBackward() {
+ return measuredInterFrameDelayVariationBackward;
+ }
+
+ @Override
+ public Duration maxInterFrameDelayVariationBackward() {
+ return maxInterFrameDelayVariationBackward;
+ }
+
+ @Override
+ public Duration averageInterFrameDelayVariationBackward() {
+ return averageInterFrameDelayVariationBackward;
+ }
+
+ @Override
+ public Duration maxFrameDelayRangeBackward() {
+ return maxFrameDelayRangeBackward;
+ }
+
+ @Override
+ public Duration averageFrameDelayRangeBackward() {
+ return averageFrameDelayRangeBackward;
+ }
+
+ public static DmThresholdBuilder builder(SoamId threshId) {
+ return new DefaultDmThresholdBuilder(threshId);
+ }
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementThreshold}.
+ */
+ private static final class DefaultDmThresholdBuilder implements DmThresholdBuilder {
+ private final SoamId threshId;
+ private Collection<ThresholdOption> thresholdsEnabled;
+ private Duration measuredFrameDelayTwoWay;
+ private Duration maxFrameDelayTwoWay;
+ private Duration averageFrameDelayTwoWay;
+ private Duration measuredInterFrameDelayVariationTwoWay;
+ private Duration maxInterFrameDelayVariationTwoWay;
+ private Duration averageInterFrameDelayVariationTwoWay;
+ private Duration maxFrameDelayRangeTwoWay;
+ private Duration averageFrameDelayRangeTwoWay;
+ private Duration measuredFrameDelayForward;
+ private Duration maxFrameDelayForward;
+ private Duration averageFrameDelayForward;
+ private Duration measuredInterFrameDelayVariationForward;
+ private Duration maxInterFrameDelayVariationForward;
+ private Duration averageInterFrameDelayVariationForward;
+ private Duration maxFrameDelayRangeForward;
+ private Duration averageFrameDelayRangeForward;
+ private Duration measuredFrameDelayBackward;
+ private Duration maxFrameDelayBackward;
+ private Duration averageFrameDelayBackward;
+ private Duration measuredInterFrameDelayVariationBackward;
+ private Duration maxInterFrameDelayVariationBackward;
+ private Duration averageInterFrameDelayVariationBackward;
+ private Duration maxFrameDelayRangeBackward;
+ private Duration averageFrameDelayRangeBackward;
+
+ protected DefaultDmThresholdBuilder(SoamId threshId) {
+ this.threshId = threshId;
+ this.thresholdsEnabled = new ArrayList<>();
+ }
+
+ @Override
+ public DmThresholdBuilder addToThresholdsEnabled(
+ ThresholdOption thresholdEnabled) {
+ this.thresholdsEnabled.add(thresholdEnabled);
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder measuredFrameDelayTwoWay(
+ Duration measuredFrameDelayTwoWay) {
+ this.measuredFrameDelayTwoWay = measuredFrameDelayTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder maxFrameDelayTwoWay(
+ Duration maxFrameDelayTwoWay) {
+ this.maxFrameDelayTwoWay = maxFrameDelayTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder averageFrameDelayTwoWay(
+ Duration averageFrameDelayTwoWay) {
+ this.averageFrameDelayTwoWay = averageFrameDelayTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder measuredInterFrameDelayVariationTwoWay(
+ Duration measuredInterFrameDelayVariationTwoWay) {
+ this.measuredInterFrameDelayVariationTwoWay =
+ measuredInterFrameDelayVariationTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder maxInterFrameDelayVariationTwoWay(
+ Duration maxInterFrameDelayVariationTwoWay) {
+ this.maxInterFrameDelayVariationTwoWay =
+ maxInterFrameDelayVariationTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder averageInterFrameDelayVariationTwoWay(
+ Duration averageInterFrameDelayVariationTwoWay) {
+ this.averageInterFrameDelayVariationTwoWay =
+ averageInterFrameDelayVariationTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder maxFrameDelayRangeTwoWay(
+ Duration maxFrameDelayRangeTwoWay) {
+ this.maxFrameDelayRangeTwoWay = maxFrameDelayRangeTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder averageFrameDelayRangeTwoWay(
+ Duration averageFrameDelayRangeTwoWay) {
+ this.averageFrameDelayRangeTwoWay = averageFrameDelayRangeTwoWay;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder measuredFrameDelayForward(
+ Duration measuredFrameDelayForward) {
+ this.measuredFrameDelayForward = measuredFrameDelayForward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder maxFrameDelayForward(
+ Duration maxFrameDelayForward) {
+ this.maxFrameDelayForward = maxFrameDelayForward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder averageFrameDelayForward(
+ Duration averageFrameDelayForward) {
+ this.averageFrameDelayForward = averageFrameDelayForward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder measuredInterFrameDelayVariationForward(
+ Duration measuredInterFrameDelayVariationForward) {
+ this.measuredInterFrameDelayVariationForward =
+ measuredInterFrameDelayVariationForward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder maxInterFrameDelayVariationForward(
+ Duration maxInterFrameDelayVariationForward) {
+ this.maxInterFrameDelayVariationForward =
+ maxInterFrameDelayVariationForward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder averageInterFrameDelayVariationForward(
+ Duration averageInterFrameDelayVariationForward) {
+ this.averageInterFrameDelayVariationForward =
+ averageInterFrameDelayVariationForward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder maxFrameDelayRangeForward(
+ Duration maxFrameDelayRangeForward) {
+ this.maxFrameDelayRangeForward = maxFrameDelayRangeForward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder averageFrameDelayRangeForward(
+ Duration averageFrameDelayRangeForward) {
+ this.averageFrameDelayRangeForward = averageFrameDelayRangeForward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder measuredFrameDelayBackward(
+ Duration measuredFrameDelayBackward) {
+ this.measuredFrameDelayBackward = measuredFrameDelayBackward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder maxFrameDelayBackward(
+ Duration maxFrameDelayBackward) {
+ this.maxFrameDelayBackward = maxFrameDelayBackward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder averageFrameDelayBackward(
+ Duration averageFrameDelayBackward) {
+ this.averageFrameDelayBackward = averageFrameDelayBackward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder measuredInterFrameDelayVariationBackward(
+ Duration measuredInterFrameDelayVariationBackward) {
+ this.measuredInterFrameDelayVariationBackward =
+ measuredInterFrameDelayVariationBackward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder maxInterFrameDelayVariationBackward(
+ Duration maxInterFrameDelayVariationBackward) {
+ this.maxInterFrameDelayVariationBackward =
+ maxInterFrameDelayVariationBackward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder averageInterFrameDelayVariationBackward(
+ Duration averageInterFrameDelayVariationBackward) {
+ this.averageInterFrameDelayVariationBackward =
+ averageInterFrameDelayVariationBackward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder maxFrameDelayRangeBackward(
+ Duration maxFrameDelayRangeBackward) {
+ this.maxFrameDelayRangeBackward = maxFrameDelayRangeBackward;
+ return this;
+ }
+
+ @Override
+ public DmThresholdBuilder averageFrameDelayRangeBackward(
+ Duration averageFrameDelayRangeBackward) {
+ this.averageFrameDelayRangeBackward = averageFrameDelayRangeBackward;
+ return this;
+ }
+
+ @Override
+ public DelayMeasurementThreshold build() {
+ return new DefaultDelayMeasurementThreshold(this);
+ }
+ }
+
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementCreate.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementCreate.java
new file mode 100644
index 0000000..4934146
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementCreate.java
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.soam.MeasurementCreateBase;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+
+/**
+ * A model of Delay Measurement from ITU Y.1731 Chapter 8.2, MEF 17, MEF 36.1 and MEF 39.
+ *
+ * In this model delay measurements entries are returned as a collection in the
+ * MepEntry. In this way Delay Measurements are created by calling on the
+ * Create Delay Measurement function, passing this DelayMeasurementCreate object
+ * and any other arguments needed.
+ * The Delay Measurement Entry is a result and not configured or
+ * persisted in ONOS, but instead is is passed on to some analytics system
+ */
+public interface DelayMeasurementCreate extends MeasurementCreateBase {
+ /**
+ * The type of Delay Measurement is to be performed.
+ * The exact PDUs to use are specified by this object in combination with version
+ * @return enumerated type
+ */
+ DmType dmCfgType();
+
+ /**
+ * A vector of bits that indicates the type of SOAM DM counters that are enabled.
+ * A present bit enables the specific SOAM DM counter.
+ * A not present bit disables the SOAM DM counter.
+ * If a particular SOAM DM counter is not supported the BIT value is not present.
+ * Not all SOAM DM counters are supported for all SOAM DM types.
+ * @return A collection of options
+ */
+ Collection<MeasurementOption> measurementsEnabled();
+
+ /**
+ * The number of measurement bins per Measurement Interval for Frame Delay measurements.
+ * At least 3 bins are to be supported; at least 10 bins are recommended to be supported
+ * @return the number of bins
+ */
+ Short binsPerFdInterval();
+
+ /**
+ * The number of measurement bins per Measurement Interval for Inter-Frame Delay Variation measurements.
+ * The minimum number of measurement bins to be supported is 2. The desired
+ * number of measurements bins to be supported is 10
+ * @return the number of bins
+ */
+ Short binsPerIfdvInterval();
+
+ /**
+ * The selection offset for Inter-Frame Delay Variation measurements.
+ * If this value is set to n, then the IFDV is calculated by taking the
+ * difference in frame delay between frame F and frame (F+n).
+ * reference: MEF-SOAM-PM-MIB.mefSoamDmCfgInterFrameDelayVariationSelectionOffset
+ * @return The selection offset
+ */
+ Short ifdvSelectionOffset();
+
+ /**
+ * The number of measurement bins per Measurement Interval for Frame Delay Range measurements.
+ * @return the number of bins
+ */
+ Short binsPerFdrInterval();
+
+ /**
+ * The Delay Measurement threshold configuration values for DM Performance Monitoring.
+ * The main purpose of the threshold configuration list is to configure
+ * threshold alarm notifications indicating that a specific performance metric
+ * is not being met
+ * @return a collection of Thresholds
+ */
+ Collection<DelayMeasurementThreshold> thresholds();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate}.
+ */
+ public interface DmCreateBuilder extends MeasCreateBaseBuilder {
+
+ DmCreateBuilder addToMeasurementsEnabled(
+ MeasurementOption measurementEnabled);
+
+ DmCreateBuilder binsPerFdInterval(Short binsPerFdInterval)
+ throws SoamConfigException;
+
+ DmCreateBuilder binsPerIfdvInterval(Short binsPerIfdvInterval)
+ throws SoamConfigException;
+
+ DmCreateBuilder ifdvSelectionOffset(Short ifdvSelectionOffset)
+ throws SoamConfigException;
+
+ DmCreateBuilder binsPerFdrInterval(Short binsPerFdrInterval)
+ throws SoamConfigException;
+
+ DmCreateBuilder addToThresholds(DelayMeasurementThreshold threshold);
+
+ DelayMeasurementCreate build();
+ }
+
+ /**
+ * Enumerated options for Delay Measurement Types.
+ */
+ public enum DmType {
+ /**
+ * DMM SOAM PDU generated, DMR responses received (one-way or two-way measurements).
+ */
+ DMDMM,
+ /**
+ * 1DM SOAM PDU generated (one-way measurements are made by the receiver).
+ */
+ DM1DMTX,
+ /**
+ * 1DM SOAM PDU received and tracked (one-way measurements).
+ */
+ DM1DMRX
+ }
+
+ /**
+ * Supported Versions of Y.1731.
+ */
+ public enum Version {
+ Y17312008("Y.1731-2008"),
+ Y17312011("Y.1731-2011");
+
+ private String literal;
+ private Version(String literal) {
+ this.literal = literal;
+ }
+
+ public String literal() {
+ return literal;
+ }
+ }
+
+ /**
+ * Selection of Measurement types.
+ */
+ public enum MeasurementOption {
+ SOAM_PDUS_SENT,
+ SOAM_PDUS_RECEIVED,
+ FRAME_DELAY_TWO_WAY_BINS,
+ FRAME_DELAY_TWO_WAY_MIN,
+ FRAME_DELAY_TWO_WAY_MAX,
+ FRAME_DELAY_TWO_WAY_AVERAGE,
+ FRAME_DELAY_FORWARD_BINS,
+ FRAME_DELAY_FORWARD_MIN,
+ FRAME_DELAY_FORWARD_MAX,
+ FRAME_DELAY_FORWARD_AVERAGE,
+ FRAME_DELAY_BACKWARD_BINS,
+ FRAME_DELAY_BACKWARD_MIN,
+ FRAME_DELAY_BACKWARD_MAX,
+ FRAME_DELAY_BACKWARD_AVERAGE,
+ INTER_FRAME_DELAY_VARIATION_FORWARD_BINS,
+ INTER_FRAME_DELAY_VARIATION_FORWARD_MIN,
+ INTER_FRAME_DELAY_VARIATION_FORWARD_MAX,
+ INTER_FRAME_DELAY_VARIATION_FORWARD_AVERAGE,
+ INTER_FRAME_DELAY_VARIATION_BACKWARD_BINS,
+ INTER_FRAME_DELAY_VARIATION_BACKWARD_MIN,
+ INTER_FRAME_DELAY_VARIATION_BACKWARD_MAX,
+ INTER_FRAME_DELAY_VARIATION_BACKWARD_AVERAGE,
+ INTER_FRAME_DELAY_VARIATION_TWO_WAY_BINS,
+ INTER_FRAME_DELAY_VARIATION_TWO_WAY_MIN,
+ INTER_FRAME_DELAY_VARIATION_TWO_WAY_MAX,
+ INTER_FRAME_DELAY_VARIATION_TWO_WAY_AVERAGE,
+ FRAME_DELAY_RANGE_FORWARD_BINS,
+ FRAME_DELAY_RANGE_FORWARD_MAX,
+ FRAME_DELAY_RANGE_FORWARD_AVERAGE,
+ FRAME_DELAY_RANGE_BACKWARD_BINS,
+ FRAME_DELAY_RANGE_BACKWARD_MAX,
+ FRAME_DELAY_RANGE_BACKWARD_AVERAGE,
+ FRAME_DELAY_RANGE_TWO_WAY_BINS,
+ FRAME_DELAY_RANGE_TWO_WAY_MAX,
+ FRAME_DELAY_RANGE_TWO_WAY_AVERAGE,
+ MEASURED_STATS_FRAME_DELAY_TWO_WAY,
+ MEASURED_STATS_FRAME_DELAY_FORWARD,
+ MEASURED_STATS_FRAME_DELAY_BACKWARD,
+ MEASURED_STATS_INTER_FRAME_DELAY_VARIATION_TWO_WAY,
+ MEASURED_STATS_INTER_FRAME_DELAY_VARIATION_FORWARD,
+ MEASURED_STATS_INTER_FRAME_DELAY_VARIATION_BACKWARD;
+ }
+
+ /**
+ * Selection of Data Patterns.
+ */
+ public enum DataPattern {
+ ZEROES,
+ ONES;
+ }
+
+ /**
+ * Selection of Test TLV Patterns.
+ */
+ public enum TestTlvPattern {
+ /**
+ * This test pattern is a Null signal without CRC-32.
+ */
+ NULL_SIGNAL_WITHOUT_CRC_32,
+ /**
+ * This test pattern is a Null signal with CRC-32.
+ */
+ NULL_SIGNAL_WITH_CRC_32,
+ /**
+ * This test pattern is a PRBS 2^31-1 without CRC-32.
+ */
+ PRBS_2311_WITHOUT_CRC_32,
+ /**
+ * This test pattern is a PRBS 2^31-1 with CRC-32.
+ */
+ PRBS_2311_WITH_CRC_32;
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementEntry.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementEntry.java
new file mode 100644
index 0000000..3571922
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementEntry.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Duration;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * Delay Measurement from ITU Y.1731 Chapter 8.2, MEF 17, MEF 36.1 and MEF 39.
+ *
+ * This represents the result returned and includes the parameters used to
+ * configure the DM when it was created
+ */
+public interface DelayMeasurementEntry extends DelayMeasurementCreate {
+ /**
+ * This uniquely identifies a scheduled measurement.
+ * It is automatically generated by the server on creation of a new measurement
+ * @return the id
+ */
+ SoamId dmId();
+
+ /**
+ * The current status of the DM session.
+ * A value of 'active' indicates the current DM session is active,
+ * i.e. the current time lies between the start time and the stop time, and
+ * enabled is true. A value of 'not-active' indicates the current DM session
+ * is not active, i.e. it has not started yet, has stopped upon reaching the
+ * stop time, or is disabled
+ * @return the status
+ */
+ SessionStatus sessionStatus();
+
+ /**
+ * The two-way frame delay calculated by this MEP from the last received SOAM PDU.
+ * This object is undefined is measurement-type is dm1-transmitted or dm1-received
+ * @return The delay as a java duration
+ */
+ Duration frameDelayTwoWay();
+
+ /**
+ * The frame delay in the forward direction calculated by this MEP from the last received SOAM PDU.
+ * The value of this object may not be accurate in the absence of sufficiently
+ * precise clock synchronization.
+ * This object is undefined is measurement-type is dm1-transmitted
+ * @return The delay as a java duration
+ */
+ Duration frameDelayForward();
+
+ /**
+ * The frame delay in the backward direction calculated by this MEP from the last received SOAM PDU.
+ * The value of this object may not be accurate in the absence of sufficiently
+ * precise clock synchronization.
+ * This object is undefined is measurement-type is dm1-transmitted or dm1-received
+ * @return The delay as a java duration
+ */
+ Duration frameDelayBackward();
+
+ /**
+ * The last two-way inter-frame delay interval calculated by this MEP.
+ * The value of this object is undefined when measurement-type is dm1-transmitted or dm1-received
+ * @return The delay as a java duration
+ */
+ Duration interFrameDelayVariationTwoWay();
+
+ /**
+ * The last one-way inter-frame delay interval in the forward direction calculated by this MEP.
+ * The value of this object is undefined when measurement-type is dm1-transmitted
+ * @return The delay as a java duration
+ */
+ Duration interFrameDelayVariationForward();
+
+ /**
+ * The last one-way inter-frame delay interval in the backward direction calculated by this MEP.
+ * The value of this object is undefined when measurement-type is
+ * dm1-transmitted or dm1-received
+ * @return The delay as a java duration
+ */
+ Duration interFrameDelayVariationBackward();
+
+ /**
+ * The results for the current Measurement Interval in a SOAM Delay Measurement session.
+ * gathered during the interval indicated by measurement-interval.
+ * @return The current set of results
+ */
+ DelayMeasurementStatCurrent currentResult();
+
+ /**
+ * The results for history Measurement Intervals in a SOAM Delay Measurement session.
+ * @return A collection of history results
+ */
+ Collection<DelayMeasurementStatHistory> historicalResults();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry}.
+ */
+ public interface DmEntryBuilder extends DmCreateBuilder {
+ DmEntryBuilder sessionStatus(SessionStatus sessionStatus);
+
+ DmEntryBuilder frameDelayTwoWay(Duration frameDelayTwoWay);
+
+ DmEntryBuilder frameDelayForward(Duration frameDelayForward);
+
+ DmEntryBuilder frameDelayBackward(Duration frameDelayBackward);
+
+ DmEntryBuilder interFrameDelayVariationTwoWay(Duration interFrameDelayVariationTwoWay);
+
+ DmEntryBuilder interFrameDelayVariationForward(Duration interFrameDelayVariationForward);
+
+ DmEntryBuilder interFrameDelayVariationBackward(Duration interFrameDelayVariationBackward);
+
+ DmEntryBuilder currentResult(DelayMeasurementStatCurrent currentResult);
+
+ DmEntryBuilder addToHistoricalResults(
+ DelayMeasurementStatHistory historicalResult);
+
+ DelayMeasurementEntry build();
+ }
+
+ /**
+ * Session Status options.
+ */
+ public enum SessionStatus {
+ ACTIVE,
+ NOT_ACTIVE;
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStat.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStat.java
new file mode 100644
index 0000000..c218c06
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStat.java
@@ -0,0 +1,356 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Duration;
+import java.util.Map;
+
+/**
+ * Abstract object as a base for DelayMeasurementStatCurrent and DelayMeasurementStatHistory interfaces.
+ */
+public interface DelayMeasurementStat {
+ /**
+ * The time that the current Measurement Interval has been running.
+ * @return A java duration
+ */
+ Duration elapsedTime();
+
+ /**
+ * The suspect flag for the current measurement interval in which the notification was generated.
+ * reference MEF-SOAM-PM-MIB.mefSoamPmNotificationObjSuspect";
+ * @return true if the measurement might include an error
+ */
+ boolean suspectStatus();
+
+ /**
+ * The minimum two-way frame delay calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayTwoWayMin();
+
+ /**
+ * The maximum two-way frame delay calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayTwoWayMax();
+
+ /**
+ * The average two-way frame delay calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayTwoWayAvg();
+
+ /**
+ * The minimum foward frame delay calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayForwardMin();
+
+ /**
+ * The maximum forward frame delay calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayForwardMax();
+
+ /**
+ * The average forward frame delay calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayForwardAvg();
+
+ /**
+ * The minimum backward frame delay calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayBackwardMin();
+
+ /**
+ * The maximum backward frame delay calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayBackwardMax();
+
+ /**
+ * The average backward frame delay calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayBackwardAvg();
+
+ /**
+ * The minimum two-way inter-frame delay interval calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration interFrameDelayVariationTwoWayMin();
+
+ /**
+ * The maximum two-way inter-frame delay interval calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration interFrameDelayVariationTwoWayMax();
+
+ /**
+ * The average two-way inter-frame delay interval calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration interFrameDelayVariationTwoWayAvg();
+
+ /**
+ * The minimum one-way inter-frame delay interval in the forward direction.
+ * calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration interFrameDelayVariationForwardMin();
+
+ /**
+ * The maximum one-way inter-frame delay interval in the forward direction.
+ * calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration interFrameDelayVariationForwardMax();
+
+ /**
+ * The average one-way inter-frame delay interval in the forward direction.
+ * calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration interFrameDelayVariationForwardAvg();
+
+ /**
+ * The minimum one-way inter-frame delay interval in the backward direction.
+ * calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration interFrameDelayVariationBackwardMin();
+
+ /**
+ * The maximum one-way inter-frame delay interval in the backward direction.
+ * calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration interFrameDelayVariationBackwardMax();
+
+ /**
+ * The average one-way inter-frame delay interval in the backward direction.
+ * calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration interFrameDelayVariationBackwardAvg();
+
+ /**
+ * The maximum two-way Frame Delay Range calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayRangeTwoWayMax();
+
+ /**
+ * The average two-way Frame Delay Range calculated by this MEP for this Measurement Interval.
+ * @return A java duration
+ */
+ Duration frameDelayRangeTwoWayAvg();
+
+ /**
+ * The maximum one-way Frame Delay Range in the forward direction.
+ * calculated by this MEP for this Measurement Interval
+ * @return A java duration
+ */
+ Duration frameDelayRangeForwardMax();
+
+ /**
+ * The average one-way Frame Delay Range in the forward direction.
+ * calculated by this MEP for this Measurement Interval
+ * @return A java duration
+ */
+ Duration frameDelayRangeForwardAvg();
+
+ /**
+ * The maximum one-way Frame Delay Range in the backward direction.
+ * calculated by this MEP for this Measurement Interval
+ * @return A java duration
+ */
+ Duration frameDelayRangeBackwardMax();
+
+ /**
+ * The average one-way Frame Delay Range in the backward direction.
+ * calculated by this MEP for this Measurement Interval
+ * @return A java duration
+ */
+ Duration frameDelayRangeBackwardAvg();
+
+ /**
+ * The count of the number of SOAM PDUs sent during this Measurement Interval.
+ * @return the count as an integer
+ */
+ Integer soamPdusSent();
+
+ /**
+ * The count of the number of SOAM PDUs received during this Measurement Interval.
+ * @return the count as an integer
+ */
+ Integer soamPdusReceived();
+
+ /**
+ * Bins calculated for two-way Frame Delay measurements.
+ * calculated by this MEP for this Measurement interval.
+ *
+ * The reply contains a set of counts of packets per bin
+ * The bin is defined by the durations given as the lower limit and the next
+ * size being the upper limit. For the largest duration, the count is of packets
+ * of that size up to infinity
+ *
+ * For example, if there are 4 elements in the result
+ * PT0.000S 4 - This means there are 4 packets in the 0-20ms bin
+ * PT0.020S 6 - This means there are 6 packets in the 20-30ms bin
+ * PT0.030S 8 - This means there are 8 packets in the 30-50ms bin
+ * PT0.050S 10 - This means there are 10 packets in the 50ms-infinity bin
+ *
+ * @return A map of counts per time periods
+ */
+ Map<Duration, Integer> frameDelayTwoWayBins();
+
+ /**
+ * Bins calculated for one-way Frame Delay measurements in the Forward direction.
+ * calculated by this MEP for this Measurement interval.
+ * @return A map of counts per time periods
+ */
+ Map<Duration, Integer> frameDelayForwardBins();
+
+ /**
+ * Bins calculated for one-way Frame Delay measurements in the Backward direction.
+ * calculated by this MEP for this Measurement interval.
+ * @return A map of counts per time periods
+ */
+ Map<Duration, Integer> frameDelayBackwardBins();
+
+ /**
+ * Bins calculated for two-way Inter Frame Delay Variation measurements.
+ * calculated by this MEP for this Measurement interval.
+ * @return A map of counts per time periods
+ */
+ Map<Duration, Integer> interFrameDelayVariationTwoWayBins();
+
+ /**
+ * Bins calculated for one-way Inter Frame Delay Variation measurements in the Forward direction.
+ * calculated by this MEP for this Measurement interval.
+ * @return A map of counts per time periods
+ */
+ Map<Duration, Integer> interFrameDelayVariationForwardBins();
+
+ /**
+ * Bins calculated for one-way Inter Frame Delay Variation measurements in the Backward direction.
+ * calculated by this MEP for this Measurement interval.
+ * @return A map of counts per time periods
+ */
+ Map<Duration, Integer> interFrameDelayVariationBackwardBins();
+
+ /**
+ * Bins calculated for two-way Frame Delay Range measurements.
+ * calculated by this MEP for this Measurement interval.
+ * @return A map of counts per time periods
+ */
+ Map<Duration, Integer> frameDelayRangeTwoWayBins();
+
+ /**
+ * Bins calculated for one-way Frame Delay Range measurements in the Forward direction.
+ * calculated by this MEP for this Measurement interval.
+ * @return A map of counts per time periods
+ */
+ Map<Duration, Integer> frameDelayRangeForwardBins();
+
+ /**
+ * Bins calculated for one-way Frame Delay Range measurements in the Backward direction.
+ * calculated by this MEP for this Measurement interval.
+ * @return A map of counts per time periods
+ */
+ Map<Duration, Integer> frameDelayRangeBackwardBins();
+
+ /**
+ * Abstract Builder interface for DelayMeasurementStat.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStat}.
+ */
+ interface DmStatBuilder {
+ DmStatBuilder frameDelayTwoWayMin(Duration frameDelayTwoWayMin);
+
+ DmStatBuilder frameDelayTwoWayMax(Duration frameDelayTwoWayMax);
+
+ DmStatBuilder frameDelayTwoWayAvg(Duration frameDelayTwoWayAvg);
+
+ DmStatBuilder frameDelayForwardMin(Duration frameDelayForwardMin);
+
+ DmStatBuilder frameDelayForwardMax(Duration frameDelayForwardMax);
+
+ DmStatBuilder frameDelayForwardAvg(Duration frameDelayForwardAvg);
+
+ DmStatBuilder frameDelayBackwardMin(Duration frameDelayBackwardMin);
+
+ DmStatBuilder frameDelayBackwardMax(Duration frameDelayBackwardMax);
+
+ DmStatBuilder frameDelayBackwardAvg(Duration frameDelayBackwardAvg);
+
+ DmStatBuilder interFrameDelayVariationTwoWayMin(Duration interFrameDelayVariationTwoWayMin);
+
+ DmStatBuilder interFrameDelayVariationTwoWayMax(Duration interFrameDelayVariationTwoWayMax);
+
+ DmStatBuilder interFrameDelayVariationTwoWayAvg(Duration interFrameDelayVariationTwoWayAvg);
+
+ DmStatBuilder interFrameDelayVariationForwardMin(Duration interFrameDelayVariationForwardMin);
+
+ DmStatBuilder interFrameDelayVariationForwardMax(Duration interFrameDelayVariationForwardMax);
+
+ DmStatBuilder interFrameDelayVariationForwardAvg(Duration interFrameDelayVariationForwardAvg);
+
+ DmStatBuilder interFrameDelayVariationBackwardMin(Duration interFrameDelayVariationBackwardMin);
+
+ DmStatBuilder interFrameDelayVariationBackwardMax(Duration interFrameDelayVariationBackwardMax);
+
+ DmStatBuilder interFrameDelayVariationBackwardAvg(Duration interFrameDelayVariationBackwardAvg);
+
+ DmStatBuilder frameDelayRangeTwoWayMax(Duration frameDelayRangeTwoWayMax);
+
+ DmStatBuilder frameDelayRangeTwoWayAvg(Duration frameDelayRangeTwoWayAvg);
+
+ DmStatBuilder frameDelayRangeForwardMax(Duration frameDelayRangeForwardMax);
+
+ DmStatBuilder frameDelayRangeForwardAvg(Duration frameDelayRangeForwardAvg);
+
+ DmStatBuilder frameDelayRangeBackwardMax(Duration frameDelayRangeBackwardMax);
+
+ DmStatBuilder frameDelayRangeBackwardAvg(Duration frameDelayRangeBackwardAvg);
+
+ DmStatBuilder soamPdusSent(Integer soamPdusSent);
+
+ DmStatBuilder soamPdusReceived(Integer soamPdusReceived);
+
+ DmStatBuilder frameDelayTwoWayBins(Map<Duration, Integer> frameDelayTwoWayBins);
+
+ DmStatBuilder frameDelayForwardBins(Map<Duration, Integer> frameDelayForwardBins);
+
+ DmStatBuilder frameDelayBackwardBins(Map<Duration, Integer> frameDelayBackwardBins);
+
+ DmStatBuilder interFrameDelayVariationTwoWayBins(Map<Duration, Integer> interFrameDelayVariationTwoWayBins);
+
+ DmStatBuilder interFrameDelayVariationForwardBins(Map<Duration, Integer> interFrameDelayVariationForwardBins);
+
+ DmStatBuilder interFrameDelayVariationBackwardBins(Map<Duration, Integer> interFrameDelayVariationBackwardBins);
+
+ DmStatBuilder frameDelayRangeTwoWayBins(Map<Duration, Integer> frameDelayRangeTwoWayBins);
+
+ DmStatBuilder frameDelayRangeForwardBins(Map<Duration, Integer> frameDelayRangeForwardBins);
+
+ DmStatBuilder frameDelayRangeBackwardBins(Map<Duration, Integer> frameDelayRangeBackwardBins);
+
+ DelayMeasurementStat build();
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStatCurrent.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStatCurrent.java
new file mode 100644
index 0000000..f9bb25f
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStatCurrent.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Instant;
+
+/**
+ * Object for representing Delay Measurement Current Stats.
+ */
+public interface DelayMeasurementStatCurrent extends DelayMeasurementStat {
+ /**
+ * The time that the current Measurement Interval started.
+ * @return The start time as a java Instant
+ */
+ Instant startTime();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatCurrent}.
+ */
+ public interface DmStatCurrentBuilder extends DmStatBuilder {
+ DmStatCurrentBuilder startTime(Instant startTime);
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStatHistory.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStatHistory.java
new file mode 100644
index 0000000..c55c66a
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStatHistory.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Instant;
+
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * Object for representing Delay Measurement History Stats.
+ */
+public interface DelayMeasurementStatHistory extends DelayMeasurementStat {
+ /**
+ * The identifier of the historic measurement.
+ * @return The id
+ */
+ SoamId historyStatsId();
+
+ /**
+ * The time that the historic Measurement Interval ended.
+ * @return A java Instant
+ */
+ Instant endTime();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatHistory}.
+ */
+ public interface DmStatHistoryBuilder extends DmStatBuilder {
+ DmStatHistoryBuilder endTime(Instant endTime);
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementThreshold.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementThreshold.java
new file mode 100644
index 0000000..78ae5d4
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementThreshold.java
@@ -0,0 +1,298 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import java.time.Duration;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * Object to represent a Delay Measurement Threshold.
+ */
+public interface DelayMeasurementThreshold {
+ /**
+ * The identifier or the scheduled measurement.
+ * @return The id
+ */
+ SoamId threshId();
+
+ /**
+ * A vector of bits that indicates the type of SOAM LM thresholds notifications that are enabled.
+ * A present bit enables the specific SOAM LM threshold notification and
+ * when the specific counter is enabled and the threshold is crossed a
+ * notification is generated.
+ * A not present bit disables the specific SOAM LM threshold notification. If
+ * a particular SOAM LM threshold is not supported the BIT value is not present.
+ * @return A collection of bit options
+ */
+ Collection<ThresholdOption> thresholdsEnabled();
+
+ /**
+ * The measurement two-way delay threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration measuredFrameDelayTwoWay();
+
+ /**
+ * The maximum two-way delay threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration maxFrameDelayTwoWay();
+
+ /**
+ * The average two-way delay threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration averageFrameDelayTwoWay();
+
+ /**
+ * The measurement two-way IFDV threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration measuredInterFrameDelayVariationTwoWay();
+
+ /**
+ * The maximum two-way IFDV threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration maxInterFrameDelayVariationTwoWay();
+
+ /**
+ * The average two-way IFDV threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration averageInterFrameDelayVariationTwoWay();
+
+ /**
+ * The maximum two-way Frame Delay Range threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration maxFrameDelayRangeTwoWay();
+
+ /**
+ * The average two-way Frame Delay Range threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration averageFrameDelayRangeTwoWay();
+
+ /**
+ * The measurement forward delay threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration measuredFrameDelayForward();
+
+ /**
+ * The maximum forward delay threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration maxFrameDelayForward();
+
+ /**
+ * The average forward delay threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration averageFrameDelayForward();
+
+ /**
+ * The measurement IFDV threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration measuredInterFrameDelayVariationForward();
+
+ /**
+ * The maximum IFDV threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration maxInterFrameDelayVariationForward();
+
+ /**
+ * The average IFDV threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration averageInterFrameDelayVariationForward();
+
+ /**
+ * The maximum Frame Delay Range threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration maxFrameDelayRangeForward();
+
+ /**
+ * The average Frame Delay Range threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration averageFrameDelayRangeForward();
+
+ /**
+ * The measurement backward delay threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration measuredFrameDelayBackward();
+
+ /**
+ * The maximum backward delay threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration maxFrameDelayBackward();
+
+ /**
+ * The average backward delay threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration averageFrameDelayBackward();
+
+ /**
+ * The measurement backward IFDV threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration measuredInterFrameDelayVariationBackward();
+
+ /**
+ * The maximum backward IFDV threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration maxInterFrameDelayVariationBackward();
+
+ /**
+ * The average backward IFDV threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration averageInterFrameDelayVariationBackward();
+
+ /**
+ * The maximum backward Frame Delay Range threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration maxFrameDelayRangeBackward();
+
+ /**
+ * The average backward Frame Delay Range threshold used to determine if a threshold notification is generated.
+ * @return A java duration
+ */
+ Duration averageFrameDelayRangeBackward();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementThreshold}.
+ */
+ public interface DmThresholdBuilder {
+ DmThresholdBuilder addToThresholdsEnabled(
+ ThresholdOption thresholdEnabled);
+
+ DmThresholdBuilder measuredFrameDelayTwoWay(
+ Duration measuredFrameDelayTwoWay);
+
+ DmThresholdBuilder maxFrameDelayTwoWay(Duration maxFrameDelayTwoWay);
+
+ DmThresholdBuilder averageFrameDelayTwoWay(Duration averageFrameDelayTwoWay);
+
+ DmThresholdBuilder measuredInterFrameDelayVariationTwoWay(
+ Duration measuredInterFrameDelayVariationTwoWay);
+
+ DmThresholdBuilder maxInterFrameDelayVariationTwoWay(
+ Duration maxInterFrameDelayVariationTwoWay);
+
+ DmThresholdBuilder averageInterFrameDelayVariationTwoWay(
+ Duration averageInterFrameDelayVariationTwoWay);
+
+ DmThresholdBuilder maxFrameDelayRangeTwoWay(
+ Duration maxFrameDelayRangeTwoWay);
+
+ DmThresholdBuilder averageFrameDelayRangeTwoWay(
+ Duration averageFrameDelayRangeTwoWay);
+
+ DmThresholdBuilder measuredFrameDelayForward(
+ Duration averageFrameDelayRangeTwoWay);
+
+ DmThresholdBuilder maxFrameDelayForward(
+ Duration maxFrameDelayForward);
+
+ DmThresholdBuilder averageFrameDelayForward(
+ Duration averageFrameDelayForward);
+
+ DmThresholdBuilder measuredInterFrameDelayVariationForward(
+ Duration measuredInterFrameDelayVariationForward);
+
+ DmThresholdBuilder maxInterFrameDelayVariationForward(
+ Duration maxInterFrameDelayVariationForward);
+
+ DmThresholdBuilder averageInterFrameDelayVariationForward(
+ Duration averageInterFrameDelayVariationForward);
+
+ DmThresholdBuilder maxFrameDelayRangeForward(
+ Duration maxFrameDelayRangeForward);
+
+ DmThresholdBuilder averageFrameDelayRangeForward(
+ Duration averageFrameDelayRangeForward);
+
+ DmThresholdBuilder measuredFrameDelayBackward(
+ Duration measuredFrameDelayBackward);
+
+ DmThresholdBuilder maxFrameDelayBackward(
+ Duration maxFrameDelayBackward);
+
+ DmThresholdBuilder averageFrameDelayBackward(
+ Duration averageFrameDelayBackward);
+
+ DmThresholdBuilder measuredInterFrameDelayVariationBackward(
+ Duration measuredInterFrameDelayVariationBackward);
+
+ DmThresholdBuilder maxInterFrameDelayVariationBackward(
+ Duration maxInterFrameDelayVariationBackward);
+
+ DmThresholdBuilder averageInterFrameDelayVariationBackward(
+ Duration averageInterFrameDelayVariationBackward);
+
+ DmThresholdBuilder maxFrameDelayRangeBackward(
+ Duration maxFrameDelayRangeBackward);
+
+ DmThresholdBuilder averageFrameDelayRangeBackward(
+ Duration averageFrameDelayRangeBackward);
+
+ public DelayMeasurementThreshold build();
+
+ }
+
+ /**
+ * Selection of Threshold choices.
+ */
+ public enum ThresholdOption {
+ MEASURED_FRAME_DELAY_TWO_WAY,
+ MAX_FRAME_DELAY_TWO_WAY,
+ AVERAGE_FRAME_DELAY_TWO_WAY,
+ MEASURED_INTER_FRAME_DELAY_VARIATION_TWO_WAY,
+ MAX_INTER_FRAME_DELAY_VARIATION_TWO_WAY,
+ AVERAGE_INTER_FRAME_DELAY_VARIATION_TWO_WAY,
+ MAX_FRAME_DELAY_RANGE_TWO_WAY,
+ AVERAGE_FRAME_DELAY_RANGE_TWO_WAY,
+ MEASURED_FRAME_DELAY_FORWARD,
+ MAX_FRAME_DELAY_FORWARD,
+ AVERAGE_FRAME_DELAY_FORWARD,
+ MEASURED_INTER_FRAME_DELAY_VARIATION_FORWARD,
+ MAX_INTER_FRAME_DELAY_VARIATION_FORWARD,
+ AVERAGE_INTER_FRAME_DELAY_VARIATION_FORWARD,
+ MAX_FRAME_DELAY_RANGE_FORWARD,
+ AVERAGE_FRAME_DELAY_RANGE_FORWARD,
+ MEASURED_FRAME_DELAY_BACKWARD,
+ MAX_FRAME_DELAY_BACKWARD,
+ AVERAGE_FRAME_DELAY_BACKWARD,
+ MEASURED_INTER_FRAME_DELAY_VARIATION_BACKWARD,
+ MAX_INTER_FRAME_DELAY_VARIATION_BACKWARD,
+ AVERAGE_INTER_FRAME_DELAY_VARIATION_BACKWARD,
+ MAX_FRAME_DELAY_RANGE_BACKWARD,
+ AVERAGE_FRAME_DELAY_RANGE_BACKWARD;
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/package-info.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/package-info.java
new file mode 100644
index 0000000..310eb12
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/delay/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of Service Operation and Maintenance related to Frame delay measurement.
+ *
+ * From ITU Y.1731 (ETH-DM) and MEF 17 Frame Delay Performance and Frame Delay Variation Performance
+ * MEF 36.1 Service OAM SNMP MIB for Performance Monitoring, MEF 39 Service OAM Performance Monitoring YANG Module
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
\ No newline at end of file
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLaStat.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLaStat.java
new file mode 100644
index 0000000..0616a55
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLaStat.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+
+/**
+ * The default implementation of {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStat}.
+ */
+public abstract class DefaultLaStat implements LossAvailabilityStat {
+ private final Duration elapsedTime;
+ private final boolean suspectStatus;
+ private final Long forwardHighLoss;
+ private final Long backwardHighLoss;
+ private final Long forwardConsecutiveHighLoss;
+ private final Long backwardConsecutiveHighLoss;
+ private final Long forwardAvailable;
+ private final Long backwardAvailable;
+ private final Long forwardUnavailable;
+ private final Long backwardUnavailable;
+ private final MilliPct forwardMinFrameLossRatio;
+ private final MilliPct forwardMaxFrameLossRatio;
+ private final MilliPct forwardAverageFrameLossRatio;
+ private final MilliPct backwardMinFrameLossRatio;
+ private final MilliPct backwardMaxFrameLossRatio;
+ private final MilliPct backwardAverageFrameLossRatio;
+
+ protected DefaultLaStat(DefaultLaStatBuilder builder) {
+ this.elapsedTime = builder.elapsedTime;
+ this.suspectStatus = builder.suspectStatus;
+ this.forwardHighLoss = builder.forwardHighLoss;
+ this.backwardHighLoss = builder.backwardHighLoss;
+ this.forwardConsecutiveHighLoss = builder.forwardConsecutiveHighLoss;
+ this.backwardConsecutiveHighLoss = builder.backwardConsecutiveHighLoss;
+ this.forwardAvailable = builder.forwardAvailable;
+ this.backwardAvailable = builder.backwardAvailable;
+ this.forwardUnavailable = builder.forwardUnavailable;
+ this.backwardUnavailable = builder.backwardUnavailable;
+ this.forwardMinFrameLossRatio = builder.forwardMinFrameLossRatio;
+ this.forwardMaxFrameLossRatio = builder.forwardMaxFrameLossRatio;
+ this.forwardAverageFrameLossRatio = builder.forwardAverageFrameLossRatio;
+ this.backwardMinFrameLossRatio = builder.backwardMinFrameLossRatio;
+ this.backwardMaxFrameLossRatio = builder.backwardMaxFrameLossRatio;
+ this.backwardAverageFrameLossRatio = builder.backwardAverageFrameLossRatio;
+ }
+
+ @Override
+ public Duration elapsedTime() {
+ return elapsedTime;
+ }
+
+ @Override
+ public boolean suspectStatus() {
+ return suspectStatus;
+ }
+
+ @Override
+ public Long forwardHighLoss() {
+ return forwardHighLoss;
+ }
+
+ @Override
+ public Long backwardHighLoss() {
+ return backwardHighLoss;
+ }
+
+ @Override
+ public Long forwardConsecutiveHighLoss() {
+ return forwardConsecutiveHighLoss;
+ }
+
+ @Override
+ public Long backwardConsecutiveHighLoss() {
+ return backwardConsecutiveHighLoss;
+ }
+
+ @Override
+ public Long forwardAvailable() {
+ return forwardAvailable;
+ }
+
+ @Override
+ public Long backwardAvailable() {
+ return backwardAvailable;
+ }
+
+ @Override
+ public Long forwardUnavailable() {
+ return forwardUnavailable;
+ }
+
+ @Override
+ public Long backwardUnavailable() {
+ return backwardUnavailable;
+ }
+
+ @Override
+ public MilliPct forwardMinFrameLossRatio() {
+ return forwardMinFrameLossRatio;
+ }
+
+ @Override
+ public MilliPct forwardMaxFrameLossRatio() {
+ return forwardMaxFrameLossRatio;
+ }
+
+ @Override
+ public MilliPct forwardAverageFrameLossRatio() {
+ return forwardAverageFrameLossRatio;
+ }
+
+ @Override
+ public MilliPct backwardMinFrameLossRatio() {
+ return backwardMinFrameLossRatio;
+ }
+
+ @Override
+ public MilliPct backwardMaxFrameLossRatio() {
+ return backwardMaxFrameLossRatio;
+ }
+
+ @Override
+ public MilliPct backwardAverageFrameLossRatio() {
+ return backwardAverageFrameLossRatio;
+ }
+
+ /**
+ * Abstract base class for builders of.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStat}.
+ */
+ protected abstract static class DefaultLaStatBuilder implements LaStatBuilder {
+ private final Duration elapsedTime;
+ private final boolean suspectStatus;
+ private Long forwardHighLoss;
+ private Long backwardHighLoss;
+ private Long forwardConsecutiveHighLoss;
+ private Long backwardConsecutiveHighLoss;
+ private Long forwardAvailable;
+ private Long backwardAvailable;
+ private Long forwardUnavailable;
+ private Long backwardUnavailable;
+ private MilliPct forwardMinFrameLossRatio;
+ private MilliPct forwardMaxFrameLossRatio;
+ private MilliPct forwardAverageFrameLossRatio;
+ private MilliPct backwardMinFrameLossRatio;
+ private MilliPct backwardMaxFrameLossRatio;
+ private MilliPct backwardAverageFrameLossRatio;
+
+ protected DefaultLaStatBuilder(Duration elapsedTime, boolean suspectStatus) {
+ this.elapsedTime = elapsedTime;
+ this.suspectStatus = suspectStatus;
+ }
+
+ @Override
+ public LaStatBuilder forwardHighLoss(Long forwardHighLoss) {
+ this.forwardHighLoss = forwardHighLoss;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder backwardHighLoss(Long backwardHighLoss) {
+ this.backwardHighLoss = backwardHighLoss;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder forwardConsecutiveHighLoss(
+ Long forwardConsecutiveHighLoss) {
+ this.forwardConsecutiveHighLoss = forwardConsecutiveHighLoss;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder backwardConsecutiveHighLoss(
+ Long backwardConsecutiveHighLoss) {
+ this.backwardConsecutiveHighLoss = backwardConsecutiveHighLoss;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder forwardAvailable(Long forwardAvailable) {
+ this.forwardAvailable = forwardAvailable;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder backwardAvailable(Long backwardAvailable) {
+ this.backwardAvailable = backwardAvailable;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder forwardUnavailable(Long forwardUnavailable) {
+ this.forwardUnavailable = forwardUnavailable;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder backwardUnavailable(Long backwardUnavailable) {
+ this.backwardUnavailable = backwardUnavailable;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder forwardMinFrameLossRatio(
+ MilliPct forwardMinFrameLossRatio) {
+ this.forwardMinFrameLossRatio = forwardMinFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder forwardMaxFrameLossRatio(
+ MilliPct forwardMaxFrameLossRatio) {
+ this.forwardMaxFrameLossRatio = forwardMaxFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder forwardAverageFrameLossRatio(
+ MilliPct forwardAverageFrameLossRatio) {
+ this.forwardAverageFrameLossRatio = forwardAverageFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder backwardMinFrameLossRatio(
+ MilliPct backwardMinFrameLossRatio) {
+ this.backwardMinFrameLossRatio = backwardMinFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder backwardMaxFrameLossRatio(
+ MilliPct backwardMaxFrameLossRatio) {
+ this.backwardMaxFrameLossRatio = backwardMaxFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LaStatBuilder backwardAverageFrameLossRatio(
+ MilliPct backwardAverageFrameLossRatio) {
+ this.backwardAverageFrameLossRatio = backwardAverageFrameLossRatio;
+ return this;
+ }
+ }
+
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLaStatCurrent.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLaStatCurrent.java
new file mode 100644
index 0000000..9564ef0
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLaStatCurrent.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+import java.time.Instant;
+
+/**
+ * The default implementation of LossAvailabilityStatCurrent.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStatCurrent}.
+ */
+public final class DefaultLaStatCurrent extends DefaultLaStat
+ implements LossAvailabilityStatCurrent {
+ private final Instant startTime;
+
+ private DefaultLaStatCurrent(DefaultLaStatCurrentBuilder builder) {
+ super(builder);
+ this.startTime = builder.startTime;
+ }
+
+ @Override
+ public Instant startTime() {
+ return startTime;
+ }
+
+ public static LaStatCurrentBuilder builder(Duration elapsedTime,
+ boolean suspectStatus, Instant startTime) {
+ return new DefaultLaStatCurrentBuilder(elapsedTime, suspectStatus,
+ startTime);
+ }
+
+ private static final class DefaultLaStatCurrentBuilder
+ extends DefaultLaStatBuilder implements LaStatCurrentBuilder {
+ private Instant startTime;
+
+ protected DefaultLaStatCurrentBuilder(Duration elapsedTime,
+ boolean suspectStatus, Instant startTime) {
+ super(elapsedTime, suspectStatus);
+ this.startTime = startTime;
+ }
+
+ @Override
+ public LossAvailabilityStatCurrent build() {
+ return new DefaultLaStatCurrent(this);
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLaStatHistory.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLaStatHistory.java
new file mode 100644
index 0000000..6203bbd
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLaStatHistory.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * The default implementation of LossAvailabilityStatHistory.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStatHistory}.
+ */
+public final class DefaultLaStatHistory extends DefaultLaStat
+ implements LossAvailabilityStatHistory {
+ private final Instant endTime;
+ private final SoamId historyStatsId;
+
+ private DefaultLaStatHistory(DefaultLaStatHistoryBuilder builder) {
+ super(builder);
+ this.endTime = builder.endTime;
+ this.historyStatsId = builder.historyStatsId;
+ }
+
+ @Override
+ public Instant endTime() {
+ return endTime;
+ }
+
+ @Override
+ public SoamId historyStatsId() {
+ return historyStatsId;
+ }
+
+ public static LaStatHistoryBuilder builder(Duration elapsedTime,
+ boolean suspectStatus, SoamId historyStatsId, Instant endTime) {
+ return new DefaultLaStatHistoryBuilder(elapsedTime, suspectStatus,
+ historyStatsId, endTime);
+ }
+
+ private static final class DefaultLaStatHistoryBuilder
+ extends DefaultLaStatBuilder implements LaStatHistoryBuilder {
+ private Instant endTime;
+ private SoamId historyStatsId;
+
+ protected DefaultLaStatHistoryBuilder(Duration elapsedTime,
+ boolean suspectStatus, SoamId historyStatsId, Instant endTime) {
+ super(elapsedTime, suspectStatus);
+ this.historyStatsId = historyStatsId;
+ this.endTime = endTime;
+ }
+
+ @Override
+ public LossAvailabilityStatHistory build() {
+ return new DefaultLaStatHistory(this);
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmCreate.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmCreate.java
new file mode 100644
index 0000000..c735994
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmCreate.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.soam.DefaultMeasurementCreateBase;
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version;
+
+/**
+ * The default implementation of {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate}.
+ */
+public class DefaultLmCreate extends DefaultMeasurementCreateBase
+ implements LossMeasurementCreate {
+
+ private final LmType lmCfgType;
+ private final Collection<CounterOption> countersEnabled;
+ private final Duration availabilityMeasurementInterval;
+ private final Integer availabilityNumberConsecutiveFlrMeasurements;
+ private final MilliPct availabilityFlrThreshold;
+ private final Short availabilityNumberConsecutiveIntervals;
+ private final Short availabilityNumberConsecutiveHighFlr;
+ private final Collection<LossMeasurementThreshold> lossMeasurementThresholds;
+
+ protected DefaultLmCreate(DefaultLmCreateBuilder builder) {
+ super(builder);
+ this.lmCfgType = builder.lmCfgType;
+ this.countersEnabled = builder.countersEnabled;
+ this.availabilityMeasurementInterval = builder.availabilityMeasurementInterval;
+ this.availabilityNumberConsecutiveFlrMeasurements = builder.availabilityNumberConsecutiveFlrMeasurements;
+ this.availabilityFlrThreshold = builder.availabilityFlrThreshold;
+ this.availabilityNumberConsecutiveIntervals = builder.availabilityNumberConsecutiveIntervals;
+ this.availabilityNumberConsecutiveHighFlr = builder.availabilityNumberConsecutiveHighFlr;
+ this.lossMeasurementThresholds = builder.lossMeasurementThresholds;
+ }
+
+ @Override
+ public LmType lmCfgType() {
+ return this.lmCfgType;
+ }
+
+ @Override
+ public Collection<CounterOption> countersEnabled() {
+ return this.countersEnabled;
+ }
+
+ @Override
+ public Duration availabilityMeasurementInterval() {
+ return this.availabilityMeasurementInterval;
+ }
+
+ @Override
+ public Integer availabilityNumberConsecutiveFlrMeasurements() {
+ return this.availabilityNumberConsecutiveFlrMeasurements;
+ }
+
+ @Override
+ public MilliPct availabilityFlrThreshold() {
+ return this.availabilityFlrThreshold;
+ }
+
+ @Override
+ public Short availabilityNumberConsecutiveIntervals() {
+ return this.availabilityNumberConsecutiveIntervals;
+ }
+
+ @Override
+ public Short availabilityNumberConsecutiveHighFlr() {
+ return this.availabilityNumberConsecutiveHighFlr;
+ }
+
+ @Override
+ public Collection<LossMeasurementThreshold> lossMeasurementThreshold() {
+ return this.lossMeasurementThresholds;
+ }
+
+ public static LmCreateBuilder builder(Version version, MepId remoteMepId,
+ Priority priority, LmType lmCfgType) throws SoamConfigException {
+ return new DefaultLmCreateBuilder(version, remoteMepId,
+ priority, lmCfgType);
+ }
+
+ /**
+ * Implementation of LmCreateBuilder.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmCreateBuilder}
+ */
+ protected static class DefaultLmCreateBuilder extends DefaultMeasCreateBaseBuilder
+ implements LmCreateBuilder {
+ private final LmType lmCfgType;
+ private Collection<CounterOption> countersEnabled;
+ private Duration availabilityMeasurementInterval;
+ private Integer availabilityNumberConsecutiveFlrMeasurements;
+ private MilliPct availabilityFlrThreshold;
+ private Short availabilityNumberConsecutiveIntervals;
+ private Short availabilityNumberConsecutiveHighFlr;
+ private Collection<LossMeasurementThreshold> lossMeasurementThresholds;
+
+ protected DefaultLmCreateBuilder(Version version, MepId remoteMepId,
+ Priority priority, LmType lmCfgType) throws SoamConfigException {
+ super(version, remoteMepId, priority);
+ this.lmCfgType = lmCfgType;
+ countersEnabled = new ArrayList<>();
+ lossMeasurementThresholds = new ArrayList<>();
+ }
+
+ @Override
+ public LmCreateBuilder addToCountersEnabled(
+ CounterOption counterOption) {
+ this.countersEnabled.add(counterOption);
+ return this;
+ }
+
+ @Override
+ public LmCreateBuilder availabilityMeasurementInterval(
+ Duration availabilityMeasurementInterval) {
+ this.availabilityMeasurementInterval = availabilityMeasurementInterval;
+ return this;
+ }
+
+ @Override
+ public LmCreateBuilder availabilityNumberConsecutiveFlrMeasurements(
+ Integer availabilityNumberConsecutiveFlrMeasurements) {
+ this.availabilityNumberConsecutiveFlrMeasurements =
+ availabilityNumberConsecutiveFlrMeasurements;
+ return this;
+ }
+
+ @Override
+ public LmCreateBuilder availabilityFlrThreshold(
+ MilliPct availabilityFlrThreshold) {
+ this.availabilityFlrThreshold = availabilityFlrThreshold;
+ return this;
+ }
+
+ @Override
+ public LmCreateBuilder availabilityNumberConsecutiveIntervals(
+ Short availabilityNumberConsecutiveIntervals)
+ throws SoamConfigException {
+ this.availabilityNumberConsecutiveIntervals = availabilityNumberConsecutiveIntervals;
+ return this;
+ }
+
+ @Override
+ public LmCreateBuilder availabilityNumberConsecutiveHighFlr(
+ Short availabilityNumberConsecutiveHighFlr)
+ throws SoamConfigException {
+ this.availabilityNumberConsecutiveHighFlr = availabilityNumberConsecutiveHighFlr;
+ return this;
+ }
+
+ @Override
+ public LmCreateBuilder addToLossMeasurementThreshold(
+ LossMeasurementThreshold lossMeasurementThreshold) {
+ this.lossMeasurementThresholds.add(lossMeasurementThreshold);
+ return this;
+ }
+
+ @Override
+ public LossMeasurementCreate build() {
+ return new DefaultLmCreate(this);
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmEntry.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmEntry.java
new file mode 100644
index 0000000..3e45303
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmEntry.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version;
+
+/**
+ * The default implementation of {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementEntry}.
+ */
+public final class DefaultLmEntry extends DefaultLmCreate
+ implements LossMeasurementEntry {
+ private final SoamId lmId;
+ private final MilliPct measuredForwardFlr;
+ private final MilliPct measuredBackwardFlr;
+ private final AvailabilityType measuredAvailabilityForwardStatus;
+ private final AvailabilityType measuredAvailabilityBackwardStatus;
+ private final Instant measuredForwardLastTransitionTime;
+ private final Instant measuredBackwardLastTransitionTime;
+ private final LossMeasurementStatCurrent measurementCurrent;
+ private final Collection<LossMeasurementStatHistory> measurementHistories;
+ private final LossAvailabilityStatCurrent availabilityCurrent;
+ private final Collection<LossAvailabilityStatHistory> availabilityHistories;
+
+ protected DefaultLmEntry(DefaultLmEntryBuilder builder) {
+ super(builder);
+ this.lmId = builder.lmId;
+ this.measuredForwardFlr = builder.measuredForwardFlr;
+ this.measuredBackwardFlr = builder.measuredBackwardFlr;
+ this.measuredAvailabilityForwardStatus = builder.measuredAvailabilityForwardStatus;
+ this.measuredAvailabilityBackwardStatus = builder.measuredAvailabilityBackwardStatus;
+ this.measuredForwardLastTransitionTime = builder.measuredForwardLastTransitionTime;
+ this.measuredBackwardLastTransitionTime = builder.measuredBackwardLastTransitionTime;
+ this.measurementCurrent = builder.measurementCurrent;
+ this.measurementHistories = builder.measurementHistories;
+ this.availabilityCurrent = builder.availabilityCurrent;
+ this.availabilityHistories = builder.availabilityHistories;
+ }
+
+ @Override
+ public SoamId lmId() {
+ return lmId;
+ }
+
+ @Override
+ public MilliPct measuredForwardFlr() {
+ return measuredForwardFlr;
+ }
+
+ @Override
+ public MilliPct measuredBackwardFlr() {
+ return measuredBackwardFlr;
+ }
+
+ @Override
+ public AvailabilityType measuredAvailabilityForwardStatus() {
+ return measuredAvailabilityForwardStatus;
+ }
+
+ @Override
+ public AvailabilityType measuredAvailabilityBackwardStatus() {
+ return measuredAvailabilityBackwardStatus;
+ }
+
+ @Override
+ public Instant measuredForwardLastTransitionTime() {
+ return measuredForwardLastTransitionTime;
+ }
+
+ @Override
+ public Instant measuredBackwardLastTransitionTime() {
+ return measuredBackwardLastTransitionTime;
+ }
+
+ @Override
+ public LossMeasurementStatCurrent measurementCurrent() {
+ return measurementCurrent;
+ }
+
+ @Override
+ public Collection<LossMeasurementStatHistory> measurementHistories() {
+ return measurementHistories;
+ }
+
+ @Override
+ public LossAvailabilityStatCurrent availabilityCurrent() {
+ return availabilityCurrent;
+ }
+
+ @Override
+ public Collection<LossAvailabilityStatHistory> availabilityHistories() {
+ return availabilityHistories;
+ }
+
+ public static LmEntryBuilder builder(Version version, MepId remoteMepId,
+ Priority priority, LmType lmCfgType, SoamId lmId)
+ throws SoamConfigException {
+ return new DefaultLmEntryBuilder(version, remoteMepId,
+ priority, lmCfgType, lmId);
+ }
+
+ private static final class DefaultLmEntryBuilder extends DefaultLmCreateBuilder
+ implements LmEntryBuilder {
+ private final SoamId lmId;
+ private MilliPct measuredForwardFlr;
+ private MilliPct measuredBackwardFlr;
+ private AvailabilityType measuredAvailabilityForwardStatus;
+ private AvailabilityType measuredAvailabilityBackwardStatus;
+ private Instant measuredForwardLastTransitionTime;
+ private Instant measuredBackwardLastTransitionTime;
+ private LossMeasurementStatCurrent measurementCurrent;
+ private Collection<LossMeasurementStatHistory> measurementHistories;
+ private LossAvailabilityStatCurrent availabilityCurrent;
+ private Collection<LossAvailabilityStatHistory> availabilityHistories;
+
+ protected DefaultLmEntryBuilder(Version version, MepId remoteMepId,
+ Priority priority, LmType lmCfgType, SoamId lmId)
+ throws SoamConfigException {
+ super(version, remoteMepId, priority, lmCfgType);
+ this.lmId = lmId;
+ measurementHistories = new ArrayList<>();
+ availabilityHistories = new ArrayList<>();
+ }
+
+ @Override
+ public LmEntryBuilder measuredForwardFlr(MilliPct measuredForwardFlr) {
+ this.measuredForwardFlr = measuredForwardFlr;
+ return this;
+ }
+
+ @Override
+ public LmEntryBuilder measuredBackwardFlr(
+ MilliPct measuredBackwardFlr) {
+ this.measuredBackwardFlr = measuredBackwardFlr;
+ return this;
+ }
+
+ @Override
+ public LmEntryBuilder measuredAvailabilityForwardStatus(
+ AvailabilityType measuredAvailabilityForwardStatus) {
+ this.measuredAvailabilityForwardStatus = measuredAvailabilityForwardStatus;
+ return this;
+ }
+
+ @Override
+ public LmEntryBuilder measuredAvailabilityBackwardStatus(
+ AvailabilityType measuredAvailabilityBackwardStatus) {
+ this.measuredAvailabilityBackwardStatus = measuredAvailabilityBackwardStatus;
+ return this;
+ }
+
+ @Override
+ public LmEntryBuilder measuredForwardLastTransitionTime(
+ Instant measuredForwardLastTransitionTime) {
+ this.measuredForwardLastTransitionTime = measuredForwardLastTransitionTime;
+ return this;
+ }
+
+ @Override
+ public LmEntryBuilder measuredBackwardLastTransitionTime(
+ Instant measuredBackwardLastTransitionTime) {
+ this.measuredBackwardLastTransitionTime = measuredBackwardLastTransitionTime;
+ return this;
+ }
+
+ @Override
+ public LmEntryBuilder measurementCurrent(
+ LossMeasurementStatCurrent measurementCurrent) {
+ this.measurementCurrent = measurementCurrent;
+ return this;
+ }
+
+ @Override
+ public LmEntryBuilder addToMeasurementHistories(
+ LossMeasurementStatHistory history) {
+ this.measurementHistories.add(history);
+ return this;
+ }
+
+ @Override
+ public LmEntryBuilder availabilityCurrent(
+ LossAvailabilityStatCurrent availabilityCurrent) {
+ this.availabilityCurrent = availabilityCurrent;
+ return this;
+ }
+
+ @Override
+ public LmEntryBuilder addToAvailabilityHistories(
+ LossAvailabilityStatHistory history) {
+ this.availabilityHistories.add(history);
+ return this;
+ }
+
+ @Override
+ public LossMeasurementEntry build() {
+ return new DefaultLmEntry(this);
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmStat.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmStat.java
new file mode 100644
index 0000000..0410e47
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmStat.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+
+/**
+ * The default implementation of {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStat}.
+ */
+public abstract class DefaultLmStat implements LossMeasurementStat {
+ private final Duration elapsedTime;
+ private final boolean suspectStatus;
+ private final Long forwardTransmittedFrames;
+ private final Long forwardReceivedFrames;
+ private final MilliPct forwardMinFrameLossRatio;
+ private final MilliPct forwardMaxFrameLossRatio;
+ private final MilliPct forwardAverageFrameLossRatio;
+ private final Long backwardTransmittedFrames;
+ private final Long backwardReceivedFrames;
+ private final MilliPct backwardMinFrameLossRatio;
+ private final MilliPct backwardMaxFrameLossRatio;
+ private final MilliPct backwardAverageFrameLossRatio;
+ private final Long soamPdusSent;
+ private final Long soamPdusReceived;
+
+ protected DefaultLmStat(DefaultLmStatBuilder builder) {
+ this.elapsedTime = builder.elapsedTime;
+ this.suspectStatus = builder.suspectStatus;
+ this.forwardTransmittedFrames = builder.forwardTransmittedFrames;
+ this.forwardReceivedFrames = builder.forwardReceivedFrames;
+ this.forwardMinFrameLossRatio = builder.forwardMinFrameLossRatio;
+ this.forwardMaxFrameLossRatio = builder.forwardMaxFrameLossRatio;
+ this.forwardAverageFrameLossRatio = builder.forwardAverageFrameLossRatio;
+ this.backwardTransmittedFrames = builder.backwardTransmittedFrames;
+ this.backwardReceivedFrames = builder.backwardReceivedFrames;
+ this.backwardMinFrameLossRatio = builder.backwardMinFrameLossRatio;
+ this.backwardMaxFrameLossRatio = builder.backwardMaxFrameLossRatio;
+ this.backwardAverageFrameLossRatio = builder.backwardAverageFrameLossRatio;
+ this.soamPdusSent = builder.soamPdusSent;
+ this.soamPdusReceived = builder.soamPdusReceived;
+ }
+
+ @Override
+ public Duration elapsedTime() {
+ return this.elapsedTime;
+ }
+
+ @Override
+ public boolean suspectStatus() {
+ return this.suspectStatus;
+ }
+
+ @Override
+ public Long forwardTransmittedFrames() {
+ return this.forwardTransmittedFrames;
+ }
+
+ @Override
+ public Long forwardReceivedFrames() {
+ return this.forwardReceivedFrames;
+ }
+
+ @Override
+ public MilliPct forwardMinFrameLossRatio() {
+ return this.forwardMinFrameLossRatio;
+ }
+
+ @Override
+ public MilliPct forwardMaxFrameLossRatio() {
+ return this.forwardMaxFrameLossRatio;
+ }
+
+ @Override
+ public MilliPct forwardAverageFrameLossRatio() {
+ return this.forwardAverageFrameLossRatio;
+ }
+
+ @Override
+ public Long backwardTransmittedFrames() {
+ return this.backwardTransmittedFrames;
+ }
+
+ @Override
+ public Long backwardReceivedFrames() {
+ return this.backwardReceivedFrames;
+ }
+
+ @Override
+ public MilliPct backwardMinFrameLossRatio() {
+ return this.backwardMinFrameLossRatio;
+ }
+
+ @Override
+ public MilliPct backwardMaxFrameLossRatio() {
+ return this.backwardMaxFrameLossRatio;
+ }
+
+ @Override
+ public MilliPct backwardAverageFrameLossRatio() {
+ return this.backwardAverageFrameLossRatio;
+ }
+
+ @Override
+ public Long soamPdusSent() {
+ return this.soamPdusSent;
+ }
+
+ @Override
+ public Long soamPdusReceived() {
+ return this.soamPdusReceived;
+ }
+
+ /**
+ * Abstract implementation of LmStatBuilder.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStat.LmStatBuilder}
+ */
+ protected abstract static class DefaultLmStatBuilder implements LmStatBuilder {
+ private final Duration elapsedTime;
+ private final boolean suspectStatus;
+ private Long forwardTransmittedFrames;
+ private Long forwardReceivedFrames;
+ private MilliPct forwardMinFrameLossRatio;
+ private MilliPct forwardMaxFrameLossRatio;
+ private MilliPct forwardAverageFrameLossRatio;
+ private Long backwardTransmittedFrames;
+ private Long backwardReceivedFrames;
+ private MilliPct backwardMinFrameLossRatio;
+ private MilliPct backwardMaxFrameLossRatio;
+ private MilliPct backwardAverageFrameLossRatio;
+ private Long soamPdusSent;
+ private Long soamPdusReceived;
+
+ protected DefaultLmStatBuilder(Duration elapsedTime, boolean suspectStatus) {
+ this.elapsedTime = elapsedTime;
+ this.suspectStatus = suspectStatus;
+ }
+
+ @Override
+ public LmStatBuilder forwardTransmittedFrames(
+ Long forwardTransmittedFrames) {
+ this.forwardTransmittedFrames = forwardTransmittedFrames;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder forwardReceivedFrames(Long forwardReceivedFrames) {
+ this.forwardReceivedFrames = forwardReceivedFrames;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder forwardMinFrameLossRatio(
+ MilliPct forwardMinFrameLossRatio) {
+ this.forwardMinFrameLossRatio = forwardMinFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder forwardMaxFrameLossRatio(
+ MilliPct forwardMaxFrameLossRatio) {
+ this.forwardMaxFrameLossRatio = forwardMaxFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder forwardAverageFrameLossRatio(
+ MilliPct forwardAverageFrameLossRatio) {
+ this.forwardAverageFrameLossRatio = forwardAverageFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder backwardTransmittedFrames(
+ Long backwardTransmittedFrames) {
+ this.backwardTransmittedFrames = backwardTransmittedFrames;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder backwardReceivedFrames(
+ Long backwardReceivedFrames) {
+ this.backwardReceivedFrames = backwardReceivedFrames;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder backwardMinFrameLossRatio(
+ MilliPct backwardMinFrameLossRatio) {
+ this.backwardMinFrameLossRatio = backwardMinFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder backwardMaxFrameLossRatio(
+ MilliPct backwardMaxFrameLossRatio) {
+ this.backwardMaxFrameLossRatio = backwardMaxFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder backwardAverageFrameLossRatio(
+ MilliPct backwardAverageFrameLossRatio) {
+ this.backwardAverageFrameLossRatio = backwardAverageFrameLossRatio;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder soamPdusSent(Long soamPdusSent) {
+ this.soamPdusSent = soamPdusSent;
+ return this;
+ }
+
+ @Override
+ public LmStatBuilder soamPdusReceived(Long soamPdusReceived) {
+ this.soamPdusReceived = soamPdusReceived;
+ return this;
+ }
+ }
+
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmStatCurrent.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmStatCurrent.java
new file mode 100644
index 0000000..1920845
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmStatCurrent.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+import java.time.Instant;
+
+/**
+ * The default implementation of LossMeasurementStatCurrent.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatCurrent}
+ */
+public final class DefaultLmStatCurrent extends DefaultLmStat
+ implements LossMeasurementStatCurrent {
+ private final Instant startTime;
+
+ protected DefaultLmStatCurrent(DefaultLmStatCurrentBuilder builder) {
+ super(builder);
+ this.startTime = builder.startTime;
+ }
+
+ @Override
+ public Instant startTime() {
+ return startTime;
+ }
+
+ public static LmStatCurrentBuilder builder(Duration elapsedTime,
+ boolean suspectStatus, Instant startTime) {
+ return new DefaultLmStatCurrentBuilder(elapsedTime,
+ suspectStatus, startTime);
+ }
+
+ private static class DefaultLmStatCurrentBuilder extends DefaultLmStatBuilder
+ implements LmStatCurrentBuilder {
+ private final Instant startTime;
+
+ protected DefaultLmStatCurrentBuilder(Duration elapsedTime,
+ boolean suspectStatus, Instant startTime) {
+ super(elapsedTime, suspectStatus);
+ this.startTime = startTime;
+ }
+
+ @Override
+ public LossMeasurementStatCurrent build() {
+ return new DefaultLmStatCurrent(this);
+ }
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmStatHistory.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmStatHistory.java
new file mode 100644
index 0000000..1109e92
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmStatHistory.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * The default implementation of LossMeasurementStatHistory.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatHistory}
+ */
+public final class DefaultLmStatHistory extends DefaultLmStat
+ implements LossMeasurementStatHistory {
+ private final SoamId historyStatsId;
+ private final Instant endTime;
+
+ protected DefaultLmStatHistory(DefaultLmStatHistoryBuilder builder) {
+ super(builder);
+ this.historyStatsId = builder.historyStatsId;
+ this.endTime = builder.endTime;
+ }
+
+ @Override
+ public SoamId historyStatsId() {
+ return historyStatsId;
+ }
+
+
+ @Override
+ public Instant endTime() {
+ return endTime;
+ }
+
+ public static LmStatHistoryBuilder builder(Duration elapsedTime,
+ boolean suspectStatus, SoamId historyStatsId, Instant endTime) {
+ return new DefaultLmStatHistoryBuilder(elapsedTime,
+ suspectStatus, historyStatsId, endTime);
+ }
+
+ private static class DefaultLmStatHistoryBuilder extends DefaultLmStatBuilder
+ implements LmStatHistoryBuilder {
+ private final SoamId historyStatsId;
+ private final Instant endTime;
+
+ protected DefaultLmStatHistoryBuilder(Duration elapsedTime,
+ boolean suspectStatus, SoamId historyStatsId, Instant endTime) {
+ super(elapsedTime, suspectStatus);
+ this.historyStatsId = historyStatsId;
+ this.endTime = endTime;
+ }
+
+ @Override
+ public LossMeasurementStatHistory build() {
+ return new DefaultLmStatHistory(this);
+ }
+ }
+
+
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmThreshold.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmThreshold.java
new file mode 100644
index 0000000..0487516
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/DefaultLmThreshold.java
@@ -0,0 +1,274 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * The default implementation of {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementThreshold}.
+ */
+public final class DefaultLmThreshold implements LossMeasurementThreshold {
+
+ private final SoamId thresholdId;
+ private final Collection<ThresholdOption> threshold;
+ private final MilliPct measuredFlrForward;
+ private final MilliPct maxFlrForward;
+ private final MilliPct averageFlrForward;
+ private final MilliPct measuredFlrBackward;
+ private final MilliPct maxFlrBackward;
+ private final MilliPct averageFlrBackward;
+ private final Long forwardHighLoss;
+ private final Long forwardConsecutiveHighLoss;
+ private final Long backwardHighLoss;
+ private final Long backwardConsecutiveHighLoss;
+ private final Long forwardUnavailableCount;
+ private final MilliPct forwardAvailableRatio;
+ private final Long backwardUnavailableCount;
+ private final MilliPct backwardAvailableRatio;
+
+ private DefaultLmThreshold(DefaultLmThresholdBuilder builder) {
+ this.thresholdId = builder.thresholdId;
+ this.threshold = builder.threshold;
+ this.measuredFlrForward = builder.measuredFlrForward;
+ this.maxFlrForward = builder.maxFlrForward;
+ this.averageFlrForward = builder.averageFlrForward;
+ this.measuredFlrBackward = builder.measuredFlrBackward;
+ this.maxFlrBackward = builder.maxFlrBackward;
+ this.averageFlrBackward = builder.averageFlrBackward;
+ this.forwardHighLoss = builder.forwardHighLoss;
+ this.forwardConsecutiveHighLoss = builder.forwardConsecutiveHighLoss;
+ this.backwardHighLoss = builder.backwardHighLoss;
+ this.backwardConsecutiveHighLoss = builder.backwardConsecutiveHighLoss;
+ this.forwardUnavailableCount = builder.forwardUnavailableCount;
+ this.forwardAvailableRatio = builder.forwardAvailableRatio;
+ this.backwardUnavailableCount = builder.backwardUnavailableCount;
+ this.backwardAvailableRatio = builder.backwardAvailableRatio;
+ }
+
+ @Override
+ public SoamId thresholdId() {
+ return thresholdId;
+ }
+
+ @Override
+ public Collection<ThresholdOption> thresholds() {
+ return threshold;
+ }
+
+ @Override
+ public MilliPct measuredFlrForward() {
+ return measuredFlrForward;
+ }
+
+ @Override
+ public MilliPct maxFlrForward() {
+ return maxFlrForward;
+ }
+
+ @Override
+ public MilliPct averageFlrForward() {
+ return averageFlrForward;
+ }
+
+ @Override
+ public MilliPct measuredFlrBackward() {
+ return measuredFlrBackward;
+ }
+
+ @Override
+ public MilliPct maxFlrBackward() {
+ return maxFlrBackward;
+ }
+
+ @Override
+ public MilliPct averageFlrBackward() {
+ return averageFlrBackward;
+ }
+
+ @Override
+ public Long forwardHighLoss() {
+ return forwardHighLoss;
+ }
+
+ @Override
+ public Long forwardConsecutiveHighLoss() {
+ return forwardConsecutiveHighLoss;
+ }
+
+ @Override
+ public Long backwardHighLoss() {
+ return backwardHighLoss;
+ }
+
+ @Override
+ public Long backwardConsecutiveHighLoss() {
+ return backwardConsecutiveHighLoss;
+ }
+
+ @Override
+ public Long forwardUnavailableCount() {
+ return forwardUnavailableCount;
+ }
+
+ @Override
+ public MilliPct forwardAvailableRatio() {
+ return forwardAvailableRatio;
+ }
+
+ @Override
+ public Long backwardUnavailableCount() {
+ return backwardUnavailableCount;
+ }
+
+ @Override
+ public MilliPct backwardAvailableRatio() {
+ return backwardAvailableRatio;
+ }
+
+ public static LmThresholdBuilder builder(SoamId thresholdId) {
+ return new DefaultLmThresholdBuilder(thresholdId);
+ }
+
+ private static final class DefaultLmThresholdBuilder implements LmThresholdBuilder {
+ private final SoamId thresholdId;
+ private Collection<ThresholdOption> threshold;
+ private MilliPct measuredFlrForward;
+ private MilliPct maxFlrForward;
+ private MilliPct averageFlrForward;
+ private MilliPct measuredFlrBackward;
+ private MilliPct maxFlrBackward;
+ private MilliPct averageFlrBackward;
+ private Long forwardHighLoss;
+ private Long forwardConsecutiveHighLoss;
+ private Long backwardHighLoss;
+ private Long backwardConsecutiveHighLoss;
+ private Long forwardUnavailableCount;
+ private MilliPct forwardAvailableRatio;
+ private Long backwardUnavailableCount;
+ private MilliPct backwardAvailableRatio;
+
+ protected DefaultLmThresholdBuilder(SoamId thresholdId) {
+ this.thresholdId = thresholdId;
+ threshold = new ArrayList<>();
+ }
+
+ @Override
+ public LmThresholdBuilder addToThreshold(ThresholdOption threshold) {
+ this.threshold.add(threshold);
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder measuredFlrForward(MilliPct measuredFlrForward) {
+ this.measuredFlrForward = measuredFlrForward;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder maxFlrForward(MilliPct maxFlrForward) {
+ this.maxFlrForward = maxFlrForward;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder averageFlrForward(MilliPct averageFlrForward) {
+ this.averageFlrForward = averageFlrForward;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder measuredFlrBackward(
+ MilliPct measuredFlrBackward) {
+ this.measuredFlrBackward = measuredFlrBackward;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder maxFlrBackward(MilliPct maxFlrBackward) {
+ this.maxFlrBackward = maxFlrBackward;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder averageFlrBackward(MilliPct averageFlrBackward) {
+ this.averageFlrBackward = averageFlrBackward;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder forwardHighLoss(Long forwardHighLoss) {
+ this.forwardHighLoss = forwardHighLoss;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder forwardConsecutiveHighLoss(
+ Long forwardConsecutiveHighLoss) {
+ this.forwardConsecutiveHighLoss = forwardConsecutiveHighLoss;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder backwardHighLoss(Long backwardHighLoss) {
+ this.backwardHighLoss = backwardHighLoss;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder backwardConsecutiveHighLoss(
+ Long backwardConsecutiveHighLoss) {
+ this.backwardConsecutiveHighLoss = backwardConsecutiveHighLoss;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder forwardUnavailableCount(
+ Long forwardUnavailableCount) {
+ this.forwardUnavailableCount = forwardUnavailableCount;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder forwardAvailableRatio(
+ MilliPct forwardAvailableRatio) {
+ this.forwardAvailableRatio = forwardAvailableRatio;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder backwardUnavailableCount(
+ Long backwardUnavailableCount) {
+ this.backwardUnavailableCount = backwardUnavailableCount;
+ return this;
+ }
+
+ @Override
+ public LmThresholdBuilder backwardAvailableRatio(
+ MilliPct backwardAvailableRatio) {
+ this.backwardAvailableRatio = backwardAvailableRatio;
+ return this;
+ }
+
+ @Override
+ public LossMeasurementThreshold build() {
+ return new DefaultLmThreshold(this);
+ }
+ }
+}
\ No newline at end of file
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStat.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStat.java
new file mode 100644
index 0000000..09b6e0e
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStat.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+
+/**
+ * Abstract base interface to represent Loss Availability Stats.
+ */
+public interface LossAvailabilityStat {
+
+ Duration elapsedTime();
+
+ /**
+ * Indicates whether the Measurement Interval has been marked as suspect.
+ * The object is set to false at the start of a measurement interval.
+ * Conditions for a discontinuity include, but are not limited to the following:
+ * 1 - The local time-of-day clock is adjusted by at least 10 seconds
+ * 2 - The conducting of a performance measurement is halted before the
+ * current Measurement Interval is completed
+ * 3 - A local test, failure, or reconfiguration that disrupts service
+ * @return true when there is a discontinuity in the performance measurements during the Measurement Interval
+ */
+ boolean suspectStatus();
+
+ /**
+ * The number of high loss intervals (HLI) over time in the forward direction.
+ * The value starts at 0 and increments for every HLI that occurs.
+ * This parameter is equivalent to 'L Sub T' found in MEF 10.2.1
+ * @return the number of intervals
+ */
+ Long forwardHighLoss();
+
+ /**
+ * The number of high loss intervals (HLI) over time in the backward direction.
+ * The value starts at 0 and increments for every HLI that occurs.
+ * This parameter is equivalent to 'L Sub T' found in MEF 10.2.1
+ * @return the number of intervals
+ */
+ Long backwardHighLoss();
+
+ /**
+ * The number of consecutive high loss intervals (CHLI) over time in the forward direction.
+ * The value starts at 0 and increments for every HLI that occurs.
+ * This parameter is equivalent to 'B Sub T' found in MEF 10.2.1
+ * @return the number of intervals
+ */
+ Long forwardConsecutiveHighLoss();
+
+ /**
+ * The number of consecutive high loss intervals (CHLI) over time in the backward direction.
+ * The value starts at 0 and increments for every HLI that occurs.
+ * This parameter is equivalent to 'B Sub T' found in MEF 10.2.1
+ * @return the number of intervals
+ */
+ Long backwardConsecutiveHighLoss();
+
+ /**
+ * The number of availability indicators during a small time interval.
+ * evaluated as available (low frame loss) in the forward direction by this
+ * MEP during this measurement interval.
+ * @return The number of availability indicators
+ */
+ Long forwardAvailable();
+
+ /**
+ * The number of availability indicators during a small time interval.
+ * evaluated as available (low frame loss) in the backward direction by
+ * this MEP during this measurement interval.
+ * @return The number of availability indicators
+ */
+ Long backwardAvailable();
+
+ /**
+ * The number of availability indicators during a small time interval.
+ * evaluated as unavailable (high frame loss) in the forward direction by
+ * this MEP during this measurement interval
+ * @return The number of availability indicators
+ */
+ Long forwardUnavailable();
+
+ /**
+ * The number of availability indicators during a small time interval.
+ * evaluated as unavailable (high frame loss) in the backward direction by
+ * this MEP during this measurement interval
+ * @return The number of availability indicators
+ */
+ Long backwardUnavailable();
+
+ /**
+ * The minimum one-way availability flr in the forward direction,.
+ * from among the set of availability flr values calculated by the MEP in this Measurement Interval.
+ * There is one availability flr value for each 'delta_t' time period within
+ * the Measurement Interval, as specified in MEF 10.2.1.
+ * The flr value is a ratio that is expressed as a percent with a value of 0
+ * (ratio 0.00) through 100000 (ratio 1.00).
+ * @return The ratio as 1/1000th of a percent, where 1 indicates 0.001 percent
+ */
+ MilliPct forwardMinFrameLossRatio();
+
+ /**
+ * The maximum one-way availability flr in the forward direction,.
+ * from among the set of availability flr values calculated by the MEP in this Measurement Interval.
+ * There is one availability flr value for each 'delta_t' time period within
+ * the Measurement Interval, as specified in MEF 10.2.1.
+ * The flr value is a ratio that is expressed as a percent with a value of 0
+ * (ratio 0.00) through 100000 (ratio 1.00).
+ * @return The ratio as 1/1000th of a percent, where 1 indicates 0.001 percent
+ */
+ MilliPct forwardMaxFrameLossRatio();
+
+ /**
+ * The average one-way availability flr in the forward direction,.
+ * from among the set of availability flr values calculated by the MEP in this Measurement Interval.
+ * There is one availability flr value for each 'delta_t' time period within
+ * the Measurement Interval, as specified in MEF 10.2.1.
+ * The flr value is a ratio that is expressed as a percent with a value of 0
+ * (ratio 0.00) through 100000 (ratio 1.00).
+ * @return The ratio as 1/1000th of a percent, where 1 indicates 0.001 percent
+ */
+ MilliPct forwardAverageFrameLossRatio();
+
+ /**
+ * The minimum one-way availability flr in the backward direction,.
+ * from among the set of availability flr values calculated by the MEP in this Measurement Interval.
+ * There is one availability flr value for each 'delta_t' time period within
+ * the Measurement Interval, as specified in MEF 10.2.1.
+ * The flr value is a ratio that is expressed as a percent with a value of 0
+ * (ratio 0.00) through 100000 (ratio 1.00).
+ * @return The ratio as 1/1000th of a percent, where 1 indicates 0.001 percent
+ */
+ MilliPct backwardMinFrameLossRatio();
+
+ /**
+ * The maximum one-way availability flr in the backward direction,.
+ * from among the set of availability flr values calculated by the MEP in this Measurement Interval.
+ * There is one availability flr value for each 'delta_t' time period within
+ * the Measurement Interval, as specified in MEF 10.2.1.
+ * The flr value is a ratio that is expressed as a percent with a value of 0
+ * (ratio 0.00) through 100000 (ratio 1.00).
+ * @return The ratio as 1/1000th of a percent, where 1 indicates 0.001 percent
+ */
+ MilliPct backwardMaxFrameLossRatio();
+
+ /**
+ * The average one-way availability flr in the backward direction,.
+ * from among the set of availability flr values calculated by the MEP in this Measurement Interval.
+ * There is one availability flr value for each 'delta_t' time period within
+ * the Measurement Interval, as specified in MEF 10.2.1.
+ * The flr value is a ratio that is expressed as a percent with a value of 0
+ * (ratio 0.00) through 100000 (ratio 1.00).
+ * @return The ratio as 1/1000th of a percent, where 1 indicates 0.001 percent
+ */
+ MilliPct backwardAverageFrameLossRatio();
+
+ /**
+ * Abstract builder for classes derived from LossAvailabilityStat.
+ * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStat}.
+ */
+ public interface LaStatBuilder {
+ LaStatBuilder forwardHighLoss(Long forwardHighLoss);
+
+ LaStatBuilder backwardHighLoss(Long backwardHighLoss);
+
+ LaStatBuilder forwardConsecutiveHighLoss(Long forwardConsecutiveHighLoss);
+
+ LaStatBuilder backwardConsecutiveHighLoss(Long backwardConsecutiveHighLoss);
+
+ LaStatBuilder forwardAvailable(Long forwardAvailable);
+
+ LaStatBuilder backwardAvailable(Long backwardAvailable);
+
+ LaStatBuilder forwardUnavailable(Long forwardUnavailable);
+
+ LaStatBuilder backwardUnavailable(Long backwardUnavailable);
+
+ LaStatBuilder forwardMinFrameLossRatio(MilliPct forwardMinFrameLossRatio);
+
+ LaStatBuilder forwardMaxFrameLossRatio(MilliPct forwardMaxFrameLossRatio);
+
+ LaStatBuilder forwardAverageFrameLossRatio(MilliPct forwardAverageFrameLossRatio);
+
+ LaStatBuilder backwardMinFrameLossRatio(MilliPct backwardMinFrameLossRatio);
+
+ LaStatBuilder backwardMaxFrameLossRatio(MilliPct backwardMaxFrameLossRatio);
+
+ LaStatBuilder backwardAverageFrameLossRatio(MilliPct backwardAverageFrameLossRatio);
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatCurrent.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatCurrent.java
new file mode 100644
index 0000000..9c1465a
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatCurrent.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Instant;
+
+/**
+ * Object for representing Loss Availability Stats Current.
+ * Extends {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStat}
+ */
+public interface LossAvailabilityStatCurrent extends LossAvailabilityStat {
+ /**
+ * The time that the current Measurement Interval started.
+ * @return The start time as a java Instant
+ */
+ Instant startTime();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStatCurrent}.
+ */
+ public interface LaStatCurrentBuilder extends LaStatBuilder {
+ LossAvailabilityStatCurrent build();
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatHistory.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatHistory.java
new file mode 100644
index 0000000..49beef5
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatHistory.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Instant;
+
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * Object for representing Loss Availability Stats History.
+ * Extends {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStat}
+ */
+public interface LossAvailabilityStatHistory extends LossAvailabilityStat {
+ /**
+ * The identifier of the historic measurement.
+ * @return The id
+ */
+ SoamId historyStatsId();
+
+ /**
+ * The time that the historic Measurement Interval ended.
+ * @return A java Instant
+ */
+ Instant endTime();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStatHistory}.
+ */
+ public interface LaStatHistoryBuilder extends LaStatBuilder {
+ LossAvailabilityStatHistory build();
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementCreate.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementCreate.java
new file mode 100644
index 0000000..6dcb3bb
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementCreate.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.soam.MeasurementCreateBase;
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+
+/**
+ * Object to support creation of Loss Measurement tests.
+ */
+public interface LossMeasurementCreate extends MeasurementCreateBase {
+ /**
+ * The type of Loss Measurement that will be performed.
+ * @return A loss Measurement type
+ */
+ LmType lmCfgType();
+
+ /**
+ * A vector of bits that indicates the type of SOAM LM counters found.
+ * in the current-stats and history-stats that are enabled.
+ * A present bit enables the specific SOAM LM counter. A not present bit disables the SOAM LM counter.
+ * If a particular SOAM LM counter is not supported the BIT value is not present.
+ * Not all SOAM LM counters are supported for all SOAM LM types.
+ * @return A collection of bit options
+ */
+ Collection<CounterOption> countersEnabled();
+
+ /**
+ * This object specifies the availability measurement interval in minutes.
+ * A measurement interval of 15 minutes is to be supported, other intervals can be supported
+ * @return A java Duration
+ */
+ Duration availabilityMeasurementInterval();
+
+ /**
+ * Specifies a configurable number of consecutive loss measurement PDUs.
+ * to be used in evaluating the availability/unavailability status of each
+ * availability indicator per MEF 10.2.1.
+ * Loss Measurement PDUs (LMMs, CCMs or SLMs) are sent regularly with a
+ * period defined by message-period. Therefore, this object, when multiplied
+ * by message-period, is equivalent to the Availability parameter of 'delta_t'
+ * as specified by MEF 10.2.1.
+ *
+ * If the measurement-type is lmm or ccm, this object defines the number of
+ * LMM or CCM PDUs transmitted during each 'delta_t' period. The Availability
+ * flr for a given 'delta_t' can be calculated based on the counters in the
+ * last LMM/R or CCM during this 'delta_t' and the last LMM/R or CCM in the
+ * previous 'delta_t'.
+ *
+ * If the measurement-type is slm, this object defines the number of SLM PDUs
+ * transmitted during each 'delta_t' period. The Availability flr for a
+ * given 'delta_t' is calculated based on the number of those SLM PDUs that are lost.
+ *
+ * If the measurement-type is lmm or ccm, the number range of 1 through 10
+ * must be supported. The number range of 10 through 1000000 may be supported,
+ * but is not mandatory.
+ *
+ * If the measurement-type is slm, the number range of 10 through 100 must be
+ * supported. The number range of 100 through 1000000 may be supported,
+ * but is not mandatory
+ * @return number of consecutive loss measurement PDUs
+ */
+ Integer availabilityNumberConsecutiveFlrMeasurements();
+
+ /**
+ * Specifies a configurable availability threshold to be used in evaluating
+ * the availability/unavailability status of an availability indicator per
+ * MEF 10.2.1. The availability threshold range of 0.00 (0) through 1.00 (100000)
+ * is supported. This parameter is equivalent to the Availability parameter
+ * of 'C' as specified by MEF 10.2.1.
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct availabilityFlrThreshold();
+
+ /**
+ * Specifies a configurable number of consecutive availability indicators to
+ * be used to determine a change in the availability status as indicated by
+ * MEF 10.2.1. This parameter is equivalent to the Availability parameter of
+ * 'n' as specified by MEF 10.2.1.
+ * The number range of 1 through 10 must be supported.
+ * The number range of 1 through 1000 may be supported, but is not mandatory
+ * @return number of consecutive availability indicators
+ */
+ Short availabilityNumberConsecutiveIntervals();
+
+ /**
+ * Specifies a configurable number of consecutive availability indicators.
+ * to be used for assessing CHLI. This parameter is equivalent to the
+ * Resilency parameter of 'p' as specified by MEF 10.2.1.
+ *
+ * Availability-consecutive-high-flr must be strictly less than
+ * availability-number-consecutive-intervals. If not, the count of high loss
+ * intervals over time, and the count of consecutive high loss levels, is disabled.
+ *
+ * The number range of 1 through 10 must be supported. The number range of 1
+ * through 1000 may be supported, but is not mandatory
+ * @return number of consecutive availability indicators
+ */
+ Short availabilityNumberConsecutiveHighFlr();
+
+ /**
+ * The list of Loss Measurement configuration threshold values for LM Performance Monitoring.
+ * The main purpose of the threshold configuration list is to configure
+ * threshold alarm notifications indicating that a specific performance metric
+ * is not being met
+ * @return A collection of Loss Measurement Thresholds
+ */
+ Collection<LossMeasurementThreshold> lossMeasurementThreshold();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate}.
+ */
+ public interface LmCreateBuilder extends MeasCreateBaseBuilder {
+
+ LmCreateBuilder addToCountersEnabled(CounterOption counterOption);
+
+ LmCreateBuilder availabilityMeasurementInterval(
+ Duration availabilityMeasurementInterval);
+
+ LmCreateBuilder availabilityNumberConsecutiveFlrMeasurements(
+ Integer availabilityNumberConsecutiveFlrMeasurements);
+
+ LmCreateBuilder availabilityFlrThreshold(MilliPct availabilityFlrThreshold);
+
+ LmCreateBuilder availabilityNumberConsecutiveIntervals(
+ Short availabilityNumberConsecutiveIntervals) throws SoamConfigException;
+
+ LmCreateBuilder availabilityNumberConsecutiveHighFlr(
+ Short availabilityNumberConsecutiveHighFlr) throws SoamConfigException;
+
+ LmCreateBuilder addToLossMeasurementThreshold(
+ LossMeasurementThreshold lossMeasurementThreshold);
+
+ LossMeasurementCreate build();
+ }
+
+ /**
+ * Enumerated set of Loss Measurement types.
+ */
+ public enum LmType {
+ /**
+ * LMM SOAM PDU generated and received LMR responses tracked.
+ */
+ LMLMM,
+ /**
+ * SLM SOAM PDU generated and received SLR responses tracked.
+ */
+ LMSLM,
+ /**
+ * CCM SOAM PDU generated and received CCM PDUs tracked.
+ */
+ LMCCM;
+ }
+
+ /**
+ * Options for Counters that may be enabled.
+ */
+ public enum CounterOption {
+ FORWARD_TRANSMITTED_FRAMES,
+ FORWARD_RECEIVED_FRAMES,
+ FORWARD_MIN_FLR,
+ FORWARD_MAX_FLR,
+ FORWARD_AVERAGE_FLR,
+ BACKWARD_TRANSMITTED_FRAMES,
+ BACKWARD_RECEIVED_FRAMES,
+ BACKWARD_MIN_FLR,
+ BACKWARD_MAX_FLR,
+ BACKWARD_AVERAGE_FLR,
+ SOAM_PDUS_SENT,
+ SOAM_PDUS_RECEIVED,
+ AVAILABILITY_FORWARD_HIGH_LOSS,
+ AVAILABILITY_FORWARD_CONSECUTIVE_HIGH_LOSS,
+ AVAILABILITY_FORWARD_AVAILABLE,
+ AVAILABILITY_FORWARD_UNAVAILABLE,
+ AVAILABILILITY_FORWARD_MIN_FLR,
+ AVAILABILITY_FORWARD_MAX_FLR,
+ AVAILABILITY_FORWARD_AVERAGE_FLR,
+ AVAILABILITY_BACKWARD_HIGH_LOSS,
+ AVAILABILITY_BACKWARD_CONSECUTIVE_HIGH_LOSS,
+ AVAILABILITY_BACKWARD_AVAILABLE,
+ AVAILABLE_BACKWARD_UNAVAILABLE,
+ AVAILABLE_BACKWARD_MIN_FLR,
+ AVAILABLE_BACKWARD_MAX_FLR,
+ AVAILABLE_BACKWARD_AVERAGE_FLR,
+ MEASURED_STATS_FORWARD_MEASURED_FLR,
+ MEASURED_STATS_BACKWARD_MEASURED_FLR,
+ MEASURED_STATS_AVAILABILITY_FORWARD_STATUS,
+ MEASURED_STATS_AVAILABILITY_BACKWARD_STATUS;
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementEntry.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementEntry.java
new file mode 100644
index 0000000..fb0cecb
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementEntry.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Instant;
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * A model of Loss Measurement from ITU Y.1731 Chapter 8.2, MEF 17, MEF 36.1 and MEF 39.
+ *
+ * In this model Loss Measurements entries are returned as a collection in the
+ * MepEntry. In this way Loss Measurements are created by calling on the
+ * Create Loss Measurement function, passing in any arguments needed to
+ * configure it. The Loss Measurement is a result and not configured or
+ * persisted in ONOS, but instead is is passed on to some analytics system.
+ */
+public interface LossMeasurementEntry extends LossMeasurementCreate {
+ /**
+ * Ian id that uniquely identifies a scheduled measurement.
+ * It is automatically generated by the server on creation of a new measurement
+ * @return An LM id
+ */
+ SoamId lmId();
+
+ /**
+ * Contains the Frame Loss Ratio in the forward direction calculated by this MEP.
+ * from the last received SOAM PDU.
+ * The FLR value is a ratio that is expressed as a percent with a value of
+ * 0 (ratio 0.00) through 100000 (ratio 1.00).
+ * @return Units are in milli-percent, where 1 indicates 0.001 per-cent
+ */
+ MilliPct measuredForwardFlr();
+
+ /**
+ * Contains the Frame Loss Ratio in the backward direction calculated by this MEP.
+ * from the last received SOAM PDU.
+ * The FLR value is a ratio that is expressed as a percent with a value of
+ * 0 (ratio 0.00) through 100000 (ratio 1.00).
+ * @return Units are in milli-percent, where 1 indicates 0.001 per-cent
+ */
+ MilliPct measuredBackwardFlr();
+
+ /**
+ * The availability status (the outcome of the last availability indicator) in the forward direction.
+ * based upon the last received SOAM PDU
+ * @return enumerated availability value
+ */
+ AvailabilityType measuredAvailabilityForwardStatus();
+
+ /**
+ * The availability status (the outcome of the last availability indicator) in the backward direction.
+ * based upon the last received SOAM PDU
+ * @return enumerated availability value
+ */
+ AvailabilityType measuredAvailabilityBackwardStatus();
+
+ /**
+ * The time of the last transition between available and unavailable in the forward direction.
+ * If there have been no transitions since the Loss Measurement Session was
+ * started, this is set to 0
+ * @return The transition time
+ */
+ Instant measuredForwardLastTransitionTime();
+
+ /**
+ * The time of the last transition between available and unavailable in the backward direction.
+ * If there have been no transitions since the Loss Measurement Session was
+ * started, this is set to 0
+ * @return The transition time
+ */
+ Instant measuredBackwardLastTransitionTime();
+
+ /**
+ * The results for the current Measurement Interval in a SOAM Loss Measurement session.
+ * gathered during the interval indicated by measurement-interval
+ * @return An object with current measurements
+ */
+ LossMeasurementStatCurrent measurementCurrent();
+
+ /**
+ * The results for history Measurement Intervals in a SOAM Loss Measurement session.
+ * @return An object with historic measurements
+ */
+ Collection<LossMeasurementStatHistory> measurementHistories();
+
+ /**
+ * The current results for a SOAM Loss Measurement session for availability statistics.
+ * gathered during the interval indicated by availability-measurement-interval
+ * @return An object with current availability
+ */
+ LossAvailabilityStatCurrent availabilityCurrent();
+
+ /**
+ * The results for availability history Measurement Intervals in a SOAM Loss Measurement session.
+ * @return An object with historic availability
+ */
+ Collection<LossAvailabilityStatHistory> availabilityHistories();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementEntry}.
+ */
+ public interface LmEntryBuilder extends LmCreateBuilder {
+ LmEntryBuilder measuredForwardFlr(MilliPct measuredForwardFlr);
+
+ LmEntryBuilder measuredBackwardFlr(MilliPct measuredBackwardFlr);
+
+ LmEntryBuilder measuredAvailabilityForwardStatus(
+ AvailabilityType measuredAvailabilityForwardStatus);
+
+ LmEntryBuilder measuredAvailabilityBackwardStatus(
+ AvailabilityType measuredAvailabilityBackwardStatus);
+
+ LmEntryBuilder measuredForwardLastTransitionTime(
+ Instant measuredForwardLastTransitionTime);
+
+ LmEntryBuilder measuredBackwardLastTransitionTime(
+ Instant measuredBackwardLastTransitionTime);
+
+ LmEntryBuilder measurementCurrent(
+ LossMeasurementStatCurrent measurementCurrent);
+
+ LmEntryBuilder addToMeasurementHistories(
+ LossMeasurementStatHistory history);
+
+ LmEntryBuilder availabilityCurrent(
+ LossAvailabilityStatCurrent availabilityCurrent);
+
+ LmEntryBuilder addToAvailabilityHistories(LossAvailabilityStatHistory history);
+
+ LossMeasurementEntry build();
+ }
+
+ /**
+ * Options for Availability test types.
+ */
+ public enum AvailabilityType {
+ AVAILABLE,
+ UNAVAILABLE,
+ UNKNOWN;
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStat.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStat.java
new file mode 100644
index 0000000..f61aab5
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStat.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Duration;
+
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+
+/**
+ * Abstract base interface for the creation of Loss Measurement Stat.
+ * This is the base for {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatHistory}
+ * and {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatCurrent}
+ */
+public interface LossMeasurementStat {
+ /**
+ * The time that the current Measurement Interval has been running.
+ * @return A java Duration
+ */
+ Duration elapsedTime();
+
+ /**
+ * The suspect flag for the current measurement interval in which the notification was generated.
+ * reference MEF-SOAM-PM-MIB.mefSoamPmNotificationObjSuspect";
+ * @return true if the measurement might include an error
+ */
+ boolean suspectStatus();
+
+ /**
+ * The number of frames transmitted in the forward direction by this MEP.
+ * For a PM Session of types lmm or ccm this includes Ethernet Service Frames
+ * and SOAM PDUs that are in a higher MEG level only.
+ * For a PM Session of type slm this includes the count of SOAM ETH-SLM frames only
+ * @return The number of frames
+ */
+ Long forwardTransmittedFrames();
+
+ /**
+ * The number of frames received in the forward direction by this MEP.
+ * For a PM Session of types lmm or ccm this includes Ethernet
+ * Service Frames and SOAM PDUs that are in a higher MEG level only.
+ * For a PM Session of type slm this includes the count of SOAM ETH-SLM frames only
+ * @return The number of frames received
+ */
+ Long forwardReceivedFrames();
+
+ /**
+ * The minimum one-way frame loss ratio in the forward direction calculated by this MEP for this Interval.
+ * The FLR value is a ratio that is expressed as a percent with a value of
+ * 0 (ratio 0.00) through 100000 (ratio 1.00).
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct forwardMinFrameLossRatio();
+
+ /**
+ * The maximum one-way frame loss ratio in the forward direction calculated by this MEP for this Interval.
+ * The FLR value is a ratio that is expressed as a percent with a value of
+ * 0 (ratio 0.00) through 100000 (ratio 1.00).
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct forwardMaxFrameLossRatio();
+
+ /**
+ * The average one-way frame loss ratio in the forward direction calculated by this MEP for this Interval.
+ * The FLR value is a ratio that is expressed as a percent with a value of
+ * 0 (ratio 0.00) through 100000 (ratio 1.00).
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct forwardAverageFrameLossRatio();
+
+ /**
+ * The number of frames transmitted in the backward direction by this MEP.
+ * For a PM Session of type lmm or ccm this includes Ethernet Service Frames
+ * and SOAM PDUs that are in a higher MEG level only.
+ * For a PM Session of type slm this includes the count of SOAM ETH-SLM frames only
+ * @return The number of frames
+ */
+ Long backwardTransmittedFrames();
+
+ /**
+ * The number of frames received in the backward direction by this MEP.
+ * For a PM Session of type lmm this includes Ethernet Service Frames and
+ * SOAM PDUs that are in a higher MEG level only.
+ * For a PM Session of type slm this includes the count of SOAM ETH-SLM frames only
+ * @return The number of frames
+ */
+ Long backwardReceivedFrames();
+
+ /**
+ * The minimum one-way frame loss ratio in the backward direction.
+ * calculated by this MEP for this Measurement Interval. The FLR value is a
+ * ratio that is expressed as a percent with a value of 0 (ratio 0.00)
+ * through 100000 (ratio 1.00).
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct backwardMinFrameLossRatio();
+
+ /**
+ * The maximum one-way frame loss ratio in the backward direction.
+ * calculated by this MEP for this Measurement Interval. The FLR value is a
+ * ratio that is expressed as a percent with a value of 0 (ratio 0.00)
+ * through 100000 (ratio 1.00).
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct backwardMaxFrameLossRatio();
+
+ /**
+ * The average one-way frame loss ratio in the backward direction.
+ * calculated by this MEP for this Measurement Interval. The FLR value is a
+ * ratio that is expressed as a percent with a value of 0 (ratio 0.00)
+ * through 100000 (ratio 1.00).
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct backwardAverageFrameLossRatio();
+
+ /**
+ * The count of the number of SOAM PDUs sent during this Measurement Interval.
+ * This object applies when type is lmm, slm or ccm. It indicates the number
+ * of LMM, CCM, or SLM SOAM frames transmitted
+ * @return the number of SOAM PDUs sent
+ */
+ Long soamPdusSent();
+
+ /**
+ * The count of the number of SOAM PDUs PDUs received in this Measurement Interval.
+ * This object applies when type is lmm, slm, or ccm. This object indicates
+ * the number of LMR, CCM, or SLR SOAM frames received
+ * @return the number of SOAM PDUs PDUs received
+ */
+ Long soamPdusReceived();
+
+ /**
+ * Base interface for builders of {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStat}.
+ */
+ interface LmStatBuilder {
+ LmStatBuilder forwardTransmittedFrames(Long forwardTransmittedFrames);
+
+ LmStatBuilder forwardReceivedFrames(Long forwardReceivedFrames);
+
+ LmStatBuilder forwardMinFrameLossRatio(MilliPct forwardMinFrameLossRatio);
+
+ LmStatBuilder forwardMaxFrameLossRatio(MilliPct forwardMaxFrameLossRatio);
+
+ LmStatBuilder forwardAverageFrameLossRatio(MilliPct forwardAverageFrameLossRatio);
+
+ LmStatBuilder backwardTransmittedFrames(Long backwardTransmittedFrames);
+
+ LmStatBuilder backwardReceivedFrames(Long backwardReceivedFrames);
+
+ LmStatBuilder backwardMinFrameLossRatio(MilliPct backwardMinFrameLossRatio);
+
+ LmStatBuilder backwardMaxFrameLossRatio(MilliPct backwardMaxFrameLossRatio);
+
+ LmStatBuilder backwardAverageFrameLossRatio(MilliPct backwardAverageFrameLossRatio);
+
+ LmStatBuilder soamPdusSent(Long soamPdusSent);
+
+ LmStatBuilder soamPdusReceived(Long soamPdusReceived);
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatCurrent.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatCurrent.java
new file mode 100644
index 0000000..c5b2423
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatCurrent.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Instant;
+
+/**
+ * Object for representing Loss Availability Stats Current.
+ * Extends {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStat}
+ */
+public interface LossMeasurementStatCurrent extends LossMeasurementStat {
+ /**
+ * The time that the current Measurement Interval started.
+ * @return The start time as a java Instant
+ */
+ Instant startTime();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatCurrent}.
+ */
+ public interface LmStatCurrentBuilder extends LmStatBuilder {
+ LossMeasurementStatCurrent build();
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatHistory.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatHistory.java
new file mode 100644
index 0000000..90c7a5f
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatHistory.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.time.Instant;
+
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * Object for representing Loss Measurement Stats History.
+ * Extends {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStat}
+ */
+public interface LossMeasurementStatHistory extends LossMeasurementStat {
+ /**
+ * The identifier of the historic measurement.
+ * @return The id
+ */
+ SoamId historyStatsId();
+
+ /**
+ * The time that the historic Measurement Interval ended.
+ * @return A java Instant
+ */
+ Instant endTime();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatHistory}.
+ */
+ public interface LmStatHistoryBuilder extends LmStatBuilder {
+ LossMeasurementStatHistory build();
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementThreshold.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementThreshold.java
new file mode 100644
index 0000000..1624204
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementThreshold.java
@@ -0,0 +1,209 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import java.util.Collection;
+
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+/**
+ * Object to support the setting of Loss Measurement Thresholds.
+ *
+ * The main purpose of the threshold configuration is to configure threshold
+ * alarm notifications indicating that a specific performance metric is not being met
+ */
+public interface LossMeasurementThreshold {
+ /**
+ * The index of the threshold number for the specific LM threshold entry.
+ * An index value of '1' needs to be supported. Other index values can also be supported
+ * @return The threshold Id
+ */
+ SoamId thresholdId();
+
+ /**
+ * A vector of bits that indicates the type of SOAM LM thresholds notifications that are enabled.
+ * A present but enables the specific SOAM LM threshold notification and
+ * when the specific counter is enabled and the threshold is crossed a
+ * notification is generated.
+ * A not present bit disables the specific SOAM LM threshold notification.
+ * If a particular SOAM LM threshold is not supported the BIT value is not present
+ * @return A collection of bit options
+ */
+ Collection<ThresholdOption> thresholds();
+
+ /**
+ * The measured forward frame loss ratio threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct measuredFlrForward();
+
+ /**
+ * The maximum forward frame loss ratio threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct maxFlrForward();
+
+ /**
+ * The average forward frame loss ratio threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct averageFlrForward();
+
+ /**
+ * The measured backward frame loss ratio threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct measuredFlrBackward();
+
+ /**
+ * The maximum backward frame loss ratio threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct maxFlrBackward();
+
+ /**
+ * The average backward frame loss ratio threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct averageFlrBackward();
+
+ /**
+ * The forward high loss threshold value.
+ * that will be used to determine if a threshold notification is generated.
+ * @return The threshold value
+ */
+ Long forwardHighLoss();
+
+ /**
+ * The consecutive forward high loss threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return The threshold value
+ */
+ Long forwardConsecutiveHighLoss();
+
+ /**
+ * The backward high loss threshold value.
+ * that will be used to determine if a threshold notification is generated.
+ * @return The threshold value
+ */
+ Long backwardHighLoss();
+
+ /**
+ * The consecutive backward high loss threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return The threshold value
+ */
+ Long backwardConsecutiveHighLoss();
+
+ /**
+ * The forward unavailability threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return The threshold value
+ */
+ Long forwardUnavailableCount();
+
+ /**
+ * The forward availability/total time ratio threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * if the ratio drops below the configured value.
+ * The ratio value is expressed as a percent with a value of 0 (ratio 0.00)
+ * through 100000 (ratio 1.00)
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct forwardAvailableRatio();
+
+ /**
+ * The backward unavailability threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * @return The threshold value
+ */
+ Long backwardUnavailableCount();
+
+ /**
+ * The backward availability/total time ratio threshold value.
+ * that will be used to determine if a threshold notification is generated
+ * if the ratio drops below the configured value.
+ * The ratio value is expressed as a percent with a value of 0 (ratio 0.00)
+ * through 100000 (ratio 1.00)
+ * @return Units are in milli-percent, where 1 indicates 0.001 percent
+ */
+ MilliPct backwardAvailableRatio();
+
+ /**
+ * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementThreshold}.
+ */
+ public interface LmThresholdBuilder {
+
+ LmThresholdBuilder addToThreshold(ThresholdOption threshold);
+
+ LmThresholdBuilder measuredFlrForward(MilliPct measuredFlrForward);
+
+ LmThresholdBuilder maxFlrForward(MilliPct maxFlrForward);
+
+ LmThresholdBuilder averageFlrForward(MilliPct averageFlrForward);
+
+ LmThresholdBuilder measuredFlrBackward(MilliPct measuredFlrBackward);
+
+ LmThresholdBuilder maxFlrBackward(MilliPct maxFlrBackward);
+
+ LmThresholdBuilder averageFlrBackward(MilliPct averageFlrBackward);
+
+ LmThresholdBuilder forwardHighLoss(Long forwardHighLoss);
+
+ LmThresholdBuilder forwardConsecutiveHighLoss(Long forwardConsecutiveHighLoss);
+
+ LmThresholdBuilder backwardHighLoss(Long backwardHighLoss);
+
+ LmThresholdBuilder backwardConsecutiveHighLoss(Long backwardConsecutiveHighLoss);
+
+ LmThresholdBuilder forwardUnavailableCount(Long forwardUnavailableCount);
+
+ LmThresholdBuilder forwardAvailableRatio(MilliPct forwardAvailableRatio);
+
+ LmThresholdBuilder backwardUnavailableCount(Long backwardUnavailableCount);
+
+ LmThresholdBuilder backwardAvailableRatio(MilliPct backwardAvailableRatio);
+
+ LossMeasurementThreshold build();
+ }
+
+ /**
+ * Set of enumerated threshold options.
+ */
+ public enum ThresholdOption {
+ MEASURED_FLR_FORWARD,
+ MAX_FLR_FORWARD,
+ AVERAGE_FLR_FORWARD,
+ MEASURED_FLR_BACKWARD,
+ MAX_FLR_BACKWARD,
+ AVERAGE_FLR_BACKWARD,
+ FORWARD_HIGH_LOSS,
+ FORWARD_CONSECUTIVE_HIGH_LOSS,
+ BACKWARD_HIGH_LOSS,
+ BACKWARD_CONSECUTIVE_HIGH_LOSS,
+ FORWARD_UNAVAILABLE_COUNT,
+ FORWARD_AVAILABLE_RATIO,
+ BACKWARD_UNAVAILABLE_COUNT,
+ BACKWARD_AVAILABLE_RATIO;
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/package-info.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/package-info.java
new file mode 100644
index 0000000..909113a
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/loss/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of Service Operation and Maintenance related to Frame loss measurement.
+ *
+ * From ITU Y.1731 (ETH-DM) and MEF 17 Frame Delay Performance and Frame Delay Variation Performance
+ * MEF 36.1 Service OAM SNMP MIB for Performance Monitoring, MEF 39 Service OAM Performance Monitoring YANG Module
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
\ No newline at end of file
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/package-info.java b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/package-info.java
new file mode 100644
index 0000000..a718c8b
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/l2monitoring/soam/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of MEF Service Operation and Maintenance.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
\ No newline at end of file