@Component(value="cuba_Scheduling") public class Scheduling extends java.lang.Object implements SchedulingAPI
ScheduledTask
s in distributed environment.Modifier and Type | Field and Description |
---|---|
protected io.jmix.core.security.SystemAuthenticator |
authenticator |
protected Configuration |
configuration |
protected Coordinator |
coordinator |
protected java.util.Map<ScheduledTask,java.lang.Long> |
lastFinishCache |
protected java.util.Map<ScheduledTask,java.lang.Long> |
lastStartCache |
protected Runner |
runner |
protected java.util.concurrent.ConcurrentMap<ScheduledTask,java.lang.Long> |
runningTasks |
protected long |
schedulingStartTime |
protected ServerInfoAPI |
serverInfo |
protected ServerInfoService |
serverInfoService |
protected io.jmix.core.TimeSource |
timeSource |
NAME
Constructor and Description |
---|
Scheduling() |
Modifier and Type | Method and Description |
---|---|
protected long |
calculateNextCronDate(ScheduledTask task,
long date,
long currentDate,
long frame) |
protected long |
calculateNextDelayDate(ScheduledTask task,
long lastStart,
long lastFinish,
long currentDate,
long frame,
long period) |
protected long |
calculateNextPeriodDate(ScheduledTask task,
long date,
long currentDate,
long frame,
long period) |
protected boolean |
checkFirst(ScheduledTask task,
java.lang.Integer serverPriority,
long now) |
java.util.List<ScheduledTask> |
getActiveTasks() |
protected java.util.TimeZone |
getCurrentTimeZone() |
java.util.List<ScheduledTask> |
getRunningTasks() |
protected long |
getSchedulingInterval() |
protected java.lang.Integer |
getServerPriority(ScheduledTask task,
java.lang.String serverId) |
boolean |
isActive()
Whether the scheduling is currently active.
|
protected boolean |
isRunning(ScheduledTask task) |
protected boolean |
lastServerWasNotMe(ScheduledTask task,
java.lang.String me) |
protected boolean |
needToStartInTimeFrame(long now,
long frame,
long lastStart,
long currentStart) |
void |
processScheduledTasks()
Process all active scheduled tasks once.
|
void |
processScheduledTasks(boolean onlyIfActive) |
protected void |
processTask(ScheduledTask task) |
void |
runOnce(ScheduledTask task)
Runs a task right now and only once.
|
protected void |
runSingletonTask(ScheduledTask task,
long now,
java.lang.String server) |
protected void |
runTask(ScheduledTask task,
long time) |
void |
setActive(boolean value)
Activate/deactivate scheduling.
|
void |
setFinished(ScheduledTask task)
Mark the scheduled task as finished in the internal list.
|
boolean |
setRunning(ScheduledTask task,
boolean running)
Mark the scheduled task as running/not running in the internal list.
|
@Inject protected Configuration configuration
@Inject protected ServerInfoAPI serverInfo
@Inject protected io.jmix.core.TimeSource timeSource
@Inject protected io.jmix.core.security.SystemAuthenticator authenticator
@Inject protected Coordinator coordinator
@Inject protected Runner runner
@Inject protected ServerInfoService serverInfoService
protected java.util.concurrent.ConcurrentMap<ScheduledTask,java.lang.Long> runningTasks
protected java.util.Map<ScheduledTask,java.lang.Long> lastStartCache
protected java.util.Map<ScheduledTask,java.lang.Long> lastFinishCache
protected volatile long schedulingStartTime
@Scheduled(fixedRate=1000L) public void processScheduledTasks()
SchedulingAPI
<task:scheduled ref="cuba_Scheduling" method="processScheduledTasks" fixed-rate="1000"/>
This methods returns immediately if scheduling is not active.
processScheduledTasks
in interface SchedulingAPI
public void processScheduledTasks(boolean onlyIfActive)
processScheduledTasks
in interface SchedulingAPI
public boolean setRunning(ScheduledTask task, boolean running)
SchedulingAPI
setRunning
in interface SchedulingAPI
task
- task instancerunning
- true to mark as running, false to mark as not runningpublic void setFinished(ScheduledTask task)
SchedulingAPI
setFinished
in interface SchedulingAPI
task
- task instancepublic boolean isActive()
SchedulingAPI
SchedulingConfig.getSchedulingActive()
configuration parameter.isActive
in interface SchedulingAPI
public void setActive(boolean value)
SchedulingAPI
SchedulingConfig.getSchedulingActive()
configuration parameter.setActive
in interface SchedulingAPI
value
- true to activate schedulingpublic java.util.List<ScheduledTask> getActiveTasks()
getActiveTasks
in interface SchedulingAPI
protected long getSchedulingInterval()
protected void processTask(ScheduledTask task)
protected boolean needToStartInTimeFrame(long now, long frame, long lastStart, long currentStart)
protected long calculateNextCronDate(ScheduledTask task, long date, long currentDate, long frame)
protected long calculateNextPeriodDate(ScheduledTask task, long date, long currentDate, long frame, long period)
protected long calculateNextDelayDate(ScheduledTask task, long lastStart, long lastFinish, long currentDate, long frame, long period)
protected java.util.TimeZone getCurrentTimeZone()
protected boolean lastServerWasNotMe(ScheduledTask task, java.lang.String me)
protected void runSingletonTask(ScheduledTask task, long now, java.lang.String server) throws javax.security.auth.login.LoginException
javax.security.auth.login.LoginException
protected void runTask(ScheduledTask task, long time) throws javax.security.auth.login.LoginException
javax.security.auth.login.LoginException
protected boolean checkFirst(ScheduledTask task, java.lang.Integer serverPriority, long now)
protected java.lang.Integer getServerPriority(ScheduledTask task, java.lang.String serverId)
protected boolean isRunning(ScheduledTask task)
public void runOnce(ScheduledTask task)
SchedulingAPI
runOnce
in interface SchedulingAPI
task
- task to executepublic java.util.List<ScheduledTask> getRunningTasks()
getRunningTasks
in interface SchedulingAPI