Partial fix for ONOS-6767.
- pruning removed annotation tombstones
- processing netcfg only on master node
- swapping priority of processing of geo/grid coordinates
Change-Id: Icade1032f94ea774136d863d388402c79094c5a7
diff --git a/core/api/src/main/java/org/onosproject/net/DefaultAnnotations.java b/core/api/src/main/java/org/onosproject/net/DefaultAnnotations.java
index a78987c..2a0eeb5 100644
--- a/core/api/src/main/java/org/onosproject/net/DefaultAnnotations.java
+++ b/core/api/src/main/java/org/onosproject/net/DefaultAnnotations.java
@@ -205,6 +205,16 @@
throw new IllegalArgumentException("Expecting HashMap instance");
}
+ private static HashMap<String, String> compress(Map<String, String> original) {
+ HashMap<String, String> compressed = new HashMap<>();
+ original.forEach((k, v) -> {
+ if (!Objects.equals(v, Builder.REMOVED)) {
+ compressed.put(k, v);
+ }
+ });
+ return compressed;
+ }
+
@Override
public String toString() {
return (map == null) ? "null" : map.toString();
@@ -289,11 +299,22 @@
/**
* Returns immutable annotations built from the accrued key/values pairs.
+ * Any removed annotation tombstones will be preserved.
*
* @return annotations
*/
public DefaultAnnotations build() {
return new DefaultAnnotations(copy(builder));
}
+
+ /**
+ * Returns immutable annotations built from the accrued key/values
+ * pairs after compressing them to eliminate removed annotation tombstones.
+ *
+ * @return annotations
+ */
+ public DefaultAnnotations buildCompressed() {
+ return new DefaultAnnotations(compress(builder));
+ }
}
}