Class IdMapService
java.lang.Object
org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck
org.apache.sling.discovery.commons.providers.spi.base.IdMapService
- All Implemented Interfaces:
ResourceChangeListener
public class IdMapService
extends AbstractServiceWithBackgroundCheck
implements ResourceChangeListener
The IdMapService is responsible for storing a slingId-clusterNodeId
pair to the repository and given all other instances in the cluster
do the same can map clusterNodeIds to slingIds (or vice-versa)
-
Field Summary
Fields inherited from class org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck
backgroundCheckRunnable, logger
Fields inherited from interface org.apache.sling.api.resource.observation.ResourceChangeListener
CHANGE_ADDED, CHANGE_CHANGED, CHANGE_PROVIDER_ADDED, CHANGE_PROVIDER_REMOVED, CHANGE_REMOVED, CHANGES, PATHS, PROPERTY_NAMES_HINT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
activate
(org.osgi.framework.BundleContext bundleContext) void
protected void
long
getMyId()
boolean
void
onChange
(List<ResourceChange> changes) Report resource changes based on the filter properties of this listener.static IdMapService
testConstructor
(DiscoveryLiteConfig commonsConfig, SlingSettingsService settingsService, ResourceResolverFactory resourceResolverFactory) test-only constructortoSlingId
(int clusterNodeId, ResourceResolver resourceResolver) boolean
waitForInit
(long timeout) for testing onlyMethods inherited from class org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck
cancelPreviousBackgroundCheck, startBackgroundCheck, triggerBackgroundCheck
-
Constructor Details
-
IdMapService
public IdMapService()
-
-
Method Details
-
testConstructor
public static IdMapService testConstructor(DiscoveryLiteConfig commonsConfig, SlingSettingsService settingsService, ResourceResolverFactory resourceResolverFactory) test-only constructor -
activate
protected void activate(org.osgi.framework.BundleContext bundleContext) -
deactivate
protected void deactivate() -
getMyId
public long getMyId() -
waitForInit
public boolean waitForInit(long timeout) for testing only -
isInitialized
public boolean isInitialized() -
clearCache
public void clearCache() -
toSlingId
public String toSlingId(int clusterNodeId, ResourceResolver resourceResolver) throws PersistenceException - Throws:
PersistenceException
-
onChange
Description copied from interface:ResourceChangeListener
Report resource changes based on the filter properties of this listener.Note that resource changes for paths which are ancestors of the paths this listener was registered to may be reported through this method. This is due to limitations of certain resource providers to provide events on a more granular level (e.g. for deletion or movement of resources containing (potentially nested) child resources).
Starting with version 1.2 of this API, an instance of
ResoureChangeList
is passed as the parameter to allow passing additional information.- Specified by:
onChange
in interfaceResourceChangeListener
- Parameters:
changes
- The changes list. This list is immutable.
-