Class MappingService

  • All Implemented Interfaces:
    java.lang.AutoCloseable, IMappingService, OdlMappingserviceService, org.opendaylight.yangtools.yang.binding.RpcService

    public class MappingService
    extends java.lang.Object
    implements OdlMappingserviceService, IMappingService, java.lang.AutoCloseable
    Dispatcher of API calls that implements the RPC and Java APIs in mappingservice.yang and IMappingService respectively. It also coordinates and acts as container for all objects in charge of - saving and updating md-sal datastore stored mappings - monitoring md-sal datastore mapping updates and pushing them to the in memory mapping-system - in memory mapping-system
    Author:
    Lorand Jakab, Florin Coras
    • Constructor Detail

      • MappingService

        public MappingService​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                              org.opendaylight.mdsal.binding.api.NotificationPublishService notificationPublishService,
                              ILispDAO lispDAO)
    • Method Detail

      • setMappingMerge

        public void setMappingMerge​(boolean mergeMapping)
        Description copied from interface: IMappingService
        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.
        Specified by:
        setMappingMerge in interface IMappingService
        Parameters:
        mergeMapping - enables or disables mapping merge
      • initialize

        public void initialize()
      • addMapping

        public void addMapping​(MappingOrigin origin,
                               Eid key,
                               SiteId siteId,
                               MappingData mappingData)
        Description copied from interface: IMappingService
        Add mapping.
        Specified by:
        addMapping in interface IMappingService
        Parameters:
        origin - Table where mapping should be added
        key - Key of the mapping
        siteId - Site that stores the mapping
        mappingData - Mapping to be stored
      • addNegativeMapping

        public MappingData addNegativeMapping​(Eid key)
        Description copied from interface: IMappingService
        Generate and add a negative mapping entry originated from the southbound, and return the generated mapping.
        Specified by:
        addNegativeMapping in interface IMappingService
        Parameters:
        key - Key of the mapping
        Returns:
        Returns the generated negative mapping (which is never null).
      • refreshMappingRegistration

        public void refreshMappingRegistration​(Eid key,
                                               XtrId xtrId,
                                               java.lang.Long timestamp)
        Description copied from interface: IMappingService
        Refresh southbound mapping registration timestamp.
        Specified by:
        refreshMappingRegistration in interface IMappingService
        Parameters:
        key - The EID whose registration must be refreshed
        xtrId - xTR-ID of the mapping to be refreshed
        timestamp - New timestamp for the mapping
      • getMapping

        public MappingData getMapping​(MappingOrigin origin,
                                      Eid key)
        Description copied from interface: IMappingService
        Retrieves mapping with given origin for the provided key. The lookup policy for the key is defined in the Mapping System.
        Specified by:
        getMapping in interface IMappingService
        Parameters:
        origin - Table where the mapping should be looked up.
        key - Key to be looked up
        Returns:
        Returns the mapping found in the Mapping System or null if nothing is found.
      • getMapping

        public MappingData getMapping​(Eid key)
        Description copied from interface: IMappingService
        Retrieves mapping for given key.The lookup policy for the key is defined in the Mapping System.
        Specified by:
        getMapping in interface IMappingService
        Parameters:
        key - Key to be looked up
        Returns:
        Returns the mapping found in the Mapping System or null if nothing is found.
      • getMapping

        public MappingData getMapping​(Eid srcKey,
                                      Eid dstKey)
        Description copied from interface: IMappingService
        Retrieves mapping with a Source/Dest policy. This method is meant to avoid the overhead of building LcafSourceDest addresses.
        Specified by:
        getMapping in interface IMappingService
        Parameters:
        srcKey - Source key being looked up
        dstKey - Destination key being looked up
        Returns:
        Returns the mapping found in the Mapping System or null if nothing is found.
      • subscribe

        public void subscribe​(Subscriber subscriber,
                              Eid subscribedEid)
        Description copied from interface: IMappingService
        Subscribe a Subscriber to receive updates about mapping changes for an EID.
        Specified by:
        subscribe in interface IMappingService
        Parameters:
        subscriber - The Subscriber object with information about the subscriber
        subscribedEid - The EID for which the subscriber will receive updates
      • getSubscribers

        public java.util.Set<Subscriber> getSubscribers​(Eid eid)
        Description copied from interface: IMappingService
        Retrieves the subscribers for an EID.
        Specified by:
        getSubscribers in interface IMappingService
        Parameters:
        eid - The EID to be looked up
        Returns:
        The set of subscribers for the EID
      • removeMapping

        public void removeMapping​(MappingOrigin origin,
                                  Eid key)
        Description copied from interface: IMappingService
        Remove mapping.
        Specified by:
        removeMapping in interface IMappingService
        Parameters:
        origin - Table from where the mapping should be removed
        key - Key to be removed
      • getWidestNegativePrefix

        public Eid getWidestNegativePrefix​(Eid key)
        Description copied from interface: IMappingService
        Retrieves widest negative prefix found in the Mapping System for given key.
        Specified by:
        getWidestNegativePrefix in interface IMappingService
        Parameters:
        key - Key being looked up
        Returns:
        Returns the widest negative prefix or null if nothing is found.
      • getSubtree

        public java.util.Set<Eid> getSubtree​(MappingOrigin origin,
                                             Eid key)
        Description copied from interface: IMappingService
        Retrieves the subtree of a maskable prefix from the given map-cache.
        Specified by:
        getSubtree in interface IMappingService
        Parameters:
        origin - Table where the key should be looked up
        key - Key to be looked up
        Returns:
        The child prefixes of the prefix, including the prefix itself if present
      • addAuthenticationKey

        public void addAuthenticationKey​(Eid key,
                                         MappingAuthkey authKey)
        Description copied from interface: IMappingService
        Add authentication key.
        Specified by:
        addAuthenticationKey in interface IMappingService
        Parameters:
        key - The key for which the authentication key is added
        authKey - The authentication key
      • getAuthenticationKey

        public MappingAuthkey getAuthenticationKey​(Eid key)
        Description copied from interface: IMappingService
        Retrieve authentication key.
        Specified by:
        getAuthenticationKey in interface IMappingService
        Parameters:
        key - The key for which the authentication key is being looked up.
        Returns:
        The authentication key.
      • removeAuthenticationKey

        public void removeAuthenticationKey​(Eid key)
        Description copied from interface: IMappingService
        Remove authentication key.
        Specified by:
        removeAuthenticationKey in interface IMappingService
        Parameters:
        key - Key for which the authentication key should be removed.
      • addData

        public void addData​(MappingOrigin origin,
                            Eid key,
                            java.lang.String subKey,
                            java.lang.Object data)
        Description copied from interface: IMappingService
        Generic addition of data. Not stored in MD-SAL datastore!
        Specified by:
        addData in interface IMappingService
        Parameters:
        origin - Table where data should be inserted
        key - The key where data should be inserted
        subKey - The subKey where data should be inserted
        data - The data to be stored
      • getData

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

        public void removeData​(MappingOrigin origin,
                               Eid key,
                               java.lang.String subKey)
        Description copied from interface: IMappingService
        Generic removal of data.
        Specified by:
        removeData in interface IMappingService
        Parameters:
        origin - The table from where the data should be removed
        key - The key of the data to be removed
        subKey - The subKey of the data to be removed
      • getParentPrefix

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

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

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

        public java.lang.String printKeys()
        Description copied from interface: IMappingService
        Print all authentication keys. Used for testing, debugging and the karaf shell.
        Specified by:
        printKeys in interface IMappingService
        Returns:
        String consisting of all mappings
      • prettyPrintKeys

        public java.lang.String prettyPrintKeys()
        Description copied from interface: IMappingService
        Print keys in cache in a human friendly format.
        Specified by:
        prettyPrintKeys in interface IMappingService
        Returns:
        a String consisting of all the keys in the cache
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • setIsMaster

        public void setIsMaster​(boolean isMaster)
        Description copied from interface: IMappingService
        Set cluster master status.
        Specified by:
        setIsMaster in interface IMappingService
        Parameters:
        isMaster - is|isn't master
      • isMaster

        public boolean isMaster()
        Description copied from interface: IMappingService
        Get cluster master status.
        Specified by:
        isMaster in interface IMappingService
        Returns:
        isMaster is|isn't master