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

# Class OakBacklogClusterSyncService

java.lang.Object
org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck
org.apache.sling.discovery.commons.providers.spi.base.OakBacklogClusterSyncService

All Implemented Interfaces:
  `ClusterSyncService`

public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundCheck implements ClusterSyncService
The OakBacklogClusterSyncService will wait until all instances in the local cluster are no longer in any backlog state.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected DiscoveryLiteConfig`
`commonsConfig`
`protected org.apache.sling.api.resource.ResourceResolverFactory`
`resourceResolverFactory`
`protected org.apache.sling.settings.SlingSettingsService`
`settingsService`

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

`backgroundCheckRunnable, logger, slingId`

## Constructor Summary

Constructors
Constructor
Description
`OakBacklogClusterSyncService()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`activate()`
`void`
`cancelSync()`
`protected DiscoveryLiteConfig`
`getCommonsConfig()`
`ClusterSyncHistory`
`getConsistencyHistory()`
`protected org.apache.sling.api.resource.ResourceResolver`
`getResourceResolver()`
Get or create a ResourceResolver
`protected org.apache.sling.settings.SlingSettingsService`
`getSettingsService()`
`List<String>`
`getSyncHistory()`
`void`
`setConsistencyHistory(ClusterSyncHistory consistencyHistory)`
`void`
`sync(BaseTopologyView view, Runnable callback)`
Starts the synchronization process and calls the provided callback upon completion.
`static OakBacklogClusterSyncService`
`testConstructor(DiscoveryLiteConfig commonsConfig, IdMapService idMapService, org.apache.sling.settings.SlingSettingsService settingsService, org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)`
for testing only!
`static OakBacklogClusterSyncService`
`testConstructorAndActivate(DiscoveryLiteConfig commonsConfig, IdMapService idMapService, org.apache.sling.settings.SlingSettingsService settingsService, org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)`

### 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`

## Field Details

### commonsConfig

protected DiscoveryLiteConfig commonsConfig

### resourceResolverFactory

protected org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory

### settingsService

protected org.apache.sling.settings.SlingSettingsService settingsService

## Constructor Details

### OakBacklogClusterSyncService

public OakBacklogClusterSyncService()

## Method Details

### testConstructorAndActivate

public static OakBacklogClusterSyncService testConstructorAndActivate(DiscoveryLiteConfig commonsConfig, IdMapService idMapService, org.apache.sling.settings.SlingSettingsService settingsService, org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)

### testConstructor

public static OakBacklogClusterSyncService testConstructor(DiscoveryLiteConfig commonsConfig, IdMapService idMapService, org.apache.sling.settings.SlingSettingsService settingsService, org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)
for testing only!

### activate

protected void activate()

### setConsistencyHistory

public void setConsistencyHistory(ClusterSyncHistory consistencyHistory)

### getConsistencyHistory

public ClusterSyncHistory getConsistencyHistory()

### getResourceResolver

protected org.apache.sling.api.resource.ResourceResolver getResourceResolver() throws org.apache.sling.api.resource.LoginException
Get or create a ResourceResolver

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

### cancelSync

public void cancelSync()

Specified by:
  `cancelSync` in interface `ClusterSyncService`

### sync

public void sync(BaseTopologyView view, Runnable callback)
Description copied from interface: `ClusterSyncService`
Starts the synchronization process and calls the provided callback upon completion.

sync() is not thread-safe and should not be invoked concurrently.

If sync() gets called before a previous invocation finished, that previous invocation will be discarded, ie the callback of the previous invocation will no longer be called.

The synchronization process consists of making sure that the repository has processed any potential backlog of instances that are no longer part of the provided, new view. Plus it writes a 'sync-token' to a well-defined location, with all peers doing the same, and upon seeing all other sync-tokens declares successful completion - at which point it calls the callback.run().

Specified by:
  `sync` in interface `ClusterSyncService`
Parameters:
  `view` - the view which all instances in the local cluster should agree on having seen
  `callback` - the runnable which should be called after successful syncing

### getCommonsConfig

protected DiscoveryLiteConfig getCommonsConfig()

### getSettingsService

protected org.apache.sling.settings.SlingSettingsService getSettingsService()

### getSyncHistory

public List<String> getSyncHistory()