Class AbstractServiceWithBackgroundCheck
java.lang.Object
org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck
- Direct Known Subclasses:
IdMapService
,OakBacklogClusterSyncService
,SyncTokenService
Base class which implements the concept of a 'BackgroundCheck',
a thread that periodically executes a check until that one succeeds.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck.BackgroundCheckRunnable
protected final org.slf4j.Logger
protected String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Cancel the currently ongoing background check if there is any ongoing.protected void
startBackgroundCheck
(String threadName, org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck.BackgroundCheck check, Runnable callback, long timeoutMillis, long waitMillis) Start a new BackgroundCheck in a separate thread, that periodically calls BackgroundCheck.check and upon completion calls the provided callback.run()protected void
for testing only!
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
slingId
-
backgroundCheckRunnable
protected org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck.BackgroundCheckRunnable backgroundCheckRunnable
-
-
Constructor Details
-
AbstractServiceWithBackgroundCheck
public AbstractServiceWithBackgroundCheck()
-
-
Method Details
-
cancelPreviousBackgroundCheck
protected void cancelPreviousBackgroundCheck()Cancel the currently ongoing background check if there is any ongoing. -
startBackgroundCheck
protected void startBackgroundCheck(String threadName, org.apache.sling.discovery.commons.providers.spi.base.AbstractServiceWithBackgroundCheck.BackgroundCheck check, Runnable callback, long timeoutMillis, long waitMillis) Start a new BackgroundCheck in a separate thread, that periodically calls BackgroundCheck.check and upon completion calls the provided callback.run()- Parameters:
threadName
- the name of the thread (to allow identifying the thread)check
- the BackgroundCheck to periodically invoke with check()callback
- the Runnable to invoke upon a successful check()timeoutMillis
- a timeout at which point the BackgroundCheck is terminated and no callback is invoked. Note that this happens unnoticed at the moment, ie there is no feedback about whether a background check was successfully termianted (ie callback was invoked) or whether the timeout has hit (that's left as a TODO if needed).
-
triggerBackgroundCheck
protected void triggerBackgroundCheck()for testing only!
-