public abstract class AbstractPollingScheduler
extends java.lang.Object
A subclass should supply the specific scheduling logic in schedule(Runnable)
and stop()
.
Constructor and Description |
---|
AbstractPollingScheduler()
Create an instance where
ignoreDeletesFromSource is set to false. |
AbstractPollingScheduler(boolean ignoreDeletesFromSource) |
Modifier and Type | Method and Description |
---|---|
void |
addPollListener(PollListener l)
Add the PollLisetner
|
protected java.lang.Object |
getNextCheckPoint(java.lang.Object lastCheckpoint)
Get the check point used in next
PolledConfigurationSource.poll(boolean, Object) . |
protected java.lang.Runnable |
getPollingRunnable(PolledConfigurationSource source,
Configuration config)
Gets the runnable to be scheduled.
|
protected void |
initialLoad(PolledConfigurationSource source,
Configuration config)
Do an initial poll from the source and apply the result to the configuration.
|
boolean |
isIgnoreDeletesFromSource() |
protected void |
populateProperties(PollResult result,
Configuration config)
Apply the polled result to the configuration.
|
void |
removePollListener(PollListener l) |
protected abstract void |
schedule(java.lang.Runnable pollingRunnable)
Schedule the runnable for polling the configuration source
|
void |
setIgnoreDeletesFromSource(boolean ignoreDeletesFromSource)
Set if the scheduler should ignore deletes from source when applying property changes
|
void |
startPolling(PolledConfigurationSource source,
Configuration config)
Initiate the first poll of the configuration source and schedule the runnable.
|
abstract void |
stop()
Stop the scheduler
|
public AbstractPollingScheduler(boolean ignoreDeletesFromSource)
ignoreDeletesFromSource
- true if deletes happened in the configuration source should be ignored
by the Configuration. Warning: If both WatchedUpdateResult.isIncremental()
and this parameter are false, any property in the configuration that is missing in the
polled result will be deleted once the PollResult is applied.public AbstractPollingScheduler()
ignoreDeletesFromSource
is set to false.AbstractPollingScheduler(boolean)
protected void initialLoad(PolledConfigurationSource source, Configuration config)
source
- source of the configurationconfig
- Configuration to apply the polling resultjava.lang.RuntimeException
- if any error occurs in polling the configuration sourceprotected void populateProperties(PollResult result, Configuration config)
result
- Polled result from sourceprotected java.lang.Runnable getPollingRunnable(PolledConfigurationSource source, Configuration config)
schedule(Runnable)
public void startPolling(PolledConfigurationSource source, Configuration config)
schedule(Runnable)
.source
- Configuration source being polledconfig
- Configuration where the properties will be updatedjava.lang.RuntimeException
- if any error occurs in the initial pollingpublic void addPollListener(PollListener l)
l
- public void removePollListener(PollListener l)
protected java.lang.Object getNextCheckPoint(java.lang.Object lastCheckpoint)
PolledConfigurationSource.poll(boolean, Object)
.
The check point can be used by the PolledConfigurationSource
to determine
the set of records to return. For example, a check point can be a time stamp and
the PolledConfigurationSource
can return the records modified since the time stamp.
This method is called before the poll. The
default implementation returns the check point received from last poll.lastCheckpoint
- checkPoint from last PollResult.getCheckPoint()
protected abstract void schedule(java.lang.Runnable pollingRunnable)
pollingRunnable
- The runnable to be scheduled.public abstract void stop()
public final boolean isIgnoreDeletesFromSource()
public final void setIgnoreDeletesFromSource(boolean ignoreDeletesFromSource)