Added metered annotation to link
Change-Id: Ief7410d442e8e1c556cc97c0578aa5d717a7b127
diff --git a/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java b/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
index f1d4fb7..d19117f 100644
--- a/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
+++ b/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
@@ -242,6 +242,12 @@
public static final String FLAPPING = "flapping";
/**
+ * Annotation key for identifying a metered link.
+ * The value of this key is expected to be a boolean for metered as true/false.
+ */
+ public static final String METERED = "metered";
+
+ /**
* Returns the value annotated object for the specified annotation key.
* The annotated value is expected to be String that can be parsed as double.
* If parsing fails, the returned value will be {@value #DEFAULT_VALUE}.
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java
index ff4edb0..8ee0c1b 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java
@@ -48,6 +48,7 @@
public static final String FLAPPING = "flapping";
public static final String IS_DURABLE = "durable";
public static final String IS_BIDIRECTIONAL = "bidirectional";
+ public static final String IS_METERED = "metered";
@Override
public boolean isValid() {
@@ -55,12 +56,13 @@
type();
return hasOnlyFields(ALLOWED, TYPE, METRIC, LATENCY, BANDWIDTH, JITTER, DELAY, LOSS, AVAILABILITY, FLAPPING,
- IS_DURABLE, IS_BIDIRECTIONAL) &&
+ IS_DURABLE, IS_BIDIRECTIONAL, IS_METERED) &&
isBoolean(ALLOWED, OPTIONAL) && isNumber(METRIC, OPTIONAL) &&
isNumber(LATENCY, OPTIONAL) && isNumber(BANDWIDTH, OPTIONAL) && isDecimal(JITTER, OPTIONAL) &&
isDecimal(DELAY, OPTIONAL) && isDecimal(LOSS, OPTIONAL) && isDecimal(AVAILABILITY, OPTIONAL) &&
isDecimal(FLAPPING, OPTIONAL) &&
- isBoolean(IS_BIDIRECTIONAL, OPTIONAL);
+ isBoolean(IS_BIDIRECTIONAL, OPTIONAL) &&
+ isBoolean(IS_METERED, OPTIONAL);
}
/**
@@ -307,6 +309,29 @@
}
/**
+ * Returns if link is metered in the network model or not.
+ *
+ * @return true for metered, false otherwise
+ */
+ public Boolean isMetered() {
+ JsonNode res = object.path(IS_METERED);
+ if (res.isMissingNode()) {
+ return true;
+ }
+ return res.asBoolean();
+ }
+
+ /**
+ * Sets durability for this link.
+ *
+ * @param isMetered true for metered, false otherwise
+ * @return this BasicLinkConfig
+ */
+ public BasicLinkConfig isMetered(Boolean isMetered) {
+ return (BasicLinkConfig) setOrClear(IS_METERED, isMetered);
+ }
+
+ /**
* Create a {@link BasicLinkConfig} instance.
* <p>
* Note: created instance needs to be initialized by #init(..) before using.