use of org.quartz.TriggerKey in project new-cloud by xie-summer.
the class MachineCenterImpl method deployMachineMonitor.
/**
* 为监控每台机器的状态部署trigger
*
* @param hostId 机器id
* @param ip ip
* @return 是否部署成功
*/
@Override
public boolean deployMachineMonitor(final long hostId, final String ip) {
Assert.isTrue(hostId > 0);
Assert.hasText(ip);
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put(ConstUtils.HOST_KEY, ip);
dataMap.put(ConstUtils.HOST_ID_KEY, hostId);
JobKey jobKey = JobKey.jobKey(ConstUtils.MACHINE_MONITOR_JOB_NAME, ConstUtils.MACHINE_MONITOR_JOB_GROUP);
TriggerKey triggerKey = TriggerKey.triggerKey(ip, ConstUtils.MACHINE_MONITOR_TRIGGER_GROUP + hostId);
boolean result = schedulerCenter.deployJobByCron(jobKey, triggerKey, dataMap, ScheduleUtil.getHourCronByHostId(hostId), false);
return result;
}
use of org.quartz.TriggerKey in project new-cloud by xie-summer.
the class RedisCenterImpl method deployRedisSlowLogCollection.
@Override
public boolean deployRedisSlowLogCollection(long appId, String host, int port) {
Assert.isTrue(appId > 0);
Assert.hasText(host);
Assert.isTrue(port > 0);
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put(ConstUtils.HOST_KEY, host);
dataMap.put(ConstUtils.PORT_KEY, port);
dataMap.put(ConstUtils.APP_KEY, appId);
JobKey jobKey = JobKey.jobKey(ConstUtils.REDIS_SLOWLOG_JOB_NAME, ConstUtils.REDIS_SLOWLOG_JOB_GROUP);
TriggerKey triggerKey = TriggerKey.triggerKey(ObjectConvert.linkIpAndPort(host, port), ConstUtils.REDIS_SLOWLOG_TRIGGER_GROUP + appId);
boolean result = schedulerCenter.deployJobByCron(jobKey, triggerKey, dataMap, ScheduleUtil.getRedisSlowLogCron(appId), false);
return result;
}
use of org.quartz.TriggerKey in project new-cloud by xie-summer.
the class RedisCenterImpl method unDeployRedisCollection.
@Override
public boolean unDeployRedisCollection(long appId, String host, int port) {
Assert.isTrue(appId > 0);
Assert.hasText(host);
Assert.isTrue(port > 0);
TriggerKey triggerKey = TriggerKey.triggerKey(ObjectConvert.linkIpAndPort(host, port), ConstUtils.REDIS_TRIGGER_GROUP + appId);
Trigger trigger = schedulerCenter.getTrigger(triggerKey);
if (trigger == null) {
return true;
}
return schedulerCenter.unscheduleJob(triggerKey);
}
use of org.quartz.TriggerKey in project new-cloud by xie-summer.
the class SchedulerCenterTest method testSchedule.
@Test
public void testSchedule() {
TriggerKey key = TriggerKey.triggerKey("appInfoAlertTrigger", "appAlert");
Trigger trigger = schedulerCenter.getTrigger(key);
if (trigger != null) {
boolean isSchedule = schedulerCenter.unscheduleJob(key);
logger.warn("isSchedule={}", isSchedule);
}
// try {
// TimeUnit.SECONDS.sleep(5);
// } catch (InterruptedException e) {
// logger.error("{}", e);
// }
}
use of org.quartz.TriggerKey in project openolat by klemens.
the class ViteroModule method initCronJob.
private void initCronJob() {
try {
TriggerKey triggerKey = new TriggerKey("Vitero_Cleaner_Cron_Trigger", Scheduler.DEFAULT_GROUP);
if (scheduler.getTrigger(triggerKey) == null) {
// Create job with cron trigger configuration
JobDetail jobDetail = newJob(ViteroZombieSlayerJob.class).withIdentity("Vitero_Cleaner_Cron_Job", Scheduler.DEFAULT_GROUP).build();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 30);
Trigger trigger = newTrigger().withIdentity("Vitero_Cleaner_Cron_Trigger").withSchedule(cronSchedule(cronExpression)).startAt(cal.getTime()).build();
scheduler.scheduleJob(jobDetail, trigger);
}
} catch (Exception e) {
log.error("Cannot start the Quartz Job which clean the Vitero rooms", e);
}
}
Aggregations