Class GlobalRegistryCache
- java.lang.Object
-
- de.aristaflow.adept2.base.globalregistry.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 Summary
Fields Modifier and Type Field Description protected Map<List<URI>,List<URI>>
globalLocalUris
The mapping from global service URIs to the corresponding locally exported URIs.protected Map<URI,Pair<String,String>>
globalNames
The mapping from each global URI to the corresponding service name.protected ReadWriteLock
lock
The lock for synchronising access to the data structures.protected Map<Pair<String,String>,List<URI>>
nameGlobalUris
The mapping from service name (type and instance name) to the corresponding globally exported URIs.protected Map<Pair<String,String>,List<URI>>
nameLocalUris
The mapping from service name (type and instance name) to the corresponding locally exported URIs.
-
Constructor Summary
Constructors Constructor Description GlobalRegistryCache()
Creates a new cache with empty data structures.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.List<URI>
getGlobalServiceUris(String servType, String servName)
Gets the URIs with which the designated service can be reached globally (via the global registry).List<URI>
getLocalServiceUris(String servType, String servName)
Gets the URIs with which the designated service has been exported locally.List<URI>
getLocalServiceUris(URI globUri)
Gets the URIs with which the designated service has been exported locally.List<URI>
getLocalServiceUris(List<URI> globUris)
Gets the URIs with which the designated service has been exported locally.void
invalidateAll()
Invalidates all local URIs in this cache.void
invalidateService(String servType, String servName)
Invalidates the local URIs of the designated service and removes them from this cache.void
invalidateService(List<URI> globUris)
Invalidates the local URIs of the service with the designated global URIs and removes them from this cache.void
invalidateUri(URI globUri)
Invalidates the local URIs of the service with the designated global URI and removes them from this cache.void
publishService(String servType, String servName, List<URI> globUris, List<URI> locUris)
Adds the designated service information to the cache.void
renew(String servType, String servName, List<URI> locUris)
Renews the locally exported URIs of the designated service identified by its name.void
renew(List<URI> globUris, List<URI> locUris)
Renews the locally exported URIs of the designated service identified by its global URIs.
-
-
-
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.
-
-
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 apublished
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 apublished
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 apublished
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 apublished
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 apublished
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 apublished
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 apublished
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.
-
-