use of org.apache.cloudstack.managed.context.ManagedContextTimerTask in project cloudstack by apache.
the class AsyncJobMonitor method configure.
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
_messageBus.subscribe(AsyncJob.Topics.JOB_HEARTBEAT, MessageDispatcher.getDispatcher(this));
_timer.scheduleAtFixedRate(new ManagedContextTimerTask() {
@Override
protected void runInContext() {
heartbeat();
}
}, _inactivityCheckIntervalMs, _inactivityCheckIntervalMs);
return true;
}
use of org.apache.cloudstack.managed.context.ManagedContextTimerTask in project cloudstack by apache.
the class SnapshotSchedulerImpl method start.
@Override
@DB
public boolean start() {
// reschedule all policies after management restart
final List<SnapshotPolicyVO> policyInstances = _snapshotPolicyDao.listAll();
for (final SnapshotPolicyVO policyInstance : policyInstances) {
if (policyInstance.getId() != Snapshot.MANUAL_POLICY_ID) {
scheduleNextSnapshotJob(policyInstance);
}
}
if (_testTimerTask != null) {
_testClockTimer = new Timer("TestClock");
// Run the test clock every 60s. Because every tick is counted as 1 minute.
// Else it becomes too confusing.
_testClockTimer.schedule(_testTimerTask, 100 * 1000L, 60 * 1000L);
} else {
final TimerTask timerTask = new ManagedContextTimerTask() {
@Override
protected void runInContext() {
try {
final Date currentTimestamp = new Date();
poll(currentTimestamp);
} catch (final Throwable t) {
s_logger.warn("Catch throwable in snapshot scheduler ", t);
}
}
};
_testClockTimer = new Timer("SnapshotPollTask");
_testClockTimer.schedule(timerTask, _snapshotPollInterval * 1000L, _snapshotPollInterval * 1000L);
}
return true;
}
Aggregations