Search in sources :

Example 1 with MachineCenter

use of com.sohu.cache.machine.MachineCenter in project cachecloud by sohutv.

the class MachineMonitorJob method action.

@Override
public void action(JobExecutionContext context) {
    try {
        JobDataMap dataMap = context.getMergedJobDataMap();
        String ip = dataMap.getString(ConstUtils.HOST_KEY);
        long hostId = dataMap.getLong(ConstUtils.HOST_ID_KEY);
        SchedulerContext schedulerContext = context.getScheduler().getContext();
        ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
        MachineCenter machineCenter = applicationContext.getBean("machineCenter", MachineCenter.class);
        machineCenter.asyncMonitorMachineStats(hostId, ip);
    } catch (SchedulerException e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) ApplicationContext(org.springframework.context.ApplicationContext) MachineCenter(com.sohu.cache.machine.MachineCenter) SchedulerException(org.quartz.SchedulerException) SchedulerContext(org.quartz.SchedulerContext)

Example 2 with MachineCenter

use of com.sohu.cache.machine.MachineCenter 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);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) ApplicationContext(org.springframework.context.ApplicationContext) MachineCenter(com.sohu.cache.machine.MachineCenter) SchedulerException(org.quartz.SchedulerException) SchedulerContext(org.quartz.SchedulerContext) Date(java.util.Date) SchedulerException(org.quartz.SchedulerException)

Aggregations

MachineCenter (com.sohu.cache.machine.MachineCenter)2 JobDataMap (org.quartz.JobDataMap)2 SchedulerContext (org.quartz.SchedulerContext)2 SchedulerException (org.quartz.SchedulerException)2 ApplicationContext (org.springframework.context.ApplicationContext)2 Date (java.util.Date)1