Search in sources :

Example 11 with SchedulerContext

use of org.quartz.SchedulerContext in project cachecloud by sohutv.

the class SystemConfigRefreshJob method action.

@Override
public void action(JobExecutionContext context) {
    try {
        SchedulerContext schedulerContext = context.getScheduler().getContext();
        ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
        ConfigService configService = applicationContext.getBean("configService", ConfigService.class);
        configService.reloadSystemConfig();
    } catch (SchedulerException e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ConfigService(com.sohu.cache.web.service.ConfigService) SchedulerException(org.quartz.SchedulerException) SchedulerContext(org.quartz.SchedulerContext)

Example 12 with SchedulerContext

use of org.quartz.SchedulerContext in project ddf by codice.

the class QueryJob method execute.

@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
    LOGGER.trace("Calling execute");
    LOCK.lock();
    try {
        SchedulerContext schedulerContext = jobExecutionContext.getScheduler().getContext();
        WorkspaceQueryService workspaceQueryService = (WorkspaceQueryService) schedulerContext.get(WorkspaceQueryServiceImpl.JOB_IDENTITY);
        workspaceQueryService.run();
    } catch (SchedulerException e) {
        LOGGER.warn("Could not get Scheduler Context.  The job will not run", e);
    } finally {
        LOCK.unlock();
    }
}
Also used : WorkspaceQueryService(org.codice.ddf.catalog.ui.query.monitor.api.WorkspaceQueryService) SchedulerException(org.quartz.SchedulerException) SchedulerContext(org.quartz.SchedulerContext)

Example 13 with SchedulerContext

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);
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) SchedulerException(org.quartz.SchedulerException) AppDailyDataCenter(com.sohu.cache.stats.app.AppDailyDataCenter) SchedulerContext(org.quartz.SchedulerContext)

Example 14 with SchedulerContext

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);
    }
}
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)

Example 15 with SchedulerContext

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);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) ApplicationContext(org.springframework.context.ApplicationContext) Trigger(org.quartz.Trigger) SchedulerException(org.quartz.SchedulerException) RedisCenter(com.sohu.cache.redis.RedisCenter) SchedulerContext(org.quartz.SchedulerContext) SchedulerException(org.quartz.SchedulerException)

Aggregations

SchedulerContext (org.quartz.SchedulerContext)18 SchedulerException (org.quartz.SchedulerException)12 ApplicationContext (org.springframework.context.ApplicationContext)10 JobDataMap (org.quartz.JobDataMap)5 JobExecutionException (org.quartz.JobExecutionException)4 Date (java.util.Date)3 Trigger (org.quartz.Trigger)3 MachineCenter (com.sohu.cache.machine.MachineCenter)2 RedisCenter (com.sohu.cache.redis.RedisCenter)2 SimpleDateFormat (java.text.SimpleDateFormat)2 CamelContext (org.apache.camel.CamelContext)2 Route (org.apache.camel.Route)2 RoutePolicy (org.apache.camel.spi.RoutePolicy)2 ClientReportCostDistriService (com.sohu.cache.client.service.ClientReportCostDistriService)1 ClientReportValueDistriService (com.sohu.cache.client.service.ClientReportValueDistriService)1 ErrorLoggerWatcherMBean (com.sohu.cache.jmx.ErrorLoggerWatcherMBean)1 AppDailyDataCenter (com.sohu.cache.stats.app.AppDailyDataCenter)1 InstanceAlertValueService (com.sohu.cache.stats.instance.InstanceAlertValueService)1 InstanceStatsCenter (com.sohu.cache.stats.instance.InstanceStatsCenter)1 EmailComponent (com.sohu.cache.web.component.EmailComponent)1