Class SimpleMapCache

  • All Implemented Interfaces:
    ILispMapCache, IMapCache

    public class SimpleMapCache
    extends java.lang.Object
    implements ILispMapCache
    Simple map-cache that works with 'simple' addresses (see lisp-proto.yang). It can do longest prefix matching for IP addresses.
    Author:
    Florin Coras, Lorand Jakab
    • Constructor Detail

      • SimpleMapCache

        public SimpleMapCache​(ILispDAO dao)
    • Method Detail

      • addMapping

        public void addMapping​(Eid key,
                               java.lang.Object value)
        Description copied from interface: IMapCache
        Add mapping.
        Specified by:
        addMapping in interface IMapCache
        Parameters:
        key - Key of the mapping
        value - Value to be stored
      • addMapping

        public void addMapping​(Eid key,
                               java.lang.Object value,
                               java.util.Set<IpAddressBinary> sourceRlocs)
        Description copied from interface: ILispMapCache
        Add mapping.
        Specified by:
        addMapping in interface ILispMapCache
        Parameters:
        key - Key of the mapping
        value - Mapping to be stored
        sourceRlocs - The set of RLOCs from all registrations. Used for merging
      • addMapping

        public void addMapping​(Eid key,
                               XtrId xtrId,
                               java.lang.Object value)
        Description copied from interface: ILispMapCache
        Add mapping.
        Specified by:
        addMapping in interface ILispMapCache
        Parameters:
        key - Key of the mapping
        xtrId - xTR-ID of the mapping
        value - Mapping to be stored
      • getMapping

        public java.lang.Object getMapping​(Eid srcEid,
                                           Eid dstEid)
        Description copied from interface: IMapCache
        Retrieves mapping for the provided srcKey and dstKey.
        Specified by:
        getMapping in interface IMapCache
        Parameters:
        srcEid - Source Key to be looked up
        dstEid - Destination Key to be looked up
        Returns:
        Returns the object found in the cache or null if nothing is found.
      • getMapping

        public java.lang.Object getMapping​(Eid eid,
                                           XtrId xtrId)
        Description copied from interface: ILispMapCache
        Retrieves mapping for the provided srcKey, dstKey and a XtrId.
        Specified by:
        getMapping in interface ILispMapCache
        Parameters:
        eid - Key to be looked up
        xtrId - xTR-ID for which look-up to be done
        Returns:
        Returns the mapping found in the cache
      • getAllXtrIdMappings

        public java.util.List<java.lang.Object> getAllXtrIdMappings​(Eid eid)
        Description copied from interface: ILispMapCache
        Retrieve all xTR-ID sub-mappings for an EID. Used for merging logic.
        Specified by:
        getAllXtrIdMappings in interface ILispMapCache
        Parameters:
        eid - Key to be looked up
        Returns:
        The list of Objects which should be mappings
      • getWidestNegativeMapping

        public Eid getWidestNegativeMapping​(Eid eid)
        Description copied from interface: IMapCache
        Retrieves widest negative prefix.
        Specified by:
        getWidestNegativeMapping in interface IMapCache
        Parameters:
        eid - Source Key to be looked up
        Returns:
        Returns the widest negative prefix or null if nothing is found.
      • getCoveringLessSpecific

        public Eid getCoveringLessSpecific​(Eid eid)
        Description copied from interface: ILispMapCache
        Look up the covering prefix for the argument, but exclude the argument itself, so the result is always less specific than the lookup key.
        Specified by:
        getCoveringLessSpecific in interface ILispMapCache
        Parameters:
        eid - The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
        Returns:
        The covering prefix.
      • getParentPrefix

        public Eid getParentPrefix​(Eid eid)
        Description copied from interface: ILispMapCache
        Returns the parent prefix for given key.
        Specified by:
        getParentPrefix in interface ILispMapCache
        Parameters:
        eid - The key for which parent is to be returned.
        Returns:
        The parent prefix of a specific key.
      • getSiblingPrefix

        public Eid getSiblingPrefix​(Eid eid)
        Description copied from interface: ILispMapCache
        Returns the sibling prefix for given key.
        Specified by:
        getSiblingPrefix in interface ILispMapCache
        Parameters:
        eid - The key for which sibling is to be returned.
        Returns:
        The sibling prefix of a specific key.
      • getVirtualParentSiblingPrefix

        public Eid getVirtualParentSiblingPrefix​(Eid eid)
        Description copied from interface: ILispMapCache
        Returns the virtual parent sibling prefix for given key.
        Specified by:
        getVirtualParentSiblingPrefix in interface ILispMapCache
        Parameters:
        eid - The key for which virtual parent sibling is to be returned.
        Returns:
        The virtual parent sibling prefix of a specific key.
      • getSubtree

        public java.util.Set<Eid> getSubtree​(Eid eid)
        Description copied from interface: IMapCache
        Retrieves the subtree of a prefix.
        Specified by:
        getSubtree in interface IMapCache
        Parameters:
        eid - Key to be looked up
        Returns:
        The set of prefixes in the subtree for the prefix
      • removeMapping

        public void removeMapping​(Eid eid)
        Description copied from interface: IMapCache
        Remove mapping.
        Specified by:
        removeMapping in interface IMapCache
        Parameters:
        eid - Key to be removed
      • removeMapping

        public void removeMapping​(Eid eid,
                                  XtrId xtrId)
        Description copied from interface: ILispMapCache
        Remove mapping.
        Specified by:
        removeMapping in interface ILispMapCache
        Parameters:
        eid - Key to be removed
        xtrId - xTR-ID of the mapping to be removed
      • removeXtrIdMappings

        public void removeXtrIdMappings​(Eid eid,
                                        java.util.List<XtrId> xtrIds)
        Description copied from interface: ILispMapCache
        Batch remove several xTR-ID sub-mappings under a certain key.

        This is a performance optimization, since interactive calls to removeMapping() would result in LPM lookups of the key for each call. With this method, only one such lookup is performed.

        Specified by:
        removeXtrIdMappings in interface ILispMapCache
        Parameters:
        eid - Key to be looked up
        xtrIds - List of xTR-IDs that need to be removed
      • addData

        public void addData​(Eid eid,
                            java.lang.String subKey,
                            java.lang.Object data)
        Description copied from interface: IMapCache
        Add data for key.
        Specified by:
        addData in interface IMapCache
        Parameters:
        eid - The key for which data is inserted
        subKey - The subKey where data should be inserted
        data - The data to be stored
      • getData

        public java.lang.Object getData​(Eid eid,
                                        java.lang.String subKey)
        Description copied from interface: IMapCache
        Generic retrieval of data.
        Specified by:
        getData in interface IMapCache
        Parameters:
        eid - The key where the data is stored
        subKey - The subKey where data is stored
        Returns:
        The data
      • removeData

        public void removeData​(Eid eid,
                               java.lang.String subKey)
        Description copied from interface: IMapCache
        Generic removal of data.
        Specified by:
        removeData in interface IMapCache
        Parameters:
        eid - The key of the data to be removed
        subKey - The subKey of the data to be removed
      • printMappings

        public java.lang.String printMappings()
        Description copied from interface: IMapCache
        Print mappings in cache. Used for testing, debugging and the karaf shell.
        Specified by:
        printMappings in interface IMapCache
        Returns:
        a String consisting of all the mappings in the cache
      • prettyPrintMappings

        public java.lang.String prettyPrintMappings()
        Description copied from interface: IMapCache
        Print mappings in cache in a human friendly format.
        Specified by:
        prettyPrintMappings in interface IMapCache
        Returns:
        a String consisting of all the mappings in the cache