diff options
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net')
26 files changed, 789 insertions, 93 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeConfig.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeConfig.java index 7f157e95..e3d6993c 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeConfig.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeConfig.java @@ -36,6 +36,17 @@ public interface BridgeConfig extends HandlerBehaviour { void addBridge(BridgeName bridgeName); /** + * Adds a bridge with given bridge name and dpid, and sets the controller + * of the bridge with given controllers. + * + * @param bridgeName bridge name + * @param dpid dpid + * @param controllers list of controller + * @return true if succeeds, fail otherwise + */ + boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers); + + /** * Remove a bridge. * * @param bridgeName bridge name 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/ExtensionResolver.java new file mode 100644 index 00000000..54cbc7ac --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionResolver.java @@ -0,0 +1,40 @@ +/* + * 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.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; + +/** + * Provides access to the extension implemented by this driver. + */ +@Beta +public interface ExtensionResolver extends HandlerBehaviour { + + /** + * Gets an extension instruction instance of the specified type, if supported + * by the driver. + * + * @param type type of extension to get + * @return extension instruction + * @throws UnsupportedOperationException if the extension type is not + * supported by this driver + */ + ExtensionInstruction getExtensionInstruction(ExtensionType 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 7e79a57e..e3b4c198 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 @@ -32,6 +32,15 @@ public interface TunnelConfig extends HandlerBehaviour { void createTunnel(TunnelDescription tunnel); /** + * Creates a tunnel interface on a given bridge of this device. + * + * @param bridgeName bridge name + * @param tunnel tunnel description + * @return true if succeeds, false otherwise + */ + boolean createTunnelInterface(BridgeName bridgeName, TunnelDescription tunnel); + + /** * Removes a tunnel on this device. * * @param tunnel tunnel descriptor 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 4416456c..453a7648 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 @@ -15,8 +15,14 @@ */ package org.onosproject.net.flow; -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableSet; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeSet; + import org.onlab.packet.Ip6Address; import org.onlab.packet.IpPrefix; import org.onlab.packet.MacAddress; @@ -27,13 +33,8 @@ import org.onosproject.net.PortNumber; import org.onosproject.net.flow.criteria.Criteria; import org.onosproject.net.flow.criteria.Criterion; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.TreeSet; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableSet; /** * Default traffic selector implementation. 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 6174cef6..6beeecc9 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 @@ -15,9 +15,11 @@ */ package org.onosproject.net.flow; -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.List; +import java.util.Objects; + import org.onlab.packet.EthType; import org.onlab.packet.IpAddress; import org.onlab.packet.MacAddress; @@ -25,16 +27,17 @@ import org.onlab.packet.MplsLabel; import org.onlab.packet.TpPort; import org.onlab.packet.VlanId; 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.Instruction; import org.onosproject.net.flow.instructions.Instructions; import org.onosproject.net.meter.MeterId; -import java.util.List; -import java.util.Objects; - -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; /** * Default traffic treatment implementation. @@ -239,9 +242,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { case GROUP: case QUEUE: case L0MODIFICATION: + case L1MODIFICATION: case L2MODIFICATION: case L3MODIFICATION: case L4MODIFICATION: + case EXTENSION: current.add(instruction); break; case TABLE: @@ -479,6 +484,12 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { } @Override + public TrafficTreatment.Builder extension(ExtensionInstruction extension, + DeviceId deviceId) { + return add(Instructions.extension(extension, deviceId)); + } + + @Override public TrafficTreatment build() { if (deferred.size() == 0 && immediate.size() == 0 && table == null && !clear) { 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 c7fe8b85..b14ab99c 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 @@ -15,6 +15,8 @@ */ package org.onosproject.net.flow; +import java.util.List; + import org.onlab.packet.EthType; import org.onlab.packet.IpAddress; import org.onlab.packet.MacAddress; @@ -22,13 +24,13 @@ import org.onlab.packet.MplsLabel; import org.onlab.packet.TpPort; 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.Instruction; import org.onosproject.net.flow.instructions.Instructions; import org.onosproject.net.meter.MeterId; -import java.util.List; - /** * Abstraction of network traffic treatment. */ @@ -413,6 +415,15 @@ public interface TrafficTreatment { Builder setUdpDst(TpPort port); /** + * Uses an extension treatment. + * + * @param extension extension treatment + * @param deviceId device ID + * @return a treatment builder + */ + Builder extension(ExtensionInstruction extension, DeviceId deviceId); + + /** * Builds an immutable traffic treatment descriptor. * <p> * If the treatment is empty when build() is called, it will add a default 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/AbstractExtensionInstruction.java new file mode 100644 index 00000000..9f22f888 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionInstruction.java @@ -0,0 +1,71 @@ +/* + * 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.instructions; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +/** + * Abstract implementation of the set/get property methods of ExtensionInstruction. + */ +public abstract class AbstractExtensionInstruction implements ExtensionInstruction { + + private static final String INVALID_KEY = "Invalid property key: "; + private static final String INVALID_TYPE = "Given type does not match field type: "; + + @Override + public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException { + Class<?> clazz = this.getClass(); + try { + Field field = clazz.getDeclaredField(key); + field.setAccessible(true); + field.set(this, value); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new ExtensionPropertyException(INVALID_KEY + key); + } + } + + @Override + public <T> T getPropertyValue(String key) throws ExtensionPropertyException { + Class<?> clazz = this.getClass(); + try { + Field field = clazz.getDeclaredField(key); + field.setAccessible(true); + @SuppressWarnings("unchecked") + T result = (T) field.get(this); + return result; + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new ExtensionPropertyException(INVALID_KEY + key); + } catch (ClassCastException e) { + throw new ExtensionPropertyException(INVALID_TYPE + key); + } + } + + @Override + public List<String> getProperties() { + Class<?> clazz = this.getClass(); + + List<String> fields = new ArrayList<>(); + + for (Field field : clazz.getDeclaredFields()) { + fields.add(field.getName()); + } + + return fields; + } +} 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/ExtensionInstruction.java new file mode 100644 index 00000000..89e0cc5e --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionInstruction.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.instructions; + +import java.util.List; + +/** + * An extensible instruction type. + */ +public interface ExtensionInstruction { + + /** + * Gets the type of the extension instruction. + * + * @return type + */ + ExtensionType type(); + + /** + * Sets a property on the extension instruction. + * + * @param key property key + * @param value value to set for the given key + * @param <T> class of the value + * @throws ExtensionPropertyException if the given key is not a valid + * property on this extension instruction + */ + <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException; + + /** + * Gets a property value of an extension instruction. + * + * @param key property key + * @param <T> class of the value + * @return value of the property + * @throws ExtensionPropertyException if the given key is not a valid + * property on this extension instruction + */ + <T> T getPropertyValue(String key) throws ExtensionPropertyException; + + /** + * Gets a list of all properties on the extension instruction. + * + * @return list of properties + */ + List<String> getProperties(); + + /** + * Serialize the extension instruction to a byte array. + * + * @return byte array + */ + byte[] serialize(); + + /** + * Deserialize the extension instruction from a byte array. The properties + * of this object will be overwritten with the data in the byte array. + * + * @param data input byte array + */ + void deserialize(byte[] data); + + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/Treatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionPropertyException.java index a77079ce..5750d09e 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/Treatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionPropertyException.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Open Networking Laboratory + * 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. @@ -13,24 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onosproject.net.flow; -import org.onosproject.net.PortNumber; +package org.onosproject.net.flow.instructions; /** - * Abstraction of different kinds of treatment that can be applied to an - * outbound packet. + * Exception indicating there was an error while setting/getting an extension + * instruction property. */ -public interface Treatment { +public class ExtensionPropertyException extends Exception { - // TODO: implement these later: modifications, group - // TODO: elsewhere provide factory methods for some default treatments - - /** - * Returns the port number where the packet should be emitted. - * - * @return output port number - */ - PortNumber output(); + public ExtensionPropertyException(String message) { + super(message); + } + public ExtensionPropertyException(String message, Throwable cause) { + super(message, cause); + } } 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/ExtensionType.java new file mode 100644 index 00000000..747a85b5 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java @@ -0,0 +1,92 @@ +/* + * 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.instructions; + +import com.google.common.annotations.Beta; +import com.google.common.base.MoreObjects; + +import java.util.Objects; + +/** + * Type of extension instructions. + */ +@Beta +public final class ExtensionType { + + /** + * A list of well-known named extension instruction type codes. + */ + public enum ExtensionTypes { + // TODO fix type numbers to include experimenter id + NICIRA_SET_TUNNEL_DST(31); + + private ExtensionType type; + + /** + * Creates a new named extension instruction type. + * + * @param type type code + */ + ExtensionTypes(int type) { + this.type = new ExtensionType(type); + } + + /** + * Gets the extension type object for this named type code. + * + * @return extension type object + */ + public ExtensionType type() { + return type; + } + } + + private final int type; + + /** + * Creates an extension type with the given int type code. + * + * @param type type code + */ + public ExtensionType(int type) { + this.type = type; + } + + @Override + public int hashCode() { + return Objects.hash(type); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ExtensionType) { + final ExtensionType that = (ExtensionType) obj; + return this.type == that.type; + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(ExtensionType.class) + .add("type", type) + .toString(); + } +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java index 2f6a1cc1..31ad80c5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java @@ -92,7 +92,12 @@ public interface Instruction { /** * Signifies that the traffic should be modified in L4 way. */ - L4MODIFICATION + L4MODIFICATION, + + /** + * Signifies that an extension instruction will be used. + */ + EXTENSION } /** 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 8868bf7c..aad407c8 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 @@ -22,6 +22,7 @@ import org.onlab.packet.MplsLabel; import org.onlab.packet.TpPort; import org.onlab.packet.VlanId; import org.onosproject.core.GroupId; +import org.onosproject.net.DeviceId; import org.onosproject.net.IndexedLambda; import org.onosproject.net.Lambda; import org.onosproject.net.OchSignal; @@ -480,6 +481,20 @@ public final class Instructions { } /** + * Creates an extension instruction. + * + * @param extension extension instruction + * @param deviceId device ID + * @return extension instruction + */ + public static ExtensionInstructionWrapper extension(ExtensionInstruction extension, + DeviceId deviceId) { + checkNotNull(extension, "Extension instruction cannot be null"); + checkNotNull(deviceId, "Device ID cannot be null"); + return new ExtensionInstructionWrapper(extension, deviceId); + } + + /** * Drop instruction. */ @Deprecated @@ -820,6 +835,59 @@ public final class Instructions { } } + /** + * Extension instruction. + */ + public static class ExtensionInstructionWrapper implements Instruction { + private final ExtensionInstruction extensionInstruction; + private final DeviceId deviceId; + + ExtensionInstructionWrapper(ExtensionInstruction extension, DeviceId deviceId) { + extensionInstruction = extension; + this.deviceId = deviceId; + } + + public ExtensionInstruction extensionInstruction() { + return extensionInstruction; + } + + public DeviceId deviceId() { + return deviceId; + } + + @Override + public Type type() { + return Type.EXTENSION; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("extension", extensionInstruction) + .add("deviceId", deviceId) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type().ordinal(), extensionInstruction, deviceId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ExtensionInstructionWrapper) { + ExtensionInstructionWrapper that = (ExtensionInstructionWrapper) obj; + return Objects.equals(extensionInstruction, that.extensionInstruction) + && Objects.equals(deviceId, that.deviceId); + + } + return false; + } + } + } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java index 7b5924fb..06305bf7 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.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.TrafficTreatment; import org.onosproject.net.flow.criteria.Criteria; import org.onosproject.net.flow.criteria.Criterion; @@ -46,6 +47,7 @@ public final class DefaultFilteringObjective implements FilteringObjective { private final int id; private final Operation op; private final Optional<ObjectiveContext> context; + private final TrafficTreatment meta; private DefaultFilteringObjective(Builder builder) { this.key = builder.key; @@ -57,6 +59,7 @@ public final class DefaultFilteringObjective implements FilteringObjective { this.conditions = builder.conditions; this.op = builder.op; this.context = Optional.ofNullable(builder.context); + this.meta = builder.meta; this.id = Objects.hash(type, key, conditions, permanent, timeout, appId, priority); @@ -83,6 +86,12 @@ public final class DefaultFilteringObjective implements FilteringObjective { } @Override + public TrafficTreatment meta() { + return meta; + } + + + @Override public int priority() { return priority; } @@ -135,6 +144,7 @@ public final class DefaultFilteringObjective implements FilteringObjective { private List<Criterion> conditions; private Operation op; private ObjectiveContext context; + private TrafficTreatment meta; @Override public Builder withKey(Criterion key) { @@ -186,6 +196,12 @@ public final class DefaultFilteringObjective implements FilteringObjective { } @Override + public Builder setMeta(TrafficTreatment treatment) { + this.meta = treatment; + return this; + } + + @Override public FilteringObjective add() { conditions = listBuilder.build(); op = Operation.ADD; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/FilteringObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/FilteringObjective.java index 58304571..29257c61 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/FilteringObjective.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/FilteringObjective.java @@ -17,49 +17,54 @@ package org.onosproject.net.flowobjective; import com.google.common.annotations.Beta; import org.onosproject.core.ApplicationId; +import org.onosproject.net.flow.TrafficTreatment; import org.onosproject.net.flow.criteria.Criterion; import java.util.Collection; /** * Represents a filtering flow objective. Each filtering flow objective - * is made up of a key (criterion) to a set of criteria. Using this information - * a pipeline aware driver will decide how this objective should be mapped - * to the specific device pipeline. For example, consider the following - * filtering objective: - * - * portX -> {MAC1, IP1, MAC2} - * - * The driver could decide to pass L3 packet to the L3 table and L2 packets to - * the L2 table for packets arriving on portX. - * - * Filtering objectives do not only represent what should be permitted into the - * pipeline but can also be used to deny or drop unwanted packets by specifying - * the appropriate type of filtering objective. It is also important to note - * that submitting a filtering objective does not necessarily result in rules - * programmed at the switch, the driver is free to decide when these rules are - * programmed. For example, a filtering rule may only be programmed once a - * corresponding forwarding objective has been received. + * is made up of a key (typically a PortCriterion) mapped to a set of criteria. + * Using this information, a pipeline aware driver will decide how this objective + * should be mapped to the device specific pipeline-tables in order to satisfy the + * filtering condition. For example, consider the following PERMIT filtering + * objective: + * <p> + * portX -> {MAC1, VLAN1} + * <p> + * The driver could decide to pass packets to the MAC table or VLAN or PORT + * tables to ensure that only those packets arriving with the correct dst MAC + * and VLAN ids from Port X are allowed into the pipeline. + * <p> + * Filtering objectives of type PERMIT allow packets that match the key:criteria + * to enter the pipeline. As a result, the implication is that packets that don't + * match are automatically denied (dropped). + * <p> + * Filtering objectives of type DENY, are used to deny packets that would + * otherwise be permitted and forwarded through the pipeline (ie. those packets + * that make it through the PERMIT filters). */ @Beta public interface FilteringObjective extends Objective { enum Type { /** - * Enables the filtering condition. + * Permits packets that match the filtering condition to be processed + * by the rest of the pipeline. Automatically denies packets that don't + * match the criteria. */ PERMIT, /** - * Disables the filtering condition. + * Denies packets that make it through the permit filters. */ DENY } /** - * Obtain the key for this filter. + * Obtain the key for this filter. The filter may or may not require a key. * - * @return a criterion + * @return a criterion, which could be null if no key was provided. */ Criterion key(); @@ -78,6 +83,16 @@ public interface FilteringObjective extends Objective { Collection<Criterion> conditions(); /** + * Auxiliary optional information provided to the device-driver.Typically + * conveys information about changes (treatments) to packets that are + * permitted into the pipeline by the PERMIT filtering condition. + * + * @return a treatment on the packets that make it through the PERMIT filters. + * Value may be null if no meta information is provided. + */ + TrafficTreatment meta(); + + /** * Builder of Filtering objective entities. */ interface Builder extends Objective.Builder { @@ -113,11 +128,20 @@ public interface FilteringObjective extends Objective { Builder deny(); /** + * Set meta information about this filtering condition set. + * + * @param treatment traffic treatment to use + * @return a filtering builder + */ + Builder setMeta(TrafficTreatment treatment); + + /** * Assigns an application id. * * @param appId an application id * @return a filtering builder */ + @Override Builder fromApp(ApplicationId appId); /** diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupBucket.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupBucket.java index 6efd3e79..9d942ee4 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupBucket.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupBucket.java @@ -139,6 +139,20 @@ public final class DefaultGroupBucket implements GroupBucket, StoredGroupBucketE watchGroup); } + /** + * Creates all group bucket. + * + * @param treatment traffic treatment associated with group bucket + * @return all group bucket object + */ + public static GroupBucket createAllGroupBucket(TrafficTreatment treatment) { + return new DefaultGroupBucket(GroupDescription.Type.ALL, + treatment, + (short) -1, + null, + null); + } + @Override public GroupDescription.Type type() { return this.type; 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 bd4219ad..c1467241 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 @@ -17,11 +17,15 @@ package org.onosproject.net.intent; import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; + import org.onosproject.core.ApplicationId; import org.onosproject.net.HostId; +import org.onosproject.net.Link; import org.onosproject.net.flow.TrafficSelector; import org.onosproject.net.flow.TrafficTreatment; +import org.onosproject.net.intent.constraint.LinkTypeConstraint; import java.util.List; @@ -33,6 +37,8 @@ import static com.google.common.base.Preconditions.checkNotNull; @Beta public final class HostToHostIntent extends ConnectivityIntent { + static final LinkTypeConstraint NOT_OPTICAL = new LinkTypeConstraint(false, Link.Type.OPTICAL); + private final HostId one; private final HostId two; @@ -115,6 +121,15 @@ public final class HostToHostIntent extends ConnectivityIntent { */ public HostToHostIntent build() { + List<Constraint> theConstraints = constraints; + // If not-OPTICAL constraint hasn't been specified, add them + if (!constraints.contains(NOT_OPTICAL)) { + theConstraints = ImmutableList.<Constraint>builder() + .add(NOT_OPTICAL) + .addAll(constraints) + .build(); + } + return new HostToHostIntent( appId, key, @@ -122,7 +137,7 @@ public final class HostToHostIntent extends ConnectivityIntent { two, selector, treatment, - constraints, + theConstraints, priority ); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/Key.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/Key.java index 18baafc8..0344acbf 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/Key.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/Key.java @@ -28,7 +28,7 @@ import java.util.Objects; */ // TODO maybe pull this up to utils @Beta -public abstract class Key { +public abstract class Key implements Comparable<Key> { //TODO consider making this a HashCode object (worry about performance) private final long hash; @@ -117,6 +117,12 @@ public abstract class Key { Objects.equals(this.appId, other.appId) && Objects.equals(this.key, other.key); } + + @Override + public int compareTo(Key o) { + StringKey sk = (StringKey) o; + return this.key.compareTo(sk.key); + } } private static final class LongKey extends Key { @@ -157,6 +163,13 @@ public abstract class Key { this.key == other.key && Objects.equals(this.appId, other.appId); } + + @Override + public int compareTo(Key o) { + Long myKey = key; + Long otherKey = ((LongKey) o).key; + return myKey.compareTo(otherKey); + } } } 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 43b8e4b1..20ccb55d 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 @@ -16,6 +16,8 @@ package org.onosproject.net.intent.constraint; import com.google.common.annotations.Beta; + +import org.onlab.util.DataRateUnit; import org.onosproject.net.Link; import org.onosproject.net.resource.link.BandwidthResource; import org.onosproject.net.resource.link.BandwidthResourceRequest; @@ -32,7 +34,7 @@ import static com.google.common.base.Preconditions.checkNotNull; * Constraint that evaluates links based on available bandwidths. */ @Beta -public class BandwidthConstraint extends BooleanConstraint { +public final class BandwidthConstraint extends BooleanConstraint { private final BandwidthResource bandwidth; @@ -45,6 +47,17 @@ public class BandwidthConstraint extends BooleanConstraint { this.bandwidth = checkNotNull(bandwidth, "Bandwidth cannot be null"); } + /** + * Creates a new bandwidth constraint. + * + * @param v required amount of bandwidth + * @param unit {@link DataRateUnit} of {@code v} + * @return {@link BandwidthConstraint} instance with given bandwidth requirement + */ + public static BandwidthConstraint of(double v, DataRateUnit unit) { + return new BandwidthConstraint(BandwidthResource.of(v, unit)); + } + // Constructor for serialization private BandwidthConstraint() { this.bandwidth = null; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceService.java index 82d84743..ad684c8c 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceService.java @@ -153,6 +153,14 @@ public interface ResourceService { Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer); /** + * Returns resource paths that point available child resources under the specified resource path. + * + * @param parent parent resource path + * @return available resource paths under the specified resource path + */ + Collection<ResourcePath> getAvailableResources(ResourcePath parent); + + /** * Returns the availability of the specified resource. * * @param resource resource to check the availability diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java index 5a034b4d..2cab9d4b 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java @@ -92,6 +92,14 @@ public interface ResourceStore { Collection<ResourcePath> getResources(ResourceConsumer consumer); /** + * Returns a collection of the child resources of the specified parent. + * + * @param parent parent of the resource to be returned + * @return a collection of the child resources of the specified resource + */ + Collection<ResourcePath> getChildResources(ResourcePath parent); + + /** * Returns a collection of the resources which are children of the specified parent and * whose type is the specified class. * diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResource.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResource.java index fe21e042..0bfb3795 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResource.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResource.java @@ -16,7 +16,7 @@ package org.onosproject.net.resource.link; import org.onlab.util.Bandwidth; - +import org.onlab.util.DataRateUnit; import java.util.Objects; import static com.google.common.base.Preconditions.checkNotNull; @@ -43,6 +43,17 @@ public final class BandwidthResource implements LinkResource { } /** + * Creates a new bandwidth resource. + * + * @param v amount of bandwidth to request + * @param unit {@link DataRateUnit} of {@code v} + * @return {@link BandwidthResource} instance with given bandwidth + */ + public static BandwidthResource of(double v, DataRateUnit unit) { + return new BandwidthResource(Bandwidth.of(v, unit)); + } + + /** * Returns bandwidth as a double value. * * @return bandwidth as a 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 5153aebf..f8e143a4 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 @@ -16,48 +16,47 @@ package org.onosproject.net.resource.link; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; import java.util.Objects; +import java.util.stream.Collectors; +import com.google.common.annotations.Beta; +import com.google.common.collect.ImmutableMap; import org.onlab.util.Bandwidth; import org.onosproject.net.Link; import org.onosproject.net.intent.Constraint; import org.onosproject.net.intent.IntentId; -import com.google.common.collect.ImmutableSet; - import org.onosproject.net.intent.constraint.BandwidthConstraint; import org.onosproject.net.intent.constraint.LambdaConstraint; import org.onosproject.net.resource.ResourceRequest; import org.onosproject.net.resource.ResourceType; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Implementation of {@link LinkResourceRequest}. */ public final class DefaultLinkResourceRequest implements LinkResourceRequest { private final IntentId intentId; - private final Collection<Link> links; - private final Set<ResourceRequest> resources; + protected final Map<Link, Set<ResourceRequest>> requests; /** - * Creates a new link resource request with the given ID, links, and - * resource requests. + * Creates a new link resource request with the specified Intent ID, + * and resource requests over links. * - * @param intentId intent ID related to this request - * @param links a set of links for the request - * @param resources a set of resources to be requested + * @param intentId intent ID associated with this request + * @param requests resource requests over links */ - private DefaultLinkResourceRequest(IntentId intentId, - Collection<Link> links, - Set<ResourceRequest> resources) { - this.intentId = intentId; - this.links = ImmutableSet.copyOf(links); - this.resources = ImmutableSet.copyOf(resources); + private DefaultLinkResourceRequest(IntentId intentId, Map<Link, Set<ResourceRequest>> requests) { + this.intentId = checkNotNull(intentId); + this.requests = checkNotNull(ImmutableMap.copyOf(requests)); } - @Override public ResourceType type() { return null; @@ -70,12 +69,19 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest { @Override public Collection<Link> links() { - return links; + return requests.keySet(); } @Override public Set<ResourceRequest> resources() { - return resources; + return requests.values().stream() + .flatMap(Collection::stream) + .collect(Collectors.toSet()); + } + + @Override + public Set<ResourceRequest> resources(Link link) { + return requests.get(link); } /** @@ -95,8 +101,7 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest { */ public static final class Builder implements LinkResourceRequest.Builder { private IntentId intentId; - private Collection<Link> links; - private Set<ResourceRequest> resources; + private Map<Link, Set<ResourceRequest>> requests; /** * Creates a new link resource request. @@ -106,18 +111,33 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest { */ private Builder(IntentId intentId, Collection<Link> links) { this.intentId = intentId; - this.links = links; - this.resources = new HashSet<>(); + this.requests = new HashMap<>(); + for (Link link : links) { + requests.put(link, new HashSet<>()); + } } /** * Adds lambda request. * * @return self + * @deprecated in Emu Release */ + @Deprecated @Override public Builder addLambdaRequest() { - resources.add(new LambdaResourceRequest()); + for (Link link : requests.keySet()) { + requests.get(link).add(new LambdaResourceRequest()); + } + return this; + } + + @Beta + @Override + public LinkResourceRequest.Builder addLambdaRequest(LambdaResource lambda) { + for (Link link : requests.keySet()) { + requests.get(link).add(new LambdaResourceRequest(lambda)); + } return this; } @@ -125,10 +145,36 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest { * Adds Mpls request. * * @return self + * @deprecated in Emu Release */ + @Deprecated @Override public Builder addMplsRequest() { - resources.add(new MplsLabelResourceRequest()); + for (Link link : requests.keySet()) { + requests.get(link).add(new MplsLabelResourceRequest()); + } + return this; + } + + @Beta + @Override + public Builder addMplsRequest(MplsLabel label) { + for (Link link : requests.keySet()) { + requests.get(link).add(new MplsLabelResourceRequest(label)); + } + return this; + } + + @Beta + @Override + public LinkResourceRequest.Builder addMplsRequest(Map<Link, MplsLabel> labels) { + for (Link link : labels.keySet()) { + if (!requests.containsKey(link)) { + requests.put(link, new HashSet<>()); + } + requests.get(link).add(new MplsLabelResourceRequest(labels.get(link))); + } + return this; } @@ -140,7 +186,9 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest { */ @Override public Builder addBandwidthRequest(double bandwidth) { - resources.add(new BandwidthResourceRequest(new BandwidthResource(Bandwidth.bps(bandwidth)))); + for (Link link : requests.keySet()) { + requests.get(link).add(new BandwidthResourceRequest(new BandwidthResource(Bandwidth.bps(bandwidth)))); + } return this; } @@ -162,13 +210,13 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest { */ @Override public LinkResourceRequest build() { - return new DefaultLinkResourceRequest(intentId, links, resources); + return new DefaultLinkResourceRequest(intentId, requests); } } @Override public int hashCode() { - return Objects.hash(intentId, links); + return Objects.hash(intentId, links()); } @Override @@ -181,6 +229,6 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest { } final DefaultLinkResourceRequest other = (DefaultLinkResourceRequest) obj; return Objects.equals(this.intentId, other.intentId) - && Objects.equals(this.links, other.links); + && Objects.equals(this.links(), other.links()); } } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceRequest.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceRequest.java index b0391f5a..d264d5e5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceRequest.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceRequest.java @@ -15,15 +15,50 @@ */ package org.onosproject.net.resource.link; +import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects; import org.onosproject.net.resource.ResourceRequest; import org.onosproject.net.resource.ResourceType; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Representation of a request for lambda resource. */ public class LambdaResourceRequest implements ResourceRequest { + private final LambdaResource lambda; + + /** + * Constructs a request specifying the given lambda. + * + * @param lambda lambda to be requested + */ + @Beta + public LambdaResourceRequest(LambdaResource lambda) { + this.lambda = checkNotNull(lambda); + } + + /** + * Constructs a request asking an arbitrary available lambda. + * + * @deprecated in Emu Release + */ + @Deprecated + public LambdaResourceRequest() { + this.lambda = null; + } + + /** + * Returns the lambda this request expects. + * + * @return the lambda this request expects + */ + @Beta + public LambdaResource lambda() { + return lambda; + } + @Override public ResourceType type() { return ResourceType.LAMBDA; @@ -32,6 +67,7 @@ public class LambdaResourceRequest implements ResourceRequest { @Override public String toString() { return MoreObjects.toStringHelper(this) + .add("lambda", lambda) .toString(); } } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceRequest.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceRequest.java index 8023a92e..37622e79 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceRequest.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceRequest.java @@ -16,8 +16,10 @@ package org.onosproject.net.resource.link; import java.util.Collection; +import java.util.Map; import java.util.Set; +import com.google.common.annotations.Beta; import org.onosproject.net.Link; import org.onosproject.net.intent.Constraint; import org.onosproject.net.intent.IntentId; @@ -50,22 +52,62 @@ public interface LinkResourceRequest extends ResourceRequest { Set<ResourceRequest> resources(); /** + * Returns the set of resource request against the specified link. + * + * @param link link whose associated resource request is to be returned + * @return set of resource request against the specified link + */ + @Beta + Set<ResourceRequest> resources(Link link); + + /** * Builder of link resource request. */ interface Builder { - /** + /** * Adds lambda request. * * @return self + * @deprecated in Emu Release */ + @Deprecated Builder addLambdaRequest(); /** - * Adds MPLS request. - * - * @return self - */ - Builder addMplsRequest(); + * Adds lambda request. + * + * @param lambda lambda to be requested + * @return self + */ + @Beta + Builder addLambdaRequest(LambdaResource lambda); + + /** + * Adds MPLS request. + * + * @return self + * @deprecated in Emu Release + */ + @Deprecated + Builder addMplsRequest(); + + /** + * Adds MPLS request. + * + * @param label MPLS label to be requested + * @return self + */ + @Beta + Builder addMplsRequest(MplsLabel label); + + /** + * Adds MPLS request against the specified links. + * + * @param labels MPLS labels to be requested against links + * @return self + */ + @Beta + Builder addMplsRequest(Map<Link, MplsLabel> labels); /** * Adds bandwidth request with bandwidth value. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java index 6dc04dfc..71ea7e1a 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java @@ -22,7 +22,10 @@ import org.onosproject.net.resource.ResourceRequest; /** * Service for providing link resource allocation. + * + * @deprecated in Emu Release */ +@Deprecated public interface LinkResourceService extends ListenerService<LinkResourceEvent, LinkResourceListener> { @@ -31,14 +34,18 @@ public interface LinkResourceService * * @param req resources to be allocated * @return allocated resources + * @deprecated in Emu Release */ + @Deprecated LinkResourceAllocations requestResources(LinkResourceRequest req); /** * Releases resources. * * @param allocations resources to be released + * @deprecated in Emu Release */ + @Deprecated void releaseResources(LinkResourceAllocations allocations); /** @@ -47,7 +54,9 @@ public interface LinkResourceService * @param req updated resource request * @param oldAllocations old resource allocations * @return new resource allocations + * @deprecated in Emu Release */ + @Deprecated LinkResourceAllocations updateResources(LinkResourceRequest req, LinkResourceAllocations oldAllocations); @@ -55,7 +64,9 @@ public interface LinkResourceService * Returns all allocated resources. * * @return allocated resources + * @deprecated in Emu Release */ + @Deprecated Iterable<LinkResourceAllocations> getAllocations(); /** @@ -63,7 +74,9 @@ public interface LinkResourceService * * @param link a target link * @return allocated resources + * @deprecated in Emu Release */ + @Deprecated Iterable<LinkResourceAllocations> getAllocations(Link link); /** @@ -71,7 +84,9 @@ public interface LinkResourceService * * @param intentId the target Intent's id * @return allocated resources for Intent + * @deprecated in Emu Release */ + @Deprecated LinkResourceAllocations getAllocations(IntentId intentId); /** @@ -79,7 +94,9 @@ public interface LinkResourceService * * @param link a target link * @return available resources for the target link + * @deprecated in Emu Release */ + @Deprecated Iterable<ResourceRequest> getAvailableResources(Link link); /** @@ -88,7 +105,9 @@ public interface LinkResourceService * @param link a target link * @param allocations allocations to be included as available * @return available resources for the target link + * @deprecated in Emu Release */ + @Deprecated Iterable<ResourceRequest> getAvailableResources(Link link, LinkResourceAllocations allocations); diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceRequest.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceRequest.java index 0a03f450..01a048b7 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceRequest.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceRequest.java @@ -15,15 +15,50 @@ */ package org.onosproject.net.resource.link; +import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects; import org.onosproject.net.resource.ResourceRequest; import org.onosproject.net.resource.ResourceType; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Representation of a request for lambda resource. */ public class MplsLabelResourceRequest implements ResourceRequest { + private final MplsLabel mplsLabel; + + /** + * Constructs a request specifying the given MPLS label. + * + * @param mplsLabel MPLS label to be requested + */ + @Beta + public MplsLabelResourceRequest(MplsLabel mplsLabel) { + this.mplsLabel = checkNotNull(mplsLabel); + } + + /** + * Constructs a request asking an arbitrary available MPLS label. + * + * @deprecated in Emu Release + */ + @Deprecated + public MplsLabelResourceRequest() { + this.mplsLabel = null; + } + + /** + * Returns the MPLS label this request expects. + * + * @return the MPLS label this request expects + */ + @Beta + public MplsLabel mplsLabel() { + return mplsLabel; + } + @Override public ResourceType type() { return ResourceType.MPLS_LABEL; @@ -32,6 +67,7 @@ public class MplsLabelResourceRequest implements ResourceRequest { @Override public String toString() { return MoreObjects.toStringHelper(this) + .add("mplsLabel", mplsLabel) .toString(); } } |