Class CronResourceSynchronizer<R extends CronResource<R,RN>,RN extends CronResourceNode<R,RN>>
- java.lang.Object
-
- com.aoapps.appcluster.ResourceSynchronizer<R,RN>
-
- com.aoapps.appcluster.CronResourceSynchronizer<R,RN>
-
public abstract class CronResourceSynchronizer<R extends CronResource<R,RN>,RN extends CronResourceNode<R,RN>> extends ResourceSynchronizer<R,RN>
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
Constructors Modifier Constructor Description protectedCronResourceSynchronizer(RN localResourceNode, RN remoteResourceNode, Schedule synchronizeSchedule, Schedule testSchedule)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleancanSynchronize(ResourceSynchronizationMode mode, ResourceNodeDnsResult localDnsResult, ResourceNodeDnsResult remoteDnsResult)Checks if a resource may be synchronized given the current DNS state of the nodes.booleancanSynchronizeNow(ResourceSynchronizationMode mode)Determines if the synchronizer can run now.booleangetCanSynchronizeNow()Convenience method for JavaBeans property.booleangetCanTestNow()Convenience method for JavaBeans property.ResourceSynchronizationResultgetLastResult()Gets the last synchronization result ornullif unavailable.ResourceSynchronizerStategetState()Gets the current synchronization state.StringgetStateMessage()Gets a description of the current state ornullfor no specific message.SchedulegetSynchronizeSchedule()Gets the synchronize schedule.SchedulegetTestSchedule()Gets the test schedule.protected voidstart()Starts the synchronizer.protected voidstop()Stops the synchronizer.protected abstract ResourceSynchronizationResultsynchronize(ResourceSynchronizationMode mode, ResourceNodeDnsResult localDnsResult, ResourceNodeDnsResult remoteDnsResult)Synchronizes (or tests) the resource.voidsynchronizeNow(ResourceSynchronizationMode mode)Schedules an immediate synchronization if the resource is enabled and sleeping.-
Methods inherited from class com.aoapps.appcluster.ResourceSynchronizer
getLocalResourceNode, getRemoteResourceNode, getResultStatus, toString
-
-
-
-
Method Detail
-
getSynchronizeSchedule
public Schedule getSynchronizeSchedule()
Gets the synchronize schedule.
-
canSynchronizeNow
public boolean canSynchronizeNow(ResourceSynchronizationMode mode)
Determines if the synchronizer can run now.
-
getCanSynchronizeNow
public boolean getCanSynchronizeNow()
Convenience method for JavaBeans property.
-
getCanTestNow
public boolean getCanTestNow()
Convenience method for JavaBeans property.
-
synchronizeNow
public void synchronizeNow(ResourceSynchronizationMode mode)
Schedules an immediate synchronization if the resource is enabled and sleeping.- Specified by:
synchronizeNowin classResourceSynchronizer<R extends CronResource<R,RN>,RN extends CronResourceNode<R,RN>>
-
getTestSchedule
public Schedule getTestSchedule()
Gets the test schedule.
-
getState
public ResourceSynchronizerState getState()
Description copied from class:ResourceSynchronizerGets the current synchronization state.- Specified by:
getStatein classResourceSynchronizer<R extends CronResource<R,RN>,RN extends CronResourceNode<R,RN>>
-
getStateMessage
public String getStateMessage()
Description copied from class:ResourceSynchronizerGets a description of the current state ornullfor no specific message.- Specified by:
getStateMessagein classResourceSynchronizer<R extends CronResource<R,RN>,RN extends CronResourceNode<R,RN>>
-
getLastResult
public ResourceSynchronizationResult getLastResult()
Description copied from class:ResourceSynchronizerGets the last synchronization result ornullif unavailable.- Specified by:
getLastResultin classResourceSynchronizer<R extends CronResource<R,RN>,RN extends CronResourceNode<R,RN>>
-
start
protected void start()
Description copied from class:ResourceSynchronizerStarts the synchronizer.- Specified by:
startin classResourceSynchronizer<R extends CronResource<R,RN>,RN extends CronResourceNode<R,RN>>
-
stop
protected void stop()
Description copied from class:ResourceSynchronizerStops the synchronizer.- Specified by:
stopin classResourceSynchronizer<R extends CronResource<R,RN>,RN extends CronResourceNode<R,RN>>
-
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.
-
-