Java 类org.quartz.TriggerKey 实例源码

项目:lams    文件:DefaultClusteredJobStore.java   
/**
 * <p>
 * Get the current state of the identified <code>{@link Trigger}</code>.
 * </p>
 * 
 * @see Trigger.TriggerState
 */
@Override
public Trigger.TriggerState getTriggerState(org.quartz.TriggerKey key) throws JobPersistenceException {

  TriggerWrapper tw;
  lock();
  try {
    tw = triggerFacade.get(key);
  } finally {
    unlock();
  }

  if (tw == null) { return Trigger.TriggerState.NONE; }

  if (tw.getState() == TriggerState.COMPLETE) { return Trigger.TriggerState.COMPLETE; }

  if (tw.getState() == TriggerState.PAUSED) { return Trigger.TriggerState.PAUSED; }

  if (tw.getState() == TriggerState.PAUSED_BLOCKED) { return Trigger.TriggerState.PAUSED; }

  if (tw.getState() == TriggerState.BLOCKED) { return Trigger.TriggerState.BLOCKED; }

  if (tw.getState() == TriggerState.ERROR) { return Trigger.TriggerState.ERROR; }

  return Trigger.TriggerState.NORMAL;
}
项目:lams    文件:StdJDBCDelegate.java   
/**
 * <p>
 * Delete the base trigger data for a trigger.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @return the number of rows deleted
 */
public int deleteTrigger(Connection conn, TriggerKey triggerKey) throws SQLException {
    PreparedStatement ps = null;

    deleteTriggerExtension(conn, triggerKey);

    try {
        ps = conn.prepareStatement(rtp(DELETE_TRIGGER));
        ps.setString(1, triggerKey.getName());
        ps.setString(2, triggerKey.getGroup());

        return ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }
}
项目:spring-boot-quartz-demo    文件:JobServiceImpl.java   
/**
 * Update one time scheduled job.
 */
@Override
public boolean updateOneTimeJob(String jobName, Date date) {
    System.out.println("Request received for updating one time job.");

    String jobKey = jobName;

    System.out.println("Parameters received for updating one time job : jobKey :"+jobKey + ", date: "+date);
    try {
        //Trigger newTrigger = JobUtil.createSingleTrigger(jobKey, date, SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT);
        Trigger newTrigger = JobUtil.createSingleTrigger(jobKey, date, SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW);

        Date dt = schedulerFactoryBean.getScheduler().rescheduleJob(TriggerKey.triggerKey(jobKey), newTrigger);
        System.out.println("Trigger associated with jobKey :"+jobKey+ " rescheduled successfully for date :"+dt);
        return true;
    } catch ( Exception e ) {
        System.out.println("SchedulerException while updating one time job with key :"+jobKey + " message :"+e.getMessage());
        e.printStackTrace();
        return false;
    }
}
项目:spring-boot-quartz-demo    文件:JobServiceImpl.java   
/**
 * Remove the indicated Trigger from the scheduler. 
 * If the related job does not have any other triggers, and the job is not durable, then the job will also be deleted.
 */
@Override
public boolean unScheduleJob(String jobName) {
    System.out.println("Request received for Unscheduleding job.");

    String jobKey = jobName;

    TriggerKey tkey = new TriggerKey(jobKey);
    System.out.println("Parameters received for unscheduling job : tkey :"+jobKey);
    try {
        boolean status = schedulerFactoryBean.getScheduler().unscheduleJob(tkey);
        System.out.println("Trigger associated with jobKey :"+jobKey+ " unscheduled with status :"+status);
        return status;
    } catch (SchedulerException e) {
        System.out.println("SchedulerException while unscheduling job with key :"+jobKey + " message :"+e.getMessage());
        e.printStackTrace();
        return false;
    }
}
项目:lams    文件:JobStoreSupport.java   
protected boolean updateMisfiredTrigger(Connection conn,
        TriggerKey triggerKey, String newStateIfNotComplete, boolean forceState)
    throws JobPersistenceException {
    try {

        OperableTrigger trig = retrieveTrigger(conn, triggerKey);

        long misfireTime = System.currentTimeMillis();
        if (getMisfireThreshold() > 0) {
            misfireTime -= getMisfireThreshold();
        }

        if (trig.getNextFireTime().getTime() > misfireTime) {
            return false;
        }

        doUpdateOfMisfiredTrigger(conn, trig, forceState, newStateIfNotComplete, false);

        return true;

    } catch (Exception e) {
        throw new JobPersistenceException(
                "Couldn't update misfired trigger '" + triggerKey + "': " + e.getMessage(), e);
    }
}
项目:lams    文件:QuartzScheduler.java   
public void notifySchedulerListenersUnscheduled(TriggerKey triggerKey) {
    // build a list of all scheduler listeners that are to be notified...
    List<SchedulerListener> schedListeners = buildSchedulerListenerList();

    // notify all scheduler listeners
    for(SchedulerListener sl: schedListeners) {
        try {
            if(triggerKey == null)
                sl.schedulingDataCleared();
            else
                sl.jobUnscheduled(triggerKey);
        } catch (Exception e) {
            getLog().error(
                    "Error while notifying SchedulerListener of unscheduled job."
                            + "  Triger=" + (triggerKey == null ? "ALL DATA" : triggerKey), e);
        }
    }
}
项目:lams    文件:DefaultClusteredJobStore.java   
/**
 * <p>
 * Get all of the Triggers that are associated to the given Job.
 * </p>
 * <p>
 * If there are no matches, a zero-length array should be returned.
 * </p>
 */
@Override
public List<OperableTrigger> getTriggersForJob(final JobKey jobKey) throws JobPersistenceException {
  List<OperableTrigger> trigList = new ArrayList<OperableTrigger>();

  lock();
  try {
    for (TriggerKey triggerKey : triggerFacade.allTriggerKeys()) {
      TriggerWrapper tw = triggerFacade.get(triggerKey);
      if (tw.getJobKey().equals(jobKey)) {
        trigList.add(tw.getTriggerClone());
      }
    }
  } finally {
    unlock();
  }

  return trigList;
}
项目:lams    文件:StdJDBCDelegate.java   
/**
 * <p>
 * Get the names of all of the triggers associated with the given job.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @return an array of <code>{@link
 * org.quartz.utils.Key}</code> objects
 */
public List<TriggerKey> selectTriggerKeysForJob(Connection conn, JobKey jobKey) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_TRIGGERS_FOR_JOB));
        ps.setString(1, jobKey.getName());
        ps.setString(2, jobKey.getGroup());
        rs = ps.executeQuery();

        LinkedList<TriggerKey> list = new LinkedList<TriggerKey>();
        while (rs.next()) {
            String trigName = rs.getString(COL_TRIGGER_NAME);
            String trigGroup = rs.getString(COL_TRIGGER_GROUP);
            list.add(triggerKey(trigName, trigGroup));
        }
        return list;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
项目:lams    文件:JobStoreSupport.java   
/**
 * <p>
 * Pause the <code>{@link org.quartz.Trigger}</code> with the given name.
 * </p>
 * 
 * @see #resumeTrigger(Connection, TriggerKey)
 */
public void pauseTrigger(Connection conn, 
        TriggerKey triggerKey)
    throws JobPersistenceException {

    try {
        String oldState = getDelegate().selectTriggerState(conn,
                triggerKey);

        if (oldState.equals(STATE_WAITING)
                || oldState.equals(STATE_ACQUIRED)) {

            getDelegate().updateTriggerState(conn, triggerKey,
                    STATE_PAUSED);
        } else if (oldState.equals(STATE_BLOCKED)) {
            getDelegate().updateTriggerState(conn, triggerKey,
                    STATE_PAUSED_BLOCKED);
        }
    } catch (SQLException e) {
        throw new JobPersistenceException("Couldn't pause trigger '"
                + triggerKey + "': " + e.getMessage(), e);
    }
}
项目:nh-micro    文件:MicroQuartzManager.java   
/** 
 * @Description 移除一个任务(使用默认的任务组名,触发器名,触发器组名) 
 * @param jobName 
 *  
 *  
 */  
public static void removeJob(String jobName) {   
    TriggerKey triggerKey = TriggerKey.triggerKey(  
            jobName, TRIGGER_GROUP_NAME);  
    JobKey jobKey = JobKey.jobKey(jobName, JOB_GROUP_NAME);  
    try {    
        Scheduler sched = gSchedulerFactory.getScheduler();  
        Trigger trigger = (Trigger) sched.getTrigger(triggerKey);    
        if (trigger == null) {    
            return;    
        }  
        sched.pauseTrigger(triggerKey);;// 停止触发器    
        sched.unscheduleJob(triggerKey);// 移除触发器    
        sched.deleteJob(jobKey);// 删除任务    
    } catch (Exception e) {    
        throw new RuntimeException(e);    
    }    
}
项目:lams    文件:StdJDBCDelegate.java   
public List<String> selectTriggerGroups(Connection conn, GroupMatcher<TriggerKey> matcher) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_TRIGGER_GROUPS_FILTERED));
        ps.setString(1, toSqlLikeClause(matcher));
        rs = ps.executeQuery();

        LinkedList<String> list = new LinkedList<String>();
        while (rs.next()) {
            list.add(rs.getString(1));
        }

        return list;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
项目:uflo    文件:SchedulerServiceImpl.java   
private void initScanReminderJob(){
    CronTriggerImpl trigger=new CronTriggerImpl();
    trigger.setName("UfloScanReminderTrigger");
    trigger.setKey(new TriggerKey("UfloScanReminderTrigger"));
    try {
        trigger.setCronExpression(SCAN_REMINDER_CRON);
        ScanReminderJob job=new ScanReminderJob();
        ScanReminderJobDetail detail=new ScanReminderJobDetail();
        detail.setSchedulerService(this);
        detail.setTaskService(taskService);
        detail.setReminderTaskList(reminderTaskList);
        detail.setJobClass(job.getClass());
        detail.setKey(new JobKey("UfloScanReminderJob"));
        scheduler.scheduleJob(detail, trigger);
    } catch (Exception e1) {
        throw new RuntimeException(e1);
    }
}
项目:lams    文件:RemoteScheduler.java   
/**
 * <p>
 * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
 * </p>
 */
public void resumeTriggers(GroupMatcher<TriggerKey> matcher) throws SchedulerException {
    try {
        getRemoteScheduler().resumeTriggers(matcher);
    } catch (RemoteException re) {
        throw invalidateHandleCreateException(
                "Error communicating with remote scheduler.", re);
    }
}
项目:lams    文件:QuartzScheduler.java   
/**
 * <p>
 * Remove the indicated <code>{@link org.quartz.Trigger}</code> from the
 * scheduler.
 * </p>
 */
public boolean unscheduleJob(TriggerKey triggerKey) throws SchedulerException {
    validateState();

    if (resources.getJobStore().removeTrigger(triggerKey)) {
        notifySchedulerThread(0L);
        notifySchedulerListenersUnscheduled(triggerKey);
    } else {
        return false;
    }

    return true;
}
项目:iBase4J-Common    文件:SchedulerManager.java   
public void resumeJob(TaskScheduled scheduleJob) {
    try {
        TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
        scheduler.resumeTrigger(triggerKey);
    } catch (Exception e) {
        logger.error("Try to resume Job cause error : ", e);
        throw new BusinessException(e);
    }
}
项目:iBase4J-Common    文件:SchedulerManager.java   
public void delJob(TaskScheduled scheduleJob) {
    try {
        JobKey jobKey = JobKey.jobKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
        TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
        scheduler.pauseTrigger(triggerKey);// 停止触发器
        scheduler.unscheduleJob(triggerKey);// 移除触发器
        scheduler.deleteJob(jobKey);// 删除任务
    } catch (Exception e) {
        logger.error("Try to resume Job cause error : ", e);
        throw new BusinessException(e);
    }
}
项目:lams    文件:StdJDBCDelegate.java   
/**
 * <p>
 * Get the names of all of the triggers in the given state that have
 * misfired - according to the given timestamp.  No more than count will
 * be returned.
 * </p>
 * 
 * @param conn The DB Connection
 * @param count The most misfired triggers to return, negative for all
 * @param resultList Output parameter.  A List of 
 *      <code>{@link org.quartz.utils.Key}</code> objects.  Must not be null.
 *          
 * @return Whether there are more misfired triggers left to find beyond
 *         the given count.
 */
public boolean hasMisfiredTriggersInState(Connection conn, String state1, 
    long ts, int count, List<TriggerKey> resultList) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_HAS_MISFIRED_TRIGGERS_IN_STATE));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        ps.setString(2, state1);
        rs = ps.executeQuery();

        boolean hasReachedLimit = false;
        while (rs.next() && (hasReachedLimit == false)) {
            if (resultList.size() == count) {
                hasReachedLimit = true;
            } else {
                String triggerName = rs.getString(COL_TRIGGER_NAME);
                String groupName = rs.getString(COL_TRIGGER_GROUP);
                resultList.add(triggerKey(triggerName, groupName));
            }
        }

        return hasReachedLimit;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
项目:lams    文件:QuartzSchedulerMBeanImpl.java   
public List<String> getTriggerNames(String groupName) throws Exception {
    try {
        List<String> triggerNames = new ArrayList<String>();
        for(TriggerKey key: scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(groupName))) {
            triggerNames.add(key.getName());
        }
        return triggerNames;
    } catch (Exception e) {
        throw newPlainException(e);
    }
}
项目:lams    文件:JobStoreSupport.java   
/**
 * <p>
 * Retrieve the given <code>{@link org.quartz.Trigger}</code>.
 * </p>
 * 
 * @return The desired <code>Trigger</code>, or null if there is no
 *         match.
 */
public OperableTrigger retrieveTrigger(final TriggerKey triggerKey) throws JobPersistenceException {
    return (OperableTrigger)executeWithoutLock( // no locks necessary for read...
        new TransactionCallback() {
            public Object execute(Connection conn) throws JobPersistenceException {
                return retrieveTrigger(conn, triggerKey);
            }
        });
}
项目:plugin-vm    文件:VmResource.java   
/**
 * Remove all schedules matching the given predicate from the current
 * scheduler, then from the data base.
 */
private void unscheduleAll(final Predicate<TriggerKey> predicate) throws SchedulerException {
    // Remove current schedules from the memory
    final Scheduler scheduler = vmSchedulerFactoryBean.getObject();
    for (final TriggerKey triggerKey : scheduler.getTriggerKeys(GroupMatcher.groupEquals(SCHEDULE_TRIGGER_GROUP))) {
        if (predicate.test(triggerKey)) {
            // Match subscription and operation, unschedule this trigger
            scheduler.unscheduleJob(triggerKey);
        }
    }
}
项目:webside    文件:ScheduleJobServiceImpl.java   
@Transactional
@Override
public boolean pauseJobTrigger(TriggerKey triggerKey) {
    try
    {
        Scheduler scheduler = schedulerFactoryBean.getScheduler();
        scheduler.pauseTrigger(triggerKey);
        return Boolean.TRUE;
    } catch (SchedulerException e) {
        throw new ServiceException(e);
    }
}
项目:nh-micro    文件:MicroQuartzManager.java   
/**  
 * @Description: 移除一个任务  
 * @param jobName  
 * @param jobGroupName  
 * @param triggerName  
 * @param triggerGroupName  
 *   
 * 
 */    
public static void removeJob(String jobName, String jobGroupName,    
        String triggerName, String triggerGroupName) {   
    TriggerKey triggerKey = TriggerKey.triggerKey(  
            jobName, triggerGroupName);  
    JobKey jobKey = JobKey.jobKey(jobName, jobGroupName);  
    try {    
        Scheduler sched = gSchedulerFactory.getScheduler();   
        sched.pauseTrigger(triggerKey);// 停止触发器    
        sched.unscheduleJob(triggerKey);// 移除触发器    
        sched.deleteJob(jobKey);// 删除任务  
    } catch (Exception e) {    
        throw new RuntimeException(e);    
    }    
}
项目:lams    文件:EmailProgressAction.java   
/**
    * Gets learners or monitors of the lesson and organisation containing it.
    * 
    * @throws SchedulerException
    */
   public ActionForward getEmailProgressDates(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException, JSONException, SchedulerException {
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(), "get class members", false)) {
    response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson");
    return null;
}

HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);

JSONObject responseJSON = new JSONObject();
JSONArray datesJSON = new JSONArray();

// find all the current dates set up to send the emails
Scheduler scheduler = getScheduler();
String triggerPrefix = getTriggerPrefix(lessonId);
SortedSet<Date> currentDatesSet = new TreeSet<Date>();
Set<TriggerKey> triggerKeys = scheduler
    .getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
    String triggerName = triggerKey.getName();
    if (triggerName.startsWith(triggerPrefix)) {
    Trigger trigger = scheduler.getTrigger(triggerKey);
    JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
    JobDataMap jobDataMap = jobDetail.getJobDataMap();

    // get only the trigger for the current lesson

    Object jobLessonId = jobDataMap.get(AttributeNames.PARAM_LESSON_ID);
    if (lessonId.equals(jobLessonId)) {

        Date triggerDate = trigger.getNextFireTime();
        currentDatesSet.add(triggerDate);
    }
    }
}

for (Date date : currentDatesSet) {
    datesJSON.put(createDateJSON(request.getLocale(), user, date, null));
}
responseJSON.put("dates", datesJSON);

response.setContentType("application/json;charset=utf-8");
response.getWriter().write(responseJSON.toString());
return null;
   }
项目:iBase4J    文件:SchedulerManager.java   
public void delJob(TaskScheduled scheduleJob) {
    try {
        JobKey jobKey = JobKey.jobKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
        TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
        scheduler.pauseTrigger(triggerKey);// 停止触发器
        scheduler.unscheduleJob(triggerKey);// 移除触发器
        scheduler.deleteJob(jobKey);// 删除任务
    } catch (Exception e) {
        logger.error("Try to resume Job cause error : ", e);
        throw new BusinessException(e);
    }
}
项目:lams    文件:AbstractTerracottaJobStore.java   
@Override
public Set<TriggerKey> getTriggerKeys(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException {
  try {
    return realJobStore.getTriggerKeys(matcher);
  } catch (RejoinException e) {
    throw new JobPersistenceException("Trigger key retrieval failed due to client rejoin", e);
  }
}
项目:lams    文件:RemoteScheduler.java   
/**
 * <p>
 * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
 * </p>
 */
public void pauseTriggers(GroupMatcher<TriggerKey> matcher) throws SchedulerException {
    try {
        getRemoteScheduler().pauseTriggers(matcher);
    } catch (RemoteException re) {
        throw invalidateHandleCreateException(
                "Error communicating with remote scheduler.", re);
    }
}
项目:lams    文件:ListenerManagerImpl.java   
public boolean setTriggerListenerMatchers(String listenerName, List<Matcher<TriggerKey>> matchers)  {
    if(matchers == null)
        throw new IllegalArgumentException("Non-null value not acceptable.");

    synchronized (globalTriggerListeners) {
        List<Matcher<TriggerKey>> oldMatchers = globalTriggerListenersMatchers.get(listenerName);
        if(oldMatchers == null)
            return false;
        globalTriggerListenersMatchers.put(listenerName, matchers);
        return true;
    }
}
项目:lams    文件:JobStoreSupport.java   
/** 
 * @see org.quartz.spi.JobStore#replaceTrigger(TriggerKey, OperableTrigger)
 */
public boolean replaceTrigger(final TriggerKey triggerKey, 
        final OperableTrigger newTrigger) throws JobPersistenceException {
    return (Boolean) executeInLock(
            LOCK_TRIGGER_ACCESS,
            new TransactionCallback() {
                public Object execute(Connection conn) throws JobPersistenceException {
                    return replaceTrigger(conn, triggerKey, newTrigger) ?
                            Boolean.TRUE : Boolean.FALSE;
                }
            });
}
项目:lams    文件:AbstractTerracottaJobStore.java   
@Override
public void resumeTrigger(TriggerKey triggerKey) throws JobPersistenceException {
  try {
    realJobStore.resumeTrigger(triggerKey);
  } catch (RejoinException e) {
    throw new JobPersistenceException("Resuming trigger failed due to client rejoin", e);
  }
}
项目:lams    文件:AbstractTerracottaJobStore.java   
@Override
public Collection<String> resumeTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException {
  try {
    return realJobStore.resumeTriggers(matcher);
  } catch (RejoinException e) {
    throw new JobPersistenceException("Resuming triggers failed due to client rejoin", e);
  }
}
项目:lams    文件:JobStoreSupport.java   
/**
 * <p>
 * Check existence of a given trigger.
 * </p>
 */
protected boolean triggerExists(Connection conn, TriggerKey key) throws JobPersistenceException {
    try {
        return getDelegate().triggerExists(conn, key);
    } catch (SQLException e) {
        throw new JobPersistenceException(
                "Couldn't determine trigger existence (" + key + "): " + e.getMessage(), e);
    }
}
项目:webside    文件:ScheduleJobServiceImpl.java   
@Transactional
@Override
public boolean updateJobTrigger(ScheduleJobEntity job) {
    try {
        Scheduler scheduler = schedulerFactoryBean.getScheduler();
        // 获取触发器标识
        TriggerKey triggerKey = job.getTriggerKey();
        CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);

        // Trigger已存在,更新相应的定时设置
        // 表达式调度构建器
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder
                .cronSchedule(job.getCronExpression());

        // 按新的cronExpression表达式重新构建trigger
        trigger = trigger.getTriggerBuilder()
                .forJob(job.getJobKey())
                .withIdentity(triggerKey)
                .startAt(job.getStartDate()) // job开始日期
                .endAt(job.getEndDate())// job结束日期
                .withSchedule(scheduleBuilder).build();
        // 按新的trigger重新设置job执行
        scheduler.rescheduleJob(triggerKey, trigger);
        return Boolean.TRUE;
    } catch (Exception e) {
        throw new ServiceException(e);
    }
}
项目:lams    文件:JobExecutionContextImpl.java   
public TriggerKey getRecoveringTriggerKey() {
    if (isRecovering()) {
        return new TriggerKey(jobDataMap.getString(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_GROUP),
                              jobDataMap.getString(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_NAME));
    } else {
        throw new IllegalStateException("Not a recovering job");
    }
}
项目:uflo    文件:InstanceDetection.java   
private Trigger initTrigger(){
    CronTriggerImpl trigger=new CronTriggerImpl();
    trigger.setName("UfloHeartbeatTrigger");
    trigger.setKey(new TriggerKey("UfloHeartbeatTrigger"));
    try {
        trigger.setCronExpression(detectionCron);
        return trigger;
    } catch (ParseException e1) {
        throw new RuntimeException(e1);
    }
}
项目:lams    文件:RemoteScheduler.java   
/**
 * <p>
 * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
 * </p>
 */
public void pauseTrigger(TriggerKey triggerKey)
    throws SchedulerException {
    try {
        getRemoteScheduler()
                .pauseTrigger(triggerKey);
    } catch (RemoteException re) {
        throw invalidateHandleCreateException(
                "Error communicating with remote scheduler.", re);
    }
}
项目:lams    文件:JobStoreSupport.java   
protected Set<TriggerKey> getTriggerNames(Connection conn,
        GroupMatcher<TriggerKey> matcher) throws JobPersistenceException {

    Set<TriggerKey> trigNames;

    try {
        trigNames = getDelegate().selectTriggersInGroup(conn, matcher);
    } catch (SQLException e) {
        throw new JobPersistenceException("Couldn't obtain trigger names: "
                + e.getMessage(), e);
    }

    return trigNames;
}
项目:lams    文件:JobStoreSupport.java   
protected OperableTrigger retrieveTrigger(Connection conn, TriggerKey key)
    throws JobPersistenceException {
    try {

        return getDelegate().selectTrigger(conn, key);
    } catch (Exception e) {
        throw new JobPersistenceException("Couldn't retrieve trigger: "
                + e.getMessage(), e);
    }
}
项目:lams    文件:DefaultClusteredJobStore.java   
/**
 * <p>
 * Resume (un-pause) the <code>{@link Trigger}</code> with the given name.
 * </p>
 * <p>
 * If the <code>Trigger</code> missed one or more fire-times, then the <code>Trigger</code>'s misfire instruction will
 * be applied.
 * </p>
 */
@Override
public void resumeTrigger(TriggerKey triggerKey) throws JobPersistenceException {
  lock();
  try {
    TriggerWrapper tw = triggerFacade.get(triggerKey);

    // does the trigger exist?
    if (tw == null) { return; }

    // if the trigger is not paused resuming it does not make sense...
    if (tw.getState() != TriggerState.PAUSED && tw.getState() != TriggerState.PAUSED_BLOCKED) { return; }

    if (jobFacade.blockedJobsContain(tw.getJobKey())) {
      tw.setState(TriggerState.BLOCKED, terracottaClientId, triggerFacade);
    } else {
      tw.setState(TriggerState.WAITING, terracottaClientId, triggerFacade);
    }

    applyMisfire(tw);

    if (tw.getState() == TriggerState.WAITING) {
      timeTriggers.add(tw);
    }
  } finally {
    unlock();
  }
}
项目:lams    文件:QuartzSchedulerMBeanImpl.java   
public List<CompositeData> getAllTriggers() throws Exception {
    try {
        List<Trigger> triggerList = new ArrayList<Trigger>();
        for (String triggerGroupName : scheduler.getTriggerGroupNames()) {
            for (TriggerKey triggerKey : scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(triggerGroupName))) {
                triggerList.add(scheduler.getTrigger(triggerKey));
            }
        }
        return TriggerSupport.toCompositeList(triggerList);
    } catch (Exception e) {
        throw newPlainException(e);
    }
}
项目:springboot-quartz    文件:ScheduleJobService.java   
private void updateJobCronExpression(ScheduleJob scheduleJob) throws SchedulerException{  
checkNotNull(scheduleJob);
Preconditions.checkNotNull(StringUtils.isEmpty(scheduleJob.getCronExpression()), "CronExpression is null");

      TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());  
      CronTrigger cronTrigger = (CronTrigger)scheduler.getTrigger(triggerKey);  
      CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression());  
      cronTrigger = cronTrigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();  
      scheduler.rescheduleJob(triggerKey, cronTrigger);  
  }