Class SimpleMapCache
- java.lang.Object
-
- org.opendaylight.lispflowmapping.mapcache.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 Summary
Constructors Constructor Description SimpleMapCache(ILispDAO dao)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addData(Eid eid, java.lang.String subKey, java.lang.Object data)
Add data for key.void
addMapping(Eid key, java.lang.Object value)
Add mapping.void
addMapping(Eid key, java.lang.Object value, java.util.Set<IpAddressBinary> sourceRlocs)
Add mapping.void
addMapping(Eid key, XtrId xtrId, java.lang.Object value)
Add mapping.java.util.List<java.lang.Object>
getAllXtrIdMappings(Eid eid)
Retrieve all xTR-ID sub-mappings for an EID.Eid
getCoveringLessSpecific(Eid eid)
Look up the covering prefix for the argument, but exclude the argument itself, so the result is always less specific than the lookup key.java.lang.Object
getData(Eid eid, java.lang.String subKey)
Generic retrieval of data.java.lang.Object
getMapping(Eid srcEid, Eid dstEid)
Retrieves mapping for the provided srcKey and dstKey.java.lang.Object
getMapping(Eid eid, XtrId xtrId)
Retrieves mapping for the provided srcKey, dstKey and a XtrId.Eid
getParentPrefix(Eid eid)
Returns the parent prefix for given key.Eid
getSiblingPrefix(Eid eid)
Returns the sibling prefix for given key.java.util.Set<Eid>
getSubtree(Eid eid)
Retrieves the subtree of a prefix.Eid
getVirtualParentSiblingPrefix(Eid eid)
Returns the virtual parent sibling prefix for given key.Eid
getWidestNegativeMapping(Eid eid)
Retrieves widest negative prefix.java.lang.String
prettyPrintMappings()
Print mappings in cache in a human friendly format.java.lang.String
printMappings()
Print mappings in cache.void
removeData(Eid eid, java.lang.String subKey)
Generic removal of data.void
removeMapping(Eid eid)
Remove mapping.void
removeMapping(Eid eid, XtrId xtrId)
Remove mapping.void
removeXtrIdMappings(Eid eid, java.util.List<XtrId> xtrIds)
Batch remove several xTR-ID sub-mappings under a certain key.
-
-
-
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 interfaceIMapCache
- Parameters:
key
- Key of the mappingvalue
- 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 interfaceILispMapCache
- Parameters:
key
- Key of the mappingvalue
- Mapping to be storedsourceRlocs
- 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 interfaceILispMapCache
- Parameters:
key
- Key of the mappingxtrId
- xTR-ID of the mappingvalue
- 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 interfaceIMapCache
- Parameters:
srcEid
- Source Key to be looked updstEid
- 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 interfaceILispMapCache
- Parameters:
eid
- Key to be looked upxtrId
- 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 interfaceILispMapCache
- 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 interfaceIMapCache
- 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 interfaceILispMapCache
- 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 interfaceILispMapCache
- 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 interfaceILispMapCache
- 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 interfaceILispMapCache
- 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 interfaceIMapCache
- 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 interfaceIMapCache
- 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 interfaceILispMapCache
- Parameters:
eid
- Key to be removedxtrId
- 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 interfaceILispMapCache
- Parameters:
eid
- Key to be looked upxtrIds
- 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.
-
getData
public java.lang.Object getData(Eid eid, java.lang.String subKey)
Description copied from interface:IMapCache
Generic retrieval of data.
-
removeData
public void removeData(Eid eid, java.lang.String subKey)
Description copied from interface:IMapCache
Generic removal of data.- Specified by:
removeData
in interfaceIMapCache
- Parameters:
eid
- The key of the data to be removedsubKey
- 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 interfaceIMapCache
- 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 interfaceIMapCache
- Returns:
- a String consisting of all the mappings in the cache
-
-