Make 'mappings' CLI output user friendly
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / mappingservice / IMappingService.java
index 16e2309abeb22065f2d00ec03ce6d06a153ec1d9..5f08aa619083ddec68e583fde79fe422de95c90a 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,22 +8,26 @@
 
 package org.opendaylight.lispflowmapping.interfaces.mappingservice;
 
+import org.opendaylight.lispflowmapping.lisp.type.MappingData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId;
+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;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
 
 /**
- *
- * Mapping Service Java API
+ * Mapping Service Java API.
  *
  * @author Florin Coras
  *
  */
 
 public interface IMappingService {
+
+    enum LookupPolicy { NB_FIRST, NB_AND_SB }
+
     /**
-     * Add mapping
+     * Add mapping.
      *
      * @param origin
      *            Table where mapping should be added
@@ -31,32 +35,41 @@ public interface IMappingService {
      *            Key of the mapping
      * @param siteId
      *            Site that stores the mapping
-     * @param data
-     *            Value to be stored
+     * @param mapping
+     *            Mapping to be stored
      */
-    void addMapping(MappingOrigin origin, Eid key, SiteId siteId, Object data);
+    void addMapping(MappingOrigin origin, Eid key, SiteId siteId, 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);
 
     /**
      * Retrieves mapping with given origin for the provided key. The lookup policy for the key is defined in the Mapping
-     * System
+     * System.
      *
      * @param origin
      *            Table where the mapping should be looked up.
      * @param key
      *            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(MappingOrigin origin, Eid key);
+    MappingData getMapping(MappingOrigin origin, Eid key);
 
     /**
      * Retrieves mapping for given key.The lookup policy for the key is defined in the Mapping
-     * System
+     * System.
      *
      * @param key
      *            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 key);
+    MappingData getMapping(Eid key);
 
     /**
      * Retrieves mapping with a Source/Dest policy. This method is meant to avoid the overhead of building
@@ -66,12 +79,33 @@ public interface IMappingService {
      *            Source key being looked up
      * @param dstKey
      *            Destination key being 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 srcKey, Eid dstKey);
+    MappingData getMapping(Eid srcKey, Eid dstKey);
 
     /**
-     * Remove mapping
+     * Retrieves widest negative prefix found in the Mapping System for given key.
+     *
+     * @param key
+     *            Key being looked up
+     * @return Returns the widest negative prefix or null if nothing is found.
+     */
+    Eid getWidestNegativePrefix(Eid key);
+
+    /**
+     * Refresh southbound mapping registration timestamp.
+     *
+     * @param key
+     *            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 refreshMappingRegistration(Eid key, XtrId xtrId, Long timestamp);
+
+    /**
+     * Remove mapping.
      *
      * @param origin
      *            Table from where the mapping should be removed
@@ -81,7 +115,7 @@ public interface IMappingService {
     void removeMapping(MappingOrigin origin, Eid key);
 
     /**
-     * Add authentication key
+     * Add authentication key.
      *
      * @param key
      *            The key for which the authentication key is added
@@ -91,7 +125,7 @@ public interface IMappingService {
     void addAuthenticationKey(Eid key, MappingAuthkey authKey);
 
     /**
-     * Retrieve authentication key
+     * Retrieve authentication key.
      *
      * @param key
      *            The key for which the authentication key is being looked up.
@@ -100,7 +134,7 @@ public interface IMappingService {
     MappingAuthkey getAuthenticationKey(Eid key);
 
     /**
-     * Remove authentication key
+     * Remove authentication key.
      *
      * @param key
      *            Key for which the authentication key should be removed.
@@ -122,7 +156,7 @@ public interface IMappingService {
     void addData(MappingOrigin origin, Eid key, String subKey, Object data);
 
     /**
-     * Generic retrieval of data
+     * Generic retrieval of data.
      *
      * @param origin
      *            Table from where the data should be read
@@ -135,7 +169,7 @@ public interface IMappingService {
     Object getData(MappingOrigin origin, Eid key, String subKey);
 
     /**
-     * Generic removal of data
+     * Generic removal of data.
      *
      * @param origin
      *            The table from where the data should be removed
@@ -147,13 +181,22 @@ public interface IMappingService {
     void removeData(MappingOrigin origin, Eid key, String subKey);
 
     /**
-     * Configures Mapping Service mapping overwrite option. If set to true, mappings with the same key are overwritten,
-     * otherwise, mappings with the same key but from different xTR-IDs are all stored
+     * 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);
+
+    /**
+     * Configures Mapping Service mapping merge option. If set to false, mappings with the same key are overwritten,
+     * otherwise, mappings with the same key but from different xTR-IDs are all stored.
      *
-     * @param overwrite
-     *            enables or disables mapping overwrite
+     * @param mappingMerge
+     *            enables or disables mapping merge
      */
-    void setMappingOverwrite(boolean overwrite);
+    void setMappingMerge(boolean mappingMerge);
 
     /**
      * Configures Mapping Service mapping lookup policy option.
@@ -161,17 +204,47 @@ public interface IMappingService {
      * @param policy
      *            the policy to be activated
      */
-    void setLookupPolicy(int policy);
+    void setLookupPolicy(LookupPolicy policy);
 
     /**
-     * Print all mappings. Used for testing, debugging and the karaf shell
+     * Print all mappings. Used for testing, debugging and the karaf shell.
      *
      * @return String consisting of all mappings
      */
     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();
+
     /**
      * Cleans all cached mappings.Used for testing.
      */
     void cleanCachedMappings();
+
+    /**
+     * Set cluster master status.
+     *
+     * @param isMaster
+     *            is|isn't master
+     */
+    void setIsMaster(boolean isMaster);
+
+    /**
+     * Get cluster master status.
+     *
+     * @return isMaster
+     *            is|isn't master
+     */
+    boolean isMaster();
 }