当前位置: 首页>>代码示例>>Java>>正文


Java JobExecutionContext.getJobDetail方法代码示例

本文整理汇总了Java中org.quartz.JobExecutionContext.getJobDetail方法的典型用法代码示例。如果您正苦于以下问题:Java JobExecutionContext.getJobDetail方法的具体用法?Java JobExecutionContext.getJobDetail怎么用?Java JobExecutionContext.getJobDetail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.JobExecutionContext的用法示例。


在下文中一共展示了JobExecutionContext.getJobDetail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRunningJob

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
 * 所有正在运行的job
 * 
 * @return
 * @throws SchedulerException
 */
public List<ScheduleJob> getRunningJob() throws SchedulerException {
    Scheduler scheduler = schedulerFactoryBean.getScheduler();
    List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
    List<ScheduleJob> jobList = new ArrayList<ScheduleJob>(executingJobs.size());
    for (JobExecutionContext executingJob : executingJobs) {
        ScheduleJob job = new ScheduleJob();
        JobDetail jobDetail = executingJob.getJobDetail();
        JobKey jobKey = jobDetail.getKey();
        Trigger trigger = executingJob.getTrigger();
        job.setName(jobKey.getName());
        job.setGroup(jobKey.getGroup());
        job.setDescription("触发器:" + trigger.getKey());
        Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
        job.setStatus(triggerState.name());
        if (trigger instanceof CronTrigger) {
            CronTrigger cronTrigger = (CronTrigger) trigger;
            String cronExpression = cronTrigger.getCronExpression();
            job.setCron(cronExpression);
        }
        jobList.add(job);
    }
    return jobList;
}
 
开发者ID:Zigin,项目名称:MonitorPlatform,代码行数:30,代码来源:JobConfigService.java

示例2: getRunningJobList

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
@Override
public List<ScheduleJobEntity> getRunningJobList() {
	List<ScheduleJobEntity> jobList = null;
	Scheduler scheduler = schedulerFactoryBean.getScheduler();
	try {
	List<JobExecutionContext> executingJobList = scheduler.getCurrentlyExecutingJobs();
	jobList = new ArrayList<>(executingJobList.size());
	for (JobExecutionContext executingJob : executingJobList) {
		ScheduleJobEntity scheduleJob = new ScheduleJobEntity();
		JobDetail jobDetail = executingJob.getJobDetail();
		JobKey jobKey = jobDetail.getKey();
		Trigger trigger = executingJob.getTrigger();
		this.wrapScheduleJob(scheduleJob, scheduler, jobKey, trigger);
		jobList.add(scheduleJob);
	}
	} catch (Exception e) {
		logger.error("获取计划任务列表失败", e);
		throw new ServiceException("获取计划任务列表失败", e);
	}
	return jobList;
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:22,代码来源:ScheduleJobServiceImpl.java

示例3: execute

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
  JobDetail jobDetail = jobExecutionContext.getJobDetail();
  _logger.info("Cron triggered for {0}", jobDetail.getDescription());
  JobDataMap dataMap = jobDetail.getJobDataMap();
  try {
    //Creating entry in redis to avoid duplicate job scheduling
    MemcacheService cache = AppFactory.get().getMemcacheService();
    String jobKey = "SJOB_" + DigestUtils.md5Hex(dataMap.getString("url"));
    if (cache.get(jobKey) == null) {
      HttpUtil
          .connectMulti(HttpUtil.GET, ConfigUtil.get("task.url") + dataMap.getString("url"), null,
              null, null, null);
      cache.put(jobKey, true, 1800);
    } else {
      _logger.warn("Job with url {0} is already scheduled. Doing nothing!!",
          dataMap.getString("url"));
    }
  } catch (Exception e) {
    _logger.warn("Scheduled job failed for url {0} with exception {1}", dataMap.getString("url"),
        e.getMessage(), e);
  }

}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:25,代码来源:CronJob.java

示例4: jobWasExecuted

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public void jobWasExecuted(final JobExecutionContext context, JobExecutionException exp) {
    JobDetail jobDetail = context.getJobDetail();
    if(jobDetail instanceof JobDetailImpl){
        JobDetailImpl job = (JobDetailImpl)jobDetail;

        SchedulerLog log = new SchedulerLog();
        log.setJobName(job.getName());
        log.setGroupName(job.getGroup());

        log.setTriggerName(context.getTrigger().getKey().getName());
        log.setFireTime(context.getFireTime());
        log.setScheduledFireTime(context.getScheduledFireTime());
        log.setRefireCount(context.getRefireCount());
        log.setPreviousFireTime(context.getPreviousFireTime());
        log.setNextFireTime(context.getNextFireTime());
        log.setCreateTime(new Date());
        logMapper.insert(log);
    }
}
 
开发者ID:liuxx001,项目名称:bird-java,代码行数:20,代码来源:JobListener.java

示例5: execute

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
	DetectionJobDetail jobDetail=(DetectionJobDetail)context.getJobDetail();
	Session session=jobDetail.getSessionFactory().openSession();
	try {
		String currentInstanceName=jobDetail.getCurrentInstanceName();
		Operation operation=detection(session,jobDetail.getJobInstanceNames(),currentInstanceName);
		if(operation.equals(Operation.reset)){
			ISchedulerService service=jobDetail.getSchedulerService();
			System.out.println("Current instance scheduler starting...");
			service.resetScheduer();
			System.out.println("Start successful...");				
		}
	} catch (Exception e) {
		throw new JobExecutionException(e);
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:20,代码来源:HeartbeatDetectionJob.java

示例6: execute

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
	DetectionJobDetail jobDetail=(DetectionJobDetail)context.getJobDetail();
	try {
		ISchedulerService service=jobDetail.getSchedulerService();
		if(!service.isRunJobInCurrentInstance()){
			log.warn("Current instance not allowed run scheduler!");
			return;
		}
		Scheduler scheduler=service.getCurrentScheduler();
		if(scheduler==null || scheduler.isShutdown()){
			System.out.println("Current instance scheduler was shutdown,start reset...");
			service.resetScheduer();
			System.out.println("Reset successful...");
		}
	} catch (Exception e) {
		throw new JobExecutionException(e);
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:19,代码来源:DaemonDetectionJob.java

示例7: execute

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
	ScanReminderJobDetail detail=(ScanReminderJobDetail)context.getJobDetail();
	TaskService taskService=detail.getTaskService();
	List<Long> reminderTaskList=detail.getReminderTaskList();
	List<TaskReminder> reminders=taskService.getAllTaskReminders();
	SchedulerService schedulerService=detail.getSchedulerService();
	for(TaskReminder reminder:reminders){
		long taskId=reminder.getTaskId();
		if(reminderTaskList.contains(taskId)){
			continue;
		}
		schedulerService.addReminderJob(reminder,null,null);
		reminderTaskList.add(taskId);
	}
}
 
开发者ID:youseries,项目名称:uflo,代码行数:17,代码来源:ScanReminderJob.java

示例8: getRunningScheduledJobs

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public SortedSet<ScheduledJob> getRunningScheduledJobs() {
	SortedSet<ScheduledJob> ss = new TreeSet<ScheduledJob>();
	try {
		for (JobExecutionContext ctx : (List<JobExecutionContext>) sched.getCurrentlyExecutingJobs()) {
			JobDetail jd = ctx.getJobDetail();
			if (jd.getJobDataMap().containsKey("running")) {
				ss.add((ScheduledJob) jd.getJobDataMap().get("scheduledJob"));
			}
		}
	} catch (SchedulerException e) { }
	return ss;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:14,代码来源:SchedulerManager.java

示例9: execute

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
	JobDetail jd = context.getJobDetail();
	ScheduledJob scheduledJob = (ScheduledJob) jd.getJobDataMap().get("scheduledJob");
	SchedulerManager schedulerManager = (SchedulerManager) jd.getJobDataMap().get("schedulerManager");
	AbstractJob job = scheduledJob.getJob();

	if (job != null) {
		if (schedulerManager.getRunningScheduledJobs().contains(scheduledJob)) {
			Engine.logScheduler.warn("No start " + jd.getName() + " because another still running.");
		} else {
			jd.getJobDataMap().put("running", true);
			executeJob(job, jd.getName());
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:16,代码来源:SchedulerJob.java

示例10: interrupt

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
 * Interrupt all instances of the identified InterruptableJob executing in 
 * this Scheduler instance.
 *  
 * <p>
 * This method is not cluster aware.  That is, it will only interrupt 
 * instances of the identified InterruptableJob currently executing in this 
 * Scheduler instance, not across the entire cluster.
 * </p>
 * 
 * @see org.quartz.core.RemotableQuartzScheduler#interrupt(JobKey)
 */
public boolean interrupt(JobKey jobKey) throws UnableToInterruptJobException {

    List<JobExecutionContext> jobs = getCurrentlyExecutingJobs();
    
    JobDetail jobDetail = null;
    Job job = null;
    
    boolean interrupted = false;
    
    for(JobExecutionContext jec : jobs) {
        jobDetail = jec.getJobDetail();
        if (jobKey.equals(jobDetail.getKey())) {
            job = jec.getJobInstance();
            if (job instanceof InterruptableJob) {
                ((InterruptableJob)job).interrupt();
                interrupted = true;
            } else {
                throw new UnableToInterruptJobException(
                        "Job " + jobDetail.getKey() +
                        " can not be interrupted, since it does not implement " +                        
                        InterruptableJob.class.getName());
            }
        }                        
    }
    
    return interrupted;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:QuartzScheduler.java

示例11: getRunningJobList

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public List<ScheduleJob> getRunningJobList() throws SchedulerException{  
    List<JobExecutionContext> executingJobList = scheduler.getCurrentlyExecutingJobs();  
    List<ScheduleJob> jobList = new ArrayList<>(executingJobList.size());  
    for(JobExecutionContext executingJob : executingJobList){  
        ScheduleJob scheduleJob = new ScheduleJob();  
        JobDetail jobDetail = executingJob.getJobDetail();  
        JobKey jobKey = jobDetail.getKey();  
        Trigger trigger = executingJob.getTrigger();  
        this.wrapScheduleJob(scheduleJob,scheduler,jobKey,trigger);  
        jobList.add(scheduleJob);  
    }  
    return jobList;  
}
 
开发者ID:jiwenxing,项目名称:springboot-quartz,代码行数:14,代码来源:ScheduleJobService.java

示例12: execute

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
	HeartJobDetail detail=(HeartJobDetail)context.getJobDetail();
	String instanceName=detail.getCurrentInstanceName();
	Session session=detail.getSessionFactory().openSession();
	try{
		String applicationName=Configure.getString(ISchedulerService.JOB_APPLICATION_NAME);
		String hql="from "+Heartbeat.class.getName()+" b where b.instanceName=:instanceName and b.applicationName=:applicationName";
		Query query=session.createQuery(hql).setString("instanceName",instanceName).setString("applicationName",applicationName);
		@SuppressWarnings("unchecked")
		List<Heartbeat> beats=query.list();
		Date now=new Date();
		Heartbeat beat=null;
		if(beats.size()>0){
			beat=beats.get(0);
		}else{
			beat=new Heartbeat();
			beat.setId(UUID.randomUUID().toString());
			beat.setApplicationName(applicationName);
		}
		beat.setDate(now);
		beat.setInstanceName(instanceName);
		session.saveOrUpdate(beat);
	}catch(Exception ex){
		throw new JobExecutionException(ex);
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:30,代码来源:HeartJob.java

示例13: jobWasExecuted

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public void jobWasExecuted(JobExecutionContext context,
		JobExecutionException jobException) {
	JobDetail jobDetail = context.getJobDetail();
	if (!(jobDetail instanceof SpringBeanJobExecutorDetail)) {
		return;
	}
	JobDataMap map = jobDetail.getJobDataMap();
	if (!map.containsKey(IJobDefinitionService.JOB_DEFINITION_ID)) {
		return;
	}
	Date end = new Date();
	String exception = getExceptionStackMessage(jobException);
	JobHistory history = new JobHistory();
	history.setSuccessful(exception == null ? true : false);
	if (exception != null) {
		history.setExceptionMessage(exception.length() > 1500 ? exception
				.substring(0, 1500) : exception);
	}
	history.setEndDate(end);
	history.setStartDate((Date)map.get(START_DATE_KEY));
	history.setId(UUID.randomUUID().toString());
	history.setJobId(map.getString(IJobDefinitionService.JOB_DEFINITION_ID));
	Session session = getSessionFactory().openSession();
	try {
		session.save(history);
	} finally {
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:31,代码来源:JobExecutionHistoryListener.java

示例14: execute

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
	DetectionJobDetail jobDetail=(DetectionJobDetail)context.getJobDetail();
	Session session=jobDetail.getSessionFactory().openSession();
	try {
		String currentInstanceName=jobDetail.getCurrentInstanceName();
		Operation operation=detection(session,jobDetail.getJobInstanceNames(),currentInstanceName);
		if(operation.equals(Operation.reset)){
			SchedulerService service=jobDetail.getSchedulerService();
			service.resetScheduer();
			
			Heartbeat beat=new Heartbeat();
			Calendar c=Calendar.getInstance();
			c.setTime(new Date());
			c.add(Calendar.SECOND, 1);
			beat.setDate(c.getTime());
			beat.setId(UUID.randomUUID().toString());
			beat.setInstanceName(currentInstanceName);
			session.save(beat);
			
			initHeartJob(currentInstanceName, service.getScheduler());
		}
	} catch (Exception e) {
		throw new JobExecutionException(e);
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:youseries,项目名称:uflo,代码行数:29,代码来源:HeartbeatDetectionJob.java

示例15: execute

import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
	HeartJobDetail detail=(HeartJobDetail)context.getJobDetail();
	String instanceName=detail.getCurrentInstanceName();
	Session session=detail.getSessionFactory().openSession();
	try{
		String hql="from "+Heartbeat.class.getName()+" b where b.instanceName=:instanceName order by b.date desc";
		Query query=session.createQuery(hql).setString("instanceName",instanceName);
		@SuppressWarnings("unchecked")
		List<Heartbeat> beats=query.list();
		Date now=new Date();
		Heartbeat beat=null;
		if(beats.size()>0){
			beat=beats.get(0);
		}else{
			beat=new Heartbeat();
			beat.setId(UUID.randomUUID().toString());
			beat.setInstanceName(instanceName);
		}
		beat.setDate(now);
		session.saveOrUpdate(beat);
	}catch(Exception ex){
		throw new JobExecutionException(ex);
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:youseries,项目名称:uflo,代码行数:28,代码来源:HeartJob.java


注:本文中的org.quartz.JobExecutionContext.getJobDetail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。