Support to obtain all map records from MappingDatabase
Change-Id: Ia4c5932d35c36d8dbd75e8534e52c3e0c5af4256
diff --git a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/LispMappingDatabase.java b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/LispMappingDatabase.java
index 4545542..9aec8e9 100644
--- a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/LispMappingDatabase.java
+++ b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/LispMappingDatabase.java
@@ -89,6 +89,20 @@
}
/**
+ * Obtains all of the EID-RLOC mapping records.
+ *
+ * @return all of the EID-RLOC mapping records
+ */
+ public List<LispMapRecord> getAllMapRecords() {
+
+ List<LispMapRecord> mapRecords = Lists.newArrayList();
+
+ map.values().forEach(value -> mapRecords.add(value.getMapRecord()));
+
+ return mapRecords;
+ }
+
+ /**
* Obtains an EID-RLOC mapping record in accordance with the proxy map reply
* flag bit and EID record.
*
diff --git a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/map/ExpireHashMap.java b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/map/ExpireHashMap.java
index 08f7c88..bb9fd04 100644
--- a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/map/ExpireHashMap.java
+++ b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/map/ExpireHashMap.java
@@ -18,6 +18,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
@@ -157,6 +159,13 @@
}
@Override
+ public Collection<V> values() {
+ Collection<V> values = Collections.emptyList();
+ map.values().forEach(v -> values.add(v.getValue()));
+ return values;
+ }
+
+ @Override
public boolean isEmpty() {
return map.isEmpty();
}
diff --git a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/map/ExpireMap.java b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/map/ExpireMap.java
index 7bb8fcd..b59d0ef 100644
--- a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/map/ExpireMap.java
+++ b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/map/ExpireMap.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.lisp.ctl.impl.map;
+import java.util.Collection;
import java.util.Set;
/**
@@ -125,6 +126,23 @@
Set<K> keySet();
/**
+ * Returns a {@link Collection} view of the values contained in this map.
+ * The collection is backed by the map, so changes to the map are
+ * reflected in the collection, and vice-versa. If the map is
+ * modified while an iteration over the collection is in progress
+ * (except through the iterator's own <tt>remove</tt> operation),
+ * the results of the iteration are undefined. The collection
+ * supports element removal, which removes the corresponding
+ * mapping from the map, via the <tt>Iterator.remove</tt>,
+ * <tt>Collection.remove</tt>, <tt>removeAll</tt>,
+ * <tt>retainAll</tt> and <tt>clear</tt> operations. It does not
+ * support the <tt>add</tt> or <tt>addAll</tt> operations.
+ *
+ * @return a collection view of the values contained in this map
+ */
+ Collection<V> values();
+
+ /**
* Returns <tt>true</tt> if this map contains no key-value mappings.
*
* @return <tt>true</tt> if this map contains no key-value mappings