Java Code Examples for org.quartz.Trigger#getJobName()

The following examples show how to use org.quartz.Trigger#getJobName() . 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
Source File: XExecuteBIDocumentJob.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
private boolean isTriggerPaused(JobExecutionContext jobExecutionContext) {
    Trigger trigger = jobExecutionContext.getTrigger();
    String triggerGroup = trigger.getGroup();
    String triggerName = trigger.getName();
    String jobName = trigger.getJobName();
    String jobGroupOriginal = jobExecutionContext.getJobDetail().getGroup();
    String[] bits = jobGroupOriginal.split("/");
    String jobGroup = bits[bits.length - 1];
    boolean result = false;

    ISchedulerDAO schedulerDAO = DAOFactory.getSchedulerDAO();
    result = schedulerDAO.isTriggerPaused(triggerGroup, triggerName, jobGroup, jobName);

    return result;

}
 
Example 2
Source File: TriggerSupport.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
public static CompositeData toCompositeData(Trigger trigger) {
	try {
		return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
				new Object[] {
						trigger.getName(),
						trigger.getGroup(),
						trigger.getJobName(),
						trigger.getJobGroup(),
						trigger.getDescription(),
						JobDataMapSupport.toTabularData(trigger
								.getJobDataMap()), trigger.isVolatile(),
						trigger.getCalendarName(),
						trigger.getFireInstanceId(),
						trigger.getMisfireInstruction(),
						trigger.getPriority(), trigger.getStartTime(),
						trigger.getEndTime(), trigger.getNextFireTime(),
						trigger.getPreviousFireTime(),
						trigger.getFinalFireTime() });
	} catch (OpenDataException e) {
		throw new RuntimeException(e);
	}
}
 
Example 3
Source File: AbstractSuspendableJob.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
private boolean isTriggerPaused(JobExecutionContext jobExecutionContext) {
    Trigger trigger = jobExecutionContext.getTrigger();
    String triggerGroup = trigger.getGroup();
    String triggerName = trigger.getName();
    String jobName = trigger.getJobName();
    String jobGroupOriginal = jobExecutionContext.getJobDetail().getGroup();
    String[] bits = jobGroupOriginal.split("/");
    String jobGroup = bits[bits.length - 1];

    ISchedulerDAO schedulerDAO = DAOFactory.getSchedulerDAO();
    return schedulerDAO.isTriggerPaused(triggerGroup, triggerName, jobGroup, jobName);
}
 
Example 4
Source File: LoggingTriggerHistoryPlugin.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
public void triggerMisfired(Trigger trigger) {
    if (!getLog().isInfoEnabled()) {
        return;
    } 
    
    Object[] args = {
        trigger.getName(), trigger.getGroup(),
        trigger.getPreviousFireTime(), trigger.getNextFireTime(),
        new java.util.Date(), trigger.getJobName(),
        trigger.getJobGroup()
    };

    getLog().info(MessageFormat.format(getTriggerMisfiredMessage(), args));
}
 
Example 5
Source File: JobStoreSupport.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
/**
 * <p>
 * Insert or update a trigger.
 * </p>
 */
protected void storeTrigger(Connection conn, SchedulingContext ctxt,
        Trigger newTrigger, JobDetail job, boolean replaceExisting, String state,
        boolean forceState, boolean recovering)
    throws ObjectAlreadyExistsException, JobPersistenceException {
    if (newTrigger.isVolatile() && isClustered()) {
        getLog().info(
            "note: volatile triggers are effectively non-volatile in a clustered environment.");
    }

    boolean existingTrigger = triggerExists(conn, newTrigger.getName(),
            newTrigger.getGroup());

    if ((existingTrigger) && (!replaceExisting)) { 
        throw new ObjectAlreadyExistsException(newTrigger); 
    }
    
    try {

        boolean shouldBepaused = false;

        if (!forceState) {
            shouldBepaused = getDelegate().isTriggerGroupPaused(
                    conn, newTrigger.getGroup());

            if(!shouldBepaused) {
                shouldBepaused = getDelegate().isTriggerGroupPaused(conn,
                        ALL_GROUPS_PAUSED);

                if (shouldBepaused) {
                    getDelegate().insertPausedTriggerGroup(conn, newTrigger.getGroup());
                }
            }

            if (shouldBepaused && (state.equals(STATE_WAITING) || state.equals(STATE_ACQUIRED))) {
                state = STATE_PAUSED;
            }
        }

        if(job == null) {
            job = getDelegate().selectJobDetail(conn,
                newTrigger.getJobName(), newTrigger.getJobGroup(),
                getClassLoadHelper());
        }
        if (job == null) {
            throw new JobPersistenceException("The job ("
                    + newTrigger.getFullJobName()
                    + ") referenced by the trigger does not exist.");
        }
        if (job.isVolatile() && !newTrigger.isVolatile()) {
            throw new JobPersistenceException(
                    "It does not make sense to "
                            + "associate a non-volatile Trigger with a volatile Job!");
        }

        if (job.isStateful() && !recovering) { 
            state = checkBlockedState(conn, ctxt, job.getName(), 
                    job.getGroup(), state);
        }
        
        if (existingTrigger) {
            if (newTrigger instanceof SimpleTrigger && ((SimpleTrigger)newTrigger).hasAdditionalProperties() == false ) {
                getDelegate().updateSimpleTrigger(conn,
                        (SimpleTrigger) newTrigger);
            } else if (newTrigger instanceof CronTrigger && ((CronTrigger)newTrigger).hasAdditionalProperties() == false ) {
                getDelegate().updateCronTrigger(conn,
                        (CronTrigger) newTrigger);
            } else {
                getDelegate().updateBlobTrigger(conn, newTrigger);
            }
            getDelegate().updateTrigger(conn, newTrigger, state, job);
        } else {
            getDelegate().insertTrigger(conn, newTrigger, state, job);
            if (newTrigger instanceof SimpleTrigger && ((SimpleTrigger)newTrigger).hasAdditionalProperties() == false ) {
                getDelegate().insertSimpleTrigger(conn,
                        (SimpleTrigger) newTrigger);
            } else if (newTrigger instanceof CronTrigger && ((CronTrigger)newTrigger).hasAdditionalProperties() == false ) {
                getDelegate().insertCronTrigger(conn,
                        (CronTrigger) newTrigger);
            } else {
                getDelegate().insertBlobTrigger(conn, newTrigger);
            }
        }
    } catch (Exception e) {
        throw new JobPersistenceException("Couldn't store trigger '" + newTrigger.getName() + "' for '" 
                + newTrigger.getJobName() + "' job:" + e.getMessage(), e);
    }
}
 
Example 6
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
/**
 * <p>
 * Add the <code>{@link org.quartz.Job}</code> identified by the given
 * <code>{@link org.quartz.JobDetail}</code> to the Scheduler, and
 * associate the given <code>{@link org.quartz.Trigger}</code> with it.
 * </p>
 * 
 * <p>
 * If the given Trigger does not reference any <code>Job</code>, then it
 * will be set to reference the Job passed with it into this method.
 * </p>
 * 
 * @throws SchedulerException
 *           if the Job or Trigger cannot be added to the Scheduler, or
 *           there is an internal Scheduler error.
 */
public Date scheduleJob(SchedulingContext ctxt, JobDetail jobDetail,
        Trigger trigger) throws SchedulerException {
    validateState();

    if (jobDetail == null) {
        throw new SchedulerException("JobDetail cannot be null",
                SchedulerException.ERR_CLIENT_ERROR);
    }
    
    if (trigger == null) {
        throw new SchedulerException("Trigger cannot be null",
                SchedulerException.ERR_CLIENT_ERROR);
    }
    
    jobDetail.validate();

    if (trigger.getJobName() == null) {
        trigger.setJobName(jobDetail.getName());
        trigger.setJobGroup(jobDetail.getGroup());
    } else if (trigger.getJobName() != null
            && !trigger.getJobName().equals(jobDetail.getName())) {
        throw new SchedulerException(
            "Trigger does not reference given job!",
            SchedulerException.ERR_CLIENT_ERROR);
    } else if (trigger.getJobGroup() != null
            && !trigger.getJobGroup().equals(jobDetail.getGroup())) {
        throw new SchedulerException(
            "Trigger does not reference given job!",
            SchedulerException.ERR_CLIENT_ERROR);
    }

    trigger.validate();

    Calendar cal = null;
    if (trigger.getCalendarName() != null) {
        cal = resources.getJobStore().retrieveCalendar(ctxt,
                trigger.getCalendarName());
    }
    Date ft = trigger.computeFirstFireTime(cal);

    if (ft == null) {
        throw new SchedulerException(
                "Based on configured schedule, the given trigger will never fire.",
                SchedulerException.ERR_CLIENT_ERROR);
    }

    resources.getJobStore().storeJobAndTrigger(ctxt, jobDetail, trigger);
    notifySchedulerListenersJobAdded(jobDetail);
    notifySchedulerThread(trigger.getNextFireTime().getTime());
    notifySchedulerListenersSchduled(trigger);

    return ft;
}