Class GlobalRegistryCache


  • public class GlobalRegistryCache
    extends Object
    A cache for all information from the global registry to prevent expensive look-ups in the global registry. Users should invalidate the local URIs of a service in case they find it to be invalid.
    • Field Detail

      • nameLocalUris

        protected final Map<Pair<String,​String>,​List<URI>> nameLocalUris
        The mapping from service name (type and instance name) to the corresponding locally exported URIs.
      • nameGlobalUris

        protected final Map<Pair<String,​String>,​List<URI>> nameGlobalUris
        The mapping from service name (type and instance name) to the corresponding globally exported URIs. These are not invalidated.
      • globalLocalUris

        protected final Map<List<URI>,​List<URI>> globalLocalUris
        The mapping from global service URIs to the corresponding locally exported URIs.
      • globalNames

        protected final Map<URI,​Pair<String,​String>> globalNames
        The mapping from each global URI to the corresponding service name. These are not invalidated.
      • lock

        protected final ReadWriteLock lock
        The lock for synchronising access to the data structures.
    • Constructor Detail

      • GlobalRegistryCache

        public GlobalRegistryCache()
        Creates a new cache with empty data structures.
    • Method Detail

      • publishService

        public void publishService​(String servType,
                                   String servName,
                                   List<URI> globUris,
                                   List<URI> locUris)
        Adds the designated service information to the cache. This is called right after a service has been published in the global registry.
        Parameters:
        servType - The service type name of the published service.
        servName - The (simple) name of the published service.
        globUris - The URIs the service can be reached globally (via the global registry).
        locUris - The URIs the service has been exported locally.
      • renew

        public void renew​(String servType,
                          String servName,
                          List<URI> locUris)
        Renews the locally exported URIs of the designated service identified by its name. This only works for a published service.
        Parameters:
        servType - The service type name of the published service.
        servName - The (simple) name of the published service.
        locUris - The URIs the service has been exported locally.
      • renew

        public void renew​(List<URI> globUris,
                          List<URI> locUris)
        Renews the locally exported URIs of the designated service identified by its global URIs. This only works for a published service.
        Parameters:
        globUris - The URIs the service can be reached globally (via the global registry).
        locUris - The URIs the service has been exported locally.
      • addAndRenew

        public void addAndRenew​(URI globUri,
                                List<URI> locUris)
        Adds the locally exported URIs of the designated service identified by one of its global URIs and renews the local URIs. This only works for a published service.
        Parameters:
        globUri - One of the URIs the service can be reached globally (via the global registry).
        locUris - The URIs the service has been exported locally.
      • getGlobalServiceUris

        public List<URI> getGlobalServiceUris​(String servType,
                                              String servName)
        Gets the URIs with which the designated service can be reached globally (via the global registry). This only works for a published service.
        Parameters:
        servType - The service type name of the published service for which to get its global URIs.
        servName - The (simple) name of the published service for which to get its global URIs.
        Returns:
        The URIs the service can be reached globally (via the global registry). If the service is not known, null will be returned.
      • getLocalServiceUris

        public List<URI> getLocalServiceUris​(String servType,
                                             String servName)
        Gets the URIs with which the designated service has been exported locally. This only works for a published service.
        Parameters:
        servType - The service type name of the published service for which to get its local URIs.
        servName - The (simple) name of the published service for which to get its local URIs.
        Returns:
        The URIs the service has been exported locally. If the service is not known, null will be returned.
      • getLocalServiceUris

        public List<URI> getLocalServiceUris​(List<URI> globUris)
        Gets the URIs with which the designated service has been exported locally. This only works for a published service.
        Parameters:
        globUris - The URIs the service can be reached globally (via the global registry).
        Returns:
        The URIs the service has been exported locally. If the service is not known, null will be returned.
      • getLocalServiceUris

        public List<URI> getLocalServiceUris​(URI globUri)
        Gets the URIs with which the designated service has been exported locally. This only works for a published service.
        Parameters:
        globUri - One of the URIs of a service that can be reached globally (via the global registry).
        Returns:
        The URIs the service has been exported locally. If the service is not known, null will be returned.
      • invalidateUri

        public void invalidateUri​(URI globUri)
        Invalidates the local URIs of the service with the designated global URI and removes them from this cache.
        Parameters:
        globUri - One of the URIs of a service which that can be reached globally (via the global registry) and of which to remove its local URIs from this cache.
      • invalidateService

        public void invalidateService​(String servType,
                                      String servName)
        Invalidates the local URIs of the designated service and removes them from this cache.
        Parameters:
        servType - The service type name of the published service of which to remove its local URIs from this cache.
        servName - The (simple) name of the published service of which to remove its local URIs from this cache.
      • invalidateService

        public void invalidateService​(List<URI> globUris)
        Invalidates the local URIs of the service with the designated global URIs and removes them from this cache.
        Parameters:
        globUris - The URIs the service can be reached globally (via the global registry) and of which to remove its local URIs from this cache.
      • invalidateAll

        public void invalidateAll()
        Invalidates all local URIs in this cache.