Class CronResourceSynchronizer<R extends CronResource<R,N>,N extends CronResourceNode<R,N>>
Synchronizes resource based on cron-like schedules. If the local node is stopped, the synchronizer is stopped. If the locale node or the remote node is disabled, the synchronized is disabled. Otherwise, the synchronizer will operate on a cron-like scheduled basis for testing and synchronizing.
To support masters synchronizing while slaves only test, if a test and a synchronization are scheduled at the same moment, the synchronization is performed if possible, and the test is only performed if the synchronization is not possible. Thus, a synchronization also counts as a test and should perform at least as thorough of a check as a test would perform.
If a synchronization or test is missed, no catch-up is performed. This is true for both when the node is down or when a previous test/synchronization took too long, overlapping the current schedule.
- Author:
- AO Industries, Inc.
-
Field Summary
Fields inherited from class com.aoapps.appcluster.ResourceSynchronizer
localResourceNode, remoteResourceNode
-
Constructor Summary
ModifierConstructorDescriptionprotected
CronResourceSynchronizer
(N localResourceNode, N remoteResourceNode, Schedule synchronizeSchedule, Schedule testSchedule) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract boolean
canSynchronize
(ResourceSynchronizationMode mode, ResourceNodeDnsResult localDnsResult, ResourceNodeDnsResult remoteDnsResult) Checks if a resource may be synchronized given the current DNS state of the nodes.boolean
Determines if the synchronizer can run now.boolean
Convenience method for JavaBeans property.boolean
Convenience method for JavaBeans property.Gets the last synchronization result ornull
if unavailable.getState()
Gets the current synchronization state.Gets a description of the current state ornull
for no specific message.Gets the synchronize schedule.Gets the test schedule.protected void
start()
Starts the synchronizer.protected void
stop()
Stops the synchronizer.protected abstract ResourceSynchronizationResult
synchronize
(ResourceSynchronizationMode mode, ResourceNodeDnsResult localDnsResult, ResourceNodeDnsResult remoteDnsResult) Synchronizes (or tests) the resource.void
Schedules an immediate synchronization if the resource is enabled and sleeping.Methods inherited from class com.aoapps.appcluster.ResourceSynchronizer
getLocalResourceNode, getRemoteResourceNode, getResultStatus, toString
-
Constructor Details
-
CronResourceSynchronizer
-
-
Method Details
-
getSynchronizeSchedule
Gets the synchronize schedule. -
canSynchronizeNow
Determines if the synchronizer can run now. -
getCanSynchronizeNow
public boolean getCanSynchronizeNow()Convenience method for JavaBeans property.- See Also:
-
getCanTestNow
public boolean getCanTestNow()Convenience method for JavaBeans property.- See Also:
-
synchronizeNow
Schedules an immediate synchronization if the resource is enabled and sleeping.- Specified by:
synchronizeNow
in classResourceSynchronizer<R extends CronResource<R,
N>, N extends CronResourceNode<R, N>>
-
getTestSchedule
Gets the test schedule. -
getState
Description copied from class:ResourceSynchronizer
Gets the current synchronization state.- Specified by:
getState
in classResourceSynchronizer<R extends CronResource<R,
N>, N extends CronResourceNode<R, N>>
-
getStateMessage
Description copied from class:ResourceSynchronizer
Gets a description of the current state ornull
for no specific message.- Specified by:
getStateMessage
in classResourceSynchronizer<R extends CronResource<R,
N>, N extends CronResourceNode<R, N>>
-
getLastResult
Description copied from class:ResourceSynchronizer
Gets the last synchronization result ornull
if unavailable.- Specified by:
getLastResult
in classResourceSynchronizer<R extends CronResource<R,
N>, N extends CronResourceNode<R, N>>
-
start
protected void start()Description copied from class:ResourceSynchronizer
Starts the synchronizer.- Specified by:
start
in classResourceSynchronizer<R extends CronResource<R,
N>, N extends CronResourceNode<R, N>>
-
stop
protected void stop()Description copied from class:ResourceSynchronizer
Stops the synchronizer.- Specified by:
stop
in classResourceSynchronizer<R extends CronResource<R,
N>, N extends CronResourceNode<R, N>>
-
canSynchronize
protected abstract boolean canSynchronize(ResourceSynchronizationMode mode, ResourceNodeDnsResult localDnsResult, ResourceNodeDnsResult remoteDnsResult) Checks if a resource may be synchronized given the current DNS state of the nodes. -
synchronize
protected abstract ResourceSynchronizationResult synchronize(ResourceSynchronizationMode mode, ResourceNodeDnsResult localDnsResult, ResourceNodeDnsResult remoteDnsResult) Synchronizes (or tests) the resource.
-