Bug 9116: SMR children of a prefix too
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / mapcache / IMappingSystem.java
index c280064b0b4e7bc2c788db999bf6504d2f12260c..613b75fb32d5da3eb99678cce67c2ee54653eb31 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc.  All rights reserved.
+ * Copyright (c) 2015, 2017 Cisco Systems, Inc.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,6 +8,9 @@
 
 package org.opendaylight.lispflowmapping.interfaces.mapcache;
 
+import java.util.Set;
+import org.opendaylight.lispflowmapping.interfaces.dao.Subscriber;
+import org.opendaylight.lispflowmapping.lisp.type.MappingData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
@@ -28,12 +31,31 @@ public interface IMappingSystem {
      *            Table where mapping should be added
      * @param key
      *            Key of the mapping
-     * @param data
-     *            Value to be stored
-     * @param merge
-     *            Select if mappings with the same key are merged
+     * @param mapping
+     *            Mapping to be stored
+     */
+    void addMapping(MappingOrigin origin, Eid key, MappingData mapping);
+
+    /**
+     * Generate and add a negative mapping entry originated from the southbound, and return the generated mapping.
+     *
+     * @param key
+     *            Key of the mapping
+     * @return Returns the generated negative mapping (which is never null).
+     */
+    MappingData addNegativeMapping(Eid key);
+
+    /**
+     * Update mapping.
+     *
+     * @param origin
+     *            Table where mapping should be added
+     * @param key
+     *            Key of the mapping
+     * @param mapping
+     *            Mapping to be stored
      */
-    void addMapping(MappingOrigin origin, Eid key, Object data, boolean merge);
+    void updateMapping(MappingOrigin origin, Eid key, MappingData mapping);
 
     /**
      * Retrieves mapping for the provided src and dst key.
@@ -42,18 +64,18 @@ public interface IMappingSystem {
      *            Source Key to be looked up
      * @param dst
      *            Destination Key to be looked up
-     * @return Returns the object found in the MappingSystem or null if nothing is found.
+     * @return Returns the mapping found in the MappingSystem or null if nothing is found.
      */
-    Object getMapping(Eid src, Eid dst);
+    MappingData getMapping(Eid src, Eid dst);
 
     /**
      * Retrieves mapping for the provided dst key.
      *
      * @param dst
      *            Destination Key to be looked up
-     * @return Returns the object found in the Mapping System or null if nothing is found.
+     * @return Returns the mapping found in the Mapping System or null if nothing is found.
      */
-    Object getMapping(Eid dst);
+    MappingData getMapping(Eid dst);
 
     /**
      * Retrieves mapping for the provided dst key for a particular xtr id.
@@ -64,9 +86,9 @@ public interface IMappingSystem {
      * @param xtrId
      *            Xtr Id for which this look to be done. If null, this method works like
      *            regular getMapping(src, dst)
-     * @return Returns the object found in the simple map cache or null if nothing is found.
+     * @return Returns the mapping found in the simple map cache or null if nothing is found.
      */
-    Object getMapping(Eid src, Eid dst, XtrId xtrId);
+    MappingData getMapping(Eid src, Eid dst, XtrId xtrId);
 
     /**
      * Retrieves mapping from table for provided key.
@@ -75,9 +97,9 @@ public interface IMappingSystem {
      *            Table where mapping should be looked up
      * @param key
      *            Key to be looked up
-     * @return Returns the object found in the cache or null if nothing is found.
+     * @return Returns the mapping found in the cache or null if nothing is found.
      */
-    Object getMapping(MappingOrigin origin, Eid key);
+    MappingData getMapping(MappingOrigin origin, Eid key);
 
     /**
      * Retrieves widest negative prefix from table for provided key.
@@ -86,19 +108,30 @@ public interface IMappingSystem {
      *            Key to be looked up
      * @return Returns the prefix found in the cache or null if nothing is found.
      */
-    Object getWidestNegativePrefix(Eid key);
+    Eid getWidestNegativePrefix(Eid key);
 
     /**
-     * Update mapping registration.
+     * Retrieves the subtree of a maskable prefix from the given map-cache.
      *
      * @param origin
-     *            Table for mapping that should be updated
+     *            Table where the key should be looked up
+     * @param key
+     *            Key to be looked up
+     * @return The child prefixes of the prefix, including the prefix itself if present
+     */
+    Set<Eid> getSubtree(MappingOrigin origin, Eid key);
+
+    /**
+     * Refresh southbound mapping registration timestamp.
+     *
      * @param key
-     *            The EID whose registration must be updated
+     *            The EID whose registration must be refreshed
+     * @param xtrId
+     *            xTR-ID of the mapping to be refreshed
      * @param timestamp
      *            New timestamp for the mapping
      */
-    void updateMappingRegistration(MappingOrigin origin, Eid key, Long timestamp);
+    void refreshMappingRegistration(Eid key, XtrId xtrId, Long timestamp);
 
     /**
      * Remove mapping.
@@ -111,6 +144,26 @@ public interface IMappingSystem {
      */
     void removeMapping(MappingOrigin origin, Eid key);
 
+    /**
+     * Subscribe a Subscriber to receive updates about mapping changes for an EID.
+     *
+     * @param subscriber
+     *            The Subscriber object with information about the subscriber
+     * @param subscribedEid
+     *            The EID for which the subscriber will receive updates
+     */
+    void subscribe(Subscriber subscriber, Eid subscribedEid);
+
+    /**
+     * Retrieves the subscribers for an EID.
+     *
+     * @param eid
+     *            The EID to be looked up
+     * @return
+     *            The set of subscribers for the EID
+     */
+    Set<Subscriber> getSubscribers(Eid eid);
+
     /**
      * Add authentication key.
      *
@@ -179,6 +232,15 @@ public interface IMappingSystem {
      */
     void removeData(MappingOrigin origin, Eid key, String subKey);
 
+    /**
+     * Returns the parent prefix for given key.
+     *
+     * @param key
+     *            The key which parent is to be returned.
+     * @return The parent perfix of a specific key.
+     */
+    Eid getParentPrefix(Eid key);
+
     /**
      * Sets iterateMask. If set to true, longest prefix matching for IP keys is used.
      *
@@ -189,12 +251,12 @@ public interface IMappingSystem {
     void setIterateMask(boolean iterate);
 
     /**
-     * Configure overwrite policy. If set to true, mappings are overwritten.
+     * Configure merge policy. If set to true, mappings are merged.
      *
-     * @param overwrite
+     * @param mappingMerge
      *            Value to configure
      */
-    void setOverwritePolicy(boolean overwrite);
+    void setMappingMerge(boolean mappingMerge);
 
     /**
      * Print all mappings. Used for testing, debugging and the karaf shell.
@@ -203,13 +265,34 @@ public interface IMappingSystem {
      */
     String printMappings();
 
+    /**
+     * Print mappings in cache in a human friendly format.
+     *
+     * @return a String consisting of all the mappings in the cache
+     */
+    String prettyPrintMappings();
+
+    /**
+     * Print all authentication keys. Used for testing, debugging and the karaf shell.
+     *
+     * @return String consisting of all mappings
+     */
+    String printKeys();
+
+    /**
+     * Print keys in cache in a human friendly format.
+     *
+     * @return a String consisting of all the keys in the cache
+     */
+    String prettyPrintKeys();
+
     /**
      * Set cluster master status.
      *
      * @param isMaster
      *            is|isn't master
      */
-    void setIsMaster(final boolean isMaster);
+    void setIsMaster(boolean isMaster);
 
     /**
      * Get cluster master status.