Java Code Examples for org.quartz.JobExecutionContext#getFireTime()

The following examples show how to use org.quartz.JobExecutionContext#getFireTime() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * @return composite data
 */
public static CompositeData toCompositeData(JobExecutionContext jec)
        throws SchedulerException {
    try {
        return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
                new Object[] {
                        jec.getScheduler().getSchedulerName(),
                        jec.getTrigger().getKey().getName(),
                        jec.getTrigger().getKey().getGroup(),
                        jec.getJobDetail().getKey().getName(),
                        jec.getJobDetail().getKey().getGroup(),
                        JobDataMapSupport.toTabularData(jec
                                .getMergedJobDataMap()),
                        jec.getTrigger().getCalendarName(),
                        jec.isRecovering(),
                        jec.getRefireCount(),
                        jec.getFireTime(), jec.getScheduledFireTime(),
                        jec.getPreviousFireTime(), jec.getNextFireTime(),
                        jec.getJobRunTime(),
                        jec.getFireInstanceId() });
    } catch (OpenDataException e) {
        throw new RuntimeException(e);
    }
}
 
Example 2
/**
 * @return composite data
 */
public static CompositeData toCompositeData(JobExecutionContext jec)
		throws SchedulerException {
	try {
		return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
				new Object[] {
						jec.getScheduler().getSchedulerName(),
						jec.getTrigger().getFullName(),
						jec.getJobDetail().getFullName(),
						JobDataMapSupport.toTabularData(jec
								.getMergedJobDataMap()),
						determineCalendarName(jec),
						Boolean.valueOf(jec.isRecovering()),
						Integer.valueOf(jec.getRefireCount()),
						jec.getFireTime(), jec.getScheduledFireTime(),
						jec.getPreviousFireTime(), jec.getNextFireTime(),
						Long.valueOf(jec.getJobRunTime()) });
	} catch (OpenDataException e) {
		throw new RuntimeException(e);
	}
}
 
Example 3
Source Project: quartz-glass   File: JobExecution.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Fill common attributes with properties from context.
 */
public void fillWithContext(JobExecutionContext context) {
    startDate = context.getFireTime();

    jobClass = Jobs.jobCass(context.getJobDetail()).getName();

    JobKey key = context.getJobDetail().getKey();
    jobKey = Keys.desc(key);
    jobGroup = key.getGroup();
    jobName = key.getName();
    TriggerKey key2 = context.getTrigger().getKey();
    triggerKey = Keys.desc(key2);
    triggerGroup = key2.getGroup();
    triggerName = key2.getName();
    dataMap = JobDataMapUtils.toProperties(context.getMergedJobDataMap());
}
 
Example 4
Source Project: SpringBoot2.0   File: JobBean.java    License: Apache License 2.0 5 votes vote down vote up
private void postExecute(JobExecutionContext context, SysJobRepository jobRepository) {
    long endTime = System.currentTimeMillis();
    SysJob sysJob = jobRepository.getOne(jobId);
    if (null != context.getFireTime()) {
        sysJob.setRuntimeLast(context.getFireTime());
    }
    if (null != context.getNextFireTime()) {
        sysJob.setRuntimeNext(context.getNextFireTime());
    }
    int runtimes = (null == sysJob.getRuntimes()) ? 0 : sysJob.getRuntimes();
    sysJob.setRuntimes(runtimes + 1);
    sysJob.setRunDuration(endTime - beginTime);
    sysJob.setJobStatus(JobConstantUtils.JOB_RUN_STATUS_AWAITING);
    jobRepository.save(sysJob);
}
 
Example 5
public ScheduleLogRequest(JobExecutionContext jobExecutionContext, JobExecutionException jobExecutionException) {
	JobDetail jobDetail = jobExecutionContext.getJobDetail();
	this.className = jobDetail.getKey().getName();
	this.application = jobDetail.getKey().getGroup();
	this.node = jobDetail.getDescription();
	this.type = jobExecutionContext.getTrigger().getDescription();
	this.elapsed = jobExecutionContext.getJobRunTime();
	this.fireTime = jobExecutionContext.getFireTime();
	if (null != jobExecutionException) {
		this.stackTrace = ExceptionUtils.getStackTrace(jobExecutionException);
		this.success = false;
	} else {
		this.success = true;
	}
}
 
Example 6
public void execute(JobExecutionContext jobInfo) throws JobExecutionException {
	loginToSakai("admin");

	String jobName = jobInfo.getJobDetail().getKey().getName();
	String triggerName = jobInfo.getTrigger().getKey().getName();
		Date requestedFire = jobInfo.getScheduledFireTime();
	Date actualfire = jobInfo.getFireTime();

	StringBuffer whoAmI = new StringBuffer("AutoSubmitAssessmentsJob $");
	whoAmI.append(" Job: ");
	whoAmI.append(jobName);
	whoAmI.append(" Trigger: ");
	whoAmI.append(triggerName);
	
	if (requestedFire != null) {
		whoAmI.append(" Fire scheduled: ");
		whoAmI.append(requestedFire.toString());
	}
	
	if (actualfire != null) {
		whoAmI.append(" Fire actual: ");
		whoAmI.append(actualfire.toString());
	}
	
	eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_AUTO_SUBMIT_JOB, safeEventLength(whoAmI.toString()), true));

	log.info("Start Job: {}", whoAmI);
	
	GradingService gradingService = new GradingService();
	int failures = gradingService.autoSubmitAssessments();
	
	if (failures > 0)
	{
		samigoETSProvider.notifyAutoSubmitFailures(failures);
	}
	
	log.info("End Job: {} ({} failures)", whoAmI, failures);
	
	logoutFromSakai();
}
 
Example 7
public void execute(JobExecutionContext jobInfo) throws JobExecutionException {
	loginToSakai("admin");

	String jobName = jobInfo.getJobDetail().getKey().getName();
	String triggerName = jobInfo.getTrigger().getKey().getName();
		Date requestedFire = jobInfo.getScheduledFireTime();
	Date actualfire = jobInfo.getFireTime();

	StringBuffer whoAmI = new StringBuffer("AutoSubmitAssessmentsJob $");
	whoAmI.append(" Job: ");
	whoAmI.append(jobName);
	whoAmI.append(" Trigger: ");
	whoAmI.append(triggerName);
	
	if (requestedFire != null) {
		whoAmI.append(" Fire scheduled: ");
		whoAmI.append(requestedFire.toString());
	}
	
	if (actualfire != null) {
		whoAmI.append(" Fire actual: ");
		whoAmI.append(actualfire.toString());
	}
	
	eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_AUTO_SUBMIT_JOB, safeEventLength(whoAmI.toString()), true));

	log.info("Start Job: {}", whoAmI);
	
	GradingService gradingService = new GradingService();
	int failures = gradingService.autoSubmitAssessments();
	
	if (failures > 0)
	{
		samigoETSProvider.notifyAutoSubmitFailures(failures);
	}
	
	log.info("End Job: {} ({} failures)", whoAmI, failures);
	
	logoutFromSakai();
}
 
Example 8
@Transactional(readOnly = true)
@Secured("AFTER_ACL_COLLECTION_READ")
public SchedulerJob[] getActiveSchedulerJobs() {
    List<SchedulerJob> activeJobs = new ArrayList<SchedulerJob>();
    SchedulerJob[] schedulerJobs = getSchedulerJobs();
    for (SchedulerJob job : schedulerJobs) {
        boolean active = false;
        Date now = new Date();
        if (ScheduleConstants.ONCE_TYPE.equals(job.getTime().getType())) {
            active = (job.getTime().getRunDate().compareTo(now) >= 0) || job.isRunning();
        } else {
            active = ((job.getTime().getStartActivationDate().compareTo(now) <= 0) &&
                    (job.getTime().getEndActivationDate().compareTo(now) >= 0)) || job.isRunning();
        }
        if (active) {
            activeJobs.add(job);

      Map<String, JobExecutionContext> runningJobs;
try {
	runningJobs = QuartzUtil.getRunningJobs(scheduler);
} catch (SchedulerException e) {
          throw new RuntimeException(e);
} 
            JobExecutionContext executionContext = runningJobs.get(job.getPath());
            if (executionContext != null) {  
            	Date fireTime = executionContext.getFireTime();
            	job.setRunTime(Seconds.secondsBetween(new DateTime(fireTime), new DateTime()).getSeconds());
            }
        }
    }
            
    schedulerJobs = activeJobs.toArray(new SchedulerJob[activeJobs.size()]);

    return schedulerJobs;
}
 
Example 9
@Override
public void jobToBeExecuted(final JobExecutionContext context) {
  final JobKey jobKey = context.getJobDetail().getKey();
  log.trace("Job {} : {} jobToBeExecuted", jobKey.getName(), taskInfo.getConfiguration().getTaskLogName());
  // get current trigger, which in this method SHOULD be job's trigger.
  // Still, in some circumstances (that I cannot imagine right now, except to have concurrency bug)
  // the NX Task's Trigger might be missing. Still, we don't want to throw in this listener
  // as that would make whole Quartz instance inconsistent. Also, even if job removed (coz bug exists)
  // we do want to "follow" it's lifecycle here.
  final Trigger currentTrigger = getCurrentTrigger(context);

  QuartzTaskFuture future = taskInfo.getTaskFuture();
  if (future == null) {
    log.trace("Job {} : {} has no future, creating it", jobKey.getName(),
        taskInfo.getConfiguration().getTaskLogName());

    future = new QuartzTaskFuture(scheduler,
        jobKey,
        taskInfo.getConfiguration().getTaskLogName(),
        context.getFireTime(),
        scheduler.triggerConverter().convert(context.getTrigger()),
        null
    );

    // set the future on taskinfo
    taskInfo.setNexusTaskState(
        RUNNING,
        new QuartzTaskState(
            configurationOf(context.getJobDetail()),
            scheduler.triggerConverter().convert(currentTrigger),
            currentTrigger.getNextFireTime()
        ),
        future
    );
  }

  context.put(QuartzTaskFuture.FUTURE_KEY, future);
  context.put(QuartzTaskInfo.TASK_INFO_KEY, taskInfo);

  eventManager.post(new TaskEventStarted(taskInfo));
}
 
Example 10
Source Project: javamelody   File: QuartzAdapter.java    License: Apache License 2.0 4 votes vote down vote up
Date getContextFireTime(JobExecutionContext context) {
	return context.getFireTime();
}
 
Example 11
Source Project: javamelody   File: Quartz2Adapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
Date getContextFireTime(JobExecutionContext context) {
	return context.getFireTime();
}
 
Example 12
@Override
public void triggerFired(Trigger trigger, JobExecutionContext jobExecutionContext)
{
    Date fired = jobExecutionContext.getFireTime();
    eventManager.createTriggerEvent (TriggerEvent.TRIGGER_EVENT_TYPE.FIRED, jobExecutionContext.getJobDetail().getKey(), trigger.getKey(), fired, "Trigger fired", getServerId());
}
 
Example 13
@Override
public void triggerFired(Trigger trigger, JobExecutionContext jobExecutionContext)
{
    Date fired = jobExecutionContext.getFireTime();
    eventManager.createTriggerEvent (TriggerEvent.TRIGGER_EVENT_TYPE.FIRED, jobExecutionContext.getJobDetail().getKey(), trigger.getKey(), fired, "Trigger fired", getServerId());
}