Java Code Examples for org.quartz.Trigger#STATE_NONE

The following examples show how to use org.quartz.Trigger#STATE_NONE . 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: RAMJobStore.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Get the current state of the identified <code>{@link Trigger}</code>.
 * </p>
 *
 * @see Trigger#STATE_NORMAL
 * @see Trigger#STATE_PAUSED
 * @see Trigger#STATE_COMPLETE
 * @see Trigger#STATE_ERROR
 * @see Trigger#STATE_BLOCKED
 * @see Trigger#STATE_NONE
 */
public int getTriggerState(SchedulingContext ctxt, String triggerName,
        String groupName) throws JobPersistenceException {
    synchronized(lock) {
        TriggerWrapper tw = (TriggerWrapper) triggersByFQN.get(TriggerWrapper
            .getTriggerNameKey(triggerName, groupName));
        
        if (tw == null) {
            return Trigger.STATE_NONE;
        }

        if (tw.state == TriggerWrapper.STATE_COMPLETE) {
            return Trigger.STATE_COMPLETE;
        }

        if (tw.state == TriggerWrapper.STATE_PAUSED) {
            return Trigger.STATE_PAUSED;
        }

        if (tw.state == TriggerWrapper.STATE_PAUSED_BLOCKED) {
            return Trigger.STATE_PAUSED;
        }

        if (tw.state == TriggerWrapper.STATE_BLOCKED) {
            return Trigger.STATE_BLOCKED;
        }

        if (tw.state == TriggerWrapper.STATE_ERROR) {
            return Trigger.STATE_ERROR;
        }

        return Trigger.STATE_NORMAL;
    }
}
 
Example 2
Source File: JobStoreSupport.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public int getTriggerState(Connection conn, SchedulingContext ctxt,
        String triggerName, String groupName)
    throws JobPersistenceException {
    try {
        String ts = getDelegate().selectTriggerState(conn, triggerName,
                groupName);

        if (ts == null) {
            return Trigger.STATE_NONE;
        }

        if (ts.equals(STATE_DELETED)) {
            return Trigger.STATE_NONE;
        }

        if (ts.equals(STATE_COMPLETE)) {
            return Trigger.STATE_COMPLETE;
        }

        if (ts.equals(STATE_PAUSED)) {
            return Trigger.STATE_PAUSED;
        }

        if (ts.equals(STATE_PAUSED_BLOCKED)) {
            return Trigger.STATE_PAUSED;
        }

        if (ts.equals(STATE_ERROR)) {
            return Trigger.STATE_ERROR;
        }

        if (ts.equals(STATE_BLOCKED)) {
            return Trigger.STATE_BLOCKED;
        }

        return Trigger.STATE_NORMAL;

    } catch (SQLException e) {
        throw new JobPersistenceException(
                "Couldn't determine state of trigger (" + groupName + "."
                        + triggerName + "): " + e.getMessage(), e);
    }
}
 
Example 3
Source File: StatisticsAdminController.java    From olat with Apache License 2.0 4 votes vote down vote up
private void refreshUIState() {
    boolean enabled = false;
    String cronExpression = "";
    if (CoreSpringFactory.containsBean("schedulerFactoryBean")) {
        log.info("refreshUIState: schedulerFactoryBean found");
        final Object schedulerFactoryBean = CoreSpringFactory.getBean("schedulerFactoryBean");
        if (schedulerFactoryBean != null && schedulerFactoryBean instanceof Scheduler) {
            final Scheduler schedulerBean = (Scheduler) schedulerFactoryBean;
            int triggerState;
            try {
                triggerState = schedulerBean.getTriggerState("updateStatisticsTrigger", null/* trigger group */);
                enabled = (triggerState != Trigger.STATE_NONE) && (triggerState != Trigger.STATE_ERROR);
                log.info("refreshUIState: updateStatisticsTrigger state was " + triggerState + ", enabled now: " + enabled);
            } catch (final SchedulerException e) {
                log.warn("refreshUIState: Got a SchedulerException while asking for the updateStatisticsTrigger's state", e);
            }
        }
        final CronTriggerBean triggerBean = (CronTriggerBean) CoreSpringFactory.getBean("updateStatisticsTrigger");
        final JobDetail jobDetail = triggerBean.getJobDetail();
        enabled &= jobDetail.getName().equals("statistics.job.enabled");
        log.info("refreshUIState: statistics.job.enabled check, enabled now: " + enabled);
        cronExpression = triggerBean.getCronExpression();
        final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
        if (statisticUpdateManager == null) {
            log.info("refreshUIState: statisticUpdateManager not configured");
            enabled = false;
        } else {
            enabled &= statisticUpdateManager.isEnabled();
            log.info("refreshUIState: statisticUpdateManager configured, enabled now: " + enabled);
        }
    } else {
        log.info("refreshUIState: schedulerFactoryBean not found");
    }
    if (enabled) {
        content.contextPut("status", getTranslator().translate("statistics.status.enabled", new String[] { cronExpression }));
    } else {
        content.contextPut("status", getTranslator().translate("statistics.status.disabled"));
    }
    content.contextPut("statisticEnabled", enabled);

    recalcLastUpdated();

    updateStatisticUpdateOngoingFlag();
}
 
Example 4
Source File: StatisticsAdminController.java    From olat with Apache License 2.0 4 votes vote down vote up
private void refreshUIState() {
    boolean enabled = false;
    String cronExpression = "";
    if (CoreSpringFactory.containsBean("schedulerFactoryBean")) {
        log.info("refreshUIState: schedulerFactoryBean found");
        final Object schedulerFactoryBean = CoreSpringFactory.getBean("schedulerFactoryBean");
        if (schedulerFactoryBean != null && schedulerFactoryBean instanceof Scheduler) {
            final Scheduler schedulerBean = (Scheduler) schedulerFactoryBean;
            int triggerState;
            try {
                triggerState = schedulerBean.getTriggerState("updateStatisticsTrigger", null/* trigger group */);
                enabled = (triggerState != Trigger.STATE_NONE) && (triggerState != Trigger.STATE_ERROR);
                log.info("refreshUIState: updateStatisticsTrigger state was " + triggerState + ", enabled now: " + enabled);
            } catch (final SchedulerException e) {
                log.warn("refreshUIState: Got a SchedulerException while asking for the updateStatisticsTrigger's state", e);
            }
        }
        final CronTriggerBean triggerBean = (CronTriggerBean) CoreSpringFactory.getBean("updateStatisticsTrigger");
        final JobDetail jobDetail = triggerBean.getJobDetail();
        enabled &= jobDetail.getName().equals("statistics.job.enabled");
        log.info("refreshUIState: statistics.job.enabled check, enabled now: " + enabled);
        cronExpression = triggerBean.getCronExpression();
        final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
        if (statisticUpdateManager == null) {
            log.info("refreshUIState: statisticUpdateManager not configured");
            enabled = false;
        } else {
            enabled &= statisticUpdateManager.isEnabled();
            log.info("refreshUIState: statisticUpdateManager configured, enabled now: " + enabled);
        }
    } else {
        log.info("refreshUIState: schedulerFactoryBean not found");
    }
    if (enabled) {
        content.contextPut("status", getTranslator().translate("statistics.status.enabled", new String[] { cronExpression }));
    } else {
        content.contextPut("status", getTranslator().translate("statistics.status.disabled"));
    }
    content.contextPut("statisticEnabled", enabled);

    recalcLastUpdated();

    updateStatisticUpdateOngoingFlag();
}