Added annotations for tier and meteredUsage
Change-Id: I9a32bc1b5787361cdb7c4b6d7a23279c75188571
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 d19117f..2cfb333 100644
--- a/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
+++ b/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
@@ -248,6 +248,19 @@
public static final String METERED = "metered";
/**
+ * Annotation key for data usage on a metered link.
+ * The value of this key is expected to be a percentage of the data available within the plan.
+ */
+ public static final String METERED_USAGE = "meteredUsage";
+
+ /**
+ * Annotation key for identifying the tier ranking of a link. Links with a lower tier would be
+ * selected in the path over links with a higher tier.
+ * The value of this key is expected to be a number that represents the tier value.
+ */
+ public static final String TIER = "tier";
+
+ /**
* 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 8ee0c1b..e6a5c85 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
@@ -45,6 +45,8 @@
public static final String DELAY = "delay";
public static final String LOSS = "loss";
public static final String AVAILABILITY = "availability";
+ public static final String TIER = "tier";
+ public static final String METERED_USAGE = "meteredUsage";
public static final String FLAPPING = "flapping";
public static final String IS_DURABLE = "durable";
public static final String IS_BIDIRECTIONAL = "bidirectional";
@@ -56,11 +58,13 @@
type();
return hasOnlyFields(ALLOWED, TYPE, METRIC, LATENCY, BANDWIDTH, JITTER, DELAY, LOSS, AVAILABILITY, FLAPPING,
- IS_DURABLE, IS_BIDIRECTIONAL, IS_METERED) &&
+ IS_DURABLE, IS_BIDIRECTIONAL, IS_METERED, TIER, METERED_USAGE) &&
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) &&
+ isNumber(TIER, OPTIONAL) &&
+ isDecimal(METERED_USAGE, OPTIONAL) &&
isBoolean(IS_BIDIRECTIONAL, OPTIONAL) &&
isBoolean(IS_METERED, OPTIONAL);
}
@@ -322,7 +326,7 @@
}
/**
- * Sets durability for this link.
+ * Sets metered flag for this link.
*
* @param isMetered true for metered, false otherwise
* @return this BasicLinkConfig
@@ -332,6 +336,44 @@
}
/**
+ * Returns link tier.
+ *
+ * @return link tier value; -1 if not set
+ */
+ public long tier() {
+ return get(TIER, -1);
+ }
+
+ /**
+ * Sets the link tier.
+ *
+ * @param tier new link tier value; null to clear
+ * @return self
+ */
+ public BasicLinkConfig tier(Long tier) {
+ return (BasicLinkConfig) setOrClear(TIER, tier);
+ }
+
+ /**
+ * Returns metered link usage in terms of percentage.
+ *
+ * @return metered link usage value; -1 if not set
+ */
+ public double meteredUsage() {
+ return get(METERED_USAGE, -1.0);
+ }
+
+ /**
+ * Sets the metered link usage.
+ *
+ * @param meteredUsage new metered usage value; null to clear
+ * @return self
+ */
+ public BasicLinkConfig meteredUsage(Double meteredUsage) {
+ return (BasicLinkConfig) setOrClear(METERED_USAGE, meteredUsage);
+ }
+
+ /**
* Create a {@link BasicLinkConfig} instance.
* <p>
* Note: created instance needs to be initialized by #init(..) before using.