@Service(value="blScheduledJobManager") @ManagedResource(objectName="org.broadleafcommerce:name=ScheduledJobManager", description="Manages creating SystemEvents for one or more ScheduledJobs", currencyTimeLimit=15) public class ScheduledJobManagerImpl extends Object implements ScheduledJobManager, org.springframework.context.ApplicationContextAware, org.springframework.context.SmartLifecycle
Modifier and Type | Field and Description |
---|---|
protected org.springframework.context.ApplicationContext |
context |
protected Map<String,SystemEventFactory> |
eventFactories |
protected DatabaseSystemEventNode |
eventNode |
protected long |
eventPurgeIntervalSeconds |
protected boolean |
isMaster |
protected long |
jobThreadPoolCount |
protected ConsumeWorker |
masterHeartBeatWorker |
protected ConsumeWorker |
masterIntervalJobWorker |
protected long |
masterNodeHeartbeatIntervalSeconds |
protected boolean |
masterNodeJobManagementEnabled |
protected ConsumeWorker |
masterPurgeEventWorker |
protected ConsumeWorker |
masterPurgeWorker |
protected long |
nodePurgeIntervalSeconds |
protected long |
nodePurgeThresholdSeconds |
protected boolean |
pause |
protected org.quartz.Scheduler |
scheduler |
protected DatabaseSystemEventDao |
systemEventDao |
protected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil |
transUtil |
protected List<SystemEventFactory> |
unsortedFactories |
Constructor and Description |
---|
ScheduledJobManagerImpl(DatabaseSystemEventNode eventNode) |
Modifier and Type | Method and Description |
---|---|
protected void |
buildScheduler() |
Map<String,SystemEventFactory> |
getEventFactories()
Retrieve the list of factories responsible for creating
SystemEvent instances
upon job execution. |
DatabaseSystemEventNode |
getEventNode()
This ScheduledJobManager instance is also a node in the cluster.
|
long |
getJobThreadPoolCount()
The number of Quartz thread available for jobs execution.
|
long |
getMasterNodeHeartbeatIntervalSeconds()
The amount of time between each heartbeat update for this node, if active.
|
long |
getNodePurgeIntervalSeconds()
The amount of time between each master purge attempt.
|
long |
getNodePurgeThresholdSeconds()
The amount of time an active master is allowed to not update it's heartbeat status before being a purge candidate.
|
int |
getPhase() |
org.quartz.Scheduler |
getScheduler()
Retrieve the internal Quartz scheduler instance.
|
boolean |
isAutoStartup() |
boolean |
isMaster() |
boolean |
isMaster(boolean confirmStillMasterNode)
Verifies that the current eventNode is the masterNode by retrieving the node designated as master and double checking.
|
boolean |
isPause()
Whether this node is paused.
|
boolean |
isRunning() |
void |
reset()
Programatically remove this node from master/active status.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setEventFactories(Map<String,SystemEventFactory> eventFactories) |
void |
setEventNode(DatabaseSystemEventNode eventNode) |
void |
setJobThreadPoolCount(long jobThreadPoolCount) |
void |
setMaster(boolean master) |
void |
setMasterNodeHeartbeatIntervalSeconds(long masterNodeHeartbeatIntervalSeconds) |
void |
setNodePurgeIntervalSeconds(long nodePurgeIntervalSeconds) |
void |
setNodePurgeThresholdSeconds(long nodePurgeThresholdSeconds) |
void |
setPause(boolean pause) |
void |
start() |
void |
stop() |
void |
stop(Runnable callback) |
protected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil transUtil
protected DatabaseSystemEventNode eventNode
protected DatabaseSystemEventDao systemEventDao
protected ConsumeWorker masterIntervalJobWorker
protected ConsumeWorker masterHeartBeatWorker
protected ConsumeWorker masterPurgeWorker
protected ConsumeWorker masterPurgeEventWorker
@Value(value="${master.node.heartbeat.interval.seconds:10}") protected long masterNodeHeartbeatIntervalSeconds
@Value(value="${node.purge.threshold.seconds:60}") protected long nodePurgeThresholdSeconds
@Value(value="${node.purge.interval.seconds:30}") protected long nodePurgeIntervalSeconds
@Value(value="${event.purge.interval.seconds:10}") protected long eventPurgeIntervalSeconds
@Value(value="${master.node.job.management.enabled:true}") protected boolean masterNodeJobManagementEnabled
protected List<SystemEventFactory> unsortedFactories
protected org.springframework.context.ApplicationContext context
protected long jobThreadPoolCount
protected org.quartz.Scheduler scheduler
protected Map<String,SystemEventFactory> eventFactories
protected boolean pause
protected boolean isMaster
@Autowired public ScheduledJobManagerImpl(@Qualifier(value="blDatabaseSystemEventNode") DatabaseSystemEventNode eventNode)
public boolean isAutoStartup()
isAutoStartup
in interface org.springframework.context.SmartLifecycle
public void stop(Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle
public void start()
start
in interface org.springframework.context.Lifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public int getPhase()
getPhase
in interface org.springframework.context.Phased
public void stop()
stop
in interface ScheduledJobManager
stop
in interface org.springframework.context.Lifecycle
public void reset()
ScheduledJobManager
reset
in interface ScheduledJobManager
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public long getMasterNodeHeartbeatIntervalSeconds()
ScheduledJobManager
getMasterNodeHeartbeatIntervalSeconds
in interface ScheduledJobManager
public void setMasterNodeHeartbeatIntervalSeconds(long masterNodeHeartbeatIntervalSeconds)
setMasterNodeHeartbeatIntervalSeconds
in interface ScheduledJobManager
@ManagedAttribute(description="Number of seconds a node can miss heartbeat detection before determining that the node has become defunct.", currencyTimeLimit=15) public long getNodePurgeThresholdSeconds()
ScheduledJobManager
getNodePurgeThresholdSeconds
in interface ScheduledJobManager
@ManagedAttribute(description="Number of seconds a node can miss heartbeat detection before determining that the node has become defunct.", currencyTimeLimit=15) public void setNodePurgeThresholdSeconds(long nodePurgeThresholdSeconds)
setNodePurgeThresholdSeconds
in interface ScheduledJobManager
public long getNodePurgeIntervalSeconds()
ScheduledJobManager
getNodePurgeIntervalSeconds
in interface ScheduledJobManager
public void setNodePurgeIntervalSeconds(long nodePurgeIntervalSeconds)
setNodePurgeIntervalSeconds
in interface ScheduledJobManager
@ManagedAttribute(description="Whether or not job processing is currently paused.", currencyTimeLimit=15) public boolean isPause()
ScheduledJobManager
isPause
in interface ScheduledJobManager
@ManagedAttribute(description="Whether or not job processing is currently paused.", currencyTimeLimit=15) public void setPause(boolean pause)
setPause
in interface ScheduledJobManager
public long getJobThreadPoolCount()
ScheduledJobManager
getJobThreadPoolCount
in interface ScheduledJobManager
public void setJobThreadPoolCount(long jobThreadPoolCount)
setJobThreadPoolCount
in interface ScheduledJobManager
public Map<String,SystemEventFactory> getEventFactories()
ScheduledJobManager
SystemEvent
instances
upon job execution. Jobs, when fired, result in events. Event are then consumed, which is the end goal.getEventFactories
in interface ScheduledJobManager
public void setEventFactories(Map<String,SystemEventFactory> eventFactories)
setEventFactories
in interface ScheduledJobManager
public boolean isMaster()
isMaster
in interface ScheduledJobManager
public boolean isMaster(boolean confirmStillMasterNode)
ScheduledJobManager
setMaster()
method.isMaster
in interface ScheduledJobManager
public void setMaster(boolean master)
setMaster
in interface ScheduledJobManager
public org.quartz.Scheduler getScheduler()
ScheduledJobManager
getScheduler
in interface ScheduledJobManager
public DatabaseSystemEventNode getEventNode()
ScheduledJobManager
DatabaseSystemEventNode
instance.getEventNode
in interface ScheduledJobManager
public void setEventNode(DatabaseSystemEventNode eventNode)
setEventNode
in interface ScheduledJobManager
protected void buildScheduler() throws IOException, org.quartz.SchedulerException
IOException
org.quartz.SchedulerException
Copyright © 2019. All rights reserved.