use of org.quartz.SchedulerContext in project cachecloud by sohutv.
the class AppDailyJob method action.
@Override
public void action(JobExecutionContext context) {
try {
SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
AppDailyDataCenter appDailyDataCenter = applicationContext.getBean("appDailyDataCenter", AppDailyDataCenter.class);
appDailyDataCenter.sendAppDailyEmail();
} catch (SchedulerException e) {
logger.error(e.getMessage(), e);
}
}
use of org.quartz.SchedulerContext in project cachecloud by sohutv.
the class MachineJob method action.
@Override
public void action(JobExecutionContext context) {
try {
JobDataMap dataMap = context.getMergedJobDataMap();
Date now = new Date();
dataMap.put(ConstUtils.TRIGGER_TIME_KEY, now);
SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
MachineCenter machineCenter = applicationContext.getBean("machineCenter", MachineCenter.class);
String ip = dataMap.getString(ConstUtils.HOST_KEY);
long hostId = dataMap.getLong(ConstUtils.HOST_ID_KEY);
machineCenter.asyncCollectMachineInfo(hostId, ScheduleUtil.getCollectTime(new Date()), ip);
} catch (SchedulerException e) {
logger.error(e.getMessage(), e);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
use of org.quartz.SchedulerContext in project cachecloud by sohutv.
the class RedisJob method action.
/**
* 实现收集任务,通过RedisCenter
*
* @param context
*/
@Override
public void action(JobExecutionContext context) {
JobDataMap dataMap = new JobDataMap();
try {
SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
RedisCenter redisCenter = (RedisCenter) applicationContext.getBean("redisCenter");
dataMap = context.getMergedJobDataMap();
String host = dataMap.getString(ConstUtils.HOST_KEY);
int port = dataMap.getInt(ConstUtils.PORT_KEY);
long appId = dataMap.getLong(ConstUtils.APP_KEY);
Trigger trigger = context.getTrigger();
long collectTime = ScheduleUtil.getCollectTime(trigger.getPreviousFireTime());
redisCenter.collectRedisInfo(appId, collectTime, host, port);
} catch (SchedulerException e) {
logger.error("host: {}, appId: {}", dataMap.get(ConstUtils.HOST_KEY), dataMap.get(ConstUtils.APP_KEY));
logger.error("port: {}", dataMap.get(ConstUtils.PORT_KEY));
logger.error(e.getMessage(), e);
} catch (Exception e) {
logger.error("host: {}, appId: {}", dataMap.get(ConstUtils.HOST_KEY), dataMap.get(ConstUtils.APP_KEY));
logger.error("port: {}", dataMap.get(ConstUtils.PORT_KEY));
logger.error(e.getMessage(), e);
}
}
Aggregations