aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/OduSignalId.java139
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java1
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java22
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java82
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java81
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OpticalSignalTypeCriterion.java83
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java6
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java13
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java88
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java5
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/host/PortAddresses.java127
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java85
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java89
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java1
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java14
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java30
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java1
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/OduSignalIdTest.java39
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java91
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java41
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/host/PortAddressesTest.java113
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java8
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java25
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java3
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java4
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java6
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java104
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java2
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java43
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java225
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java2
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java9
35 files changed, 725 insertions, 865 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/OduSignalId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/OduSignalId.java
new file mode 100644
index 00000000..e19a673d
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/OduSignalId.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.net;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+import org.onlab.util.HexString;
+
+import com.google.common.base.MoreObjects;
+/**
+ * Implementation of ODU Signal ID.
+ *
+ * <p>
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)".
+ * </p>
+ */
+public class OduSignalId {
+
+ private final int tributaryPortNumber; // Tributary Port number
+ private final int tributarySlotLength; // Number of Tributary Slots included in tsmap
+ private final byte[] tributarySlotBitmap; // Tributary slot bitmap
+
+ public static final int TRIBUTARY_SLOT_BITMAP_SIZE = 10;
+
+ /**
+ * Creates an instance with the specified arguments.
+ *
+ * @param tributaryPortNumber tributary port number
+ * @param tributarySlotLen tributary slot len
+ * @param tributarySlotBitmap tributary slot bitmap
+ */
+ public OduSignalId(int tributaryPortNumber, int tributarySlotLen,
+ byte[] tributarySlotBitmap) {
+
+ checkArgument(tributaryPortNumber <= 80 ,
+ "tributaryPortNumber %s must be <= 80 ",
+ tributaryPortNumber);
+
+ checkArgument(tributarySlotBitmap.length == TRIBUTARY_SLOT_BITMAP_SIZE,
+ "number of elements in list " + HexString.toHexString(tributarySlotBitmap)
+ + " must be equal to " + TRIBUTARY_SLOT_BITMAP_SIZE);
+
+ checkArgument(tributarySlotLen <= 80 ,
+ "tributarySlotLen %s must be <= 80 ",
+ tributarySlotLen);
+
+ this.tributaryPortNumber = tributaryPortNumber;
+ this.tributarySlotLength = tributarySlotLen;
+ this.tributarySlotBitmap = Arrays.copyOf(tributarySlotBitmap, tributarySlotBitmap.length);
+ }
+
+ /**
+ * Returns the OduSignalId representing the specified parameters.
+ *
+ * @param tributaryPortNumber tributary port number
+ * @param tributarySlotLen tributary slot len
+ * @param tributarySlotBitmap tributary slot bitmap
+ * @return OduSignalId
+ */
+ public static OduSignalId oduSignalId(int tributaryPortNumber, int tributarySlotLen,
+ byte[] tributarySlotBitmap) {
+ return new OduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap);
+ }
+
+
+ /**
+ * Returns tributary port number.
+ *
+ * @return the tributaryPortNumber
+ */
+ public int tributaryPortNumber() {
+ return tributaryPortNumber;
+ }
+
+ /**
+ * Returns tributary slot length.
+ *
+ * @return the tributarySlotLen
+ */
+ public int tributarySlotLength() {
+ return tributarySlotLength;
+ }
+
+ /**
+ * Returns tributary slot bitmap.
+ *
+ * @return the tributarySlotBitmap
+ */
+ public byte[] tributarySlotBitmap() {
+ return Arrays.copyOf(tributarySlotBitmap, tributarySlotBitmap.length);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tributaryPortNumber, tributarySlotLength, Arrays.hashCode(tributarySlotBitmap));
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof OduSignalId)) {
+ return false;
+ }
+ final OduSignalId other = (OduSignalId) obj;
+ return Objects.equals(this.tributaryPortNumber, other.tributaryPortNumber)
+ && Objects.equals(this.tributarySlotLength, other.tributarySlotLength)
+ && Arrays.equals(tributarySlotBitmap, other.tributarySlotBitmap);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .omitNullValues()
+ .add("tributaryPortNumber", tributaryPortNumber)
+ .add("tributarySlotLength", tributarySlotLength)
+ .add("tributarySlotBitmap", HexString.toHexString(tributarySlotBitmap))
+ .toString();
+ }
+
+}
+
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java
index ded3b3ae..0e509562 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java
@@ -34,6 +34,7 @@ public class ControllerInfo {
*
* @param ip the ip address
* @param port the tcp port
+ * @param type the connection type
*/
public ControllerInfo(IpAddress ip, int port, String type) {
this.ip = ip;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java
index a93dc071..965fd1f8 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java
@@ -54,6 +54,8 @@ public interface TypedStoredFlowEntry extends StoredFlowEntry {
/**
* Gets the flow live type for this entry.
+ *
+ * @return flow live type
*/
FlowLiveType flowLiveType();
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
index 7e1d43a5..ae940bdc 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
@@ -25,6 +25,8 @@ import org.onlab.packet.VlanId;
import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Lambda;
import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalId;
+import org.onosproject.net.OduSignalType;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.criteria.Criterion.Type;
import org.onosproject.net.OchSignalType;
@@ -486,6 +488,26 @@ public final class Criteria {
return new OchSignalTypeCriterion(signalType);
}
+ /**
+ * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value.
+ *
+ * @param oduSignalId ODU Signal Id
+ * @return match criterion
+ */
+ public static Criterion matchOduSignalId(OduSignalId oduSignalId) {
+ return new OduSignalIdCriterion(oduSignalId);
+ }
+
+ /**
+ * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value.
+ *
+ * @param signalType ODU Signal Type
+ * @return match criterion
+ */
+ public static Criterion matchOduSignalType(OduSignalType signalType) {
+ return new OduSignalTypeCriterion(signalType);
+ }
+
public static Criterion dummy() {
return new DummyCriterion();
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java
index 12ab57de..10cb629f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java
@@ -125,6 +125,10 @@ public interface Criterion {
OCH_SIGID,
/** Optical channel signal type (fixed or flexible). */
OCH_SIGTYPE,
+ /** ODU (Optical channel Data Unit) signal ID. */
+ ODU_SIGID,
+ /** ODU (Optical channel Data Unit) signal type. */
+ ODU_SIGTYPE,
/**
* An empty criterion.
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java
new file mode 100644
index 00000000..cb513397
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.net.flow.criteria;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.net.OduSignalId;
+
+/**
+ * Implementation of ODU (Optical channel Data Unit) signal ID signal criterion.
+ * This criterion is based on the specification of "OFPXMT_EXP_ODU_SIGID" in
+ * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but
+ * defined in protocol agnostic way.
+ */
+public final class OduSignalIdCriterion implements Criterion {
+
+ private final OduSignalId oduSignalId;
+
+ /**
+ * Create an instance with the specified ODU signal ID.
+ *
+ * @param oduSignalId - ODU signal ID
+ */
+ OduSignalIdCriterion(OduSignalId oduSignalId) {
+ this.oduSignalId = checkNotNull(oduSignalId);
+ }
+
+ @Override
+ public Type type() {
+ return Type.ODU_SIGID;
+ }
+
+ /**
+ * Returns the ODU Signal to match.
+ *
+ * @return the ODU signal to match
+ */
+ public OduSignalId oduSignalId() {
+ return oduSignalId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type(), oduSignalId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof OduSignalIdCriterion)) {
+ return false;
+ }
+ final OduSignalIdCriterion that = (OduSignalIdCriterion) obj;
+ return Objects.equals(this.oduSignalId, that.oduSignalId);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("oduSignalId", oduSignalId)
+ .toString();
+ }
+
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java
new file mode 100644
index 00000000..d92880db
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.net.flow.criteria;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.net.OduSignalType;
+
+/**
+ * Implementation of ODU (Optical channel Data Unit) signal Type criterion.
+ * This criterion is based on the specification of "OFPXMT_EXP_ODU_SIGTYPE" in
+ * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but
+ * defined in protocol agnostic way.
+ */
+public final class OduSignalTypeCriterion implements Criterion {
+
+ private final OduSignalType signalType;
+
+ /**
+ * Create an instance with the specified ODU signal Type.
+ *
+ * @param signalType - ODU signal Type
+ */
+ OduSignalTypeCriterion(OduSignalType signalType) {
+ this.signalType = checkNotNull(signalType);
+ }
+
+ @Override
+ public Type type() {
+ return Type.ODU_SIGTYPE;
+ }
+
+ /**
+ * Returns the ODU Signal Type to match.
+ *
+ * @return the ODU signal Type to match
+ */
+ public OduSignalType signalType() {
+ return signalType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type(), signalType);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof OduSignalTypeCriterion)) {
+ return false;
+ }
+ final OduSignalTypeCriterion that = (OduSignalTypeCriterion) obj;
+ return Objects.equals(this.signalType, that.signalType);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("signalType", signalType)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OpticalSignalTypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OpticalSignalTypeCriterion.java
deleted file mode 100644
index b712675b..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OpticalSignalTypeCriterion.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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.net.flow.criteria;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Implementation of optical signal type criterion (8 bits unsigned
- * integer).
- *
- * @deprecated in Cardinal Release
- */
-@Deprecated
-public final class OpticalSignalTypeCriterion implements Criterion {
- private static final short MASK = 0xff;
- private final short signalType; // Signal type value: 8 bits
- private final Type type;
-
- /**
- * Constructor.
- *
- * @param signalType the optical signal type to match (8 bits unsigned
- * integer)
- * @param type the match type. Should be Type.OCH_SIGTYPE
- */
- OpticalSignalTypeCriterion(short signalType, Type type) {
- this.signalType = (short) (signalType & MASK);
- this.type = type;
- }
-
- @Override
- public Type type() {
- return this.type;
- }
-
- /**
- * Gets the optical signal type to match.
- *
- * @return the optical signal type to match (8 bits unsigned integer)
- */
- public short signalType() {
- return signalType;
- }
-
- @Override
- public String toString() {
- return toStringHelper(type().toString())
- .add("signalType", signalType).toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type().ordinal(), signalType);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof OpticalSignalTypeCriterion) {
- OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj;
- return Objects.equals(signalType, that.signalType) &&
- Objects.equals(type, that.type);
- }
- return false;
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java
index d01ea298..eddbbb71 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java
@@ -59,6 +59,11 @@ public interface Instruction {
L0MODIFICATION,
/**
+ * Signifies that the traffic should be modified in L1 way.
+ */
+ L1MODIFICATION,
+
+ /**
* Signifies that the traffic should be modified in L2 way.
*/
L2MODIFICATION,
@@ -86,6 +91,7 @@ public interface Instruction {
/**
* Returns the type of instruction.
+ *
* @return type of instruction
*/
Type type();
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
index c9f10685..26981e5e 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
@@ -25,10 +25,12 @@ import org.onosproject.core.GroupId;
import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Lambda;
import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType;
import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
+import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
@@ -47,7 +49,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public final class Instructions {
-
// Ban construction
private Instructions() {}
@@ -117,6 +118,16 @@ public final class Instructions {
}
/**
+ * Creates an L1 modification with the specified ODU signal Id.
+ *
+ * @param oduSignalId ODU Signal Id
+ * @return a L1 modification
+ */
+ public static L1ModificationInstruction modL1OduSignalId(OduSignalId oduSignalId) {
+ checkNotNull(oduSignalId, "L1 ODU signal ID cannot be null");
+ return new ModOduSignalIdInstruction(oduSignalId);
+ }
+ /**
* Creates a l2 src modification.
*
* @param addr the mac address to modify to
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java
new file mode 100644
index 00000000..c6847d1c
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.net.flow.instructions;
+
+import org.onosproject.net.OduSignalId;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+public abstract class L1ModificationInstruction implements Instruction {
+
+ /**
+ * Represents the type of traffic treatment.
+ */
+ public enum L1SubType {
+ /**
+ * ODU (Optical channel Data Unit) Signal Id modification.
+ */
+ ODU_SIGID
+ }
+
+ public abstract L1SubType subtype();
+
+ @Override
+ public final Type type() {
+ return Type.L1MODIFICATION;
+ }
+
+ /**
+ * Represents an L1 ODU (Optical channel Data Unit) Signal Id modification instruction.
+ */
+ public static final class ModOduSignalIdInstruction extends L1ModificationInstruction {
+
+ private final OduSignalId oduSignalId;
+
+ ModOduSignalIdInstruction(OduSignalId oduSignalId) {
+ this.oduSignalId = oduSignalId;
+ }
+
+ @Override
+ public L1SubType subtype() {
+ return L1SubType.ODU_SIGID;
+ }
+
+ public OduSignalId oduSignalId() {
+ return oduSignalId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(oduSignalId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof ModOduSignalIdInstruction)) {
+ return false;
+ }
+ final ModOduSignalIdInstruction that = (ModOduSignalIdInstruction) obj;
+ return Objects.equals(this.oduSignalId, that.oduSignalId);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("oduSignalId", oduSignalId)
+ .toString();
+ }
+ }
+
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java
index 068663bd..3403486c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java
@@ -55,9 +55,10 @@ public interface HostProviderService extends ProviderService<HostProvider> {
void hostVanished(HostId hostId);
/**
- * Notifies the core when a host is no longer detected on a network.
+ * Notifies the core when an IP is no longer associated with a host.
*
- * @param hostId id of the host that vanished
+ * @param hostId id of the host
+ * @param ipAddress ip address of host that vanished
*/
void removeIpFromHost(HostId hostId, IpAddress ipAddress);
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/PortAddresses.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/PortAddresses.java
deleted file mode 100644
index 74f22ae9..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/PortAddresses.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * 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.net.host;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Represents address information bound to a port.
- */
-public final class PortAddresses {
-
- private final ConnectPoint connectPoint;
- private final Set<InterfaceIpAddress> ipAddresses;
- private final MacAddress macAddress;
- private final VlanId vlan;
-
- /**
- * Constructs a PortAddresses object for the given connection point, with a
- * set of IP addresses and a MAC address. Both address parameters are
- * optional and can be set to null.
- *
- * @param connectPoint the connection point these addresses are for
- * @param ipAddresses a set of interface IP addresses
- * @param mac a MAC address
- * @param vlan a VLAN ID
- */
- public PortAddresses(ConnectPoint connectPoint,
- Set<InterfaceIpAddress> ipAddresses, MacAddress mac, VlanId vlan) {
- this.connectPoint = connectPoint;
- this.ipAddresses = (ipAddresses == null) ?
- Collections.<InterfaceIpAddress>emptySet()
- : new HashSet<>(ipAddresses);
- this.macAddress = mac;
- this.vlan = vlan;
- }
-
- /**
- * Returns the connection point this address information is bound to.
- *
- * @return the connection point
- */
- public ConnectPoint connectPoint() {
- return connectPoint;
- }
-
- /**
- * Returns the set of interface IP addresses.
- *
- * @return the interface IP addresses
- */
- public Set<InterfaceIpAddress> ipAddresses() {
- return ipAddresses;
- }
-
- /**
- * Returns the MAC address.
- *
- * @return the MAC address
- */
- public MacAddress mac() {
- return macAddress;
- }
-
- /**
- * Returns the VLAN ID.
- *
- * @return the VLAN ID
- */
- public VlanId vlan() {
- return vlan;
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof PortAddresses)) {
- return false;
- }
-
- PortAddresses otherPa = (PortAddresses) other;
-
- return Objects.equals(this.connectPoint, otherPa.connectPoint)
- && Objects.equals(this.ipAddresses, otherPa.ipAddresses)
- && Objects.equals(this.macAddress, otherPa.macAddress)
- && Objects.equals(this.vlan, otherPa.vlan);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(connectPoint, ipAddresses, macAddress, vlan);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("connect-point", connectPoint)
- .add("ip-addresses", ipAddresses)
- .add("mac-address", macAddress)
- .add("vlan", vlan)
- .toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
deleted file mode 100644
index 5468dfb7..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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.net.resource.device;
-
-import com.google.common.annotations.Beta;
-import org.onosproject.net.Port;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentId;
-
-import java.util.Set;
-
-/**
- * Service for providing device resources.
- */
-@Beta
-public interface DeviceResourceService {
- /**
- * Request a set of ports needed to satisfy the intent.
- *
- * @param ports set of ports to allocate
- * @param intent the intent
- * @return true if ports were successfully allocated, false otherwise
- */
- boolean requestPorts(Set<Port> ports, Intent intent);
-
- /**
- * Returns the set of ports allocated for an intent.
- *
- * @param intentId the intent ID
- * @return set of allocated ports
- */
- Set<Port> getAllocations(IntentId intentId);
-
- /**
- * Returns the intent allocated to a port.
- *
- * @param port the port
- * @return intent ID allocated to the port
- */
- IntentId getAllocations(Port port);
-
- /**
- * Request a mapping between the given intents.
- *
- * @param keyIntentId the key intent ID
- * @param valIntentId the value intent ID
- * @return true if mapping was successful, false otherwise
- */
- boolean requestMapping(IntentId keyIntentId, IntentId valIntentId);
-
- /**
- * Returns the intents mapped to a lower intent.
- *
- * @param intentId the intent ID
- * @return the set of intent IDs
- */
- Set<IntentId> getMapping(IntentId intentId);
-
- /**
- * Release mapping of given intent.
- *
- * @param intentId intent ID
- */
- void releaseMapping(IntentId intentId);
-
- /**
- * Release ports associated with given intent ID.
- *
- * @param intentId intent ID
- */
- void releasePorts(IntentId intentId);
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
deleted file mode 100644
index a52a843f..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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.net.resource.device;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.intent.IntentId;
-
-import java.util.Set;
-
-public interface DeviceResourceStore {
- /**
- * Returns unallocated ports on the given device.
- *
- * @param deviceId device ID
- * @return set of unallocated ports
- */
- Set<Port> getFreePorts(DeviceId deviceId);
-
- /**
- * Allocates the given ports to the given intent.
- *
- * @param ports set of ports to allocate
- * @param intentId intent ID
- * @return true if allocation was successful, false otherwise
- */
- boolean allocatePorts(Set<Port> ports, IntentId intentId);
-
- /**
- * Returns set of ports allocated for an intent.
- *
- * @param intentId the intent ID
- * @return set of allocated ports
- */
- Set<Port> getAllocations(IntentId intentId);
-
- /**
- * Returns intent allocated to a port.
- *
- * @param port the port
- * @return intent ID allocated to the port
- */
- IntentId getAllocations(Port port);
-
- /**
- * Allocates the mapping between the given intents.
- *
- * @param keyIntentId key intent ID
- * @param valIntentId value intent ID
- * @return true if mapping was successful, false otherwise
- */
- boolean allocateMapping(IntentId keyIntentId, IntentId valIntentId);
-
- /**
- * Returns the set of intents mapped to a lower intent.
- *
- * @param intentId intent ID
- * @return set of intent IDs
- */
- Set<IntentId> getMapping(IntentId intentId);
-
- /**
- * Releases the mapping of the given intent.
- *
- * @param intentId intent ID
- */
- void releaseMapping(IntentId intentId);
-
- /**
- * Releases the ports allocated to the given intent.
- *
- * @param intentId intent ID
- * @return true if release was successful, false otherwise
- */
- boolean releasePorts(IntentId intentId);
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java
index 67c539df..f17bfb8e 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java
@@ -15,10 +15,12 @@
*/
package org.onosproject.net.resource.device;
+import com.google.common.annotations.Beta;
import org.onosproject.net.intent.IntentId;
import java.util.Set;
+@Beta
public interface IntentSetMultimap {
/**
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java
index f59670bc..5216839e 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java
@@ -94,6 +94,7 @@ public interface FlowStatisticService {
* @param pNumber the port number of the Device to query
* @param liveType the FlowLiveType to filter, null means no filtering .
* @param instType the InstructionType to filter, null means no filtering.
+ * @param topn topn //FIXME what?
* @return list of flow entry load
*/
List<TypedFlowEntryWithLoad> loadTopnByType(Device device, PortNumber pNumber,
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java
index 60da636a..1ec427c0 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java
@@ -94,6 +94,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns connect point.
+ *
+ * @return connect point
*/
public ConnectPoint connectPoint() {
return cp;
@@ -101,6 +103,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns total load of connect point.
+ *
+ * @return total load
*/
public Load totalLoad() {
return totalLoad;
@@ -108,6 +112,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns immediate load of connect point.
+ *
+ * @return immediate load
*/
public Load immediateLoad() {
return immediateLoad;
@@ -115,6 +121,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns short load of connect point.
+ *
+ * @return short load
*/
public Load shortLoad() {
return shortLoad;
@@ -122,6 +130,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns mid load of connect point.
+ *
+ * @return mid load
*/
public Load midLoad() {
return midLoad;
@@ -129,6 +139,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns long load of connect point.
+ *
+ * @return long load
*/
public Load longLoad() {
return longLoad;
@@ -136,6 +148,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns unknown load of connect point.
+ *
+ * @return unknown load
*/
public Load unknownLoad() {
return unknownLoad;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java
index 3e2dbdf8..a4cbd7d0 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java
@@ -36,19 +36,37 @@ public class TypedFlowEntryWithLoad {
private static final int MID_POLL_INTERVAL = 10;
private static final int LONG_POLL_INTERVAL = 15;
-
+ /**
+ * Creates a new typed flow entry with load.
+ *
+ * @param cp connect point
+ * @param tfe typed flow entry
+ * @param load load
+ */
public TypedFlowEntryWithLoad(ConnectPoint cp, TypedStoredFlowEntry tfe, Load load) {
this.cp = cp;
this.tfe = tfe;
this.load = load;
}
+ /**
+ * Creates a new typed flow entry with load.
+ *
+ * @param cp connect point
+ * @param tfe typed flow entry
+ */
public TypedFlowEntryWithLoad(ConnectPoint cp, TypedStoredFlowEntry tfe) {
this.cp = cp;
this.tfe = tfe;
this.load = new DefaultLoad(tfe.bytes(), 0, typedPollInterval(tfe));
}
+ /**
+ * Creates a new typed flow entry with load.
+ *
+ * @param cp connect point
+ * @param fe flow entry
+ */
public TypedFlowEntryWithLoad(ConnectPoint cp, FlowEntry fe) {
this.cp = cp;
this.tfe = newTypedStoredFlowEntry(fe);
@@ -70,6 +88,8 @@ public class TypedFlowEntryWithLoad {
/**
* Returns short polling interval.
+ *
+ * @return short poll interval
*/
public static int shortPollInterval() {
return CAL_AND_POLL_INTERVAL;
@@ -77,6 +97,8 @@ public class TypedFlowEntryWithLoad {
/**
* Returns mid polling interval.
+ *
+ * @return mid poll interval
*/
public static int midPollInterval() {
return MID_POLL_INTERVAL;
@@ -84,6 +106,8 @@ public class TypedFlowEntryWithLoad {
/**
* Returns long polling interval.
+ *
+ * @return long poll interval
*/
public static int longPollInterval() {
return LONG_POLL_INTERVAL;
@@ -91,6 +115,8 @@ public class TypedFlowEntryWithLoad {
/**
* Returns average polling interval.
+ *
+ * @return average poll interval
*/
public static int avgPollInterval() {
return (CAL_AND_POLL_INTERVAL + MID_POLL_INTERVAL + LONG_POLL_INTERVAL) / 3;
@@ -100,6 +126,7 @@ public class TypedFlowEntryWithLoad {
* Returns current typed flow entry's polling interval.
*
* @param tfe typed flow entry
+ * @return typed poll interval
*/
public static long typedPollInterval(TypedStoredFlowEntry tfe) {
checkNotNull(tfe, "TypedStoredFlowEntry cannot be null");
@@ -120,6 +147,7 @@ public class TypedFlowEntryWithLoad {
* Creates a new typed flow entry with the given flow entry fe.
*
* @param fe flow entry
+ * @return new typed flow entry
*/
public static TypedStoredFlowEntry newTypedStoredFlowEntry(FlowEntry fe) {
if (fe == null) {
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java
index c0df7134..cfaf314c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java
@@ -63,6 +63,7 @@ public interface AsyncAtomicCounter {
/**
* Atomically sets the given value to the current value.
*
+ * @param value new value
* @return future void
*/
CompletableFuture<Void> set(long value);
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/OduSignalIdTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/OduSignalIdTest.java
new file mode 100644
index 00000000..2ed15ff9
--- /dev/null
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/OduSignalIdTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.net;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import static org.onosproject.net.OduSignalId.oduSignalId;
+
+/**
+ * Test for OduSignalId.
+ */
+public class OduSignalIdTest {
+
+ private final OduSignalId odu1 = oduSignalId(7, 80, new byte[] {16, 16, 16, 16, 16, 16, 16, 16, 16, 16});
+ private final OduSignalId sameOdu1 = oduSignalId(7, 80, new byte[] {16, 16, 16, 16, 16, 16, 16, 16, 16, 16});
+ private final OduSignalId odu2 = oduSignalId(21, 80, new byte[] {10, 5, 10, 5, 10, 5, 10, 5, 10, 5});
+ private final OduSignalId sameOdu2 = oduSignalId(21, 80, new byte[] {10, 5, 10, 5, 10, 5, 10, 5, 10, 5});
+
+ @Test
+ public void testEquality() {
+ new EqualsTester()
+ .addEqualityGroup(odu1, sameOdu1)
+ .addEqualityGroup(odu2, sameOdu2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
index 95d605c6..d86744df 100644
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
@@ -15,6 +15,16 @@
*/
package org.onosproject.net.flow.criteria;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility;
+import static org.onosproject.net.OduSignalId.oduSignalId;
+import static org.onosproject.net.PortNumber.portNumber;
+
import org.junit.Test;
import org.onlab.packet.EthType;
import org.onlab.packet.Ip6Address;
@@ -26,20 +36,12 @@ import org.onlab.packet.VlanId;
import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.GridType;
import org.onosproject.net.Lambda;
+import org.onosproject.net.OchSignalType;
+import org.onosproject.net.OduSignalId;
+import org.onosproject.net.OduSignalType;
import org.onosproject.net.PortNumber;
import com.google.common.testing.EqualsTester;
-import org.onosproject.net.OchSignalType;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility;
-import static org.onosproject.net.PortNumber.portNumber;
-
/**
* Unit tests for the Criteria class and its subclasses.
*/
@@ -240,6 +242,18 @@ public class CriteriaTest {
Criterion matchOchSignal2 =
Criteria.matchLambda(Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 4, 8));
+ final OduSignalId odu1 = oduSignalId(1, 80, new byte [] {1, 1, 2, 2, 1, 2, 2, 1, 2, 2});
+ final OduSignalId odu2 = oduSignalId(3, 8, new byte [] {1, 0, 0, 0, 0, 0, 0, 0, 0, 0});
+ Criterion matchOduSignalId1 = Criteria.matchOduSignalId(odu1);
+ Criterion sameAsMatchOduSignalId1 = Criteria.matchOduSignalId(odu1);
+ Criterion matchOduSignalId2 = Criteria.matchOduSignalId(odu2);
+
+ final OduSignalType oduSigType1 = OduSignalType.ODU2;
+ final OduSignalType oduSigType2 = OduSignalType.ODU4;
+ Criterion matchOduSignalType1 = Criteria.matchOduSignalType(oduSigType1);
+ Criterion sameAsMatchOduSignalType1 = Criteria.matchOduSignalType(oduSigType1);
+ Criterion matchOduSignalType2 = Criteria.matchOduSignalType(oduSigType2);
+
/**
* Checks that a Criterion object has the proper type, and then converts
* it to the proper type.
@@ -294,6 +308,8 @@ public class CriteriaTest {
assertThatClassIsImmutable(MplsCriterion.class);
assertThatClassIsImmutable(IPv6ExthdrFlagsCriterion.class);
assertThatClassIsImmutable(LambdaCriterion.class);
+ assertThatClassIsImmutable(OduSignalIdCriterion.class);
+ assertThatClassIsImmutable(OduSignalTypeCriterion.class);
}
// PortCriterion class
@@ -1070,4 +1086,57 @@ public class CriteriaTest {
.addEqualityGroup(matchOchSignalType2)
.testEquals();
}
+
+ /**
+ * Test the OduSignalId method.
+ */
+ @Test
+ public void testMatchOduSignalIdMethod() {
+ OduSignalId odu = oduSignalId(1, 80, new byte[]{2, 1, 1, 3, 1, 1, 3, 1, 1, 3});
+
+ Criterion matchoduSignalId = Criteria.matchOduSignalId(odu);
+ OduSignalIdCriterion oduSignalIdCriterion =
+ checkAndConvert(matchoduSignalId,
+ Criterion.Type.ODU_SIGID,
+ OduSignalIdCriterion.class);
+ assertThat(oduSignalIdCriterion.oduSignalId(), is(equalTo(odu)));
+ }
+
+ /**
+ * Test the equals() method of the OduSignalIdCriterion class.
+ */
+ @Test
+ public void testOduSignalIdCriterionEquals() {
+ new EqualsTester()
+ .addEqualityGroup(matchOduSignalId1, sameAsMatchOduSignalId1)
+ .addEqualityGroup(matchOduSignalId2)
+ .testEquals();
+ }
+
+ // OduSignalTypeCriterion class
+
+ /**
+ * Test the OduSignalType method.
+ */
+ @Test
+ public void testMatchOduSignalTypeMethod() {
+ OduSignalType oduSigType = OduSignalType.ODU2;
+ Criterion matchoduSignalType = Criteria.matchOduSignalType(oduSigType);
+ OduSignalTypeCriterion oduSignalTypeCriterion =
+ checkAndConvert(matchoduSignalType,
+ Criterion.Type.ODU_SIGTYPE,
+ OduSignalTypeCriterion.class);
+ assertThat(oduSignalTypeCriterion.signalType(), is(equalTo(oduSigType)));
+ }
+
+ /**
+ * Test the equals() method of the OduSignalTypeCriterion class.
+ */
+ @Test
+ public void testOduSignalTypeCriterionEquals() {
+ new EqualsTester()
+ .addEqualityGroup(matchOduSignalType1, sameAsMatchOduSignalType1)
+ .addEqualityGroup(matchOduSignalType2)
+ .testEquals();
+ }
}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
index 410349b5..a25783f9 100644
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
@@ -25,6 +25,7 @@ import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.GridType;
import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Lambda;
+import org.onosproject.net.OduSignalId;
import org.onosproject.net.PortNumber;
import com.google.common.testing.EqualsTester;
@@ -38,6 +39,7 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility;
import static org.onosproject.net.PortNumber.portNumber;
+import static org.onosproject.net.OduSignalId.oduSignalId;
/**
* Unit tests for the Instructions class.
@@ -96,6 +98,7 @@ public class InstructionsTest {
assertThatClassIsImmutable(Instructions.OutputInstruction.class);
assertThatClassIsImmutable(L0ModificationInstruction.ModLambdaInstruction.class);
assertThatClassIsImmutable(L0ModificationInstruction.ModOchSignalInstruction.class);
+ assertThatClassIsImmutable(L1ModificationInstruction.ModOduSignalIdInstruction.class);
assertThatClassIsImmutable(L2ModificationInstruction.ModEtherInstruction.class);
assertThatClassIsImmutable(L2ModificationInstruction.ModVlanIdInstruction.class);
assertThatClassIsImmutable(L2ModificationInstruction.ModVlanPcpInstruction.class);
@@ -259,6 +262,44 @@ public class InstructionsTest {
assertThat(ochInstruction1.hashCode(), is(not(ochInstruction2.hashCode())));
}
+ // ModOduSignalIdInstruction
+
+ private final OduSignalId odu1 = oduSignalId(1, 80, new byte[] {8, 7, 6, 5, 7, 6, 5, 7, 6, 5});
+ private final OduSignalId odu2 = oduSignalId(2, 80, new byte[] {1, 1, 2, 2, 1, 2, 2, 1, 2, 2});
+ private final Instruction oduInstruction1 = Instructions.modL1OduSignalId(odu1);
+ private final Instruction sameAsOduInstruction1 = Instructions.modL1OduSignalId(odu1);
+ private final Instruction oduInstruction2 = Instructions.modL1OduSignalId(odu2);
+
+ /**
+ * Test the modL1OduSignalId().
+ */
+ @Test
+ public void testModL1OduSignalIdMethod() {
+ Instruction instruction = Instructions.modL1OduSignalId(odu1);
+ L1ModificationInstruction.ModOduSignalIdInstruction oduInstruction =
+ checkAndConvert(instruction, Instruction.Type.L1MODIFICATION,
+ L1ModificationInstruction.ModOduSignalIdInstruction.class);
+ assertThat(oduInstruction.oduSignalId(), is(odu1));
+ }
+
+ /**
+ * Test the equals() method of the ModOduSignalInstruction class.
+ */
+ @Test
+ public void testModOduSignalIdInstructionEquals() {
+ checkEqualsAndToString(oduInstruction1, sameAsOduInstruction1, oduInstruction2);
+ }
+
+ /**
+ * Test the hashCode() method of the ModOduSignalInstruction class.
+ */
+ @Test
+ public void testModOduSignalIdInstructionHashCode() {
+ assertThat(oduInstruction1.hashCode(), is(sameAsOduInstruction1.hashCode()));
+ assertThat(oduInstruction1.hashCode(), is(not(oduInstruction2.hashCode())));
+ }
+
+
// ModEtherInstruction
private static final String MAC1 = "00:00:00:00:00:01";
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/PortAddressesTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/PortAddressesTest.java
deleted file mode 100644
index 7c10cd15..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/PortAddressesTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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.net.host;
-
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.NetTestTools;
-
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.testing.EqualsTester;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit tests for port addresses class.
- */
-public class PortAddressesTest {
-
- PortAddresses addresses1;
- PortAddresses sameAsAddresses1;
- PortAddresses addresses2;
- PortAddresses addresses3;
-
- private static final ConnectPoint CONNECT_POINT1 =
- NetTestTools.connectPoint("cp1", 1);
- private static final IpAddress IP_ADDRESS1 = IpAddress.valueOf("1.2.3.4");
- private static final IpPrefix SUBNET_ADDRESS1 =
- IpPrefix.valueOf("1.2.0.0/16");
- private static final InterfaceIpAddress INTERFACE_ADDRESS_1 =
- new InterfaceIpAddress(IP_ADDRESS1, SUBNET_ADDRESS1);
-
- private static final ConnectPoint CONNECT_POINT2 =
- NetTestTools.connectPoint("cp2", 1);
- private static final IpAddress IP_ADDRESS2 = IpAddress.valueOf("1.2.3.5");
- private static final IpPrefix SUBNET_ADDRESS2 =
- IpPrefix.valueOf("1.3.0.0/16");
- private static final InterfaceIpAddress INTERFACE_ADDRESS_2 =
- new InterfaceIpAddress(IP_ADDRESS2, SUBNET_ADDRESS2);
-
- Set<InterfaceIpAddress> ipAddresses;
-
-
- /**
- * Initializes local data used by all test cases.
- */
- @Before
- public void setUpAddresses() {
- ipAddresses = ImmutableSet.of(INTERFACE_ADDRESS_1,
- INTERFACE_ADDRESS_2);
- addresses1 = new PortAddresses(CONNECT_POINT1, ipAddresses,
- MacAddress.BROADCAST, VlanId.NONE);
- sameAsAddresses1 = new PortAddresses(CONNECT_POINT1, ipAddresses,
- MacAddress.BROADCAST, VlanId.NONE);
- addresses2 = new PortAddresses(CONNECT_POINT2, ipAddresses,
- MacAddress.BROADCAST, VlanId.NONE);
- addresses3 = new PortAddresses(CONNECT_POINT2, ipAddresses,
- MacAddress.ZERO, VlanId.NONE);
- }
-
- /**
- * Checks that the PortAddresses class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PortAddresses.class);
- }
-
- /**
- * Checks the operation of the equals(), hash() and toString()
- * methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester()
- .addEqualityGroup(addresses1, sameAsAddresses1)
- .addEqualityGroup(addresses2)
- .addEqualityGroup(addresses3)
- .testEquals();
- }
-
- /**
- * Tests that object are created correctly.
- */
- @Test
- public void testConstruction() {
- assertThat(addresses1.mac(), is(MacAddress.BROADCAST));
- assertThat(addresses1.connectPoint(), is(CONNECT_POINT1));
- assertThat(addresses1.ipAddresses(), is(ipAddresses));
- assertThat(addresses1.vlan(), is(VlanId.NONE));
- }
-}
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java
index 76f621f2..975503bb 100644
--- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java
@@ -61,6 +61,12 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
protected static final String SLOT_GRANULARITY = "slotGranularity";
protected static final String OCH_SIGNAL_ID = "ochSignalId";
protected static final String TUNNEL_ID = "tunnelId";
+ protected static final String OCH_SIGNAL_TYPE = "ochSignalType";
+ protected static final String ODU_SIGNAL_ID = "oduSignalId";
+ protected static final String TRIBUTARY_PORT_NUMBER = "tributaryPortNumber";
+ protected static final String TRIBUTARY_SLOT_LEN = "tributarySlotLen";
+ protected static final String TRIBUTARY_SLOT_BITMAP = "tributarySlotBitmap";
+ protected static final String ODU_SIGNAL_TYPE = "oduSignalType";
@Override
public ObjectNode encode(Criterion criterion, CodecContext context) {
@@ -73,6 +79,4 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
DecodeCriterionCodecHelper decoder = new DecodeCriterionCodecHelper(json);
return decoder.decode();
}
-
-
}
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
index a962c0dd..f7af736e 100644
--- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
@@ -38,6 +38,8 @@ import org.onosproject.net.flow.criteria.MetadataCriterion;
import org.onosproject.net.flow.criteria.MplsCriterion;
import org.onosproject.net.flow.criteria.OchSignalCriterion;
import org.onosproject.net.flow.criteria.OchSignalTypeCriterion;
+import org.onosproject.net.flow.criteria.OduSignalIdCriterion;
+import org.onosproject.net.flow.criteria.OduSignalTypeCriterion;
import org.onosproject.net.flow.criteria.PortCriterion;
import org.onosproject.net.flow.criteria.SctpPortCriterion;
import org.onosproject.net.flow.criteria.TcpPortCriterion;
@@ -108,7 +110,8 @@ public final class EncodeCriterionCodecHelper {
formatMap.put(Criterion.Type.OCH_SIGTYPE, new FormatOchSigType());
formatMap.put(Criterion.Type.TUNNEL_ID, new FormatTunnelId());
formatMap.put(Criterion.Type.DUMMY, new FormatDummyType());
-
+ formatMap.put(Criterion.Type.ODU_SIGID, new FormatOduSignalId());
+ formatMap.put(Criterion.Type.ODU_SIGTYPE, new FormatOduSignalType());
// Currently unimplemented
formatMap.put(Criterion.Type.ARP_OP, new FormatUnknown());
formatMap.put(Criterion.Type.ARP_SPA, new FormatUnknown());
@@ -351,7 +354,7 @@ public final class EncodeCriterionCodecHelper {
public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
final OchSignalTypeCriterion ochSignalTypeCriterion =
(OchSignalTypeCriterion) criterion;
- return root.put("ochSignalType", ochSignalTypeCriterion.signalType().name());
+ return root.put(CriterionCodec.OCH_SIGNAL_TYPE, ochSignalTypeCriterion.signalType().name());
}
}
@@ -364,6 +367,24 @@ public final class EncodeCriterionCodecHelper {
}
}
+ private static class FormatOduSignalId implements CriterionTypeFormatter {
+ @Override
+ public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
+ final OduSignalIdCriterion oduSignalIdCriterion =
+ (OduSignalIdCriterion) criterion;
+ return root.put(CriterionCodec.ODU_SIGNAL_ID, oduSignalIdCriterion.oduSignalId().toString());
+ }
+ }
+
+ private static class FormatOduSignalType implements CriterionTypeFormatter {
+ @Override
+ public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
+ final OduSignalTypeCriterion oduSignalTypeCriterion =
+ (OduSignalTypeCriterion) criterion;
+ return root.put(CriterionCodec.ODU_SIGNAL_TYPE, oduSignalTypeCriterion.signalType().name());
+ }
+ }
+
private class FormatDummyType implements CriterionTypeFormatter {
@Override
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
index e35dc0c5..9215d3a0 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
@@ -18,6 +18,7 @@ package org.onosproject.net.device.impl;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onlab.util.Tools.nullIsNotFound;
import static org.onosproject.net.MastershipRole.MASTER;
import static org.onosproject.net.MastershipRole.NONE;
import static org.onosproject.net.MastershipRole.STANDBY;
@@ -435,7 +436,7 @@ public class DeviceManager
portDescription);
return;
}
- final Device device = getDevice(deviceId);
+ Device device = nullIsNotFound(getDevice(deviceId), "Device not found");
if ((Device.Type.ROADM.equals(device.type()))) {
Port port = getPort(deviceId, portDescription.portNumber());
portDescription = OpticalPortOperator.descriptionOf(port, portDescription.isEnabled());
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java
index 8f2bda01..19377cf6 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java
@@ -158,8 +158,8 @@ public final class OpticalPortOperator implements ConfigOperator {
/**
* Returns a description built from an existing port and reported status.
*
- * @param port
- * @param isEnabled
+ * @param port port
+ * @param isEnabled true if enabled
* @return a PortDescription based on the port
*/
static PortDescription descriptionOf(Port port, boolean isEnabled) {
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
index 417627ad..a387d6f4 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
@@ -235,8 +235,10 @@ public class IntentCleanup implements Runnable, IntentListener {
stuckCount++;
}
- log.debug("Intent cleanup ran and resubmitted {} corrupt, {} failed, {} stuck, and {} pending intents",
- corruptCount, failedCount, stuckCount, pendingCount);
+ if (corruptCount + failedCount + stuckCount + pendingCount > 0) {
+ log.debug("Intent cleanup ran and resubmitted {} corrupt, {} failed, {} stuck, and {} pending intents",
+ corruptCount, failedCount, stuckCount, pendingCount);
+ }
}
@Override
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java
deleted file mode 100644
index 62b4112b..00000000
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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.net.resource.impl;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onosproject.net.Port;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.resource.device.DeviceResourceService;
-import org.onosproject.net.resource.device.DeviceResourceStore;
-import org.slf4j.Logger;
-
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides basic implementation of device resources allocation.
- */
-@Component(immediate = true)
-@Service
-public class DeviceResourceManager implements DeviceResourceService {
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- private DeviceResourceStore store;
-
- @Activate
- public void activate() {
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public boolean requestPorts(Set<Port> ports, Intent intent) {
- checkNotNull(intent);
-
- return store.allocatePorts(ports, intent.id());
- }
-
- @Override
- public Set<Port> getAllocations(IntentId intentId) {
- return store.getAllocations(intentId);
- }
-
- @Override
- public IntentId getAllocations(Port port) {
- return store.getAllocations(port);
- }
-
- @Override
- public void releaseMapping(IntentId intentId) {
- store.releaseMapping(intentId);
- }
-
- @Override
- public boolean requestMapping(IntentId keyIntentId, IntentId valIntentId) {
- return store.allocateMapping(keyIntentId, valIntentId);
- }
-
- @Override
- public Set<IntentId> getMapping(IntentId intentId) {
- return store.getMapping(intentId);
- }
-
- @Override
- public void releasePorts(IntentId intentId) {
- store.releasePorts(intentId);
- }
-
- private Port getTypedPort(Set<Port> ports, Port.Type type) {
- for (Port port : ports) {
- if (port.type() == type) {
- return port;
- }
- }
-
- return null;
- }
-}
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
index 648119e5..10f79eb0 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
@@ -304,7 +304,7 @@ public class ConsistentResourceStore implements ResourceStore {
}
/**
- * Removes teh values from the existing values associated with the specified key.
+ * Removes the values from the existing values associated with the specified key.
* If the map doesn't contain the given values, removal will not happen.
*
* @param map map holding multiple values for a key
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java
index f0f3eb5e..3865a779 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java
@@ -41,6 +41,7 @@ import org.onosproject.store.cluster.messaging.MessageSubject;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.serializers.KryoSerializer;
import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.ConsistentMapException;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.slf4j.Logger;
@@ -52,6 +53,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onlab.util.Tools.retryable;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -66,6 +68,8 @@ public class DistributedPacketStore
private final Logger log = getLogger(getClass());
+ private static final int MAX_BACKOFF = 10;
+
// TODO: make this configurable.
private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 4;
@@ -159,11 +163,11 @@ public class DistributedPacketStore
return tracker.requests();
}
- private class PacketRequestTracker {
+ private final class PacketRequestTracker {
private ConsistentMap<TrafficSelector, Set<PacketRequest>> requests;
- public PacketRequestTracker() {
+ private PacketRequestTracker() {
requests = storageService.<TrafficSelector, Set<PacketRequest>>consistentMapBuilder()
.withName("onos-packet-requests")
.withPartitionsDisabled()
@@ -171,7 +175,17 @@ public class DistributedPacketStore
.build();
}
- public void add(PacketRequest request) {
+ private void add(PacketRequest request) {
+ AtomicBoolean firstRequest =
+ retryable(this::addInternal, ConsistentMapException.class,
+ 3, MAX_BACKOFF).apply(request);
+ if (firstRequest.get() && delegate != null) {
+ // The instance that makes the first request will push to all devices
+ delegate.requestPackets(request);
+ }
+ }
+
+ private AtomicBoolean addInternal(PacketRequest request) {
AtomicBoolean firstRequest = new AtomicBoolean(false);
requests.compute(request.selector(), (s, existingRequests) -> {
if (existingRequests == null) {
@@ -186,14 +200,20 @@ public class DistributedPacketStore
return existingRequests;
}
});
+ return firstRequest;
+ }
- if (firstRequest.get() && delegate != null) {
- // The instance that makes the first request will push to all devices
- delegate.requestPackets(request);
+ private void remove(PacketRequest request) {
+ AtomicBoolean removedLast =
+ retryable(this::removeInternal, ConsistentMapException.class,
+ 3, MAX_BACKOFF).apply(request);
+ if (removedLast.get() && delegate != null) {
+ // The instance that removes the last request will remove from all devices
+ delegate.cancelPackets(request);
}
}
- public void remove(PacketRequest request) {
+ private AtomicBoolean removeInternal(PacketRequest request) {
AtomicBoolean removedLast = new AtomicBoolean(false);
requests.computeIfPresent(request.selector(), (s, existingRequests) -> {
if (existingRequests.contains(request)) {
@@ -209,15 +229,10 @@ public class DistributedPacketStore
return existingRequests;
}
});
-
- if (removedLast.get() && delegate != null) {
- // The instance that removes the last request will remove from all devices
- delegate.cancelPackets(request);
- }
-
+ return removedLast;
}
- public List<PacketRequest> requests() {
+ private List<PacketRequest> requests() {
List<PacketRequest> list = Lists.newArrayList();
requests.values().forEach(v -> list.addAll(v.value()));
list.sort((o1, o2) -> o1.priority().priorityValue() - o2.priority().priorityValue());
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
deleted file mode 100644
index 3266e96c..00000000
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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.store.resource.impl;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.resource.device.DeviceResourceStore;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.TransactionContext;
-import org.onosproject.store.service.TransactionalMap;
-import org.onosproject.store.service.Versioned;
-import org.slf4j.Logger;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static org.slf4j.LoggerFactory.getLogger;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Store that manages device resources using Copycat-backed TransactionalMaps.
- */
-@Component(immediate = true, enabled = true)
-@Service
-public class ConsistentDeviceResourceStore implements DeviceResourceStore {
- private final Logger log = getLogger(getClass());
-
- private static final String PORT_ALLOCATIONS = "PortAllocations";
- private static final String INTENT_MAPPING = "IntentMapping";
- private static final String INTENT_ALLOCATIONS = "PortIntentAllocations";
-
- private static final Serializer SERIALIZER = Serializer.using(KryoNamespaces.API);
-
- private ConsistentMap<Port, IntentId> portAllocMap;
- private ConsistentMap<IntentId, Set<Port>> intentAllocMap;
- private ConsistentMap<IntentId, Set<IntentId>> intentMapping;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
-
- @Activate
- public void activate() {
- portAllocMap = storageService.<Port, IntentId>consistentMapBuilder()
- .withName(PORT_ALLOCATIONS)
- .withSerializer(SERIALIZER)
- .build();
- intentAllocMap = storageService.<IntentId, Set<Port>>consistentMapBuilder()
- .withName(INTENT_ALLOCATIONS)
- .withSerializer(SERIALIZER)
- .build();
- intentMapping = storageService.<IntentId, Set<IntentId>>consistentMapBuilder()
- .withName(INTENT_MAPPING)
- .withSerializer(SERIALIZER)
- .build();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- private TransactionalMap<Port, IntentId> getPortAllocs(TransactionContext tx) {
- return tx.getTransactionalMap(PORT_ALLOCATIONS, SERIALIZER);
- }
-
- private TransactionalMap<IntentId, Set<Port>> getIntentAllocs(TransactionContext tx) {
- return tx.getTransactionalMap(INTENT_ALLOCATIONS, SERIALIZER);
- }
-
- private TransactionContext getTxContext() {
- return storageService.transactionContextBuilder().build();
- }
-
- @Override
- public Set<Port> getFreePorts(DeviceId deviceId) {
- checkNotNull(deviceId);
-
- Set<Port> freePorts = new HashSet<>();
- for (Port port : deviceService.getPorts(deviceId)) {
- if (!portAllocMap.containsKey(port)) {
- freePorts.add(port);
- }
- }
-
- return freePorts;
- }
-
- @Override
- public boolean allocatePorts(Set<Port> ports, IntentId intentId) {
- checkNotNull(ports);
- checkArgument(ports.size() > 0);
- checkNotNull(intentId);
-
- TransactionContext tx = getTxContext();
- tx.begin();
- try {
- TransactionalMap<Port, IntentId> portAllocs = getPortAllocs(tx);
- for (Port port : ports) {
- if (portAllocs.putIfAbsent(port, intentId) != null) {
- throw new Exception("Port already allocated " + port.toString());
- }
- }
-
- TransactionalMap<IntentId, Set<Port>> intentAllocs = getIntentAllocs(tx);
- intentAllocs.put(intentId, ports);
- tx.commit();
- } catch (Exception e) {
- log.error("Exception thrown, rolling back", e);
- tx.abort();
- return false;
- }
-
- return true;
- }
-
- @Override
- public Set<Port> getAllocations(IntentId intentId) {
- if (!intentAllocMap.containsKey(intentId)) {
- Collections.emptySet();
- }
-
- return intentAllocMap.get(intentId).value();
- }
-
- @Override
- public IntentId getAllocations(Port port) {
- if (!portAllocMap.containsKey(port)) {
- return null;
- }
-
- return portAllocMap.get(port).value();
- }
-
- @Override
- public Set<IntentId> getMapping(IntentId intentId) {
- Versioned<Set<IntentId>> result = intentMapping.get(intentId);
-
- if (result != null) {
- return result.value();
- }
-
- return null;
- }
-
- @Override
- public boolean allocateMapping(IntentId keyIntentId, IntentId valIntentId) {
- Versioned<Set<IntentId>> versionedIntents = intentMapping.get(keyIntentId);
-
- if (versionedIntents == null) {
- Set<IntentId> newSet = new HashSet<>();
- newSet.add(valIntentId);
- intentMapping.put(keyIntentId, newSet);
- } else {
- versionedIntents.value().add(valIntentId);
- }
-
- return true;
- }
-
- @Override
- public void releaseMapping(IntentId intentId) {
- for (IntentId intent : intentMapping.keySet()) {
- // TODO: optimize by checking for identical src & dst
- Set<IntentId> mapping = intentMapping.get(intent).value();
- if (mapping.remove(intentId)) {
- return;
- }
- }
- }
-
- @Override
- public boolean releasePorts(IntentId intentId) {
- checkNotNull(intentId);
-
- TransactionContext tx = getTxContext();
- tx.begin();
- try {
- TransactionalMap<IntentId, Set<Port>> intentAllocs = getIntentAllocs(tx);
- Set<Port> ports = intentAllocs.get(intentId);
- intentAllocs.remove(intentId);
-
- TransactionalMap<Port, IntentId> portAllocs = getPortAllocs(tx);
- for (Port port : ports) {
- portAllocs.remove(port);
- }
- tx.commit();
- } catch (Exception e) {
- log.error("Exception thrown, rolling back", e);
- tx.abort();
- return false;
- }
-
- return true;
- }
-}
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java
index 87e67215..8d5a1001 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.store.resource.impl;
+import com.google.common.annotations.Beta;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -42,6 +43,7 @@ import static org.slf4j.LoggerFactory.getLogger;
*/
@Component(immediate = true, enabled = true)
@Service
+@Beta
public class ConsistentIntentSetMultimap implements IntentSetMultimap {
private final Logger log = getLogger(getClass());
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
index 11137aa2..c332ada5 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
@@ -363,6 +363,15 @@ public class ConsistentLinkResourceStore extends
after.add(allocations);
linkAllocs.putIfAbsent(linkKey, after);
} else {
+ boolean overlapped = before.stream()
+ .flatMap(x -> x.getResourceAllocation(link).stream())
+ .anyMatch(x -> allocations.getResourceAllocation(link).contains(x));
+ if (overlapped) {
+ throw new ResourceAllocationException(
+ String.format("Resource allocations are overlapped between %s and %s",
+ before, allocations)
+ );
+ }
List<LinkResourceAllocations> after = new ArrayList<>(before.size() + 1);
after.addAll(before);
after.add(allocations);