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/EncapsulationType.java30
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/TributarySlot.java73
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionTreatmentResolver.java (renamed from framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionResolver.java)8
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java1
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java20
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicFeatureConfig.java54
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java7
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java8
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java78
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java32
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java90
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java75
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java75
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java (renamed from framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionInstruction.java)2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java (renamed from framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionInstruction.java)4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java (renamed from framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java)26
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java18
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java48
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java65
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java55
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java25
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java17
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java12
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java83
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java8
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java38
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java19
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java2
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/config/ConfigTest.java141
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java149
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java4
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java30
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CodecManager.java2
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeConstraintCodecHelper.java6
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java23
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeConstraintCodecHelper.java4
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java10
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/FlowEntryCodec.java1
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/PortStatisticsCodec.java51
-rw-r--r--framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/ConstraintCodecTest.java4
-rw-r--r--framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java4
-rw-r--r--framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java6
-rw-r--r--framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentJsonMatcher.java4
-rw-r--r--framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json2
-rw-r--r--framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json2
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java16
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java31
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java4
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java1
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java64
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java9
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java18
-rw-r--r--framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java11
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java3
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java4
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java8
-rw-r--r--framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/mastership/impl/DistributedMastershipStoreTest.java286
-rw-r--r--framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/resource/impl/HazelcastLinkResourceStoreTest.java227
-rw-r--r--framework/src/onos/core/store/persistence/src/main/java/org/onosproject/persistence/impl/PersistenceManager.java4
-rw-r--r--framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java12
-rw-r--r--framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java7
-rw-r--r--framework/src/onos/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java5
65 files changed, 1383 insertions, 753 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/EncapsulationType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/EncapsulationType.java
new file mode 100644
index 00000000..63ff46d3
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/EncapsulationType.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+public enum EncapsulationType {
+ /**
+ * Indicates an MPLS encapsulation.
+ */
+ MPLS,
+ /**
+ * Indicates a VLAN encapsulation.
+ */
+ VLAN,
+};
+
+
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/TributarySlot.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/TributarySlot.java
new file mode 100644
index 00000000..d8a10c81
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/TributarySlot.java
@@ -0,0 +1,73 @@
+/*
+ * 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.base.MoreObjects;
+
+/**
+ * Implementation of ODU Tributary Slot simply designated by an index number of slot.
+ */
+public class TributarySlot {
+
+ private final long index;
+
+ /**
+ * Creates an instance representing the TributarySlot specified by the given index number.
+ *
+ * @param index index number of wavelength
+ */
+ public TributarySlot(long index) {
+ this.index = index;
+ }
+
+ public static TributarySlot of(long index) {
+ return new TributarySlot(index);
+ }
+
+ /**
+ * Returns the index number of TributarySlot.
+ *
+ * @return the index number of TributarySlot
+ */
+ public long index() {
+ return index;
+ }
+
+ @Override
+ public int hashCode() {
+ return Long.hashCode(index);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof TributarySlot)) {
+ return false;
+ }
+
+ final TributarySlot that = (TributarySlot) obj;
+ return this.index == that.index;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("index", index)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionResolver.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionTreatmentResolver.java
index 54cbc7ac..85f0216d 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionResolver.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionTreatmentResolver.java
@@ -18,14 +18,14 @@ package org.onosproject.net.behaviour;
import com.google.common.annotations.Beta;
import org.onosproject.net.driver.HandlerBehaviour;
-import org.onosproject.net.flow.instructions.ExtensionInstruction;
-import org.onosproject.net.flow.instructions.ExtensionType;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
/**
* Provides access to the extension implemented by this driver.
*/
@Beta
-public interface ExtensionResolver extends HandlerBehaviour {
+public interface ExtensionTreatmentResolver extends HandlerBehaviour {
/**
* Gets an extension instruction instance of the specified type, if supported
@@ -36,5 +36,5 @@ public interface ExtensionResolver extends HandlerBehaviour {
* @throws UnsupportedOperationException if the extension type is not
* supported by this driver
*/
- ExtensionInstruction getExtensionInstruction(ExtensionType type);
+ ExtensionTreatment getExtensionInstruction(ExtensionTreatmentType type);
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java
index e3b4c198..a1b97ffd 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java
@@ -29,6 +29,7 @@ public interface TunnelConfig extends HandlerBehaviour {
*
* @param tunnel tunnel descriptor
*/
+ @Deprecated
void createTunnel(TunnelDescription tunnel);
/**
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java
index 3757d327..5f2c9f3a 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java
@@ -333,6 +333,26 @@ public abstract class Config<S> {
}
/**
+ * Gets the specified array property as a list of items.
+ *
+ * @param name property name
+ * @param function mapper from string to item
+ * @param defaultValue default value if property not set
+ * @param <T> type of item
+ * @return list of items
+ */
+ protected <T> List<T> getList(String name, Function<String, T> function, List<T> defaultValue) {
+ List<T> list = Lists.newArrayList();
+ JsonNode jsonNode = object.path(name);
+ if (jsonNode.isMissingNode()) {
+ return defaultValue;
+ }
+ ArrayNode arrayNode = (ArrayNode) jsonNode;
+ arrayNode.forEach(i -> list.add(function.apply(i.asText())));
+ return list;
+ }
+
+ /**
* Sets the specified property as an array of items in a given collection or
* clears it if null is given.
*
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicFeatureConfig.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicFeatureConfig.java
new file mode 100644
index 00000000..fcf24bc6
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicFeatureConfig.java
@@ -0,0 +1,54 @@
+/*
+ * 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.config.basics;
+
+import org.onosproject.net.config.Config;
+
+/**
+ * Base abstraction for configuring feature on subject.
+ *
+ * @param <S> Subject type
+ */
+public abstract class BasicFeatureConfig<S> extends Config<S> {
+
+ private static final String ENABLED = "enabled";
+
+ private final boolean defaultValue;
+
+ protected BasicFeatureConfig(boolean defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * Indicates whether the feature for the subject is enabled.
+ *
+ * @return true if feature is enabled
+ */
+ public boolean enabled() {
+ return get(ENABLED, defaultValue);
+ }
+
+ /**
+ * Specifies whether the feature for the subject is to be enabled.
+ *
+ * @param enabled true to enable; false to disable; null to clear
+ * @return self
+ */
+ public BasicFeatureConfig<S> enabled(Boolean enabled) {
+ return (BasicFeatureConfig<S>) setOrClear(ENABLED, enabled);
+ }
+
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
index a842d600..d3c2449c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
@@ -340,7 +340,7 @@ public final class DefaultTrafficSelector implements TrafficSelector {
@Override
public Builder matchMplsBos(boolean mplsBos) {
- return add(Criteria.matchMplsLabel(mplsBos));
+ return add(Criteria.matchMplsBos(mplsBos));
}
@Override
@@ -374,6 +374,11 @@ public final class DefaultTrafficSelector implements TrafficSelector {
}
@Override
+ public Builder matchArpOp(int arpOp) {
+ return add(Criteria.matchArpOp(arpOp));
+ }
+
+ @Override
public TrafficSelector build() {
return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values()));
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index 4615a82b..22bff7dd 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -30,7 +30,7 @@ import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.IndexedLambda;
import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.instructions.ExtensionInstruction;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.meter.MeterId;
@@ -489,7 +489,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
}
@Override
- public TrafficTreatment.Builder extension(ExtensionInstruction extension,
+ public TrafficTreatment.Builder extension(ExtensionTreatment extension,
DeviceId deviceId) {
return add(Instructions.extension(extension, deviceId));
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
index 9fe88d5a..b92281f5 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
@@ -419,6 +419,14 @@ public interface TrafficSelector {
Builder matchArpSha(MacAddress addr);
/**
+ * Matches a arp operation type.
+ *
+ * @param arpOp a arp operation type
+ * @return a selection builder
+ */
+ Builder matchArpOp(int arpOp);
+
+ /**
* Builds an immutable traffic selector.
*
* @return traffic selector
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
index f1a676ab..06b6ffa0 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
@@ -26,7 +26,7 @@ import org.onlab.packet.VlanId;
import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.instructions.ExtensionInstruction;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.meter.MeterId;
@@ -430,7 +430,7 @@ public interface TrafficTreatment {
* @param deviceId device ID
* @return a treatment builder
*/
- Builder extension(ExtensionInstruction extension, DeviceId deviceId);
+ Builder extension(ExtensionTreatment extension, DeviceId deviceId);
/**
* Builds an immutable traffic treatment descriptor.
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java
new file mode 100644
index 00000000..8c5398c6
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java
@@ -0,0 +1,78 @@
+/*
+ * 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 java.util.Objects;
+
+/**
+ * Implementation of arp operation type criterion.
+ */
+public final class ArpOpCriterion implements Criterion {
+ private final int arpOp;
+ private final Type type;
+
+ /**
+ * Constructor.
+ *
+ * @param arpOp the arp operation type to match.
+ * @param type the match type. Should be the following:
+ * Type.ARP_OP
+ */
+ ArpOpCriterion(int arpOp, Type type) {
+ this.arpOp = arpOp;
+ this.type = type;
+ }
+
+ @Override
+ public Type type() {
+ return this.type;
+ }
+
+ /**
+ * Gets the arp operation type to match.
+ *
+ * @return the arp operation type to match
+ */
+ public int arpOp() {
+ return this.arpOp;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("arpOp", arpOp).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type().ordinal(), arpOp);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof ArpOpCriterion) {
+ ArpOpCriterion that = (ArpOpCriterion) obj;
+ return Objects.equals(arpOp, that.arpOp) &&
+ Objects.equals(type, that.type);
+ }
+ return false;
+ }
+} \ No newline at end of file
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 554b8e74..a28a4ab9 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
@@ -230,6 +230,16 @@ public final class Criteria {
}
/**
+ * Creates a match on TCP flags using the specified value.
+ *
+ * @param flags TCP flags
+ * @return match criterion
+ */
+ public static Criterion matchTcpFlags(int flags) {
+ return new TcpFlagsCriterion(flags);
+ }
+
+ /**
* Creates a match on UDP source port field using the specified value.
*
* @param udpPort UDP source port
@@ -438,11 +448,21 @@ public final class Criteria {
* @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
* @return match criterion
*/
- public static Criterion matchMplsLabel(boolean mplsBos) {
+ public static Criterion matchMplsBos(boolean mplsBos) {
return new MplsBosCriterion(mplsBos);
}
/**
+ * Creates a match on MPLS TC.
+ *
+ * @param mplsTc MPLS TC (3 bits)
+ * @return match criterion
+ */
+ public static Criterion matchMplsTc(byte mplsTc) {
+ return new MplsTcCriterion(mplsTc);
+ }
+
+ /**
* Creates a match on Tunnel ID.
*
* @param tunnelId Tunnel ID (64 bits)
@@ -549,6 +569,16 @@ public final class Criteria {
return new ArpHaCriterion(mac, Type.ARP_SHA);
}
+ /**
+ * Creates a match on arp operation type field using the specified value.
+ *
+ * @param arpOp arp operation type value
+ * @return match criterion
+ */
+ public static Criterion matchArpOp(int arpOp) {
+ return new ArpOpCriterion(arpOp, Type.ARP_OP);
+ }
+
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 10cb629f..26665246 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
@@ -28,92 +28,136 @@ public interface Criterion {
enum Type {
/** Switch input port. */
IN_PORT,
+
/** Switch physical input port. */
IN_PHY_PORT,
+
/** Metadata passed between tables. */
METADATA,
+
/** Ethernet destination address. */
ETH_DST,
+
/** Ethernet source address. */
ETH_SRC,
+
/** Ethernet frame type. */
ETH_TYPE,
+
/** VLAN id. */
VLAN_VID,
+
/** VLAN priority. */
VLAN_PCP,
+
/** IP DSCP (6 bits in ToS field). */
IP_DSCP,
+
/** IP ECN (2 bits in ToS field). */
IP_ECN,
+
/** IP protocol. */
IP_PROTO,
+
/** IPv4 source address. */
IPV4_SRC,
+
/** IPv4 destination address. */
IPV4_DST,
+
/** TCP source port. */
TCP_SRC,
+
/** TCP destination port. */
TCP_DST,
+
/** UDP source port. */
UDP_SRC,
+
/** UDP destination port. */
UDP_DST,
+
/** SCTP source port. */
SCTP_SRC,
+
/** SCTP destination port. */
SCTP_DST,
+
/** ICMP type. */
ICMPV4_TYPE,
+
/** ICMP code. */
ICMPV4_CODE,
+
/** ARP opcode. */
ARP_OP,
+
/** ARP source IPv4 address. */
ARP_SPA,
+
/** ARP target IPv4 address. */
ARP_TPA,
+
/** ARP source hardware address. */
ARP_SHA,
+
/** ARP target hardware address. */
ARP_THA,
+
/** IPv6 source address. */
IPV6_SRC,
+
/** IPv6 destination address. */
IPV6_DST,
+
/** IPv6 Flow Label. */
IPV6_FLABEL,
+
/** ICMPv6 type. */
ICMPV6_TYPE,
+
/** ICMPv6 code. */
ICMPV6_CODE,
+
/** Target address for ND. */
IPV6_ND_TARGET,
+
/** Source link-layer for ND. */
IPV6_ND_SLL,
+
/** Target link-layer for ND. */
IPV6_ND_TLL,
+
/** MPLS label. */
MPLS_LABEL,
+
/** MPLS TC. */
MPLS_TC,
- /** MPLS BoS bit. */
+
+ /** MPLS BoS bit. */
MPLS_BOS,
+
/** PBB I-SID. */
PBB_ISID,
+
/** Logical Port Metadata. */
TUNNEL_ID,
+
/** IPv6 Extension Header pseudo-field. */
IPV6_EXTHDR,
+
/** Unassigned value: 40. */
UNASSIGNED_40,
+
/** PBB UCA header field. */
PBB_UCA,
+
/** TCP flags. */
TCP_FLAGS,
+
/** Output port from action set metadata. */
ACTSET_OUTPUT,
+
/** Packet type value. */
PACKET_TYPE,
@@ -123,16 +167,17 @@ public interface Criterion {
//
/** Optical channel signal ID (lambda). */
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.
- */
+ /** An empty criterion. */
DUMMY
}
@@ -182,4 +227,41 @@ public interface Criterion {
return this.value;
}
}
+
+ enum TCPFlags {
+
+ /** ECN-nonce concealment protection. */
+ NS((short) (1 << 0)),
+ /** Congestion Window Reduced. */
+ CWR((short) (1 << 1)),
+ /** ECN-Echo. **/
+ ECE((short) (1 << 2)),
+ /** Urgent pointer field is significant. */
+ URG((short) (1 << 3)),
+ /** Acknowledgment field is significant. */
+ ACK((short) (1 << 4)),
+ /** Push the buffered data to the receiving application. */
+ PSH((short) (1 << 5)),
+ /** Reset the connection. */
+ RST((short) (1 << 6)),
+ /** Synchronize sequence numbers. */
+ SYN((short) (1 << 7)),
+ /** No more data from sender. */
+ FIN((short) (1 << 8));
+
+ private short value;
+
+ TCPFlags(short value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value as an integer.
+ *
+ * @return the value as an integer
+ */
+ public short getValue() {
+ return this.value;
+ }
+ }
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java
new file mode 100644
index 00000000..8ad62358
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java
@@ -0,0 +1,75 @@
+/*
+ * 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 MPLS TC criterion (3 bits).
+ */
+public final class MplsTcCriterion implements Criterion {
+ private static final byte MASK = 0x7;
+ private final byte mplsTc;
+
+ /**
+ * Constructor.
+ *
+ * @param mplsTc the MPLS TC to match (3 bits)
+ */
+ MplsTcCriterion(byte mplsTc) {
+ this.mplsTc = (byte) (mplsTc & MASK);
+ }
+
+ @Override
+ public Type type() {
+ return Type.MPLS_TC;
+ }
+
+ /**
+ * Gets the MPLS TC to match.
+ *
+ * @return the MPLS TC to match (3 bits)
+ */
+ public byte tc() {
+ return mplsTc;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("tc", Long.toHexString(mplsTc)).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type().ordinal(), mplsTc);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MplsTcCriterion) {
+ MplsTcCriterion that = (MplsTcCriterion) obj;
+ return Objects.equals(mplsTc, that.mplsTc) &&
+ Objects.equals(this.type(), that.type());
+ }
+ return false;
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java
new file mode 100644
index 00000000..e0b53958
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java
@@ -0,0 +1,75 @@
+/*
+ * 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 TCP flags criterion (12 bits unsigned integer).
+ */
+public final class TcpFlagsCriterion implements Criterion {
+ private static final int MASK = 0xfffff;
+ private final int flags; // TCP flags: 12 bits
+
+ /**
+ * Constructor.
+ *
+ * @param flags the TCP flags to match (12 bits)
+ */
+ TcpFlagsCriterion(int flags) {
+ this.flags = flags & MASK;
+ }
+
+ @Override
+ public Type type() {
+ return Type.TCP_FLAGS;
+ }
+
+ /**
+ * Gets the TCP flags to match.
+ *
+ * @return the TCP flags to match (12 bits)
+ */
+ public int flags() {
+ return flags;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("flags", Long.toHexString(flags)).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type().ordinal(), flags);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TcpFlagsCriterion) {
+ TcpFlagsCriterion that = (TcpFlagsCriterion) obj;
+ return Objects.equals(flags, that.flags) &&
+ Objects.equals(this.type(), that.type());
+ }
+ return false;
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java
index 9f22f888..ac7c771f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionInstruction.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java
@@ -23,7 +23,7 @@ import java.util.List;
/**
* Abstract implementation of the set/get property methods of ExtensionInstruction.
*/
-public abstract class AbstractExtensionInstruction implements ExtensionInstruction {
+public abstract class AbstractExtensionTreatment implements ExtensionTreatment {
private static final String INVALID_KEY = "Invalid property key: ";
private static final String INVALID_TYPE = "Given type does not match field type: ";
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java
index 89e0cc5e..0e8885ed 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionInstruction.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java
@@ -21,14 +21,14 @@ import java.util.List;
/**
* An extensible instruction type.
*/
-public interface ExtensionInstruction {
+public interface ExtensionTreatment {
/**
* Gets the type of the extension instruction.
*
* @return type
*/
- ExtensionType type();
+ ExtensionTreatmentType type();
/**
* Sets a property on the extension instruction.
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
index 3e1cb75c..38fbc279 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
@@ -25,25 +25,27 @@ import java.util.Objects;
* Type of extension instructions.
*/
@Beta
-public final class ExtensionType {
+public final class ExtensionTreatmentType {
/**
* A list of well-known named extension instruction type codes.
+ * These numbers have no impact on the actual OF type id.
*/
- public enum ExtensionTypes {
+ public enum ExtensionTreatmentTypes {
// TODO fix type numbers to include experimenter id
- NICIRA_SET_TUNNEL_DST(31),
- NICIRA_RESUBMIT(32);
+ NICIRA_SET_TUNNEL_DST(0),
+ NICIRA_RESUBMIT(1),
+ NICIRA_SET_NSH_SPI(32);
- private ExtensionType type;
+ private ExtensionTreatmentType type;
/**
* Creates a new named extension instruction type.
*
* @param type type code
*/
- ExtensionTypes(int type) {
- this.type = new ExtensionType(type);
+ ExtensionTreatmentTypes(int type) {
+ this.type = new ExtensionTreatmentType(type);
}
/**
@@ -51,7 +53,7 @@ public final class ExtensionType {
*
* @return extension type object
*/
- public ExtensionType type() {
+ public ExtensionTreatmentType type() {
return type;
}
}
@@ -63,7 +65,7 @@ public final class ExtensionType {
*
* @param type type code
*/
- public ExtensionType(int type) {
+ public ExtensionTreatmentType(int type) {
this.type = type;
}
@@ -77,8 +79,8 @@ public final class ExtensionType {
if (this == obj) {
return true;
}
- if (obj instanceof ExtensionType) {
- final ExtensionType that = (ExtensionType) obj;
+ if (obj instanceof ExtensionTreatmentType) {
+ final ExtensionTreatmentType that = (ExtensionTreatmentType) obj;
return this.type == that.type;
}
return false;
@@ -86,7 +88,7 @@ public final class ExtensionType {
@Override
public String toString() {
- return MoreObjects.toStringHelper(ExtensionType.class)
+ return MoreObjects.toStringHelper(ExtensionTreatmentType.class)
.add("type", type)
.toString();
}
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 126e722e..4643b315 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
@@ -489,7 +489,7 @@ public final class Instructions {
* @param deviceId device ID
* @return extension instruction
*/
- public static ExtensionInstructionWrapper extension(ExtensionInstruction extension,
+ public static ExtensionInstructionWrapper extension(ExtensionTreatment extension,
DeviceId deviceId) {
checkNotNull(extension, "Extension instruction cannot be null");
checkNotNull(deviceId, "Device ID cannot be null");
@@ -858,16 +858,16 @@ public final class Instructions {
* Extension instruction.
*/
public static class ExtensionInstructionWrapper implements Instruction {
- private final ExtensionInstruction extensionInstruction;
+ private final ExtensionTreatment extensionTreatment;
private final DeviceId deviceId;
- ExtensionInstructionWrapper(ExtensionInstruction extension, DeviceId deviceId) {
- extensionInstruction = extension;
+ ExtensionInstructionWrapper(ExtensionTreatment extension, DeviceId deviceId) {
+ extensionTreatment = extension;
this.deviceId = deviceId;
}
- public ExtensionInstruction extensionInstruction() {
- return extensionInstruction;
+ public ExtensionTreatment extensionInstruction() {
+ return extensionTreatment;
}
public DeviceId deviceId() {
@@ -882,14 +882,14 @@ public final class Instructions {
@Override
public String toString() {
return toStringHelper(type().toString())
- .add("extension", extensionInstruction)
+ .add("extension", extensionTreatment)
.add("deviceId", deviceId)
.toString();
}
@Override
public int hashCode() {
- return Objects.hash(type().ordinal(), extensionInstruction, deviceId);
+ return Objects.hash(type().ordinal(), extensionTreatment, deviceId);
}
@Override
@@ -899,7 +899,7 @@ public final class Instructions {
}
if (obj instanceof ExtensionInstructionWrapper) {
ExtensionInstructionWrapper that = (ExtensionInstructionWrapper) obj;
- return Objects.equals(extensionInstruction, that.extensionInstruction)
+ return Objects.equals(extensionTreatment, that.extensionTreatment)
&& Objects.equals(deviceId, that.deviceId);
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
index 0abf5abe..af481805 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
@@ -16,6 +16,7 @@
package org.onosproject.net.flowobjective;
import com.google.common.annotations.Beta;
+
import org.onosproject.core.ApplicationId;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
@@ -119,6 +120,53 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
return context;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hash(selector, flag, permanent,
+ timeout, appId, priority, nextId,
+ treatment, op);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof DefaultForwardingObjective)) {
+ return false;
+ }
+ final DefaultForwardingObjective other = (DefaultForwardingObjective) obj;
+ boolean nextEq = false, treatmentEq = false;
+ if (this.selector.equals(other.selector) &&
+ this.flag == other.flag &&
+ this.permanent == other.permanent &&
+ this.timeout == other.timeout &&
+ this.appId.equals(other.appId) &&
+ this.priority == other.priority &&
+ this.op == other.op) {
+ if (this.nextId != null && other.nextId != null) {
+ nextEq = this.nextId == other.nextId;
+ }
+ if (this.treatment != null && other.treatment != null) {
+ treatmentEq = this.treatment.equals(other.treatment);
+ }
+ if (nextEq && treatmentEq) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Returns a new builder.
*
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
index 20e89295..4701589f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
@@ -18,6 +18,7 @@ package org.onosproject.net.flowobjective;
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
import org.onosproject.core.ApplicationId;
+import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import java.util.Collection;
@@ -39,6 +40,7 @@ public final class DefaultNextObjective implements NextObjective {
private final Integer id;
private final Operation op;
private final Optional<ObjectiveContext> context;
+ private final TrafficSelector meta;
private DefaultNextObjective(Builder builder) {
this.treatments = builder.treatments;
@@ -47,6 +49,7 @@ public final class DefaultNextObjective implements NextObjective {
this.id = builder.id;
this.op = builder.op;
this.context = Optional.ofNullable(builder.context);
+ this.meta = builder.meta;
}
@Override
@@ -94,6 +97,11 @@ public final class DefaultNextObjective implements NextObjective {
return context;
}
+ @Override
+ public TrafficSelector meta() {
+ return meta;
+ }
+
/**
* Returns a new builder.
*
@@ -111,6 +119,7 @@ public final class DefaultNextObjective implements NextObjective {
private List<TrafficTreatment> treatments;
private Operation op;
private ObjectiveContext context;
+ private TrafficSelector meta;
private final ImmutableList.Builder<TrafficTreatment> listBuilder
= ImmutableList.builder();
@@ -172,6 +181,12 @@ public final class DefaultNextObjective implements NextObjective {
}
@Override
+ public Builder setMeta(TrafficSelector meta) {
+ this.meta = meta;
+ return this;
+ }
+
+ @Override
public NextObjective add() {
treatments = listBuilder.build();
op = Operation.ADD;
@@ -218,5 +233,55 @@ public final class DefaultNextObjective implements NextObjective {
return new DefaultNextObjective(this);
}
+
+ @Override
+ public NextObjective addToExisting() {
+ treatments = listBuilder.build();
+ op = Operation.ADD_TO_EXISTING;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+ checkArgument(!treatments.isEmpty(), "Must have at least one treatment");
+
+ return new DefaultNextObjective(this);
+ }
+
+ @Override
+ public NextObjective removeFromExisting() {
+ treatments = listBuilder.build();
+ op = Operation.REMOVE_FROM_EXISTING;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+
+ return new DefaultNextObjective(this);
+ }
+
+ @Override
+ public NextObjective addToExisting(ObjectiveContext context) {
+ treatments = listBuilder.build();
+ op = Operation.ADD_TO_EXISTING;
+ this.context = context;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+ checkArgument(!treatments.isEmpty(), "Must have at least one treatment");
+
+ return new DefaultNextObjective(this);
+ }
+
+ @Override
+ public NextObjective removeFromExisting(ObjectiveContext context) {
+ treatments = listBuilder.build();
+ op = Operation.REMOVE_FROM_EXISTING;
+ this.context = context;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+
+ return new DefaultNextObjective(this);
+ }
+
}
+
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
index 1350d7a1..08916eb2 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
@@ -17,6 +17,7 @@ package org.onosproject.net.flowobjective;
import com.google.common.annotations.Beta;
import org.onosproject.core.ApplicationId;
+import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import java.util.Collection;
@@ -34,7 +35,7 @@ import java.util.Collection;
* - Failover
* - Simple
*
- * These types will indicate to the driver what the intended behaviour is.
+ * These types will indicate to the driver what the intended behavior is.
* For example, a broadcast next objective with a collection of output
* treatments will indicate to a driver that all output actions are expected
* to be executed simultaneously. The driver is then free to implement this
@@ -84,6 +85,16 @@ public interface NextObjective extends Objective {
Type type();
/**
+ * Auxiliary optional information provided to the device-driver.Typically
+ * conveys information about selectors (matches) that are intended to
+ * use this Next Objective.
+ *
+ * @return a selector intended to pass meta information to the device driver.
+ * Value may be null if no meta information is provided.
+ */
+ TrafficSelector meta();
+
+ /**
* A next step builder.
*/
interface Builder extends Objective.Builder {
@@ -131,6 +142,14 @@ public interface NextObjective extends Objective {
Builder withPriority(int priority);
/**
+ * Set meta information related to this next objective.
+ *
+ * @param selector match conditions
+ * @return an objective builder
+ */
+ Builder setMeta(TrafficSelector selector);
+
+ /**
* Builds the next objective that will be added.
*
* @return a next objective
@@ -162,6 +181,40 @@ public interface NextObjective extends Objective {
*/
NextObjective remove(ObjectiveContext context);
+ /**
+ * Build the next objective that will be added, with {@link Operation}
+ * ADD_TO_EXISTING.
+ *
+ * @return a next objective
+ */
+ NextObjective addToExisting();
+
+ /**
+ * Build the next objective that will be removed, with {@link Operation}
+ * REMOVE_FROM_EXISTING.
+ *
+ * @return a next objective
+ */
+ NextObjective removeFromExisting();
+
+ /**
+ * Builds the next objective that will be added, with {@link Operation}
+ * ADD_TO_EXISTING. The context will be used to notify the calling application.
+ *
+ * @param context an objective context
+ * @return a next objective
+ */
+ NextObjective addToExisting(ObjectiveContext context);
+
+ /**
+ * Builds the next objective that will be removed, with {@link Operation}
+ * REMOVE_FROM_EXISTING. The context will be used to notify the calling application.
+ *
+ * @param context an objective context
+ * @return a next objective
+ */
+ NextObjective removeFromExisting(ObjectiveContext context);
+
}
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
index 6ac7a7a2..b1d73a7c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
@@ -21,7 +21,7 @@ import org.onosproject.core.ApplicationId;
import java.util.Optional;
/**
- * Base representation of an flow description.
+ * Base representation of a flow-objective description.
*/
@Beta
public interface Objective {
@@ -35,14 +35,30 @@ public interface Objective {
*/
enum Operation {
/**
- * Adds the objective.
+ * Adds the objective. Can be used for any flow objective. For forwarding
+ * and filtering objectives, existing objectives with identical selector
+ * and priority fields (but different treatments or next) will be replaced.
+ * For next objectives, if modification is desired, ADD will not
+ * do anything - use ADD_TO_EXISTING.
*/
ADD,
/**
- * Removes the objective.
+ * Removes the objective. Can be used for any flow objective.
*/
- REMOVE
+ REMOVE,
+
+ /**
+ * Add to an existing Next Objective. Should not be used for any other
+ * objective.
+ */
+ ADD_TO_EXISTING,
+
+ /**
+ * Remove from an existing Next Objective. Should not be used for any
+ * other objective.
+ */
+ REMOVE_FROM_EXISTING
}
/**
@@ -129,6 +145,7 @@ public interface Objective {
* @return an objective builder
*/
Builder withPriority(int priority);
+
}
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java
index 7f00ae70..e1eacd1e 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java
@@ -25,6 +25,7 @@ import java.util.Arrays;
public class DefaultGroupKey implements GroupKey {
private final byte[] key;
+ protected static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
public DefaultGroupKey(byte[] key) {
this.key = checkNotNull(key);
@@ -52,4 +53,20 @@ public class DefaultGroupKey implements GroupKey {
return Arrays.hashCode(this.key);
}
+ /**
+ * Returns a hex string representation of the byte array that is used
+ * as a group key. This solution was adapted from
+ * http://stackoverflow.com/questions/9655181/
+ */
+ @Override
+ public String toString() {
+ char[] hexChars = new char[key.length * 2];
+ for (int j = 0; j < key.length; j++) {
+ int v = key[j] & 0xFF;
+ hexChars[j * 2] = HEX_ARRAY[v >>> 4];
+ hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
+ }
+ return "GroupKey:0x" + new String(hexChars);
+ }
+
} \ No newline at end of file
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
index c1467241..306597b3 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
@@ -114,6 +114,8 @@ public final class HostToHostIntent extends ConnectivityIntent {
return this;
}
+
+
/**
* Builds a host to host intent from the accumulated parameters.
*
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
index 444feee4..1b4a2600 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
@@ -17,9 +17,9 @@ package org.onosproject.net.intent.constraint;
import com.google.common.annotations.Beta;
+import org.onlab.util.Bandwidth;
import org.onlab.util.DataRateUnit;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.BandwidthResource;
import org.onosproject.net.resource.link.BandwidthResourceRequest;
import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.resource.ResourceRequest;
@@ -36,14 +36,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Beta
public final class BandwidthConstraint extends BooleanConstraint {
- private final BandwidthResource bandwidth;
+ private final Bandwidth bandwidth;
/**
* Creates a new bandwidth constraint.
*
* @param bandwidth required bandwidth
*/
- public BandwidthConstraint(BandwidthResource bandwidth) {
+ public BandwidthConstraint(Bandwidth bandwidth) {
this.bandwidth = checkNotNull(bandwidth, "Bandwidth cannot be null");
}
@@ -55,7 +55,7 @@ public final class BandwidthConstraint extends BooleanConstraint {
* @return {@link BandwidthConstraint} instance with given bandwidth requirement
*/
public static BandwidthConstraint of(double v, DataRateUnit unit) {
- return new BandwidthConstraint(BandwidthResource.of(v, unit));
+ return new BandwidthConstraint(Bandwidth.of(v, unit));
}
// Constructor for serialization
@@ -68,7 +68,7 @@ public final class BandwidthConstraint extends BooleanConstraint {
for (ResourceRequest request : resourceService.getAvailableResources(link)) {
if (request.type() == ResourceType.BANDWIDTH) {
BandwidthResourceRequest brr = (BandwidthResourceRequest) request;
- if (brr.bandwidth().toDouble() >= bandwidth.toDouble()) {
+ if (brr.bandwidth().toDouble() >= bandwidth.bps()) {
return true;
}
}
@@ -81,7 +81,7 @@ public final class BandwidthConstraint extends BooleanConstraint {
*
* @return required bandwidth
*/
- public BandwidthResource bandwidth() {
+ public Bandwidth bandwidth() {
return bandwidth;
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java
new file mode 100644
index 00000000..e8539398
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java
@@ -0,0 +1,83 @@
+/*
+ * 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.intent.constraint;
+
+
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.Link;
+import org.onosproject.net.resource.link.LinkResourceService;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Encapsulation to manage core transportation.
+ */
+public class EncapsulationConstraint extends BooleanConstraint {
+
+ private EncapsulationType encapType;
+
+ /**
+ * Creates a new encapsulation constraint.
+ *
+ * @param encapType the encapsulation type {@link EncapsulationType}
+ */
+ public EncapsulationConstraint(EncapsulationType encapType) {
+ checkNotNull(encapType, "EncapsulationType cannot be null");
+ this.encapType = encapType;
+ }
+
+
+ @Override
+ public boolean isValid(Link link, LinkResourceService resourceService) {
+ //TODO: validate the availability of the resources for each link in the path.
+ //e.g., availability of MPLSlabels, VLANID
+
+ return true;
+ }
+
+ /**
+ * Returns the encapsulation type required by this constraint.
+ *
+ * @return encapType
+ */
+ public EncapsulationType encapType() {
+ return encapType;
+ }
+
+ @Override
+ public int hashCode() {
+ return encapType.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+ final EncapsulationConstraint other = (EncapsulationConstraint) obj;
+ return this.encapType() == other.encapType();
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("encapType", encapType).toString();
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
index 7811a004..eba28984 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
@@ -16,8 +16,8 @@
package org.onosproject.net.intent.constraint;
import com.google.common.annotations.Beta;
+import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.LambdaResource;
import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
@@ -32,14 +32,14 @@ import static com.google.common.base.MoreObjects.toStringHelper;
@Beta
public class LambdaConstraint extends BooleanConstraint {
- private final LambdaResource lambda;
+ private final IndexedLambda lambda;
/**
* Creates a new optical lambda constraint.
*
* @param lambda optional lambda to indicate a specific lambda
*/
- public LambdaConstraint(LambdaResource lambda) {
+ public LambdaConstraint(IndexedLambda lambda) {
this.lambda = lambda;
}
@@ -63,7 +63,7 @@ public class LambdaConstraint extends BooleanConstraint {
*
* @return required lambda
*/
- public LambdaResource lambda() {
+ public IndexedLambda lambda() {
return lambda;
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java
index cdcd4072..28c429bd 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java
@@ -16,8 +16,8 @@
package org.onosproject.net.newresource;
import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
-import java.util.Arrays;
import java.util.List;
/**
@@ -26,50 +26,42 @@ import java.util.List;
@Beta
public interface ResourceAdminService {
/**
- * Registers resources as the children of the parent resource path.
+ * Registers the specified resources.
*
- * @param parent parent resource path under which the resource are registered
- * @param children resources to be registered as the children of the parent
- * @param <T> type of resources
+ * @param resources resources to be registered
* @return true if registration is successfully done, false otherwise. Registration
* succeeds when each resource is not registered or unallocated.
*/
- default <T> boolean registerResources(ResourcePath parent, T... children) {
- return registerResources(parent, Arrays.asList(children));
+ default boolean registerResources(ResourcePath... resources) {
+ return registerResources(ImmutableList.copyOf(resources));
}
/**
- * Registers resources as the children of the parent resource path.
+ * Registers the specified resources.
*
- * @param parent parent resource path under which the resource are registered
- * @param children resources to be registered as the children of the parent
- * @param <T> type of resources
+ * @param resources resources to be registered
* @return true if registration is successfully done, false otherwise. Registration
* succeeds when each resource is not registered or unallocated.
*/
- <T> boolean registerResources(ResourcePath parent, List<T> children);
+ boolean registerResources(List<ResourcePath> resources);
/**
- * Unregisters resources as the children of the parent resource path.
+ * Unregisters the specified resources.
*
- * @param parent parent resource path under which the resource are unregistered
- * @param children resources to be unregistered as the children of the parent
- * @param <T> type of resources
+ * @param resources resources to be unregistered
* @return true if unregistration is successfully done, false otherwise. Unregistration
* succeeds when each resource is not registered or unallocated.
*/
- default <T> boolean unregisterResources(ResourcePath parent, T... children) {
- return unregisterResources(parent, Arrays.asList(children));
+ default boolean unregisterResources(ResourcePath... resources) {
+ return unregisterResources(ImmutableList.copyOf(resources));
}
/**
- * Unregisters resources as the children of the parent resource path.
+ * Unregisters the specified resources.
*
- * @param parent parent resource path under which the resource are unregistered
- * @param children resources to be unregistered as the children of the parent
- * @param <T> type of resources
+ * @param resources resources to be unregistered
* @return true if unregistration is successfully done, false otherwise. Unregistration
* succeeds when each resource is not registered or unallocated.
*/
- <T> boolean unregisterResources(ResourcePath parent, List<T> children);
+ boolean unregisterResources(List<ResourcePath> resources);
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java
index d87682a9..c0c4e34f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java
@@ -56,6 +56,7 @@ public abstract class ResourcePath {
* Creates an resource path which represents a discrete-type resource from the specified components.
*
* @param components components of the path. The order represents hierarchical structure of the resource.
+ * @return resource path instance
*/
public static ResourcePath discrete(Object... components) {
if (components.length == 0) {
@@ -70,6 +71,7 @@ public abstract class ResourcePath {
*
* @param value amount of the resource
* @param components components of the path. The order represents hierarchical structure of the resource.
+ * @return resource path instance
*/
public static ResourcePath continuous(double value, Object... components) {
return new Continuous(ImmutableList.copyOf(components), value);
@@ -141,12 +143,27 @@ public abstract class ResourcePath {
return Optional.ofNullable(parent);
}
+ /**
+ * Returns a child resource path of this instance with specifying the child object.
+ * The child resource path is discrete-type.
+ *
+ * @param child child object
+ * @return a child resource path
+ */
public ResourcePath child(Object child) {
checkState(this instanceof Discrete);
return new Discrete((Discrete) this, child);
}
+ /**
+ * Returns a child resource path of this instance with specifying a child object and
+ * value. The child resource path is continuous-type.
+ *
+ * @param child child object
+ * @param value value
+ * @return a child resource path
+ */
public ResourcePath child(Object child, double value) {
checkState(this instanceof Discrete);
@@ -197,6 +214,7 @@ public abstract class ResourcePath {
* implementation only. It is not for resource API user.
* </p>
*/
+ @Beta
public static final class Discrete extends ResourcePath {
private Discrete() {
super();
@@ -218,6 +236,7 @@ public abstract class ResourcePath {
* Note: This class is exposed to the public, but intended to be used in the resource API
* implementation only. It is not for resource API user.
*/
+ @Beta
public static final class Continuous extends ResourcePath {
// Note: value is not taken into account for equality
private final double value;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java
index b57465f2..583570f5 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java
@@ -201,7 +201,7 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest {
return addLambdaRequest();
} else if (constraint instanceof BandwidthConstraint) {
BandwidthConstraint bw = (BandwidthConstraint) constraint;
- return addBandwidthRequest(bw.bandwidth().toDouble());
+ return addBandwidthRequest(bw.bandwidth().bps());
}
return this;
}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/config/ConfigTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/config/ConfigTest.java
new file mode 100644
index 00000000..34b0fe7b
--- /dev/null
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/config/ConfigTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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.config;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.onosproject.net.config.Config.FieldPresence.MANDATORY;
+import static org.onosproject.net.config.Config.FieldPresence.OPTIONAL;
+
+/**
+ * Test of the base network config class.
+ */
+public class ConfigTest {
+
+ private static final String SUBJECT = "subject";
+ private static final String KEY = "key";
+
+ private static final String TEXT = "text";
+ private static final String LONG = "long";
+ private static final String DOUBLE = "double";
+ private static final String MAC = "mac";
+ private static final String IP = "ip";
+
+ private final ObjectMapper mapper = new ObjectMapper();
+ private final ConfigApplyDelegate delegate = new TestDelegate();
+
+ private Config<String> cfg;
+ private JsonNode json;
+
+ @Before
+ public void setUp() {
+ json = new ObjectMapper().createObjectNode()
+ .put(TEXT, "foo").put(LONG, 5).put(DOUBLE, 0.5)
+ .put(MAC, "ab:cd:ef:ca:fe:ed").put(IP, "12.34.56.78");
+ cfg = new TestConfig();
+ cfg.init(SUBJECT, KEY, json, mapper, delegate);
+ }
+
+ @Test
+ public void hasOnlyFields() {
+ assertTrue("has unexpected fields", cfg.hasOnlyFields(TEXT, LONG, DOUBLE, MAC, IP));
+ assertFalse("did not detect unexpected fields", cfg.hasOnlyFields(TEXT, LONG, DOUBLE, MAC));
+ assertTrue("is not proper text", cfg.isString(TEXT, MANDATORY));
+ }
+
+ @Test
+ public void isString() {
+ assertTrue("is not proper text", cfg.isString(TEXT, MANDATORY));
+ assertTrue("is not proper text", cfg.isString(TEXT, MANDATORY, "^f.*"));
+ assertTrue("is not proper text", cfg.isString(TEXT, OPTIONAL, "^f.*"));
+ assertTrue("is not proper text", cfg.isString(TEXT, OPTIONAL));
+ assertTrue("is not proper text", cfg.isString("none", OPTIONAL));
+ assertFalse("did not detect missing field", cfg.isString("none", MANDATORY));
+ }
+
+ @Test
+ public void isNumber() {
+ assertTrue("is not proper number", cfg.isNumber(LONG, MANDATORY));
+ assertTrue("is not proper number", cfg.isNumber(LONG, MANDATORY, 0));
+ assertTrue("is not proper number", cfg.isNumber(LONG, MANDATORY, 0, 10));
+ assertTrue("is not proper number", cfg.isNumber(LONG, MANDATORY, 5, 6));
+ assertFalse("is not in range", cfg.isNumber(LONG, MANDATORY, 6, 10));
+ assertFalse("is not in range", cfg.isNumber(LONG, MANDATORY, 4, 5));
+ assertTrue("is not proper number", cfg.isNumber(LONG, OPTIONAL, 0, 10));
+ assertTrue("is not proper number", cfg.isNumber(LONG, OPTIONAL));
+ assertTrue("is not proper number", cfg.isNumber("none", OPTIONAL));
+ assertFalse("did not detect missing field", cfg.isNumber("none", MANDATORY));
+ }
+
+ @Test
+ public void isDecimal() {
+ assertTrue("is not proper decimal", cfg.isDecimal(DOUBLE, MANDATORY));
+ assertTrue("is not proper decimal", cfg.isDecimal(DOUBLE, MANDATORY, 0.0));
+ assertTrue("is not proper decimal", cfg.isDecimal(DOUBLE, MANDATORY, 0.0, 1.0));
+ assertTrue("is not proper decimal", cfg.isDecimal(DOUBLE, MANDATORY, 0.5, 0.6));
+ assertFalse("is not in range", cfg.isDecimal(DOUBLE, MANDATORY, 0.6, 1.0));
+ assertFalse("is not in range", cfg.isDecimal(DOUBLE, MANDATORY, 0.4, 0.5));
+ assertTrue("is not proper decimal", cfg.isDecimal(DOUBLE, OPTIONAL, 0.0, 1.0));
+ assertTrue("is not proper decimal", cfg.isDecimal(DOUBLE, OPTIONAL));
+ assertTrue("is not proper decimal", cfg.isDecimal("none", OPTIONAL));
+ assertFalse("did not detect missing field", cfg.isDecimal("none", MANDATORY));
+ }
+
+ @Test
+ public void isMacAddress() {
+ assertTrue("is not proper mac", cfg.isMacAddress(MAC, MANDATORY));
+ assertTrue("is not proper mac", cfg.isMacAddress(MAC, OPTIONAL));
+ assertTrue("is not proper mac", cfg.isMacAddress("none", OPTIONAL));
+ assertFalse("did not detect missing field", cfg.isMacAddress("none", MANDATORY));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void badMacAddress() {
+ assertTrue("is not proper mac", cfg.isMacAddress(TEXT, MANDATORY));
+ }
+
+
+ @Test
+ public void isIpAddress() {
+ assertTrue("is not proper ip", cfg.isIpAddress(IP, MANDATORY));
+ assertTrue("is not proper ip", cfg.isIpAddress(IP, OPTIONAL));
+ assertTrue("is not proper ip", cfg.isIpAddress("none", OPTIONAL));
+ assertFalse("did not detect missing field", cfg.isMacAddress("none", MANDATORY));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void badIpAddress() {
+ assertTrue("is not proper ip", cfg.isIpAddress(TEXT, MANDATORY));
+ }
+
+
+ // TODO: Add tests for other helper methods
+
+ private class TestConfig extends Config<String> {
+ }
+
+ private class TestDelegate implements ConfigApplyDelegate {
+ @Override
+ public void onApply(Config config) {
+ }
+ }
+} \ No newline at end of file
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 d86744df..56a6ff63 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
@@ -42,6 +42,7 @@ import org.onosproject.net.OduSignalType;
import org.onosproject.net.PortNumber;
import com.google.common.testing.EqualsTester;
+
/**
* Unit tests for the Criteria class and its subclasses.
*/
@@ -135,6 +136,24 @@ public class CriteriaTest {
Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(tpPort1);
Criterion matchUdpPort2 = Criteria.matchUdpDst(tpPort2);
+
+ int tcpFlags1 =
+ Criterion.TCPFlags.NS.getValue() |
+ Criterion.TCPFlags.CWR.getValue() |
+ Criterion.TCPFlags.ECE.getValue() |
+ Criterion.TCPFlags.URG.getValue() |
+ Criterion.TCPFlags.ACK.getValue() |
+ Criterion.TCPFlags.PSH.getValue() |
+ Criterion.TCPFlags.RST.getValue() |
+ Criterion.TCPFlags.SYN.getValue();
+
+ int tcpFlags2 = tcpFlags1 |
+ Criterion.TCPFlags.FIN.getValue();
+
+ Criterion matchTcpFlags1 = Criteria.matchTcpFlags(tcpFlags1);
+ Criterion sameAsmatchTcpFlags1 = Criteria.matchTcpFlags(tcpFlags1);
+ Criterion matchTcpFlags2 = Criteria.matchTcpFlags(tcpFlags2);
+
Criterion matchSctpPort1 = Criteria.matchSctpSrc(tpPort1);
Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(tpPort1);
Criterion matchSctpPort2 = Criteria.matchSctpDst(tpPort2);
@@ -174,28 +193,28 @@ public class CriteriaTest {
private Ip6Address ip6TargetAddress1 = Ip6Address.valueOf(IPV6_ADDR1);
private Ip6Address ip6TargetAddress2 = Ip6Address.valueOf(IPV6_ADDR2);
Criterion matchIpv6TargetAddr1 =
- Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1);
+ Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1);
Criterion sameAsMatchIpv6TargetAddr1 =
- Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1);
+ Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1);
Criterion matchIpv6TargetAddr2 =
- Criteria.matchIPv6NDTargetAddress(ip6TargetAddress2);
+ Criteria.matchIPv6NDTargetAddress(ip6TargetAddress2);
private static final String LL_MAC1 = "00:00:00:00:00:01";
private static final String LL_MAC2 = "00:00:00:00:00:02";
private MacAddress llMac1 = MacAddress.valueOf(LL_MAC1);
private MacAddress llMac2 = MacAddress.valueOf(LL_MAC2);
Criterion matchSrcLlAddr1 =
- Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1);
+ Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1);
Criterion sameAsMatchSrcLlAddr1 =
- Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1);
+ Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1);
Criterion matchSrcLlAddr2 =
- Criteria.matchIPv6NDSourceLinkLayerAddress(llMac2);
+ Criteria.matchIPv6NDSourceLinkLayerAddress(llMac2);
Criterion matchTargetLlAddr1 =
- Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1);
+ Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1);
Criterion sameAsMatchTargetLlAddr1 =
- Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1);
+ Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1);
Criterion matchTargetLlAddr2 =
- Criteria.matchIPv6NDTargetLinkLayerAddress(llMac2);
+ Criteria.matchIPv6NDTargetLinkLayerAddress(llMac2);
MplsLabel mpls1 = MplsLabel.mplsLabel(1);
MplsLabel mpls2 = MplsLabel.mplsLabel(2);
@@ -219,13 +238,13 @@ public class CriteriaTest {
Criterion.IPv6ExthdrFlags.HOP.getValue() |
Criterion.IPv6ExthdrFlags.UNREP.getValue();
int ipv6ExthdrFlags2 = ipv6ExthdrFlags1 |
- Criterion.IPv6ExthdrFlags.UNSEQ.getValue();
+ Criterion.IPv6ExthdrFlags.UNSEQ.getValue();
Criterion matchIpv6ExthdrFlags1 =
- Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
+ Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
Criterion sameAsMatchIpv6ExthdrFlags1 =
- Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
+ Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
Criterion matchIpv6ExthdrFlags2 =
- Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags2);
+ Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags2);
Criterion matchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID);
Criterion sameAsMatchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID);
@@ -242,8 +261,8 @@ 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});
+ 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);
@@ -259,9 +278,9 @@ public class CriteriaTest {
* it to the proper type.
*
* @param criterion Criterion object to convert
- * @param type Enumerated type value for the Criterion class
- * @param clazz Desired Criterion class
- * @param <T> The type the caller wants returned
+ * @param type Enumerated type value for the Criterion class
+ * @param clazz Desired Criterion class
+ * @param <T> The type the caller wants returned
* @return converted object
*/
@SuppressWarnings("unchecked")
@@ -297,6 +316,7 @@ public class CriteriaTest {
assertThatClassIsImmutable(IPCriterion.class);
assertThatClassIsImmutable(TcpPortCriterion.class);
assertThatClassIsImmutable(UdpPortCriterion.class);
+ assertThatClassIsImmutable(TcpFlagsCriterion.class);
assertThatClassIsImmutable(SctpPortCriterion.class);
assertThatClassIsImmutable(IcmpTypeCriterion.class);
assertThatClassIsImmutable(IcmpCodeCriterion.class);
@@ -395,8 +415,8 @@ public class CriteriaTest {
Criterion matchEthDst = Criteria.matchEthDst(mac1);
EthCriterion ethCriterion =
checkAndConvert(matchEthDst,
- Criterion.Type.ETH_DST,
- EthCriterion.class);
+ Criterion.Type.ETH_DST,
+ EthCriterion.class);
assertThat(ethCriterion.mac(), is(equalTo(mac1)));
}
@@ -461,8 +481,8 @@ public class CriteriaTest {
Criterion matchVlanId = Criteria.matchVlanId(vlanId1);
VlanIdCriterion vlanIdCriterion =
checkAndConvert(matchVlanId,
- Criterion.Type.VLAN_VID,
- VlanIdCriterion.class);
+ Criterion.Type.VLAN_VID,
+ VlanIdCriterion.class);
assertThat(vlanIdCriterion.vlanId(), is(equalTo(vlanId1)));
}
@@ -487,8 +507,8 @@ public class CriteriaTest {
Criterion matchVlanPcp = Criteria.matchVlanPcp(vlanPcp1);
VlanPcpCriterion vlanPcpCriterion =
checkAndConvert(matchVlanPcp,
- Criterion.Type.VLAN_PCP,
- VlanPcpCriterion.class);
+ Criterion.Type.VLAN_PCP,
+ VlanPcpCriterion.class);
assertThat(vlanPcpCriterion.priority(), is(equalTo(vlanPcp1)));
}
@@ -513,8 +533,8 @@ public class CriteriaTest {
Criterion matchIPDscp = Criteria.matchIPDscp(ipDscp1);
IPDscpCriterion ipDscpCriterion =
checkAndConvert(matchIPDscp,
- Criterion.Type.IP_DSCP,
- IPDscpCriterion.class);
+ Criterion.Type.IP_DSCP,
+ IPDscpCriterion.class);
assertThat(ipDscpCriterion.ipDscp(), is(equalTo(ipDscp1)));
}
@@ -539,8 +559,8 @@ public class CriteriaTest {
Criterion matchIPEcn = Criteria.matchIPEcn(ipEcn1);
IPEcnCriterion ipEcnCriterion =
checkAndConvert(matchIPEcn,
- Criterion.Type.IP_ECN,
- IPEcnCriterion.class);
+ Criterion.Type.IP_ECN,
+ IPEcnCriterion.class);
assertThat(ipEcnCriterion.ipEcn(), is(equalTo(ipEcn1)));
}
@@ -565,8 +585,8 @@ public class CriteriaTest {
Criterion matchIPProtocol = Criteria.matchIPProtocol(protocol1);
IPProtocolCriterion ipProtocolCriterion =
checkAndConvert(matchIPProtocol,
- Criterion.Type.IP_PROTO,
- IPProtocolCriterion.class);
+ Criterion.Type.IP_PROTO,
+ IPProtocolCriterion.class);
assertThat(ipProtocolCriterion.protocol(), is(equalTo(protocol1)));
}
@@ -604,8 +624,8 @@ public class CriteriaTest {
Criterion matchIPDst = Criteria.matchIPDst(ip1);
IPCriterion ipCriterion =
checkAndConvert(matchIPDst,
- Criterion.Type.IPV4_DST,
- IPCriterion.class);
+ Criterion.Type.IPV4_DST,
+ IPCriterion.class);
assertThat(ipCriterion.ip(), is(equalTo(ip1)));
}
@@ -617,8 +637,8 @@ public class CriteriaTest {
Criterion matchIpv6Src = Criteria.matchIPv6Src(ipv61);
IPCriterion ipCriterion =
checkAndConvert(matchIpv6Src,
- Criterion.Type.IPV6_SRC,
- IPCriterion.class);
+ Criterion.Type.IPV6_SRC,
+ IPCriterion.class);
assertThat(ipCriterion.ip(), is(ipv61));
}
@@ -630,8 +650,8 @@ public class CriteriaTest {
Criterion matchIPv6Dst = Criteria.matchIPv6Dst(ipv61);
IPCriterion ipCriterion =
checkAndConvert(matchIPv6Dst,
- Criterion.Type.IPV6_DST,
- IPCriterion.class);
+ Criterion.Type.IPV6_DST,
+ IPCriterion.class);
assertThat(ipCriterion.ip(), is(equalTo(ipv61)));
}
@@ -674,8 +694,8 @@ public class CriteriaTest {
Criterion matchTcpDst = Criteria.matchTcpDst(tpPort1);
TcpPortCriterion tcpPortCriterion =
checkAndConvert(matchTcpDst,
- Criterion.Type.TCP_DST,
- TcpPortCriterion.class);
+ Criterion.Type.TCP_DST,
+ TcpPortCriterion.class);
assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1)));
}
@@ -713,8 +733,8 @@ public class CriteriaTest {
Criterion matchUdpDst = Criteria.matchUdpDst(tpPort1);
UdpPortCriterion udpPortCriterion =
checkAndConvert(matchUdpDst,
- Criterion.Type.UDP_DST,
- UdpPortCriterion.class);
+ Criterion.Type.UDP_DST,
+ UdpPortCriterion.class);
assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1)));
}
@@ -729,6 +749,19 @@ public class CriteriaTest {
.testEquals();
}
+ // TcpFlagsCriterion class
+
+ /**
+ * Test the equals() method of the TcpFlagsCriterion class.
+ */
+ @Test
+ public void testTcpFlagsCriterionEquals() {
+ new EqualsTester()
+ .addEqualityGroup(matchTcpFlags1, sameAsmatchTcpFlags1)
+ .addEqualityGroup(matchTcpFlags2)
+ .testEquals();
+ }
+
// SctpPortCriterion class
/**
@@ -752,8 +785,8 @@ public class CriteriaTest {
Criterion matchSctpDst = Criteria.matchSctpDst(tpPort1);
SctpPortCriterion sctpPortCriterion =
checkAndConvert(matchSctpDst,
- Criterion.Type.SCTP_DST,
- SctpPortCriterion.class);
+ Criterion.Type.SCTP_DST,
+ SctpPortCriterion.class);
assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1)));
}
@@ -911,7 +944,7 @@ public class CriteriaTest {
@Test
public void testMatchIPv6NDTargetAddressMethod() {
Criterion matchTargetAddress =
- Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1);
+ Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1);
IPv6NDTargetAddressCriterion targetAddressCriterion =
checkAndConvert(matchTargetAddress,
Criterion.Type.IPV6_ND_TARGET,
@@ -940,11 +973,11 @@ public class CriteriaTest {
@Test
public void testMatchIPv6NDSourceLinkLayerAddressMethod() {
Criterion matchSrcLlAddr =
- Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1);
+ Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1);
IPv6NDLinkLayerAddressCriterion srcLlCriterion =
checkAndConvert(matchSrcLlAddr,
- Criterion.Type.IPV6_ND_SLL,
- IPv6NDLinkLayerAddressCriterion.class);
+ Criterion.Type.IPV6_ND_SLL,
+ IPv6NDLinkLayerAddressCriterion.class);
assertThat(srcLlCriterion.mac(), is(equalTo(llMac1)));
}
@@ -954,11 +987,11 @@ public class CriteriaTest {
@Test
public void testMatchIPv6NDTargetLinkLayerAddressMethod() {
Criterion matchTargetLlAddr =
- Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1);
+ Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1);
IPv6NDLinkLayerAddressCriterion targetLlCriterion =
checkAndConvert(matchTargetLlAddr,
- Criterion.Type.IPV6_ND_TLL,
- IPv6NDLinkLayerAddressCriterion.class);
+ Criterion.Type.IPV6_ND_TLL,
+ IPv6NDLinkLayerAddressCriterion.class);
assertThat(targetLlCriterion.mac(), is(equalTo(llMac1)));
}
@@ -988,8 +1021,8 @@ public class CriteriaTest {
Criterion matchMplsLabel = Criteria.matchMplsLabel(mpls1);
MplsCriterion mplsCriterion =
checkAndConvert(matchMplsLabel,
- Criterion.Type.MPLS_LABEL,
- MplsCriterion.class);
+ Criterion.Type.MPLS_LABEL,
+ MplsCriterion.class);
assertThat(mplsCriterion.label(), is(equalTo(mpls1)));
}
@@ -1025,10 +1058,10 @@ public class CriteriaTest {
*/
@Test
public void testTunnelIdCriterionEquals() {
- new EqualsTester()
- .addEqualityGroup(matchTunnelId1, sameAsMatchTunnelId1)
- .addEqualityGroup(matchTunnelId2)
- .testEquals();
+ new EqualsTester()
+ .addEqualityGroup(matchTunnelId1, sameAsMatchTunnelId1)
+ .addEqualityGroup(matchTunnelId2)
+ .testEquals();
}
// IPv6ExthdrFlagsCriterion class
@@ -1039,11 +1072,11 @@ public class CriteriaTest {
@Test
public void testMatchIPv6ExthdrFlagsMethod() {
Criterion matchExthdrFlags =
- Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
+ Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
IPv6ExthdrFlagsCriterion exthdrFlagsCriterion =
checkAndConvert(matchExthdrFlags,
- Criterion.Type.IPV6_EXTHDR,
- IPv6ExthdrFlagsCriterion.class);
+ Criterion.Type.IPV6_EXTHDR,
+ IPv6ExthdrFlagsCriterion.class);
assertThat(exthdrFlagsCriterion.exthdrFlags(),
is(equalTo(ipv6ExthdrFlags1)));
}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
index 88fa7f4f..dd371c15 100644
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
@@ -22,11 +22,11 @@ import java.util.Set;
import org.junit.Test;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Link;
import org.onosproject.net.NetTestTools;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.intent.constraint.LambdaConstraint;
-import org.onosproject.net.resource.link.LambdaResource;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.EqualsTester;
@@ -132,7 +132,7 @@ public class LinkCollectionIntentTest extends IntentTest {
final LinkedList<Constraint> constraints = new LinkedList<>();
links1.add(link("src", 1, "dst", 2));
- constraints.add(new LambdaConstraint(LambdaResource.valueOf(23)));
+ constraints.add(new LambdaConstraint(new IndexedLambda(23)));
final LinkCollectionIntent collectionIntent =
LinkCollectionIntent.builder()
.appId(APP_ID)
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java
index 743fc252..d2e99400 100644
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java
@@ -17,9 +17,8 @@ package org.onosproject.net.intent.constraint;
import org.junit.Test;
import org.onlab.util.Bandwidth;
+import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.BandwidthResource;
-import org.onosproject.net.resource.link.LambdaResource;
import com.google.common.testing.EqualsTester;
@@ -39,21 +38,18 @@ public class ConstraintObjectsTest {
private final Bandwidth sameAsBandwidth1 = Bandwidth.bps(100.0);
private final Bandwidth bandwidth2 = Bandwidth.bps(200.0);
- final BandwidthConstraint bandwidthConstraint1 =
- new BandwidthConstraint(new BandwidthResource(bandwidth1));
- final BandwidthConstraint bandwidthConstraintSameAs1 =
- new BandwidthConstraint(new BandwidthResource(sameAsBandwidth1));
- final BandwidthConstraint bandwidthConstraint2 =
- new BandwidthConstraint(new BandwidthResource(bandwidth2));
+ final BandwidthConstraint bandwidthConstraint1 = new BandwidthConstraint(bandwidth1);
+ final BandwidthConstraint bandwidthConstraintSameAs1 = new BandwidthConstraint(sameAsBandwidth1);
+ final BandwidthConstraint bandwidthConstraint2 = new BandwidthConstraint(bandwidth2);
/**
* Checks that the objects were created properly.
*/
@Test
public void testBandwidthConstraintCreation() {
- assertThat(bandwidthConstraint1.bandwidth().toDouble(), is(equalTo(100.0)));
- assertThat(bandwidthConstraintSameAs1.bandwidth().toDouble(), is(equalTo(100.0)));
- assertThat(bandwidthConstraint2.bandwidth().toDouble(), is(equalTo(200.0)));
+ assertThat(bandwidthConstraint1.bandwidth().bps(), is(equalTo(100.0)));
+ assertThat(bandwidthConstraintSameAs1.bandwidth().bps(), is(equalTo(100.0)));
+ assertThat(bandwidthConstraint2.bandwidth().bps(), is(equalTo(200.0)));
}
/**
@@ -70,20 +66,20 @@ public class ConstraintObjectsTest {
// Lambda Constraint
final LambdaConstraint lambdaConstraint1 =
- new LambdaConstraint(LambdaResource.valueOf(100));
+ new LambdaConstraint(new IndexedLambda(100));
final LambdaConstraint lambdaConstraintSameAs1 =
- new LambdaConstraint(LambdaResource.valueOf(100));
+ new LambdaConstraint(new IndexedLambda(100));
final LambdaConstraint lambdaConstraint2 =
- new LambdaConstraint(LambdaResource.valueOf(200));
+ new LambdaConstraint(new IndexedLambda(200));
/**
* Checks that the objects were created properly.
*/
@Test
public void testLambdaConstraintCreation() {
- assertThat(lambdaConstraint1.lambda().toInt(), is(equalTo(100)));
- assertThat(lambdaConstraintSameAs1.lambda().toInt(), is(equalTo(100)));
- assertThat(lambdaConstraint2.lambda().toInt(), is(equalTo(200)));
+ assertThat(lambdaConstraint1.lambda().index(), is(equalTo(100L)));
+ assertThat(lambdaConstraintSameAs1.lambda().index(), is(equalTo(100L)));
+ assertThat(lambdaConstraint2.lambda().index(), is(equalTo(200L)));
}
/**
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CodecManager.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CodecManager.java
index 3433b3b7..c7af4e5b 100644
--- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CodecManager.java
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CodecManager.java
@@ -38,6 +38,7 @@ import org.onosproject.net.driver.Driver;
import org.onosproject.net.flow.FlowEntry;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TableStatisticsEntry;
+import org.onosproject.net.device.PortStatistics;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criterion;
@@ -102,6 +103,7 @@ public class CodecManager implements CodecService {
registerCodec(GroupBucket.class, new GroupBucketCodec());
registerCodec(Load.class, new LoadCodec());
registerCodec(TableStatisticsEntry.class, new TableStatisticsEntryCodec());
+ registerCodec(PortStatistics.class, new PortStatisticsCodec());
log.info("Started");
}
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeConstraintCodecHelper.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeConstraintCodecHelper.java
index 5746003c..40c553d9 100644
--- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeConstraintCodecHelper.java
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeConstraintCodecHelper.java
@@ -32,8 +32,6 @@ import org.onosproject.net.intent.constraint.LatencyConstraint;
import org.onosproject.net.intent.constraint.LinkTypeConstraint;
import org.onosproject.net.intent.constraint.ObstacleConstraint;
import org.onosproject.net.intent.constraint.WaypointConstraint;
-import org.onosproject.net.resource.link.BandwidthResource;
-import org.onosproject.net.resource.link.LambdaResource;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -106,7 +104,7 @@ public final class DecodeConstraintCodecHelper {
ConstraintCodec.LAMBDA + ConstraintCodec.MISSING_MEMBER_MESSAGE)
.asLong();
- return new LambdaConstraint(LambdaResource.valueOf(new IndexedLambda(lambda)));
+ return new LambdaConstraint(new IndexedLambda(lambda));
}
/**
@@ -185,7 +183,7 @@ public final class DecodeConstraintCodecHelper {
ConstraintCodec.BANDWIDTH + ConstraintCodec.MISSING_MEMBER_MESSAGE)
.asDouble();
- return new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(bandwidth)));
+ return new BandwidthConstraint(Bandwidth.bps(bandwidth));
}
/**
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java
index 69c5e791..88cc3328 100644
--- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java
@@ -15,11 +15,8 @@
*/
package org.onosproject.codec.impl;
-import static org.onlab.util.Tools.nullIsIllegal;
-
-import java.util.HashMap;
-import java.util.Map;
-
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onlab.packet.Ip6Address;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
@@ -37,8 +34,10 @@ import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.criteria.Criteria;
import org.onosproject.net.flow.criteria.Criterion;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.onlab.util.Tools.nullIsIllegal;
/**
* Decode portion of the criterion codec.
@@ -106,12 +105,16 @@ public final class DecodeCriterionCodecHelper {
private class EthTypeDecoder implements CriterionDecoder {
@Override
public Criterion decodeCriterion(ObjectNode json) {
- int ethType = nullIsIllegal(json.get(CriterionCodec.ETH_TYPE),
- CriterionCodec.ETH_TYPE + MISSING_MEMBER_MESSAGE).asInt();
+ int ethType;
+ if (json.get(CriterionCodec.ETH_TYPE).isInt()) {
+ ethType = nullIsIllegal(json.get(CriterionCodec.ETH_TYPE),
+ CriterionCodec.ETH_TYPE + MISSING_MEMBER_MESSAGE).asInt();
+ } else {
+ ethType = Integer.decode(json.get(CriterionCodec.ETH_TYPE).textValue());
+ }
return Criteria.matchEthType(ethType);
}
}
-
private class EthDstDecoder implements CriterionDecoder {
@Override
public Criterion decodeCriterion(ObjectNode json) {
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeConstraintCodecHelper.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeConstraintCodecHelper.java
index 61f4dbf4..ec4ee444 100644
--- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeConstraintCodecHelper.java
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeConstraintCodecHelper.java
@@ -128,7 +128,7 @@ public final class EncodeConstraintCodecHelper {
final BandwidthConstraint bandwidthConstraint =
(BandwidthConstraint) constraint;
return context.mapper().createObjectNode()
- .put("bandwidth", bandwidthConstraint.bandwidth().toDouble());
+ .put("bandwidth", bandwidthConstraint.bandwidth().bps());
}
/**
@@ -142,7 +142,7 @@ public final class EncodeConstraintCodecHelper {
(LambdaConstraint) constraint;
return context.mapper().createObjectNode()
- .put("lambda", lambdaConstraint.lambda().toInt());
+ .put("lambda", lambdaConstraint.lambda().index());
}
/**
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 8fc6bbcf..33dd46a3 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
@@ -15,8 +15,7 @@
*/
package org.onosproject.codec.impl;
-import java.util.EnumMap;
-
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onlab.util.HexString;
import org.onosproject.codec.CodecContext;
import org.onosproject.net.OchSignal;
@@ -50,7 +49,7 @@ import org.onosproject.net.flow.criteria.UdpPortCriterion;
import org.onosproject.net.flow.criteria.VlanIdCriterion;
import org.onosproject.net.flow.criteria.VlanPcpCriterion;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.util.EnumMap;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -69,7 +68,7 @@ public final class EncodeCriterionCodecHelper {
* Initializes the formatter lookup map for the criterion subclasses.
*
* @param criterion Criterion to encode
- * @param context context of the JSON encoding
+ * @param context context of the JSON encoding
*/
public EncodeCriterionCodecHelper(Criterion criterion, CodecContext context) {
this.criterion = criterion;
@@ -171,7 +170,8 @@ public final class EncodeCriterionCodecHelper {
public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
final EthTypeCriterion ethTypeCriterion =
(EthTypeCriterion) criterion;
- return root.put(CriterionCodec.ETH_TYPE, ethTypeCriterion.ethType().toShort());
+ return root.put(CriterionCodec.ETH_TYPE, "0x"
+ + Integer.toHexString(ethTypeCriterion.ethType().toShort() & 0xffff));
}
}
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/FlowEntryCodec.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/FlowEntryCodec.java
index 923bdf2b..3f581bed 100644
--- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/FlowEntryCodec.java
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/FlowEntryCodec.java
@@ -39,6 +39,7 @@ public final class FlowEntryCodec extends JsonCodec<FlowEntry> {
final ObjectNode result = context.mapper().createObjectNode()
.put("id", Long.toString(flowEntry.id().value()))
+ .put("tableId", flowEntry.tableId())
.put("appId", service.getAppId(flowEntry.appId()).name())
.put("groupId", flowEntry.groupId().id())
.put("priority", flowEntry.priority())
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/PortStatisticsCodec.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/PortStatisticsCodec.java
new file mode 100644
index 00000000..e8b3c4c6
--- /dev/null
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/PortStatisticsCodec.java
@@ -0,0 +1,51 @@
+/*
+ * 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.codec.impl;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.net.device.PortStatistics;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Port statistics entry JSON codec.
+ */
+public final class PortStatisticsCodec extends JsonCodec<PortStatistics> {
+
+ @Override
+ public ObjectNode encode(PortStatistics entry, CodecContext context) {
+ checkNotNull(entry, "Port Statistics cannot be null");
+
+ final ObjectNode result = context.mapper().createObjectNode()
+ .put("port", entry.port())
+ .put("packetsReceived", entry.packetsReceived())
+ .put("packetsSent", entry.packetsSent())
+ .put("bytesReceived", entry.bytesReceived())
+ .put("bytesSent", entry.bytesSent())
+ .put("packetsRxDropped", entry.packetsRxDropped())
+ .put("packetsTxDropped", entry.packetsTxDropped())
+ .put("packetsRxErrors", entry.packetsRxErrors())
+ .put("packetsTxErrors", entry.packetsTxErrors())
+ .put("durationSec", entry.durationSec());
+
+ return result;
+ }
+
+}
+
diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/ConstraintCodecTest.java b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/ConstraintCodecTest.java
index 2a47d115..a84dab48 100644
--- a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/ConstraintCodecTest.java
+++ b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/ConstraintCodecTest.java
@@ -134,7 +134,7 @@ public class ConstraintCodecTest {
assertThat(constraint, instanceOf(BandwidthConstraint.class));
BandwidthConstraint bandwidthConstraint = (BandwidthConstraint) constraint;
- assertThat(bandwidthConstraint.bandwidth().toDouble(), is(345.678D));
+ assertThat(bandwidthConstraint.bandwidth().bps(), is(345.678D));
}
/**
@@ -146,7 +146,7 @@ public class ConstraintCodecTest {
assertThat(constraint, instanceOf(LambdaConstraint.class));
LambdaConstraint lambdaConstraint = (LambdaConstraint) constraint;
- assertThat(lambdaConstraint.lambda().toInt(), is(444));
+ assertThat(lambdaConstraint.lambda().index(), is(444L));
}
/**
diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
index b00632c3..7d8580a6 100644
--- a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
+++ b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
@@ -138,8 +138,8 @@ public final class CriterionJsonMatcher extends
* @return true if the JSON matches the criterion, false otherwise.
*/
private boolean matchCriterion(EthTypeCriterion criterion) {
- final int ethType = criterion.ethType().toShort();
- final int jsonEthType = jsonCriterion.get("ethType").intValue();
+ final int ethType = criterion.ethType().toShort() & 0xffff;
+ final int jsonEthType = Integer.decode(jsonCriterion.get("ethType").textValue()) & 0xffff;
if (ethType != jsonEthType) {
description.appendText("ethType was "
+ Integer.toString(jsonEthType));
diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
index 2f933966..596c7ef9 100644
--- a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
+++ b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
@@ -63,8 +63,6 @@ import org.onosproject.net.intent.constraint.LambdaConstraint;
import org.onosproject.net.intent.constraint.LatencyConstraint;
import org.onosproject.net.intent.constraint.ObstacleConstraint;
import org.onosproject.net.intent.constraint.WaypointConstraint;
-import org.onosproject.net.resource.link.BandwidthResource;
-import org.onosproject.net.resource.link.LambdaResource;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -181,8 +179,8 @@ public class IntentCodecTest extends AbstractIntentTest {
final List<Constraint> constraints =
ImmutableList.of(
- new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(1.0))),
- new LambdaConstraint(LambdaResource.valueOf(3)),
+ new BandwidthConstraint(Bandwidth.bps(1.0)),
+ new LambdaConstraint(new IndexedLambda(3)),
new AnnotationConstraint("key", 33.0),
new AsymmetricPathConstraint(),
new LatencyConstraint(Duration.ofSeconds(2)),
diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentJsonMatcher.java b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentJsonMatcher.java
index e485a5fa..acc1f0e8 100644
--- a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentJsonMatcher.java
+++ b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentJsonMatcher.java
@@ -141,7 +141,7 @@ public final class IntentJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNode>
final JsonNode bandwidthJson = constraintJson.get("bandwidth");
return bandwidthJson != null
&& constraintJson.get("bandwidth").asDouble()
- == bandwidthConstraint.bandwidth().toDouble();
+ == bandwidthConstraint.bandwidth().bps();
}
/**
@@ -157,7 +157,7 @@ public final class IntentJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNode>
final JsonNode lambdaJson = constraintJson.get("lambda");
return lambdaJson != null
&& constraintJson.get("lambda").asInt()
- == lambdaConstraint.lambda().toInt();
+ == lambdaConstraint.lambda().index();
}
/**
diff --git a/framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json b/framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json
index ccb2e161..82c0f59d 100644
--- a/framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json
+++ b/framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json
@@ -9,7 +9,7 @@
{"type":"IN_PORT", "port":23},
{"type":"IN_PHY_PORT", "port":44},
{"type":"METADATA", "metadata":123456},
- {"type":"ETH_TYPE","ethType":2054},
+ {"type":"ETH_TYPE","ethType":"0x806"},
{"type":"ETH_SRC","mac":"00:11:22:33:44:55"},
{"type":"ETH_DST","mac":"00:11:22:33:44:55"},
{"type":"VLAN_VID","vlanId":777},
diff --git a/framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json b/framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
index 74b9546a..2a184b34 100644
--- a/framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
+++ b/framework/src/onos/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
@@ -35,5 +35,5 @@
],
"deferred":[]
},
- "selector": {"criteria":[{"type":"ETH_TYPE","ethType":2054}]}
+ "selector": {"criteria":[{"type":"ETH_TYPE","ethType":"0x806"}]}
}
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
index d09eb1f1..80a5ca77 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
@@ -237,12 +237,22 @@ public class ApplicationManager
boolean changed = false;
for (String name : app.features()) {
Feature feature = featuresService.getFeature(name);
+
+ // If we see an attempt at activation of a non-existent feature
+ // attempt to install the app artifacts first and then retry.
+ // This can be triggered by a race condition between different ONOS
+ // instances "installing" the apps from disk at their own pace.
+ // Perhaps there is a more elegant solution to be explored in the
+ // future.
+ if (feature == null) {
+ installAppArtifacts(app);
+ feature = featuresService.getFeature(name);
+ }
+
if (feature != null && !featuresService.isInstalled(feature)) {
featuresService.installFeature(name);
changed = true;
- } else if (feature == null && !initializing) {
- // Suppress feature-not-found reporting during startup since these
- // can arise naturally from the staggered cluster install.
+ } else if (feature == null) {
log.warn("Feature {} not found", name);
}
}
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java
index a76a298f..5ecdc7a2 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java
@@ -54,6 +54,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@@ -226,10 +227,11 @@ public class FlowObjectiveManager implements FlowObjectiveService {
if (fwd.nextId() != null &&
flowObjectiveStore.getNextGroup(fwd.nextId()) == null) {
log.trace("Queuing forwarding objective for nextId {}", fwd.nextId());
- if (pendingForwards.putIfAbsent(fwd.nextId(),
- Sets.newHashSet(new PendingNext(deviceId, fwd))) != null) {
- Set<PendingNext> pending = pendingForwards.get(fwd.nextId());
- pending.add(new PendingNext(deviceId, fwd));
+ // TODO: change to computeIfAbsent
+ Set<PendingNext> pnext = pendingForwards.putIfAbsent(fwd.nextId(),
+ Sets.newHashSet(new PendingNext(deviceId, fwd)));
+ if (pnext != null) {
+ pnext.add(new PendingNext(deviceId, fwd));
}
return true;
}
@@ -412,5 +414,26 @@ public class FlowObjectiveManager implements FlowObjectiveService {
public ForwardingObjective forwardingObjective() {
return fwd;
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(deviceId, fwd);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof PendingNext)) {
+ return false;
+ }
+ final PendingNext other = (PendingNext) obj;
+ if (this.deviceId.equals(other.deviceId) &&
+ this.fwd.equals(other.fwd)) {
+ return true;
+ }
+ return false;
+ }
}
}
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
index 4dc93a51..5fb1dcf1 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
@@ -168,7 +168,9 @@ public class HostMonitor implements TimerTask {
}
}
- this.timeout = Timer.getTimer().newTimeout(this, probeRate, TimeUnit.MILLISECONDS);
+ synchronized (this) {
+ this.timeout = Timer.getTimer().newTimeout(this, probeRate, TimeUnit.MILLISECONDS);
+ }
}
/**
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
index a4ed551a..2941ddba 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
@@ -189,6 +189,7 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
List<ResourceAllocation> allocations = resourceService.allocate(intent.id(), lambdaResources);
if (allocations.isEmpty()) {
log.info("Resource allocation for {} failed (resource request: {})", intent, lambdaResources);
+ return null;
}
return minLambda;
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java
index 066dd33e..4fb0d7ba 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java
@@ -15,14 +15,23 @@
*/
package org.onosproject.net.newresource.impl;
+import com.google.common.collect.Lists;
import org.onosproject.net.Device;
import org.onosproject.net.Port;
+import org.onosproject.net.OchPort;
+import org.onosproject.net.TributarySlot;
+import org.onosproject.net.OduSignalType;
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.newresource.ResourceAdminService;
import org.onosproject.net.newresource.ResourcePath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
import java.util.concurrent.ExecutorService;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -31,6 +40,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
final class ResourceDeviceListener implements DeviceListener {
+ private static final Logger log = LoggerFactory.getLogger(ResourceDeviceListener.class);
+
+ private static final int TOTAL_ODU2_TRIBUTARY_SLOTS = 8;
+ private static final int TOTAL_ODU4_TRIBUTARY_SLOTS = 80;
+ private static final List<TributarySlot> ENTIRE_ODU2_TRIBUTARY_SLOTS = getEntireOdu2TributarySlots();
+ private static final List<TributarySlot> ENTIRE_ODU4_TRIBUTARY_SLOTS = getEntireOdu4TributarySlots();
+
private final ResourceAdminService adminService;
private final ExecutorService executor;
@@ -67,20 +83,56 @@ final class ResourceDeviceListener implements DeviceListener {
}
private void registerDeviceResource(Device device) {
- executor.submit(() -> adminService.registerResources(ResourcePath.ROOT, device.id()));
+ executor.submit(() -> adminService.registerResources(ResourcePath.discrete(device.id())));
}
private void unregisterDeviceResource(Device device) {
- executor.submit(() -> adminService.unregisterResources(ResourcePath.ROOT, device.id()));
+ executor.submit(() -> adminService.unregisterResources(ResourcePath.discrete(device.id())));
}
private void registerPortResource(Device device, Port port) {
- ResourcePath parent = ResourcePath.discrete(device.id());
- executor.submit(() -> adminService.registerResources(parent, port.number()));
+ ResourcePath portPath = ResourcePath.discrete(device.id(), port.number());
+ executor.submit(() -> {
+ adminService.registerResources(portPath);
+
+ switch (port.type()) {
+ case OCH:
+ // register ODU TributarySlots against the OCH port
+ registerTributarySlotsResources(((OchPort) port).signalType(), portPath);
+ break;
+ default:
+ break;
+ }
+ });
+ }
+
+ private void registerTributarySlotsResources(OduSignalType oduSignalType, ResourcePath portPath) {
+ switch (oduSignalType) {
+ case ODU2:
+ adminService.registerResources(Lists.transform(ENTIRE_ODU2_TRIBUTARY_SLOTS, portPath::child));
+ break;
+ case ODU4:
+ adminService.registerResources(Lists.transform(ENTIRE_ODU4_TRIBUTARY_SLOTS, portPath::child));
+ break;
+ default:
+ break;
+ }
}
private void unregisterPortResource(Device device, Port port) {
- ResourcePath parent = ResourcePath.discrete(device.id());
- executor.submit(() -> adminService.unregisterResources(parent, port.number()));
+ ResourcePath resource = ResourcePath.discrete(device.id(), port.number());
+ executor.submit(() -> adminService.unregisterResources(resource));
}
+
+ private static List<TributarySlot> getEntireOdu2TributarySlots() {
+ return IntStream.rangeClosed(1, TOTAL_ODU2_TRIBUTARY_SLOTS)
+ .mapToObj(x -> TributarySlot.of(x))
+ .collect(Collectors.toList());
+ }
+ private static List<TributarySlot> getEntireOdu4TributarySlots() {
+ return IntStream.rangeClosed(1, TOTAL_ODU4_TRIBUTARY_SLOTS)
+ .mapToObj(x -> TributarySlot.of(x))
+ .collect(Collectors.toList());
+ }
+
}
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java
index 68fd6612..9d2e06f5 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.net.newresource.impl;
+import com.google.common.collect.Lists;
import org.onlab.packet.MplsLabel;
import org.onlab.packet.VlanId;
import org.onlab.util.ItemNotFoundException;
@@ -85,24 +86,24 @@ final class ResourceLinkListener implements LinkListener {
executor.submit(() -> {
// register the link
LinkKey linkKey = LinkKey.linkKey(link);
- adminService.registerResources(ResourcePath.ROOT, linkKey);
+ adminService.registerResources(ResourcePath.discrete(linkKey));
ResourcePath linkPath = ResourcePath.discrete(linkKey);
// register VLAN IDs against the link
if (isEnabled(link, this::isVlanEnabled)) {
- adminService.registerResources(linkPath, ENTIRE_VLAN_IDS);
+ adminService.registerResources(Lists.transform(ENTIRE_VLAN_IDS, linkPath::child));
}
// register MPLS labels against the link
if (isEnabled(link, this::isMplsEnabled)) {
- adminService.registerResources(linkPath, ENTIRE_MPLS_LABELS);
+ adminService.registerResources(Lists.transform(ENTIRE_MPLS_LABELS, linkPath::child));
}
});
}
private void unregisterLinkResource(Link link) {
LinkKey linkKey = LinkKey.linkKey(link);
- executor.submit(() -> adminService.unregisterResources(ResourcePath.ROOT, linkKey));
+ executor.submit(() -> adminService.unregisterResources(ResourcePath.discrete(linkKey)));
}
private boolean isEnabled(Link link, Predicate<ConnectPoint> predicate) {
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
index 1c6930bb..3014951a 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
@@ -17,7 +17,6 @@ package org.onosproject.net.newresource.impl;
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -41,7 +40,6 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
-import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@@ -164,23 +162,17 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent
}
@Override
- public <T> boolean registerResources(ResourcePath parent, List<T> children) {
- checkNotNull(parent);
- checkNotNull(children);
- checkArgument(!children.isEmpty());
+ public boolean registerResources(List<ResourcePath> resources) {
+ checkNotNull(resources);
- List<ResourcePath> resources = Lists.transform(children, parent::child);
return store.register(resources);
}
@Override
- public <T> boolean unregisterResources(ResourcePath parent, List<T> children) {
- checkNotNull(parent);
- checkNotNull(children);
- checkArgument(!children.isEmpty());
+ public boolean unregisterResources(List<ResourcePath> resources) {
+ checkNotNull(resources);
- List<ResourcePath> resources = Lists.transform(children, parent::child);
- return store.unregister(resources);
+ return store.register(resources);
}
private class InternalStoreDelegate implements ResourceStoreDelegate {
diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
index e57d9dbe..5d7b5c8d 100644
--- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
+++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
@@ -21,6 +21,7 @@ import org.onlab.util.Bandwidth;
import org.onosproject.TestApplicationId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.flow.TrafficSelector;
@@ -34,8 +35,6 @@ import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.intent.constraint.LambdaConstraint;
import org.onosproject.net.intent.impl.PathNotFoundException;
-import org.onosproject.net.resource.link.BandwidthResource;
-import org.onosproject.net.resource.link.LambdaResource;
import org.onosproject.net.resource.link.LinkResourceService;
import java.util.Collections;
@@ -229,7 +228,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest {
final LinkResourceService resourceService =
IntentTestsMocks.MockResourceService.makeBandwidthResourceService(1000.0);
final List<Constraint> constraints =
- Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0))));
+ Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0)));
final PointToPointIntent intent = makeIntent("s1", "s3", constraints);
@@ -251,7 +250,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest {
final LinkResourceService resourceService =
IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0);
final List<Constraint> constraints =
- Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0))));
+ Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0)));
try {
final PointToPointIntent intent = makeIntent("s1", "s3", constraints);
@@ -275,7 +274,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest {
public void testLambdaConstrainedIntentSuccess() {
final List<Constraint> constraints =
- Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1)));
+ Collections.singletonList(new LambdaConstraint(new IndexedLambda(1)));
final LinkResourceService resourceService =
IntentTestsMocks.MockResourceService.makeLambdaResourceService(1);
@@ -299,7 +298,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest {
public void testLambdaConstrainedIntentFailure() {
final List<Constraint> constraints =
- Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1)));
+ Collections.singletonList(new LambdaConstraint(new IndexedLambda(1)));
final LinkResourceService resourceService =
IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0);
try {
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
index d61d7dcf..ca6f9c1c 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
@@ -48,7 +48,8 @@ public class NettyMessagingManager extends NettyMessaging {
public void activate() throws Exception {
ControllerNode localNode = clusterMetadataService.getLocalNode();
getTlsParameters();
- super.start(new Endpoint(localNode.ip(), localNode.tcpPort()));
+ super.start(clusterMetadataService.getClusterMetadata().getName().hashCode(),
+ new Endpoint(localNode.ip(), localNode.tcpPort()));
log.info("Started");
}
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java
index ca8eea37..27c79122 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.node.DoubleNode;
import com.fasterxml.jackson.databind.node.IntNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.LongNode;
+import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ShortNode;
import com.fasterxml.jackson.databind.node.TextNode;
@@ -95,7 +96,8 @@ public class DistributedNetworkConfigStore
.register(ConfigKey.class, ObjectNode.class, ArrayNode.class,
JsonNodeFactory.class, LinkedHashMap.class,
TextNode.class, BooleanNode.class,
- LongNode.class, DoubleNode.class, ShortNode.class, IntNode.class);
+ LongNode.class, DoubleNode.class, ShortNode.class, IntNode.class,
+ NullNode.class);
configs = storageService.<ConfigKey, JsonNode>consistentMapBuilder()
.withSerializer(Serializer.using(kryoBuilder.build()))
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
index a999ee7f..83319c3e 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
@@ -348,9 +348,11 @@ public class DistributedGroupStore
public void storeGroupDescription(GroupDescription groupDesc) {
log.debug("In storeGroupDescription");
// Check if a group is existing with the same key
- if (getGroup(groupDesc.deviceId(), groupDesc.appCookie()) != null) {
- log.warn("Group already exists with the same key {}",
- groupDesc.appCookie());
+ Group existingGroup = getGroup(groupDesc.deviceId(), groupDesc.appCookie());
+ if (existingGroup != null) {
+ log.warn("Group already exists with the same key {} in dev:{} with id:{}",
+ groupDesc.appCookie(), groupDesc.deviceId(),
+ Integer.toHexString(existingGroup.id().id()));
return;
}
diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/mastership/impl/DistributedMastershipStoreTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/mastership/impl/DistributedMastershipStoreTest.java
deleted file mode 100644
index 0b704011..00000000
--- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/mastership/impl/DistributedMastershipStoreTest.java
+++ /dev/null
@@ -1,286 +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.store.mastership.impl;
-
-/**
- * Test of the Hazelcast-based distributed MastershipStore implementation.
- */
-public class DistributedMastershipStoreTest {
-/*
- private static final DeviceId DID1 = DeviceId.deviceId("of:01");
- private static final DeviceId DID2 = DeviceId.deviceId("of:02");
- private static final DeviceId DID3 = DeviceId.deviceId("of:03");
-
- private static final IpAddress IP = IpAddress.valueOf("127.0.0.1");
-
- private static final NodeId N1 = new NodeId("node1");
- private static final NodeId N2 = new NodeId("node2");
-
- private static final ControllerNode CN1 = new DefaultControllerNode(N1, IP);
- private static final ControllerNode CN2 = new DefaultControllerNode(N2, IP);
-
- private DistributedMastershipStore dms;
- private TestDistributedMastershipStore testStore;
- private KryoSerializer serializationMgr;
- private StoreManager storeMgr;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- // TODO should find a way to clean Hazelcast instance without shutdown.
- TestStoreManager testStoreMgr = new TestStoreManager();
- testStoreMgr.setHazelcastInstance(testStoreMgr.initSingleInstance());
- storeMgr = testStoreMgr;
- storeMgr.activate();
-
- serializationMgr = new KryoSerializer();
-
- dms = new TestDistributedMastershipStore(storeMgr, serializationMgr);
- dms.clusterService = new TestClusterService();
- dms.activate();
-
- testStore = (TestDistributedMastershipStore) dms;
- }
-
- @After
- public void tearDown() throws Exception {
- dms.deactivate();
-
- storeMgr.deactivate();
- }
-
- @Test
- @Ignore("Disabled this test due to intermittent failures seen on Jenkins runs")
- public void getRole() {
- assertEquals("wrong role:", NONE, dms.getRole(N1, DID1));
- testStore.put(DID1, N1, true, false, true);
- assertEquals("wrong role:", MASTER, dms.getRole(N1, DID1));
- testStore.put(DID1, N2, false, true, false);
- assertEquals("wrong role:", STANDBY, dms.getRole(N2, DID1));
- }
-
- @Test
- public void getMaster() {
- assertTrue("wrong store state:", dms.roleMap.isEmpty());
-
- testStore.put(DID1, N1, true, false, false);
- TestTools.assertAfter(100, () -> //wait for up to 100ms
- assertEquals("wrong master:", N1, dms.getMaster(DID1)));
- assertNull("wrong master:", dms.getMaster(DID2));
- }
-
- @Test
- public void getDevices() {
- assertTrue("wrong store state:", dms.roleMap.isEmpty());
-
- testStore.put(DID1, N1, true, false, false);
- testStore.put(DID2, N1, true, false, false);
- testStore.put(DID3, N2, true, false, false);
- assertEquals("wrong devices",
- Sets.newHashSet(DID1, DID2), dms.getDevices(N1));
- }
-
- @Test
- public void requestRoleAndTerm() {
- //CN1 is "local"
- testStore.setCurrent(CN1);
-
- //if already MASTER, nothing should happen
- testStore.put(DID2, N1, true, false, true);
- assertEquals("wrong role for MASTER:", MASTER, Futures.getUnchecked(dms.requestRole(DID2)));
-
- //populate maps with DID1, N1 thru NONE case
- assertEquals("wrong role for NONE:", MASTER, Futures.getUnchecked(dms.requestRole(DID1)));
- assertTrue("wrong state for store:", !dms.terms.isEmpty());
- assertEquals("wrong term",
- MastershipTerm.of(N1, 1), dms.getTermFor(DID1));
-
- //CN2 now local. DID2 has N1 as MASTER so N2 is STANDBY
- testStore.setCurrent(CN2);
- assertEquals("wrong role for STANDBY:", STANDBY, Futures.getUnchecked(dms.requestRole(DID2)));
- assertEquals("wrong number of entries:", 2, dms.terms.size());
-
- //change term and requestRole() again; should persist
- testStore.increment(DID2);
- assertEquals("wrong role for STANDBY:", STANDBY, Futures.getUnchecked(dms.requestRole(DID2)));
- assertEquals("wrong term", MastershipTerm.of(N1, 1), dms.getTermFor(DID2));
- }
-
- @Test
- public void setMaster() {
- //populate maps with DID1, N1 as MASTER thru NONE case
- testStore.setCurrent(CN1);
- assertEquals("wrong role for NONE:", MASTER, Futures.getUnchecked(dms.requestRole(DID1)));
- assertNull("wrong event:", Futures.getUnchecked(dms.setMaster(N1, DID1)));
-
- //switch over to N2
- assertEquals("wrong event:", Type.MASTER_CHANGED, Futures.getUnchecked(dms.setMaster(N2, DID1)).type());
- System.out.println(dms.getTermFor(DID1).master() + ":" + dms.getTermFor(DID1).termNumber());
- assertEquals("wrong term", MastershipTerm.of(N2, 2), dms.getTermFor(DID1));
-
- //orphan switch - should be rare case
- assertEquals("wrong event:", Type.MASTER_CHANGED, Futures.getUnchecked(dms.setMaster(N2, DID2)).type());
- assertEquals("wrong term", MastershipTerm.of(N2, 1), dms.getTermFor(DID2));
- //disconnect and reconnect - sign of failing re-election or single-instance channel
- dms.roleMap.clear();
- dms.setMaster(N2, DID2);
- assertEquals("wrong term", MastershipTerm.of(N2, 2), dms.getTermFor(DID2));
- }
-
- @Test
- public void relinquishRole() {
- //populate maps with DID1, N1 as MASTER thru NONE case
- testStore.setCurrent(CN1);
- assertEquals("wrong role for NONE:", MASTER, Futures.getUnchecked(dms.requestRole(DID1)));
- //no backup, no new MASTER/event
- assertNull("wrong event:", Futures.getUnchecked(dms.relinquishRole(N1, DID1)));
-
- dms.requestRole(DID1);
-
- //add backup CN2, get it elected MASTER by relinquishing
- testStore.setCurrent(CN2);
- assertEquals("wrong role for NONE:", STANDBY, Futures.getUnchecked(dms.requestRole(DID1)));
- assertEquals("wrong event:", Type.MASTER_CHANGED, Futures.getUnchecked(dms.relinquishRole(N1, DID1)).type());
- assertEquals("wrong master", N2, dms.getMaster(DID1));
-
- //all nodes "give up" on device, which goes back to NONE.
- assertNull("wrong event:", Futures.getUnchecked(dms.relinquishRole(N2, DID1)));
- assertEquals("wrong role for node:", NONE, dms.getRole(N2, DID1));
-
- assertEquals("wrong number of retired nodes", 2,
- dms.roleMap.get(DID1).nodesOfRole(NONE).size());
-
- //bring nodes back
- assertEquals("wrong role for NONE:", MASTER, Futures.getUnchecked(dms.requestRole(DID1)));
- testStore.setCurrent(CN1);
- assertEquals("wrong role for NONE:", STANDBY, Futures.getUnchecked(dms.requestRole(DID1)));
- assertEquals("wrong number of backup nodes", 1,
- dms.roleMap.get(DID1).nodesOfRole(STANDBY).size());
-
- //If STANDBY, should drop to NONE
- assertEquals("wrong event:", Type.BACKUPS_CHANGED, Futures.getUnchecked(dms.relinquishRole(N1, DID1)).type());
- assertEquals("wrong role for node:", NONE, dms.getRole(N1, DID1));
-
- //NONE - nothing happens
- assertEquals("wrong event:", Type.BACKUPS_CHANGED, Futures.getUnchecked(dms.relinquishRole(N1, DID2)).type());
- assertEquals("wrong role for node:", NONE, dms.getRole(N1, DID2));
-
- }
-
- @Ignore("Ignore until Delegate spec. is clear.")
- @Test
- public void testEvents() throws InterruptedException {
- //shamelessly copy other distributed store tests
- final CountDownLatch addLatch = new CountDownLatch(1);
-
- MastershipStoreDelegate checkAdd = new MastershipStoreDelegate() {
- @Override
- public void notify(MastershipEvent event) {
- assertEquals("wrong event:", Type.MASTER_CHANGED, event.type());
- assertEquals("wrong subject", DID1, event.subject());
- assertEquals("wrong subject", N1, event.roleInfo().master());
- addLatch.countDown();
- }
- };
-
- dms.setDelegate(checkAdd);
- dms.setMaster(N1, DID1);
- //this will fail until we do something about single-instance-ness
- assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
- }
-
- private class TestDistributedMastershipStore extends
- DistributedMastershipStore {
- public TestDistributedMastershipStore(StoreService storeService,
- KryoSerializer kryoSerialization) {
- this.storeService = storeService;
- this.serializer = kryoSerialization;
- }
-
- //helper to populate master/backup structures
- public void put(DeviceId dev, NodeId node,
- boolean master, boolean backup, boolean term) {
- RoleValue rv = dms.roleMap.get(dev);
- if (rv == null) {
- rv = new RoleValue();
- }
-
- if (master) {
- rv.add(MASTER, node);
- rv.reassign(node, STANDBY, NONE);
- }
- if (backup) {
- rv.add(STANDBY, node);
- rv.remove(MASTER, node);
- rv.remove(NONE, node);
- }
- if (term) {
- dms.terms.put(dev, 0);
- }
- dms.roleMap.put(dev, rv);
- }
-
- //a dumb utility function.
- public void dump() {
- for (Map.Entry<DeviceId, RoleValue> el : dms.roleMap.entrySet()) {
- System.out.println("DID: " + el.getKey());
- for (MastershipRole role : MastershipRole.values()) {
- System.out.println("\t" + role.toString() + ":");
- for (NodeId n : el.getValue().nodesOfRole(role)) {
- System.out.println("\t\t" + n);
- }
- }
- }
- }
-
- //increment term for a device
- public void increment(DeviceId dev) {
- Integer t = dms.terms.get(dev);
- if (t != null) {
- dms.terms.put(dev, ++t);
- }
- }
-
- //sets the "local" node
- public void setCurrent(ControllerNode node) {
- ((TestClusterService) clusterService).current = node;
- }
- }
-
- private class TestClusterService extends ClusterServiceAdapter {
-
- protected ControllerNode current;
-
- @Override
- public ControllerNode getLocalNode() {
- return current;
- }
-
- @Override
- public Set<ControllerNode> getNodes() {
- return Sets.newHashSet(CN1, CN2);
- }
-
- }
-*/
-}
diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/resource/impl/HazelcastLinkResourceStoreTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/resource/impl/HazelcastLinkResourceStoreTest.java
deleted file mode 100644
index a5f2facb..00000000
--- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/resource/impl/HazelcastLinkResourceStoreTest.java
+++ /dev/null
@@ -1,227 +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.store.resource.impl;
-
-/**
- * Test of the simple LinkResourceStore implementation.
- */
-public class HazelcastLinkResourceStoreTest {
-/*
- private LinkResourceStore store;
- private HazelcastLinkResourceStore storeImpl;
- private Link link1;
- private Link link2;
- private Link link3;
- private TestStoreManager storeMgr;
-
- /**
- * Returns {@link Link} object.
- *
- * @param dev1 source device
- * @param port1 source port
- * @param dev2 destination device
- * @param port2 destination port
- * @return created {@link Link} object
- * /
- private Link newLink(String dev1, int port1, String dev2, int port2) {
- Annotations annotations = DefaultAnnotations.builder()
- .set(AnnotationKeys.OPTICAL_WAVES, "80")
- .set(AnnotationKeys.BANDWIDTH, "1000")
- .build();
- return new DefaultLink(
- new ProviderId("of", "foo"),
- new ConnectPoint(deviceId(dev1), portNumber(port1)),
- new ConnectPoint(deviceId(dev2), portNumber(port2)),
- DIRECT, annotations);
- }
-
- @Before
- public void setUp() throws Exception {
-
- TestStoreManager testStoreMgr = new TestStoreManager();
- testStoreMgr.setHazelcastInstance(testStoreMgr.initSingleInstance());
- storeMgr = testStoreMgr;
- storeMgr.activate();
-
-
- storeImpl = new TestHazelcastLinkResourceStore(storeMgr);
- storeImpl.activate();
- store = storeImpl;
-
- link1 = newLink("of:1", 1, "of:2", 2);
- link2 = newLink("of:2", 1, "of:3", 2);
- link3 = newLink("of:3", 1, "of:4", 2);
- }
-
- @After
- public void tearDown() throws Exception {
- storeImpl.deactivate();
-
- storeMgr.deactivate();
- }
-
- @Test
- public void testConstructorAndActivate() {
- final Iterable<LinkResourceAllocations> allAllocations = store.getAllocations();
- assertNotNull(allAllocations);
- assertFalse(allAllocations.iterator().hasNext());
-
- final Iterable<LinkResourceAllocations> linkAllocations =
- store.getAllocations(link1);
- assertNotNull(linkAllocations);
- assertFalse(linkAllocations.iterator().hasNext());
-
- final Set<ResourceAllocation> res = store.getFreeResources(link2);
- assertNotNull(res);
- }
-
- private BandwidthResourceAllocation getBandwidthObj(Set<ResourceAllocation> resources) {
- for (ResourceAllocation res : resources) {
- if (res.type() == ResourceType.BANDWIDTH) {
- return ((BandwidthResourceAllocation) res);
- }
- }
- return null;
- }
-
- private Set<LambdaResourceAllocation> getLambdaObjs(Set<ResourceAllocation> resources) {
- Set<LambdaResourceAllocation> lambdaResources = new HashSet<>();
- for (ResourceAllocation res : resources) {
- if (res.type() == ResourceType.LAMBDA) {
- lambdaResources.add((LambdaResourceAllocation) res);
- }
- }
- return lambdaResources;
- }
-
- @Test
- public void testInitialBandwidth() {
- final Set<ResourceAllocation> freeRes = store.getFreeResources(link1);
- assertNotNull(freeRes);
-
- final BandwidthResourceAllocation alloc = getBandwidthObj(freeRes);
- assertNotNull(alloc);
-
- assertEquals(new BandwidthResource(Bandwidth.mbps(1000.0)), alloc.bandwidth());
- }
-
- @Test
- public void testInitialLambdas() {
- final Set<ResourceAllocation> freeRes = store.getFreeResources(link3);
- assertNotNull(freeRes);
-
- final Set<LambdaResourceAllocation> res = getLambdaObjs(freeRes);
- assertNotNull(res);
- assertEquals(80, res.size());
- }
-
- public static final class TestHazelcastLinkResourceStore
- extends HazelcastLinkResourceStore {
-
- public TestHazelcastLinkResourceStore(StoreService storeMgr) {
- super.storeService = storeMgr;
- }
-
- }
-
- @Test
- public void testSuccessfulBandwidthAllocation() {
- final Link link = newLink("of:1", 1, "of:2", 2);
-
- final LinkResourceRequest request =
- DefaultLinkResourceRequest.builder(IntentId.valueOf(1),
- ImmutableSet.of(link))
- .build();
- final ResourceAllocation allocation =
- new BandwidthResourceAllocation(new BandwidthResource(Bandwidth.mbps(900.0)));
- final Set<ResourceAllocation> allocationSet = ImmutableSet.of(allocation);
-
- final LinkResourceAllocations allocations =
- new DefaultLinkResourceAllocations(request, ImmutableMap.of(link, allocationSet));
-
- store.allocateResources(allocations);
- }
-
- @Test
- public void testUnsuccessfulBandwidthAllocation() {
- final Link link = newLink("of:1", 1, "of:2", 2);
-
- final LinkResourceRequest request =
- DefaultLinkResourceRequest.builder(IntentId.valueOf(1),
- ImmutableSet.of(link))
- .build();
- final ResourceAllocation allocation =
- new BandwidthResourceAllocation(new BandwidthResource(Bandwidth.mbps(9000.0)));
- final Set<ResourceAllocation> allocationSet = ImmutableSet.of(allocation);
-
- final LinkResourceAllocations allocations =
- new DefaultLinkResourceAllocations(request, ImmutableMap.of(link, allocationSet));
-
- boolean gotException = false;
- try {
- store.allocateResources(allocations);
- } catch (ResourceAllocationException rae) {
- assertEquals(true, rae.getMessage().contains("Unable to allocate bandwidth for link"));
- gotException = true;
- }
- assertEquals(true, gotException);
- }
-
- @Test
- public void testSuccessfulLambdaAllocation() {
- final Link link = newLink("of:1", 1, "of:2", 2);
-
- final LinkResourceRequest request =
- DefaultLinkResourceRequest.builder(IntentId.valueOf(1),
- ImmutableSet.of(link))
- .build();
- final ResourceAllocation allocation =
- new BandwidthResourceAllocation(new BandwidthResource(Bandwidth.mbps(900.0)));
- final Set<ResourceAllocation> allocationSet = ImmutableSet.of(allocation);
-
- final LinkResourceAllocations allocations =
- new DefaultLinkResourceAllocations(request, ImmutableMap.of(link, allocationSet));
-
- store.allocateResources(allocations);
- }
-
- @Test
- public void testUnsuccessfulLambdaAllocation() {
- final Link link = newLink("of:1", 1, "of:2", 2);
-
- final LinkResourceRequest request =
- DefaultLinkResourceRequest.builder(IntentId.valueOf(1),
- ImmutableSet.of(link))
- .build();
- final ResourceAllocation allocation =
- new LambdaResourceAllocation(LambdaResource.valueOf(33));
- final Set<ResourceAllocation> allocationSet = ImmutableSet.of(allocation);
-
- final LinkResourceAllocations allocations =
- new DefaultLinkResourceAllocations(request, ImmutableMap.of(link, allocationSet));
- store.allocateResources(allocations);
-
- boolean gotException = false;
- try {
- store.allocateResources(allocations);
- } catch (ResourceAllocationException rae) {
- assertEquals(true, rae.getMessage().contains("Unable to allocate lambda for link"));
- gotException = true;
- }
- assertEquals(true, gotException);
- }
- */
-}
diff --git a/framework/src/onos/core/store/persistence/src/main/java/org/onosproject/persistence/impl/PersistenceManager.java b/framework/src/onos/core/store/persistence/src/main/java/org/onosproject/persistence/impl/PersistenceManager.java
index 64a8683a..3428bce1 100644
--- a/framework/src/onos/core/store/persistence/src/main/java/org/onosproject/persistence/impl/PersistenceManager.java
+++ b/framework/src/onos/core/store/persistence/src/main/java/org/onosproject/persistence/impl/PersistenceManager.java
@@ -60,12 +60,13 @@ public class PersistenceManager implements PersistenceService {
private static final int FLUSH_FREQUENCY_MILLIS = 3000;
- private final Timer timer = new Timer();
+ private Timer timer;
private final CommitTask commitTask = new CommitTask();
@Activate
public void activate() {
+ timer = new Timer();
Path dbPath = Paths.get(DATABASE_PATH);
Path dbFolderPath = Paths.get(ENCLOSING_FOLDER);
//Make sure the directory exists, if it does not, make it.
@@ -96,6 +97,7 @@ public class PersistenceManager implements PersistenceService {
@Deactivate
public void deactivate() {
+ timer.cancel();
for (Map.Entry<String, Object> entry : localDB.getAll().entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
diff --git a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java
index 6b12df96..e688a80c 100644
--- a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java
+++ b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java
@@ -22,13 +22,13 @@ import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import org.onlab.osgi.DefaultServiceDirectory;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.behaviour.ExtensionResolver;
+import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
import org.onosproject.net.driver.DefaultDriverData;
import org.onosproject.net.driver.DefaultDriverHandler;
import org.onosproject.net.driver.DriverHandler;
import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.flow.instructions.ExtensionInstruction;
-import org.onosproject.net.flow.instructions.ExtensionType;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
import org.onosproject.net.flow.instructions.Instructions;
/**
@@ -53,16 +53,16 @@ public class ExtensionInstructionSerializer extends
@Override
public Instructions.ExtensionInstructionWrapper read(Kryo kryo, Input input,
Class<Instructions.ExtensionInstructionWrapper> type) {
- ExtensionType exType = (ExtensionType) kryo.readClassAndObject(input);
+ ExtensionTreatmentType exType = (ExtensionTreatmentType) kryo.readClassAndObject(input);
DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
DriverHandler handler = new DefaultDriverHandler(
new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
- ExtensionResolver resolver = handler.behaviour(ExtensionResolver.class);
+ ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionInstruction instruction = resolver.getExtensionInstruction(exType);
+ ExtensionTreatment instruction = resolver.getExtensionInstruction(exType);
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
diff --git a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index 6f96498f..1b883a30 100644
--- a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -75,6 +75,7 @@ import org.onosproject.net.OduSignalType;
import org.onosproject.net.OmsPort;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
+import org.onosproject.net.TributarySlot;
import org.onosproject.net.device.DefaultDeviceDescription;
import org.onosproject.net.device.DefaultPortDescription;
import org.onosproject.net.device.DefaultPortStatistics;
@@ -128,7 +129,7 @@ import org.onosproject.net.flow.criteria.TunnelIdCriterion;
import org.onosproject.net.flow.criteria.UdpPortCriterion;
import org.onosproject.net.flow.criteria.VlanIdCriterion;
import org.onosproject.net.flow.criteria.VlanPcpCriterion;
-import org.onosproject.net.flow.instructions.ExtensionType;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.flow.instructions.L0ModificationInstruction;
import org.onosproject.net.flow.instructions.L1ModificationInstruction;
@@ -367,6 +368,7 @@ public final class KryoNamespaces {
L2ModificationInstruction.ModVlanPcpInstruction.class,
L2ModificationInstruction.PopVlanInstruction.class,
L2ModificationInstruction.ModMplsLabelInstruction.class,
+ L2ModificationInstruction.ModMplsBosInstruction.class,
L2ModificationInstruction.ModMplsTtlInstruction.class,
L2ModificationInstruction.ModTunnelIdInstruction.class,
L3ModificationInstruction.class,
@@ -454,7 +456,7 @@ public final class KryoNamespaces {
.register(new DefaultOutboundPacketSerializer(), DefaultOutboundPacket.class)
.register(new AnnotationsSerializer(), DefaultAnnotations.class)
.register(new ExtensionInstructionSerializer(), Instructions.ExtensionInstructionWrapper.class)
- .register(ExtensionType.class)
+ .register(ExtensionTreatmentType.class)
.register(Versioned.class)
.register(MapEvent.class)
.register(MapEvent.Type.class)
@@ -476,6 +478,7 @@ public final class KryoNamespaces {
.register(OduCltPortDescription.class)
.register(OchPortDescription.class)
.register(OmsPortDescription.class)
+ .register(TributarySlot.class)
.register(
MplsIntent.class,
MplsPathIntent.class,
diff --git a/framework/src/onos/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java b/framework/src/onos/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
index 11a62d4e..45b4da1a 100644
--- a/framework/src/onos/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
+++ b/framework/src/onos/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
@@ -43,6 +43,7 @@ import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.GridType;
import org.onosproject.net.HostLocation;
+import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Link;
import org.onosproject.net.Link.Type;
import org.onosproject.net.LinkKey;
@@ -395,12 +396,12 @@ public class KryoSerializerTest {
@Test
public void testLambdaConstraint() {
- testSerializable(new LambdaConstraint(LambdaResource.valueOf(1)));
+ testSerializable(new LambdaConstraint(new IndexedLambda(1)));
}
@Test
public void testBandwidthConstraint() {
- testSerializable(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(1000.0))));
+ testSerializable(new BandwidthConstraint(Bandwidth.bps(1000.0)));
}
@Test