Package org.apache.sling.discovery.commons.providers.spi.base

# 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:
  `org.apache.sling.api.resource.observation.ResourceChangeListener`

public class IdMapService extends AbstractServiceWithBackgroundCheck implements org.apache.sling.api.resource.observation.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

`CHANGES, PATHS, PROPERTY_NAMES_HINT`

## Constructor Summary

Constructors
Constructor
Description
`IdMapService()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`activate(org.osgi.framework.BundleContext bundleContext)`
`void`
`clearCache()`
`protected void`
`deactivate()`
`long`
`getMyId()`
`boolean`
`isInitialized()`
`void`
`onChange(List<org.apache.sling.api.resource.observation.ResourceChange> changes)`
`static IdMapService`
`testConstructor(DiscoveryLiteConfig commonsConfig, org.apache.sling.settings.SlingSettingsService settingsService, org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)`
test-only constructor
`String`
`toSlingId(int clusterNodeId, org.apache.sling.api.resource.ResourceResolver resourceResolver)`
`boolean`
`waitForInit(long timeout)`
for testing only

### Methods inherited from class org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck

`cancelPreviousBackgroundCheck, startBackgroundCheck, triggerBackgroundCheck`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### IdMapService

public IdMapService()

## Method Details

### testConstructor

public static IdMapService testConstructor(DiscoveryLiteConfig commonsConfig, org.apache.sling.settings.SlingSettingsService settingsService, org.apache.sling.api.resource.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, org.apache.sling.api.resource.ResourceResolver resourceResolver) throws org.apache.sling.api.resource.PersistenceException

Throws:
  `org.apache.sling.api.resource.PersistenceException`

### onChange

public void onChange(List<org.apache.sling.api.resource.observation.ResourceChange> changes)

Specified by:
  `onChange` in interface `org.apache.sling.api.resource.observation.ResourceChangeListener`