aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/net
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/AbstractDescription.java15
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultHost.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/PortNumber.java129
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeConfig.java9
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java143
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigService.java4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStore.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java31
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java22
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java21
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java7
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java33
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java9
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpHaCriterion.java83
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java34
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java37
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/host/DefaultHostDescription.java21
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java40
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java6
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java6
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/link/DefaultLinkDescription.java20
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java8
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceEvent.java54
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceListener.java26
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java168
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceService.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStoreDelegate.java24
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResource.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java5
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java5
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceAllocations.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResource.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java5
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceRequest.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResource.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceAllocations.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceEvent.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceListener.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceRequest.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStore.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStoreDelegate.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResources.java6
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabel.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java5
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceRequest.java3
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/package-info.java6
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/package-info.java4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java5
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java2
65 files changed, 973 insertions, 102 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/AbstractDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/AbstractDescription.java
index d81b83cc..34042dad 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/AbstractDescription.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/AbstractDescription.java
@@ -16,6 +16,7 @@
package org.onosproject.net;
import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.base.Objects;
/**
* Base implementation of an annotated model description.
@@ -46,4 +47,18 @@ public abstract class AbstractDescription implements Annotated {
return annotations;
}
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(annotations);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object instanceof AbstractDescription) {
+ AbstractDescription that = (AbstractDescription) object;
+ return Objects.equal(this.annotations, that.annotations);
+ }
+ return false;
+ }
+
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultHost.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultHost.java
index 2877701e..557fa5c1 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultHost.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultHost.java
@@ -98,7 +98,8 @@ public class DefaultHost extends AbstractElement implements Host {
return Objects.equals(this.id, other.id) &&
Objects.equals(this.mac, other.mac) &&
Objects.equals(this.vlan, other.vlan) &&
- Objects.equals(this.location, other.location);
+ Objects.equals(this.location, other.location) &&
+ Objects.equals(this.ipAddresses(), other.ipAddresses());
}
return false;
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java
index a4789cac..2da2463a 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java
@@ -88,7 +88,7 @@ public class DefaultPath extends DefaultLink implements Path {
@Override
public int hashCode() {
- return Objects.hash(links);
+ return links.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java
index 5331342e..e2c1214f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java
@@ -75,7 +75,7 @@ public final class DeviceId extends ElementId {
@Override
public int hashCode() {
- return Objects.hash(str);
+ return str.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/PortNumber.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/PortNumber.java
index 03e6dba9..8c9b1349 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/PortNumber.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/PortNumber.java
@@ -15,6 +15,16 @@
*/
package org.onosproject.net;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.primitives.UnsignedLongs;
/**
@@ -26,8 +36,7 @@ public final class PortNumber {
// TODO: revisit the max and the logical port value assignments
- private static final long MAX_NUMBER = (2L * Integer.MAX_VALUE) + 1;
-
+ static final long MAX_NUMBER = (2L * Integer.MAX_VALUE) + 1;
static final long IN_PORT_NUMBER = -8L;
static final long TABLE_NUMBER = -7L;
@@ -37,6 +46,39 @@ public final class PortNumber {
static final long LOCAL_NUMBER = -2L;
static final long CONTROLLER_NUMBER = -3L;
+ /**
+ * Logical PortNumbers.
+ */
+ public static enum Logical {
+ IN_PORT(IN_PORT_NUMBER),
+ TABLE(TABLE_NUMBER),
+ NORMAL(NORMAL_NUMBER),
+ FLOOD(FLOOD_NUMBER),
+ ALL(ALL_NUMBER),
+ LOCAL(LOCAL_NUMBER),
+ CONTROLLER(CONTROLLER_NUMBER);
+
+ private final long number;
+ private final PortNumber instance;
+
+ public long number() {
+ return number;
+ }
+
+ /**
+ * PortNumber instance for the logical port.
+ * @return {@link PortNumber}
+ */
+ public PortNumber instance() {
+ return instance;
+ }
+
+ Logical(long number) {
+ this.number = number;
+ this.instance = new PortNumber(number);
+ }
+ }
+
public static final PortNumber IN_PORT = new PortNumber(IN_PORT_NUMBER);
public static final PortNumber TABLE = new PortNumber(TABLE_NUMBER);
public static final PortNumber NORMAL = new PortNumber(NORMAL_NUMBER);
@@ -45,6 +87,15 @@ public final class PortNumber {
public static final PortNumber LOCAL = new PortNumber(LOCAL_NUMBER);
public static final PortNumber CONTROLLER = new PortNumber(CONTROLLER_NUMBER);
+ // lazily populated Logical port number to PortNumber
+ static final Supplier<Map<Long, Logical>> LOGICAL = Suppliers.memoize(() -> {
+ Builder<Long, Logical> builder = ImmutableMap.<Long, Logical>builder();
+ for (Logical lp : Logical.values()) {
+ builder.put(lp.number(), lp);
+ }
+ return builder.build();
+ });
+
private final long number;
private final String name;
private final boolean hasName;
@@ -136,30 +187,68 @@ public final class PortNumber {
}
private String decodeLogicalPort() {
- if (number == CONTROLLER_NUMBER) {
- return "CONTROLLER";
- } else if (number == LOCAL_NUMBER) {
- return "LOCAL";
- } else if (number == ALL_NUMBER) {
- return "ALL";
- } else if (number == FLOOD_NUMBER) {
- return "FLOOD";
- } else if (number == NORMAL_NUMBER) {
- return "NORMAL";
- } else if (number == TABLE_NUMBER) {
- return "TABLE";
- } else if (number == IN_PORT_NUMBER) {
- return "IN_PORT";
+ Logical logical = LOGICAL.get().get(number);
+ if (logical != null) {
+ // enum name
+ return logical.toString();
+ }
+ return String.format("UNKNOWN(%s)", UnsignedLongs.toString(number));
+ }
+
+
+ /**
+ * Regular expression to match String representation of named PortNumber.
+ *
+ * Format: "[name](num:unsigned decimal string)"
+ */
+ private static final Pattern NAMED = Pattern.compile("^\\[(?<name>.*)\\]\\((?<num>\\d+)\\)$");
+
+ private static boolean isAsciiDecimal(char c) {
+ return '0' <= c && c <= '9';
+ }
+
+ /**
+ * Returns PortNumber instance from String representation.
+ *
+ * @param s String representation equivalent to {@link PortNumber#toString()}
+ * @return {@link PortNumber} instance
+ * @throws IllegalArgumentException if given String was malformed
+ */
+ public static PortNumber fromString(String s) {
+ checkNotNull(s);
+ checkArgument(!s.isEmpty(), "cannot be empty");
+
+ if (isAsciiDecimal(s.charAt(0))) {
+ // unsigned decimal string
+ return portNumber(s);
+ } else if (s.startsWith("[")) {
+ // named PortNumber
+ Matcher matcher = NAMED.matcher(s);
+ checkArgument(matcher.matches(), "Invalid named PortNumber %s", s);
+
+ String name = matcher.group("name");
+ String num = matcher.group("num");
+ return portNumber(UnsignedLongs.parseUnsignedLong(num), name);
+ }
+
+ // Logical
+ if (s.startsWith("UNKNOWN(") && s.endsWith(")")) {
+ return portNumber(s.substring("UNKNOWN(".length(), s.length() - 1));
+ } else {
+ return Logical.valueOf(s).instance;
}
- return "UNKNOWN";
}
@Override
public String toString() {
- if (!isLogical()) {
- return name;
- } else {
+ if (isLogical()) {
return decodeLogicalPort();
+ } else if (hasName()) {
+ // named port
+ return String.format("[%s](%d)", name, number);
+ } else {
+ // unsigned decimal string
+ return name;
}
}
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 e3d6993c..cf7bed6d 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,15 @@ public interface BridgeConfig extends HandlerBehaviour {
void addBridge(BridgeName bridgeName);
/**
+ * Adds a bridge with given bridge name, dpid and exPortName.
+ *
+ * @param bridgeName bridge name
+ * @param dpid dpid
+ * @param exPortName external port name
+ */
+ void addBridge(BridgeName bridgeName, String dpid, String exPortName);
+
+ /**
* Adds a bridge with given bridge name and dpid, and sets the controller
* of the bridge with given controllers.
*
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java
index 3f782954..a15217c6 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java
@@ -52,7 +52,7 @@ public final class BridgeName {
@Override
public int hashCode() {
- return Objects.hash(name);
+ return name.hashCode();
}
@Override
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 5cdc0c12..3757d327 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
@@ -20,10 +20,15 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import java.util.function.Function;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -51,6 +56,21 @@ public abstract class Config<S> {
protected ConfigApplyDelegate delegate;
/**
+ * Indicator of whether a configuration JSON field is required.
+ */
+ public enum FieldPresence {
+ /**
+ * Signifies that config field is an optional one.
+ */
+ OPTIONAL,
+
+ /**
+ * Signifies that config field is mandatory.
+ */
+ MANDATORY
+ }
+
+ /**
* Initializes the configuration behaviour with necessary context.
*
* @param subject configuration subject
@@ -71,6 +91,29 @@ public abstract class Config<S> {
}
/**
+ * Indicates whether or not the backing JSON node contains valid data.
+ * <p>
+ * Default implementation returns true.
+ * Subclasses are expected to override this with their own validation.
+ * </p>
+ *
+ * @return true if the data is valid; false otherwise
+ */
+ public boolean isValid() {
+ // TODO: figure out what assertions could be made in the base class
+ // NOTE: The thought is to have none, but instead to provide a set
+ // of predicates to allow configs to test validity of present fields,
+ // e.g.:
+ // isString(path)
+ // isBoolean(path)
+ // isNumber(path, [min, max])
+ // isDecimal(path, [min, max])
+ // isMacAddress(path)
+ // isIpAddress(path)
+ return true;
+ }
+
+ /**
* Returns the specific subject to which this configuration pertains.
*
* @return configuration subject
@@ -309,4 +352,104 @@ public abstract class Config<S> {
return this;
}
+ /**
+ * Indicates whether only the specified fields are present in the backing JSON.
+ *
+ * @param allowedFields allowed field names
+ * @return true if all allowedFields are present; false otherwise
+ */
+ protected boolean hasOnlyFields(String... allowedFields) {
+ Set<String> fields = ImmutableSet.copyOf(allowedFields);
+ return !Iterators.any(object.fieldNames(), f -> !fields.contains(f));
+ }
+
+ /**
+ * Indicates whether the specified field holds a valid MAC address.
+ *
+ * @param field JSON field name
+ * @param presence specifies if field is optional or mandatory
+ * @return true if valid; false otherwise
+ * @throws IllegalArgumentException if field is present, but not valid MAC
+ */
+ protected boolean isMacAddress(String field, FieldPresence presence) {
+ JsonNode node = object.path(field);
+ return isValid(node, presence, node.isTextual() &&
+ MacAddress.valueOf(node.asText()) != null);
+ }
+
+ /**
+ * Indicates whether the specified field holds a valid IP address.
+ *
+ * @param field JSON field name
+ * @param presence specifies if field is optional or mandatory
+ * @return true if valid; false otherwise
+ * @throws IllegalArgumentException if field is present, but not valid IP
+ */
+ protected boolean isIpAddress(String field, FieldPresence presence) {
+ JsonNode node = object.path(field);
+ return isValid(node, presence, node.isTextual() &&
+ IpAddress.valueOf(node.asText()) != null);
+ }
+
+ /**
+ * Indicates whether the specified field holds a valid string value.
+ *
+ * @param field JSON field name
+ * @param presence specifies if field is optional or mandatory
+ * @param pattern optional regex pattern
+ * @return true if valid; false otherwise
+ * @throws IllegalArgumentException if field is present, but not valid MAC
+ */
+ protected boolean isString(String field, FieldPresence presence, String... pattern) {
+ JsonNode node = object.path(field);
+ return isValid(node, presence, node.isTextual() &&
+ (pattern.length > 0 && node.asText().matches(pattern[0]) || pattern.length < 1));
+ }
+
+ /**
+ * Indicates whether the specified field holds a valid number.
+ *
+ * @param field JSON field name
+ * @param presence specifies if field is optional or mandatory
+ * @param minMax optional min/max values
+ * @return true if valid; false otherwise
+ * @throws IllegalArgumentException if field is present, but not valid
+ */
+ protected boolean isNumber(String field, FieldPresence presence, long... minMax) {
+ JsonNode node = object.path(field);
+ return isValid(node, presence, (node.isLong() || node.isInt()) &&
+ (minMax.length > 0 && minMax[0] <= node.asLong() || minMax.length < 1) &&
+ (minMax.length > 1 && minMax[1] > node.asLong() || minMax.length < 2));
+ }
+
+ /**
+ * Indicates whether the specified field holds a valid decimal number.
+ *
+ * @param field JSON field name
+ * @param presence specifies if field is optional or mandatory
+ * @param minMax optional min/max values
+ * @return true if valid; false otherwise
+ * @throws IllegalArgumentException if field is present, but not valid
+ */
+ protected boolean isDecimal(String field, FieldPresence presence, double... minMax) {
+ JsonNode node = object.path(field);
+ return isValid(node, presence, (node.isDouble() || node.isFloat()) &&
+ (minMax.length > 0 && minMax[0] <= node.asDouble() || minMax.length < 1) &&
+ (minMax.length > 1 && minMax[1] > node.asDouble() || minMax.length < 2));
+ }
+
+ /**
+ * Indicates whether the node is present and of correct value or not
+ * mandatory and absent.
+ *
+ * @param node JSON node
+ * @param presence specifies if field is optional or mandatory
+ * @param correctValue true if the value is correct
+ * @return true if the field is as expected
+ */
+ private boolean isValid(JsonNode node, FieldPresence presence, boolean correctValue) {
+ boolean isMandatory = presence == FieldPresence.MANDATORY;
+ return isMandatory && correctValue || !isMandatory && !node.isNull() || correctValue;
+ }
+
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigService.java
index 8eb69a45..f1b22c41 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigService.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigService.java
@@ -119,7 +119,7 @@ public interface NetworkConfigService
/**
* Applies configuration for the specified subject and configuration
- * class using the raw JSON object. If configuration already exists, it
+ * class using the raw JSON node. If configuration already exists, it
* will be updated.
*
* @param subject configuration subject
@@ -128,6 +128,8 @@ public interface NetworkConfigService
* @param <S> type of subject
* @param <C> type of configuration
* @return configuration or null if one is not available
+ * @throws IllegalArgumentException if the supplied JSON node contains
+ * invalid data
*/
<S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
JsonNode json);
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStore.java
index 9dd66e8d..9be4b120 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStore.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStore.java
@@ -113,6 +113,8 @@ public interface NetworkConfigStore extends Store<NetworkConfigEvent, NetworkCon
* @param <S> type of subject
* @param <C> type of configuration
* @return configuration object
+ * @throws IllegalArgumentException if the supplied JSON node contains
+ * invalid data
*/
<S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
JsonNode json);
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java
index 3a8c8c1f..9074792c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java
@@ -24,6 +24,7 @@ import java.net.URI;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.Device.Type;
+import com.google.common.base.Objects;
/**
* Default implementation of immutable device description entity.
@@ -71,7 +72,7 @@ public class DefaultDeviceDescription extends AbstractDescription
*/
public DefaultDeviceDescription(DeviceDescription base,
SparseAnnotations... annotations) {
- this(base.deviceURI(), base.type(), base.manufacturer(),
+ this(base.deviceUri(), base.type(), base.manufacturer(),
base.hwVersion(), base.swVersion(), base.serialNumber(),
base.chassisId(), annotations);
}
@@ -83,13 +84,13 @@ public class DefaultDeviceDescription extends AbstractDescription
* @param annotations Annotations to use.
*/
public DefaultDeviceDescription(DeviceDescription base, Type type, SparseAnnotations... annotations) {
- this(base.deviceURI(), type, base.manufacturer(),
+ this(base.deviceUri(), type, base.manufacturer(),
base.hwVersion(), base.swVersion(), base.serialNumber(),
base.chassisId(), annotations);
}
@Override
- public URI deviceURI() {
+ public URI deviceUri() {
return uri;
}
@@ -132,6 +133,30 @@ public class DefaultDeviceDescription extends AbstractDescription
.toString();
}
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), uri, type, manufacturer,
+ hwVersion, swVersion, serialNumber, chassisId);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object instanceof DefaultDeviceDescription) {
+ if (!super.equals(object)) {
+ return false;
+ }
+ DefaultDeviceDescription that = (DefaultDeviceDescription) object;
+ return Objects.equal(this.uri, that.uri)
+ && Objects.equal(this.type, that.type)
+ && Objects.equal(this.manufacturer, that.manufacturer)
+ && Objects.equal(this.hwVersion, that.hwVersion)
+ && Objects.equal(this.swVersion, that.swVersion)
+ && Objects.equal(this.serialNumber, that.serialNumber)
+ && Objects.equal(this.chassisId, that.chassisId);
+ }
+ return false;
+ }
+
// default constructor for serialization
private DefaultDeviceDescription() {
this.uri = null;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java
index 572d201c..d62e932c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java
@@ -21,6 +21,7 @@ import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
import static org.onosproject.net.Port.Type;
+import com.google.common.base.Objects;
/**
* Default implementation of immutable port description.
@@ -117,4 +118,25 @@ public class DefaultPortDescription extends AbstractDescription
.toString();
}
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), number, isEnabled, type,
+ portSpeed);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object != null && getClass() == object.getClass()) {
+ if (!super.equals(object)) {
+ return false;
+ }
+ DefaultPortDescription that = (DefaultPortDescription) object;
+ return Objects.equal(this.number, that.number)
+ && Objects.equal(this.isEnabled, that.isEnabled)
+ && Objects.equal(this.type, that.type)
+ && Objects.equal(this.portSpeed, that.portSpeed);
+ }
+ return false;
+ }
+
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java
index 64b84b5a..f206b080 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java
@@ -33,7 +33,7 @@ public interface DeviceDescription extends Description {
*
* @return provider specific URI for the device
*/
- URI deviceURI();
+ URI deviceUri();
/**
* Returns the type of the infrastructure device.
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 453a7648..a842d600 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
@@ -23,6 +23,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip6Address;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
@@ -353,6 +354,26 @@ public final class DefaultTrafficSelector implements TrafficSelector {
}
@Override
+ public Builder matchArpTpa(Ip4Address addr) {
+ return add(Criteria.matchArpTpa(addr));
+ }
+
+ @Override
+ public Builder matchArpSpa(Ip4Address addr) {
+ return add(Criteria.matchArpSpa(addr));
+ }
+
+ @Override
+ public Builder matchArpTha(MacAddress addr) {
+ return add(Criteria.matchArpTha(addr));
+ }
+
+ @Override
+ public Builder matchArpSha(MacAddress addr) {
+ return add(Criteria.matchArpSha(addr));
+ }
+
+ @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 6beeecc9..4615a82b 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
@@ -388,7 +388,12 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
@Override
public Builder setQueue(long queueId) {
- return add(Instructions.setQueue(queueId));
+ return add(Instructions.setQueue(queueId, null));
+ }
+
+ @Override
+ public Builder setQueue(long queueId, PortNumber port) {
+ return add(Instructions.setQueue(queueId, port));
}
@Override
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 1286ffc1..9fe88d5a 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
@@ -17,6 +17,7 @@ package org.onosproject.net.flow;
import java.util.Set;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip6Address;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
@@ -386,6 +387,38 @@ public interface TrafficSelector {
Builder matchIPv6ExthdrFlags(short exthdrFlags);
/**
+ * Matches a arp IPv4 destination address.
+ *
+ * @param addr a arp IPv4 destination address
+ * @return a selection builder
+ */
+ Builder matchArpTpa(Ip4Address addr);
+
+ /**
+ * Matches a arp IPv4 source address.
+ *
+ * @param addr a arp IPv4 source address
+ * @return a selection builder
+ */
+ Builder matchArpSpa(Ip4Address addr);
+
+ /**
+ * Matches a arp_eth_dst address.
+ *
+ * @param addr a arp_eth_dst address
+ * @return a selection builder
+ */
+ Builder matchArpTha(MacAddress addr);
+
+ /**
+ * Matches a arp_eth_src address.
+ *
+ * @param addr a arp_eth_src address
+ * @return a selection builder
+ */
+ Builder matchArpSha(MacAddress addr);
+
+ /**
* 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 b14ab99c..f1a676ab 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
@@ -271,6 +271,15 @@ public interface TrafficTreatment {
Builder setQueue(long queueId);
/**
+ * Sets the Queue ID for a specific port.
+ *
+ * @param queueId a queue ID
+ * @param port a port number
+ * @return a treatment builder
+ */
+ Builder setQueue(long queueId, PortNumber port);
+
+ /**
* Sets a meter to be used by this flow.
*
* @param meterId a meter id
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpHaCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpHaCriterion.java
new file mode 100644
index 00000000..71269dd1
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpHaCriterion.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.flow.criteria;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onlab.packet.MacAddress;
+
+/**
+ * Implementation of arp_eth_src address or arp_eth_dst address criterion.
+ */
+public final class ArpHaCriterion implements Criterion {
+ private final MacAddress mac;
+ private final Type type;
+
+ /**
+ * Constructor.
+ *
+ * @param mac the MAC Address to match.
+ * @param type the match type. Should be one of the following:
+ * Type.ARP_SHA, Type.ARP_THA
+ */
+ ArpHaCriterion(MacAddress mac, Type type) {
+ checkNotNull(mac, "mac cannot be null");
+ checkNotNull(type, "type cannot be null");
+ this.mac = mac;
+ this.type = type;
+ }
+
+ @Override
+ public Type type() {
+ return this.type;
+ }
+
+ /**
+ * Gets the MAC Address to match.
+ *
+ * @return the MAC Address to match
+ */
+ public MacAddress mac() {
+ return this.mac;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("mac", mac).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type().ordinal(), mac);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof ArpHaCriterion) {
+ ArpHaCriterion that = (ArpHaCriterion) obj;
+ return Objects.equals(mac, that.mac) &&
+ 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 778d50a5..554b8e74 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
@@ -510,15 +510,45 @@ public final class Criteria {
}
/**
- * Creates a match on IPv4 source field using the specified value.
+ * Creates a match on IPv4 destination field using the specified value.
*
- * @param ip ipv4 source value
+ * @param ip ipv4 destination value
* @return match criterion
*/
public static Criterion matchArpTpa(Ip4Address ip) {
return new ArpPaCriterion(ip, Type.ARP_TPA);
}
+ /**
+ * Creates a match on IPv4 source field using the specified value.
+ *
+ * @param ip ipv4 source value
+ * @return match criterion
+ */
+ public static Criterion matchArpSpa(Ip4Address ip) {
+ return new ArpPaCriterion(ip, Type.ARP_SPA);
+ }
+
+ /**
+ * Creates a match on MAC destination field using the specified value.
+ *
+ * @param mac MAC destination value
+ * @return match criterion
+ */
+ public static Criterion matchArpTha(MacAddress mac) {
+ return new ArpHaCriterion(mac, Type.ARP_THA);
+ }
+
+ /**
+ * Creates a match on MAC source field using the specified value.
+ *
+ * @param mac MAC source value
+ * @return match criterion
+ */
+ public static Criterion matchArpSha(MacAddress mac) {
+ return new ArpHaCriterion(mac, Type.ARP_SHA);
+ }
+
public static Criterion dummy() {
return new DummyCriterion();
}
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
index 747a85b5..3e1cb75c 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/ExtensionType.java
@@ -32,7 +32,8 @@ public final class ExtensionType {
*/
public enum ExtensionTypes {
// TODO fix type numbers to include experimenter id
- NICIRA_SET_TUNNEL_DST(31);
+ NICIRA_SET_TUNNEL_DST(31),
+ NICIRA_RESUBMIT(32);
private ExtensionType type;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
index aad407c8..126e722e 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
@@ -15,6 +15,7 @@
*/
package org.onosproject.net.flow.instructions;
+import com.google.common.base.MoreObjects;
import org.onlab.packet.EthType;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
@@ -99,11 +100,12 @@ public final class Instructions {
* Creates a set-queue instruction.
*
* @param queueId Queue Id
+ * @param port Port number
* @return set-queue instruction
*/
- public static SetQueueInstruction setQueue(final long queueId) {
+ public static SetQueueInstruction setQueue(final long queueId, final PortNumber port) {
checkNotNull(queueId, "queue ID cannot be null");
- return new SetQueueInstruction(queueId);
+ return new SetQueueInstruction(queueId, port);
}
public static MeterInstruction meterTraffic(final MeterId meterId) {
@@ -514,7 +516,7 @@ public final class Instructions {
@Override
public int hashCode() {
- return Objects.hash(type().ordinal());
+ return type().ordinal();
}
@Override
@@ -548,7 +550,7 @@ public final class Instructions {
@Override
public int hashCode() {
- return Objects.hash(type().ordinal());
+ return type().ordinal();
}
@Override
@@ -628,7 +630,8 @@ public final class Instructions {
@Override
public String toString() {
return toStringHelper(type().toString())
- .add("group ID", groupId.id()).toString();
+ .addValue("group ID=0x" + Integer.toHexString(groupId.id()))
+ .toString();
}
@Override
@@ -655,15 +658,26 @@ public final class Instructions {
*/
public static final class SetQueueInstruction implements Instruction {
private final long queueId;
+ private final PortNumber port;
private SetQueueInstruction(long queueId) {
this.queueId = queueId;
+ this.port = null;
+ }
+
+ private SetQueueInstruction(long queueId, PortNumber port) {
+ this.queueId = queueId;
+ this.port = port;
}
public long queueId() {
return queueId;
}
+ public PortNumber port() {
+ return port;
+ }
+
@Override
public Type type() {
return Type.QUEUE;
@@ -671,13 +685,18 @@ public final class Instructions {
@Override
public String toString() {
- return toStringHelper(type().toString())
- .add("queueId", queueId).toString();
+ MoreObjects.ToStringHelper toStringHelper = toStringHelper(type().toString());
+ toStringHelper.add("queueId", queueId);
+
+ if (port() != null) {
+ toStringHelper.add("port", port);
+ }
+ return toStringHelper.toString();
}
@Override
public int hashCode() {
- return Objects.hash(type().ordinal(), queueId);
+ return Objects.hash(type().ordinal(), queueId, port);
}
@Override
@@ -687,7 +706,7 @@ public final class Instructions {
}
if (obj instanceof SetQueueInstruction) {
SetQueueInstruction that = (SetQueueInstruction) obj;
- return Objects.equals(queueId, that.queueId);
+ return Objects.equals(queueId, that.queueId) && Objects.equals(port, that.port);
}
return false;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java
index a6e5903c..4af3d168 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java
@@ -114,7 +114,7 @@ public abstract class L0ModificationInstruction implements Instruction {
@Override
public int hashCode() {
- return Objects.hash(lambda);
+ return lambda.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java
index c6847d1c..b72dd7bc 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java
@@ -62,7 +62,7 @@ public abstract class L1ModificationInstruction implements Instruction {
@Override
public int hashCode() {
- return Objects.hash(oduSignalId);
+ return oduSignalId.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java
index 546a4513..97f8aedf 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java
@@ -186,7 +186,7 @@ public class DefaultGroup extends DefaultGroupDescription
*/
@Override
public int hashCode() {
- return super.hashCode() + Objects.hash(id);
+ return Objects.hash(super.hashCode(), id);
}
/*
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/DefaultHostDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/DefaultHostDescription.java
index 1f05197a..307a6078 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/DefaultHostDescription.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/DefaultHostDescription.java
@@ -28,6 +28,7 @@ import org.onlab.packet.VlanId;
import com.google.common.collect.ImmutableSet;
import static com.google.common.base.MoreObjects.toStringHelper;
+import com.google.common.base.Objects;
/**
* Default implementation of an immutable host description.
@@ -119,4 +120,24 @@ public class DefaultHostDescription extends AbstractDescription
.toString();
}
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), mac, vlan, location, ip);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object != null && getClass() == object.getClass()) {
+ if (!super.equals(object)) {
+ return false;
+ }
+ DefaultHostDescription that = (DefaultHostDescription) object;
+ return Objects.equal(this.mac, that.mac)
+ && Objects.equal(this.vlan, that.vlan)
+ && Objects.equal(this.location, that.location)
+ && Objects.equal(this.ip, that.ip);
+ }
+ return false;
+ }
+
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
index 98329df0..92824cf8 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
@@ -15,9 +15,12 @@
*/
package org.onosproject.net.host;
+import org.joda.time.LocalDateTime;
import org.onosproject.event.AbstractEvent;
import org.onosproject.net.Host;
+import static com.google.common.base.MoreObjects.toStringHelper;
+
/**
* Describes end-station host event.
*/
@@ -48,6 +51,8 @@ public class HostEvent extends AbstractEvent<HostEvent.Type, Host> {
HOST_MOVED
}
+ private Host prevSubject;
+
/**
* Creates an event of a given type and for the specified host and the
* current time.
@@ -70,4 +75,39 @@ public class HostEvent extends AbstractEvent<HostEvent.Type, Host> {
super(type, host, time);
}
+ /**
+ * Creates an event with previous subject.
+ *
+ * The previous subject is ignored if the type is not moved or updated
+ *
+ * @param type host event type
+ * @param host event host subject
+ * @param prevSubject previous host subject
+ */
+ public HostEvent(Type type, Host host, Host prevSubject) {
+ super(type, host);
+ if (type == Type.HOST_MOVED || type == Type.HOST_UPDATED) {
+ this.prevSubject = prevSubject;
+ }
+ }
+
+ /**
+ * Gets the previous subject in this host event.
+ *
+ * @return the previous subject, or null if previous subject is not
+ * specified.
+ */
+ public Host prevSubject() {
+ return this.prevSubject;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("time", new LocalDateTime(time()))
+ .add("type", type())
+ .add("subject", subject())
+ .add("prevSubject", prevSubject())
+ .toString();
+ }
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
index caa5fbb9..4548c44d 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
@@ -42,6 +42,7 @@ public final class MplsPathIntent extends PathIntent {
* ports and using the specified explicit path.
*
* @param appId application identifier
+ * @param key intent key
* @param selector traffic selector
* @param treatment treatment
* @param path traversed links
@@ -51,11 +52,11 @@ public final class MplsPathIntent extends PathIntent {
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException {@code path} is null
*/
- private MplsPathIntent(ApplicationId appId, TrafficSelector selector,
+ private MplsPathIntent(ApplicationId appId, Key key, TrafficSelector selector,
TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
Optional<MplsLabel> egressLabel, List<Constraint> constraints,
int priority) {
- super(appId, selector, treatment, path, constraints,
+ super(appId, key, selector, treatment, path, constraints,
priority);
this.ingressLabel = checkNotNull(ingressLabel);
@@ -149,6 +150,7 @@ public final class MplsPathIntent extends PathIntent {
return new MplsPathIntent(
appId,
+ key,
selector,
treatment,
path,
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
index 0c831fd5..9bf137a1 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
@@ -42,6 +42,7 @@ public class PathIntent extends ConnectivityIntent {
* ports and using the specified explicit path.
*
* @param appId application identifier
+ * @param key intent key
* @param selector traffic selector
* @param treatment treatment
* @param path traversed links
@@ -50,12 +51,13 @@ public class PathIntent extends ConnectivityIntent {
* @throws NullPointerException {@code path} is null
*/
protected PathIntent(ApplicationId appId,
+ Key key,
TrafficSelector selector,
TrafficTreatment treatment,
Path path,
List<Constraint> constraints,
int priority) {
- super(appId, null, resources(path.links()), selector, treatment, constraints,
+ super(appId, key, resources(path.links()), selector, treatment, constraints,
priority);
PathIntent.validate(path.links());
this.path = path;
@@ -138,6 +140,7 @@ public class PathIntent extends ConnectivityIntent {
return new PathIntent(
appId,
+ key,
selector,
treatment,
path,
@@ -184,6 +187,7 @@ public class PathIntent extends ConnectivityIntent {
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("id", id())
+ .add("key", key())
.add("appId", appId())
.add("priority", priority())
.add("resources", resources())
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 20ccb55d..444feee4 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
@@ -87,7 +87,7 @@ public final class BandwidthConstraint extends BooleanConstraint {
@Override
public int hashCode() {
- return Objects.hash(bandwidth);
+ return bandwidth.hashCode();
}
@Override
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 9dd813b2..7811a004 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
@@ -69,7 +69,7 @@ public class LambdaConstraint extends BooleanConstraint {
@Override
public int hashCode() {
- return Objects.hash(lambda);
+ return Objects.hashCode(lambda);
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
index 54eb4ea5..aecef879 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
@@ -67,7 +67,7 @@ public class LatencyConstraint implements Constraint {
@Override
public int hashCode() {
- return Objects.hash(latency);
+ return latency.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java
index cb1e6b2b..ca4f3fd3 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java
@@ -66,7 +66,7 @@ public class ObstacleConstraint extends BooleanConstraint {
@Override
public int hashCode() {
- return Objects.hash(obstacles);
+ return obstacles.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java
index 1acf6dfe..4839feec 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java
@@ -91,7 +91,7 @@ public class WaypointConstraint implements Constraint {
@Override
public int hashCode() {
- return Objects.hash(waypoints);
+ return waypoints.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/link/DefaultLinkDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/link/DefaultLinkDescription.java
index 891eb65d..cba17640 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/link/DefaultLinkDescription.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/link/DefaultLinkDescription.java
@@ -20,6 +20,7 @@ import org.onosproject.net.AbstractDescription;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Link;
import org.onosproject.net.SparseAnnotations;
+import com.google.common.base.Objects;
/**
* Default implementation of immutable link description entity.
@@ -70,4 +71,23 @@ public class DefaultLinkDescription extends AbstractDescription
.add("type", type()).toString();
}
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), src, dst, type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object != null && getClass() == object.getClass()) {
+ if (!super.equals(object)) {
+ return false;
+ }
+ DefaultLinkDescription that = (DefaultLinkDescription) object;
+ return Objects.equal(this.src, that.src)
+ && Objects.equal(this.dst, that.dst)
+ && Objects.equal(this.type, that.type);
+ }
+ return false;
+ }
+
}
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 e94ee452..cdcd4072 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
@@ -26,7 +26,7 @@ import java.util.List;
@Beta
public interface ResourceAdminService {
/**
- * Register resources as the children of the parent resource path.
+ * Registers resources as the children of the parent resource path.
*
* @param parent parent resource path under which the resource are registered
* @param children resources to be registered as the children of the parent
@@ -39,7 +39,7 @@ public interface ResourceAdminService {
}
/**
- * Register resources as the children of the parent resource path.
+ * Registers resources as the children of the parent resource path.
*
* @param parent parent resource path under which the resource are registered
* @param children resources to be registered as the children of the parent
@@ -50,7 +50,7 @@ public interface ResourceAdminService {
<T> boolean registerResources(ResourcePath parent, List<T> children);
/**
- * Unregister resources as the children of the parent resource path.
+ * Unregisters resources as the children of the parent resource path.
*
* @param parent parent resource path under which the resource are unregistered
* @param children resources to be unregistered as the children of the parent
@@ -63,7 +63,7 @@ public interface ResourceAdminService {
}
/**
- * Unregister resources as the children of the parent resource path.
+ * Unregisters resources as the children of the parent resource path.
*
* @param parent parent resource path under which the resource are unregistered
* @param children resources to be unregistered as the children of the parent
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceEvent.java
new file mode 100644
index 00000000..98abf301
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceEvent.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.newresource;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.event.AbstractEvent;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Describes an event related to a resource.
+ */
+@Beta
+public final class ResourceEvent extends AbstractEvent<ResourceEvent.Type, ResourcePath> {
+
+ /**
+ * Type of resource events.
+ */
+ @Beta
+ public enum Type {
+ /**
+ * Signifies that a new resource has been detected.
+ */
+ RESOURCE_ADDED,
+
+ /**
+ * Signifies that a resource has been removed.
+ */
+ RESOURCE_REMOVED
+ }
+
+ /**
+ * Create a resource event.
+ *
+ * @param type type of resource event
+ * @param subject subject of resource event
+ */
+ public ResourceEvent(Type type, ResourcePath subject) {
+ super(checkNotNull(type), checkNotNull(subject));
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceListener.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceListener.java
new file mode 100644
index 00000000..3f871900
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceListener.java
@@ -0,0 +1,26 @@
+/*
+ * 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.newresource;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.event.EventListener;
+
+/**
+ * Entity capable of receiving resource related events.
+ */
+@Beta
+public interface ResourceListener extends EventListener<ResourceEvent> {
+}
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 3aa29f6b..d87682a9 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
@@ -19,12 +19,14 @@ import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
-import java.util.Arrays;
+import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
+import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
/**
* An object that is used to locate a resource in a network.
@@ -32,32 +34,45 @@ import static com.google.common.base.Preconditions.checkNotNull;
* of elementary resources that are not globally identifiable. A ResourcePath can be a globally
* unique resource identifier.
*
+ * Two types of resource are considered. One is discrete type and the other is continuous type.
+ * Discrete type resource is a resource whose amount is measured as a discrete unit. VLAN ID and
+ * MPLS label are examples of discrete type resource. Continuous type resource is a resource whose
+ * amount is measured as a continuous value. Bandwidth is an example of continuous type resource.
+ * A double value is associated with a continuous type value.
+ *
* Users of this class must keep the semantics of resources regarding the hierarchical structure.
* For example, resource path, Link:1/VLAN ID:100, is valid, but resource path, VLAN ID:100/Link:1
* is not valid because a link is not a sub-component of a VLAN ID.
*/
@Beta
-public final class ResourcePath {
+public abstract class ResourcePath {
- private final List<Object> resources;
+ private final Discrete parent;
+ private final Object last;
- public static final ResourcePath ROOT = new ResourcePath(ImmutableList.of());
+ public static final Discrete ROOT = new Discrete();
- public static ResourcePath child(ResourcePath parent, Object child) {
- ImmutableList<Object> components = ImmutableList.builder()
- .addAll(parent.components())
- .add(child)
- .build();
- return new ResourcePath(components);
+ /**
+ * 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.
+ */
+ public static ResourcePath discrete(Object... components) {
+ if (components.length == 0) {
+ return ROOT;
+ } else {
+ return new Discrete(ImmutableList.copyOf(components));
+ }
}
/**
- * Creates an resource path from the specified components.
+ * Creates an resource path which represents a continuous-type resource from the specified components.
*
+ * @param value amount of the resource
* @param components components of the path. The order represents hierarchical structure of the resource.
*/
- public ResourcePath(Object... components) {
- this(Arrays.asList(components));
+ public static ResourcePath continuous(double value, Object... components) {
+ return new Continuous(ImmutableList.copyOf(components), value);
}
/**
@@ -65,15 +80,37 @@ public final class ResourcePath {
*
* @param components components of the path. The order represents hierarchical structure of the resource.
*/
- public ResourcePath(List<Object> components) {
+ ResourcePath(List<Object> components) {
checkNotNull(components);
+ checkArgument(!components.isEmpty());
+
+ LinkedList<Object> children = new LinkedList<>(components);
+ this.last = children.pollLast();
+ if (children.isEmpty()) {
+ this.parent = ROOT;
+ } else {
+ this.parent = new Discrete(children);
+ }
+ }
- this.resources = ImmutableList.copyOf(components);
+ /**
+ * Creates an resource path from the specified parent and child.
+ *
+ * @param parent the parent of this resource
+ * @param last a child of the parent
+ */
+ ResourcePath(Discrete parent, Object last) {
+ checkNotNull(parent);
+ checkNotNull(last);
+
+ this.parent = parent;
+ this.last = last;
}
// for serialization
private ResourcePath() {
- this.resources = null;
+ this.parent = null;
+ this.last = null;
}
/**
@@ -82,7 +119,15 @@ public final class ResourcePath {
* @return the components of this resource path
*/
public List<Object> components() {
- return resources;
+ LinkedList<Object> components = new LinkedList<>();
+
+ ResourcePath current = this;
+ while (current.parent().isPresent()) {
+ components.addFirst(current.last);
+ current = current.parent;
+ }
+
+ return components;
}
/**
@@ -92,21 +137,20 @@ public final class ResourcePath {
* @return the parent resource path of this instance.
* If there is no parent, empty instance will be returned.
*/
- public Optional<ResourcePath> parent() {
- if (!isRoot()) {
- return Optional.of(new ResourcePath(resources.subList(0, resources.size() - 1)));
- }
+ public Optional<Discrete> parent() {
+ return Optional.ofNullable(parent);
+ }
+
+ public ResourcePath child(Object child) {
+ checkState(this instanceof Discrete);
- return Optional.empty();
+ return new Discrete((Discrete) this, child);
}
- /**
- * Returns true if the path represents root.
- *
- * @return true if the path represents root, false otherwise.
- */
- public boolean isRoot() {
- return resources.size() == 0;
+ public ResourcePath child(Object child, double value) {
+ checkState(this instanceof Discrete);
+
+ return new Continuous((Discrete) this, child, value);
}
/**
@@ -115,14 +159,13 @@ public final class ResourcePath {
* @return the last component of this instance.
* The return value is equal to the last object of {@code components()}.
*/
- public Object lastComponent() {
- int last = resources.size() - 1;
- return resources.get(last);
+ public Object last() {
+ return last;
}
@Override
public int hashCode() {
- return resources.hashCode();
+ return Objects.hash(this.parent, this.last);
}
@Override
@@ -134,13 +177,68 @@ public final class ResourcePath {
return false;
}
final ResourcePath that = (ResourcePath) obj;
- return Objects.equals(this.resources, that.resources);
+ return Objects.equals(this.parent, that.parent)
+ && Objects.equals(this.last, that.last);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
- .add("resources", resources)
+ .add("parent", parent)
+ .add("last", last)
.toString();
}
+
+ /**
+ * Represents a resource path which specifies a resource which can be measured
+ * as a discrete unit. A VLAN ID and a MPLS label of a link are examples of the resource.
+ * <p>
+ * 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.
+ * </p>
+ */
+ public static final class Discrete extends ResourcePath {
+ private Discrete() {
+ super();
+ }
+
+ private Discrete(List<Object> components) {
+ super(components);
+ }
+
+ private Discrete(Discrete parent, Object last) {
+ super(parent, last);
+ }
+ }
+
+ /**
+ * Represents a resource path which specifies a resource which can be measured
+ * as continuous value. Bandwidth of a link is an example of the resource.
+ * <p>
+ * 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.
+ */
+ public static final class Continuous extends ResourcePath {
+ // Note: value is not taken into account for equality
+ private final double value;
+
+ private Continuous(List<Object> components, double value) {
+ super(components);
+ this.value = value;
+ }
+
+ public Continuous(Discrete parent, Object last, double value) {
+ super(parent, last);
+ this.value = value;
+ }
+
+ /**
+ * Returns the value of the resource amount.
+ *
+ * @return the value of the resource amount
+ */
+ public double value() {
+ return value;
+ }
+ }
}
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 ad684c8c..966de500 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
@@ -17,6 +17,7 @@ package org.onosproject.net.newresource;
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
+import org.onosproject.event.ListenerService;
import java.util.Arrays;
import java.util.Collection;
@@ -29,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Service for allocating/releasing resource(s) and retrieving allocation(s) and availability.
*/
@Beta
-public interface ResourceService {
+public interface ResourceService extends ListenerService<ResourceEvent, ResourceListener> {
/**
* Allocates the specified resource to the specified user.
*
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 2cab9d4b..7c67430e 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
@@ -16,6 +16,7 @@
package org.onosproject.net.newresource;
import com.google.common.annotations.Beta;
+import org.onosproject.store.Store;
import java.util.Collection;
import java.util.List;
@@ -25,7 +26,7 @@ import java.util.Optional;
* Service for storing resource and consumer information.
*/
@Beta
-public interface ResourceStore {
+public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegate> {
/**
* Registers the resources in transactional way.
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStoreDelegate.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStoreDelegate.java
new file mode 100644
index 00000000..a0b9bb25
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStoreDelegate.java
@@ -0,0 +1,24 @@
+/*
+ * 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.newresource;
+
+import org.onosproject.store.StoreDelegate;
+
+/**
+ * Resource store delegate abstraction.
+ */
+public interface ResourceStoreDelegate extends StoreDelegate<ResourceEvent> {
+}
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 0bfb3795..d3bd2d7b 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
@@ -23,7 +23,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Representation of bandwidth resource in bps.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public final class BandwidthResource implements LinkResource {
private final Bandwidth bandwidth;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java
index 74f6e102..5f36d5f8 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java
@@ -23,7 +23,10 @@ import java.util.Objects;
/**
* Representation of allocated bandwidth resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public class BandwidthResourceAllocation implements ResourceAllocation {
private final BandwidthResource bandwidth;
@@ -53,7 +56,7 @@ public class BandwidthResourceAllocation implements ResourceAllocation {
@Override
public int hashCode() {
- return Objects.hash(bandwidth);
+ return bandwidth.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java
index e07309cb..ff26e81e 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java
@@ -23,7 +23,10 @@ import org.onosproject.net.resource.ResourceType;
/**
* Representation of a request for bandwidth resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public class BandwidthResourceRequest implements ResourceRequest {
private final BandwidthResource bandwidth;
@@ -53,7 +56,7 @@ public class BandwidthResourceRequest implements ResourceRequest {
@Override
public int hashCode() {
- return Objects.hash(bandwidth);
+ return bandwidth.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceAllocations.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceAllocations.java
index 379bf71e..2fa4fa6b 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceAllocations.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceAllocations.java
@@ -36,7 +36,10 @@ import java.util.Set;
/**
* Implementation of {@link LinkResourceAllocations}.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public class DefaultLinkResourceAllocations implements LinkResourceAllocations {
private final LinkResourceRequest request;
// TODO: probably should be using LinkKey instead
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 f8e143a4..b57465f2 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
@@ -39,7 +39,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Implementation of {@link LinkResourceRequest}.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public final class DefaultLinkResourceRequest implements LinkResourceRequest {
private final IntentId intentId;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResource.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResource.java
index 3733e467..06582497 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResource.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResource.java
@@ -23,7 +23,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Representation of lambda resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public final class LambdaResource implements LinkResource {
private final IndexedLambda lambda;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java
index 545f025f..930a6b27 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java
@@ -23,7 +23,10 @@ import java.util.Objects;
/**
* Representation of allocated lambda resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public class LambdaResourceAllocation implements ResourceAllocation {
private final LambdaResource lambda;
@@ -53,7 +56,7 @@ public class LambdaResourceAllocation implements ResourceAllocation {
@Override
public int hashCode() {
- return Objects.hash(lambda);
+ return Objects.hashCode(lambda);
}
@Override
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 d264d5e5..24d3d78d 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
@@ -24,7 +24,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Representation of a request for lambda resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public class LambdaResourceRequest implements ResourceRequest {
private final LambdaResource lambda;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResource.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResource.java
index ec06611e..b06f16bf 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResource.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResource.java
@@ -17,6 +17,9 @@ package org.onosproject.net.resource.link;
/**
* Abstraction of link resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public interface LinkResource {
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceAllocations.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceAllocations.java
index 7828867c..d0211e26 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceAllocations.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceAllocations.java
@@ -25,7 +25,10 @@ import org.onosproject.net.resource.ResourceRequest;
/**
* Representation of allocated link resources.
+ *
+ * @deprecated
*/
+@Deprecated
public interface LinkResourceAllocations extends ResourceAllocation {
/**
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceEvent.java
index 3edb386a..a3702923 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceEvent.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceEvent.java
@@ -23,7 +23,10 @@ import com.google.common.collect.ImmutableList;
/**
* Describes an event related to a Link Resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public final class LinkResourceEvent
extends AbstractEvent<LinkResourceEvent.Type, Collection<LinkResourceAllocations>> {
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceListener.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceListener.java
index 599dd4fb..bbb02e2f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceListener.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceListener.java
@@ -19,6 +19,9 @@ import org.onosproject.event.EventListener;
/**
* Entity for receiving link resource events.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public interface LinkResourceListener extends EventListener<LinkResourceEvent> {
}
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 37622e79..9774e8e7 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
@@ -27,7 +27,10 @@ import org.onosproject.net.resource.ResourceRequest;
/**
* Representation of a request for link resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public interface LinkResourceRequest extends ResourceRequest {
/**
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStore.java
index e6674dbd..e8a295c2 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStore.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStore.java
@@ -23,7 +23,10 @@ import org.onosproject.net.resource.ResourceAllocation;
/**
* Manages link resources.
+ *
+ * @deprecated in Emu Release.
*/
+@Deprecated
public interface LinkResourceStore {
/**
* Returns free resources for given link.
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStoreDelegate.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStoreDelegate.java
index 6c051d6a..dbfb3b04 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStoreDelegate.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceStoreDelegate.java
@@ -19,6 +19,9 @@ import org.onosproject.store.StoreDelegate;
/**
* Link resource store delegate abstraction.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public interface LinkResourceStoreDelegate extends StoreDelegate<LinkResourceEvent> {
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResources.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResources.java
index dc005227..46450427 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResources.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LinkResources.java
@@ -19,7 +19,10 @@ import java.util.Set;
/**
* Abstraction of a resources of a link.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public interface LinkResources {
/**
@@ -31,7 +34,10 @@ public interface LinkResources {
/**
* Builder of {@link LinkResources}.
+ *
+ * @deprecated in Emu Release
*/
+ @Deprecated
interface Builder {
/**
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabel.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabel.java
index 89c87760..5138d02c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabel.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabel.java
@@ -20,7 +20,10 @@ import java.util.Objects;
/**
* Representation of MPLS label resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public final class MplsLabel implements LinkResource {
private final org.onlab.packet.MplsLabel mplsLabel;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java
index 10911539..7441bee9 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java
@@ -24,7 +24,10 @@ import java.util.Objects;
/**
* Representation of allocated MPLS label resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public class MplsLabelResourceAllocation implements ResourceAllocation {
private final MplsLabel mplsLabel;
@@ -54,7 +57,7 @@ public class MplsLabelResourceAllocation implements ResourceAllocation {
@Override
public int hashCode() {
- return Objects.hash(mplsLabel);
+ return Objects.hashCode(mplsLabel);
}
@Override
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 01a048b7..5b9c4a0a 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
@@ -24,7 +24,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Representation of a request for lambda resource.
+ *
+ * @deprecated in Emu Release
*/
+@Deprecated
public class MplsLabelResourceRequest implements ResourceRequest {
private final MplsLabel mplsLabel;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/package-info.java
index b10e4ba4..f374d778 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/package-info.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/package-info.java
@@ -17,5 +17,11 @@
/**
* Services for reserving links and their capacity as network resources,
* e.g.&nbsp;bandwidth, lambdas.
+ * <p>
+ * Note: Classes under the package will be remove.
+ * Developers should not use the classes.
+ * This package is marked as deprecated in Emu Release.
+ * </p>
*/
+@Deprecated
package org.onosproject.net.resource.link;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/package-info.java
index e676fc87..a05dfda1 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/package-info.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/package-info.java
@@ -16,5 +16,9 @@
/**
* Abstractions for reserving network resources.
+ * <p>
+ * Note: Classes under the package will be removed.
+ * Developers should not use the classes.
+ * </p>
*/
package org.onosproject.net.resource;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java
index 676f0068..1e6780fa 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java
@@ -53,7 +53,7 @@ public final class ClusterId {
@Override
public int hashCode() {
- return Objects.hash(id);
+ return id;
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java
index dacb5fd8..99d700e1 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java
@@ -20,6 +20,7 @@ import org.onosproject.net.Link;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
/**
* Implementation of the topology edge backed by a link.
@@ -40,7 +41,7 @@ public class DefaultTopologyEdge implements TopologyEdge {
public DefaultTopologyEdge(TopologyVertex src, TopologyVertex dst, Link link) {
this.src = src;
this.dst = dst;
- this.link = link;
+ this.link = checkNotNull(link);
}
@Override
@@ -60,7 +61,7 @@ public class DefaultTopologyEdge implements TopologyEdge {
@Override
public int hashCode() {
- return Objects.hash(link);
+ return link.hashCode();
}
@Override
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java
index 07a09cbd..4782bc95 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java
@@ -42,7 +42,7 @@ public class DefaultTopologyVertex implements TopologyVertex {
@Override
public int hashCode() {
- return Objects.hash(deviceId);
+ return deviceId.hashCode();
}
@Override