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

# Class ClusterSyncServiceChain

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

All Implemented Interfaces:
  `ClusterSyncService`

public class ClusterSyncServiceChain extends Object implements ClusterSyncService
Allows chaining of ClusterSyncService, itself implementing the ClusterSyncService interface

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final org.slf4j.Logger`
`logger`

## Constructor Summary

Constructors
Constructor
Description
`ClusterSyncServiceChain(ClusterSyncService... chain)`
Creates a new chain of ClusterSyncService that calls a cascaded sync with the provided ClusterSyncService.

## Method Summary

Modifier and Type
Method
Description
`void`
`cancelSync()`
`void`
`sync(BaseTopologyView view, Runnable callback)`
Starts the synchronization process and calls the provided callback upon completion.

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

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

## Field Details

### logger

protected final org.slf4j.Logger logger

## Constructor Details

### ClusterSyncServiceChain

public ClusterSyncServiceChain(ClusterSyncService... chain)
Creates a new chain of ClusterSyncService that calls a cascaded sync with the provided ClusterSyncService.

## Method Details

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

### cancelSync

public void cancelSync()

Specified by:
  `cancelSync` in interface `ClusterSyncService`