@Service(value={ClusterSyncService.class,OakBacklogClusterSyncService.class}) public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundCheck implements ClusterSyncService
Modifier and Type | Field and Description |
---|---|
protected DiscoveryLiteConfig |
commonsConfig |
protected org.apache.sling.api.resource.ResourceResolverFactory |
resourceResolverFactory |
protected org.apache.sling.settings.SlingSettingsService |
settingsService |
backgroundCheckRunnable, logger, slingId
Constructor and Description |
---|
OakBacklogClusterSyncService() |
Modifier and Type | Method and 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) |
cancelPreviousBackgroundCheck, startBackgroundCheck, triggerBackgroundCheck
@Reference protected DiscoveryLiteConfig commonsConfig
@Reference protected org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory
@Reference protected org.apache.sling.settings.SlingSettingsService settingsService
public static OakBacklogClusterSyncService testConstructorAndActivate(DiscoveryLiteConfig commonsConfig, IdMapService idMapService, org.apache.sling.settings.SlingSettingsService settingsService, org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)
public static OakBacklogClusterSyncService testConstructor(DiscoveryLiteConfig commonsConfig, IdMapService idMapService, org.apache.sling.settings.SlingSettingsService settingsService, org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)
resourceResolverFactory
- slingId
- the local slingIdsyncTokenTimeoutMillis
- timeout value in millis after which the
sync-token process is cancelled - or -1 if no timeout should be used therebacklogWaitTimeoutMillis
- timeout value in millis after which
the waiting-while-backlog should be cancelled - or -1 if no timeout should be
used thereorg.apache.sling.api.resource.LoginException
- when the login for initialization failedorg.apache.sling.commons.json.JSONException
- when the descriptor wasn't proper json at init time@Activate protected void activate()
public void setConsistencyHistory(ClusterSyncHistory consistencyHistory)
public ClusterSyncHistory getConsistencyHistory()
protected org.apache.sling.api.resource.ResourceResolver getResourceResolver() throws org.apache.sling.api.resource.LoginException
org.apache.sling.api.resource.LoginException
public void cancelSync()
cancelSync
in interface ClusterSyncService
public void sync(BaseTopologyView view, Runnable callback)
ClusterSyncService
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().
sync
in interface ClusterSyncService
view
- the view which all instances in the local cluster
should agree on having seencallback
- the runnable which should be called after
successful syncingprotected DiscoveryLiteConfig getCommonsConfig()
protected org.apache.sling.settings.SlingSettingsService getSettingsService()
Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.