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

The following examples show how to use org.quartz.Trigger#getName() . 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: LoggingJobHistoryPlugin.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
/** 
 * @see org.quartz.JobListener#jobToBeExecuted(JobExecutionContext)
 */
public void jobToBeExecuted(JobExecutionContext context) {
    if (!getLog().isInfoEnabled()) {
        return;
    } 
    
    Trigger trigger = context.getTrigger();

    Object[] args = {
        context.getJobDetail().getName(),
        context.getJobDetail().getGroup(), new java.util.Date(),
        trigger.getName(), trigger.getGroup(),
        trigger.getPreviousFireTime(), trigger.getNextFireTime(),
        new Integer(context.getRefireCount())
    };

    getLog().info(MessageFormat.format(getJobToBeFiredMessage(), args));
}
 
Example 4
Source File: LoggingJobHistoryPlugin.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
/** 
 * @see org.quartz.JobListener#jobExecutionVetoed(org.quartz.JobExecutionContext)
 */
public void jobExecutionVetoed(JobExecutionContext context) {
    
    if (!getLog().isInfoEnabled()) {
        return;
    } 
    
    Trigger trigger = context.getTrigger();

    Object[] args = {
        context.getJobDetail().getName(),
        context.getJobDetail().getGroup(), new java.util.Date(),
        trigger.getName(), trigger.getGroup(),
        trigger.getPreviousFireTime(), trigger.getNextFireTime(),
        new Integer(context.getRefireCount())
    };

    getLog().info(MessageFormat.format(getJobWasVetoedMessage(), args));
}
 
Example 5
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 6
Source File: SchedulerServiceSupplier.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Builds the triggers list xml string.
 * 
 * @param triggers the triggers
 * 
 * @return the string
 * 
 * @throws SourceBeanException the source bean exception
 */
public  String buildTriggersListXmlString(Trigger[] triggers) throws SourceBeanException {
	StringBuffer buffer = new StringBuffer("<ROWS>");
	if (triggers != null && triggers.length > 0) {
		for (int i = 0; i < triggers.length; i++) {
			Trigger trigger = triggers[i];
			if(trigger.getName().startsWith("schedule_uuid_")) {
				continue;
			}
			buffer.append("<ROW ");
			String triggerName = trigger.getName();
			String triggerGroup = trigger.getGroup();
			String triggerDescription = trigger.getDescription();
			String triggerCalendarName = trigger.getCalendarName();
			Date triggerStartTime = trigger.getStartTime();
			String triggerStartTimeStr = triggerStartTime != null ? triggerStartTime.toString(): "";
			Date triggerEndTime = trigger.getEndTime();
			String triggerEndTimeStr = triggerEndTime != null ? triggerEndTime.toString(): "";
			buffer.append(" triggerName=\"" + (triggerName != null ? triggerName : "") + "\"");
			buffer.append(" triggerGroup=\"" + (triggerGroup != null ? triggerGroup : "") + "\"");
			buffer.append(" triggerDescription=\"" + (triggerDescription != null ? triggerDescription : "") + "\"");
			buffer.append(" triggerCalendarName=\"" + (triggerCalendarName != null ? triggerCalendarName : "") + "\"");
			buffer.append(" triggerStartTime=\"" + triggerStartTimeStr + "\"");
			buffer.append(" triggerEndTime=\"" + triggerEndTimeStr + "\"");
			buffer.append(" />");
		}
	}
	buffer.append("</ROWS>");
	return buffer.toString();
}
 
Example 7
Source File: LoggingTriggerHistoryPlugin.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
public void triggerFired(Trigger trigger, JobExecutionContext context) {
    if (!getLog().isInfoEnabled()) {
        return;
    } 
    
    Object[] args = {
        trigger.getName(), trigger.getGroup(),
        trigger.getPreviousFireTime(), trigger.getNextFireTime(),
        new java.util.Date(), context.getJobDetail().getName(),
        context.getJobDetail().getGroup(),
        new Integer(context.getRefireCount())
    };

    getLog().info(MessageFormat.format(getTriggerFiredMessage(), args));
}
 
Example 8
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 9
Source File: LoggingTriggerHistoryPlugin.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
public void triggerComplete(Trigger trigger, JobExecutionContext context,
        int triggerInstructionCode) {
    if (!getLog().isInfoEnabled()) {
        return;
    } 
    
    String instrCode = "UNKNOWN";
    if (triggerInstructionCode == Trigger.INSTRUCTION_DELETE_TRIGGER) {
        instrCode = "DELETE TRIGGER";
    } else if (triggerInstructionCode == Trigger.INSTRUCTION_NOOP) {
        instrCode = "DO NOTHING";
    } else if (triggerInstructionCode == Trigger.INSTRUCTION_RE_EXECUTE_JOB) {
        instrCode = "RE-EXECUTE JOB";
    } else if (triggerInstructionCode == Trigger.INSTRUCTION_SET_ALL_JOB_TRIGGERS_COMPLETE) {
        instrCode = "SET ALL OF JOB'S TRIGGERS COMPLETE";
    } else if (triggerInstructionCode == Trigger.INSTRUCTION_SET_TRIGGER_COMPLETE) {
        instrCode = "SET THIS TRIGGER COMPLETE";
    }

    Object[] args = {
        trigger.getName(), trigger.getGroup(),
        trigger.getPreviousFireTime(), trigger.getNextFireTime(),
        new java.util.Date(), context.getJobDetail().getName(),
        context.getJobDetail().getGroup(),
        new Integer(context.getRefireCount()),
        new Integer(triggerInstructionCode), instrCode
    };

    getLog().info(MessageFormat.format(getTriggerCompleteMessage(), args));
}
 
Example 10
Source File: RAMJobStore.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
static String getTriggerNameKey(Trigger trigger) {
    return trigger.getGroup() + "_$x$x$_" + trigger.getName();
}
 
Example 11
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 12
Source File: LoggingJobHistoryPlugin.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
/** 
 * @see org.quartz.JobListener#jobWasExecuted(JobExecutionContext, JobExecutionException)
 */
public void jobWasExecuted(JobExecutionContext context,
        JobExecutionException jobException) {

    Trigger trigger = context.getTrigger();
    
    Object[] args = null;
    
    if (jobException != null) {
        if (!getLog().isWarnEnabled()) {
            return;
        } 
        
        String errMsg = jobException.getMessage();
        args = 
            new Object[] {
                context.getJobDetail().getName(),
                context.getJobDetail().getGroup(), new java.util.Date(),
                trigger.getName(), trigger.getGroup(),
                trigger.getPreviousFireTime(), trigger.getNextFireTime(),
                new Integer(context.getRefireCount()), errMsg
            };
        
        getLog().warn(MessageFormat.format(getJobFailedMessage(), args), jobException); 
    } else {
        if (!getLog().isInfoEnabled()) {
            return;
        } 
        
        String result = String.valueOf(context.getResult());
        args =
            new Object[] {
                context.getJobDetail().getName(),
                context.getJobDetail().getGroup(), new java.util.Date(),
                trigger.getName(), trigger.getGroup(),
                trigger.getPreviousFireTime(), trigger.getNextFireTime(),
                new Integer(context.getRefireCount()), result
            };
        
        getLog().info(MessageFormat.format(getJobSuccessMessage(), args));
    }
}