org.quartz.Trigger.TriggerState Java Examples
The following examples show how to use
org.quartz.Trigger.TriggerState.
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: RedisJobStore.java From redis-quartz with MIT License | 6 votes |
@Override public TriggerState getTriggerState(TriggerKey triggerKey) throws JobPersistenceException { String triggerHashKey = createTriggerHashKey(triggerKey.getGroup(), triggerKey.getName()); try (Jedis jedis = pool.getResource()) { lockPool.acquire(); if (jedis.zscore(RedisTriggerState.PAUSED.getKey(), triggerHashKey) != null || jedis.zscore(RedisTriggerState.PAUSED_BLOCKED.getKey(), triggerHashKey)!= null) return TriggerState.PAUSED; else if (jedis.zscore(RedisTriggerState.BLOCKED.getKey(), triggerHashKey) != null) return TriggerState.BLOCKED; else if (jedis.zscore(RedisTriggerState.WAITING.getKey(), triggerHashKey) != null || jedis.zscore(RedisTriggerState.ACQUIRED.getKey(), triggerHashKey) != null) return TriggerState.NORMAL; else if (jedis.zscore(RedisTriggerState.COMPLETED.getKey(), triggerHashKey) != null) return TriggerState.COMPLETE; else if (jedis.zscore(RedisTriggerState.ERROR.getKey(), triggerHashKey) != null) return TriggerState.ERROR; else return TriggerState.NONE; } catch (Exception ex) { log.error("could not get trigger state: " + triggerHashKey, ex); throw new JobPersistenceException(ex.getMessage(), ex.getCause()); } finally { lockPool.release(); } }
Example #2
Source File: Scheduler.java From mangooio with Apache License 2.0 | 6 votes |
/** * Changes the state of a normally running job from pause to resume or resume to pause * * @param jobName The name of the job * @throws MangooSchedulerException if an error occurs during access to the quartz scheduler */ public void changeState(String jobName) throws MangooSchedulerException { Objects.requireNonNull(this.quartzScheduler, Required.SCHEDULER.toString()); try { for (JobKey jobKey : getAllJobKeys()) { if (jobKey.getName().equalsIgnoreCase(jobName)) { TriggerState triggerState = getTriggerState(jobKey); if (TriggerState.NORMAL == triggerState) { this.quartzScheduler.pauseJob(jobKey); } else { this.quartzScheduler.resumeJob(jobKey); } } } } catch (SchedulerException | MangooSchedulerException e) { throw new MangooSchedulerException(e); } }
Example #3
Source File: Scheduler.java From mangooio with Apache License 2.0 | 6 votes |
/** * Retrieves a list of all jobs and their current status * * @return List of io.mangoo.models.Job objects * @throws MangooSchedulerException if an error occurs during access to the Quartz Scheduler */ @SuppressWarnings("unchecked") public List<io.mangoo.models.Job> getAllJobs() throws MangooSchedulerException { Objects.requireNonNull(this.quartzScheduler, Required.SCHEDULER.toString()); List<io.mangoo.models.Job> jobs = new ArrayList<>(); try { for (JobKey jobKey : getAllJobKeys()) { List<Trigger> triggers = (List<Trigger>) this.quartzScheduler.getTriggersOfJob(jobKey); Trigger trigger = triggers.get(0); TriggerState triggerState = quartzScheduler.getTriggerState(trigger.getKey()); boolean active = TriggerState.NORMAL == triggerState; jobs.add(new io.mangoo.models.Job(active, jobKey.getName(), trigger.getDescription(), trigger.getNextFireTime(), trigger.getPreviousFireTime())); } } catch (SchedulerException e) { throw new MangooSchedulerException(e); } return jobs; }
Example #4
Source File: SchedulerTest.java From mangooio with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testExecuteJob() throws SchedulerException, MangooSchedulerException { //given JobKey jobKey = scheduler.getJobKey(JOB_NAME); //when scheduler.executeJob(JOB_NAME); //then List<Trigger> triggers = (List<Trigger>) scheduler.getQuartzScheduler().getTriggersOfJob(jobKey); Trigger trigger = triggers.get(0); TriggerState triggerState = scheduler.getQuartzScheduler().getTriggerState(trigger.getKey()); assertThat(triggerState, equalTo(TriggerState.NORMAL)); }
Example #5
Source File: SchedulerTest.java From mangooio with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void testPauseJob() throws MangooSchedulerException, SchedulerException { //given JobKey jobKey = scheduler.getJobKey(JOB_NAME); //when scheduler.pauseJob(JOB_NAME); //then List<Trigger> triggers = (List<Trigger>) scheduler.getQuartzScheduler().getTriggersOfJob(jobKey); Trigger trigger = triggers.get(0); TriggerState triggerState = scheduler.getQuartzScheduler().getTriggerState(trigger.getKey()); assertThat(triggerState, equalTo(TriggerState.PAUSED)); }
Example #6
Source File: SchedulerTest.java From mangooio with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void testResumeJob() throws MangooSchedulerException, SchedulerException { //given JobKey jobKey = scheduler.getJobKey("jobs.InfoJob"); //when scheduler.resumeJob("jobs.InfoJob"); //then List<Trigger> triggers = (List<Trigger>) scheduler.getQuartzScheduler().getTriggersOfJob(jobKey); Trigger trigger = triggers.get(0); TriggerState triggerState = scheduler.getQuartzScheduler().getTriggerState(trigger.getKey()); assertThat(triggerState, equalTo(TriggerState.NORMAL)); }
Example #7
Source File: AbstractQuartzTaskManager.java From carbon-commons with Apache License 2.0 | 6 votes |
private TaskState triggerStateToTaskState(TriggerState triggerState) { if (triggerState == TriggerState.NONE) { return TaskState.NONE; } else if (triggerState == TriggerState.PAUSED) { return TaskState.PAUSED; } else if (triggerState == TriggerState.COMPLETE) { return TaskState.FINISHED; } else if (triggerState == TriggerState.ERROR) { return TaskState.ERROR; } else if (triggerState == TriggerState.NORMAL) { return TaskState.NORMAL; } else if (triggerState == TriggerState.BLOCKED) { return TaskState.BLOCKED; } else { return TaskState.UNKNOWN; } }
Example #8
Source File: QuartzUtils.java From quartz-web with Apache License 2.0 | 6 votes |
/** * 将TriggerState英文翻译成中文 * @param triggerState * @return */ public static String triggerStateEN2CN(TriggerState triggerState){ if (TriggerState.NORMAL.ordinal() == triggerState.ordinal()) { return "正常"; } else if (TriggerState.PAUSED.ordinal() == triggerState.ordinal()) { return "暂停"; } else if (TriggerState.COMPLETE.ordinal() == triggerState.ordinal()) { return "完成"; } else if (TriggerState.ERROR.ordinal() == triggerState.ordinal()) { return "错误"; } else if (TriggerState.BLOCKED.ordinal() == triggerState.ordinal()) { return "阻塞"; } else { return "无"; } }
Example #9
Source File: AbstractQuartzTaskManager.java From micro-integrator with Apache License 2.0 | 6 votes |
private TaskState triggerStateToTaskState(TriggerState triggerState) { if (triggerState == TriggerState.NONE) { return TaskState.NONE; } else if (triggerState == TriggerState.PAUSED) { return TaskState.PAUSED; } else if (triggerState == TriggerState.COMPLETE) { return TaskState.FINISHED; } else if (triggerState == TriggerState.ERROR) { return TaskState.ERROR; } else if (triggerState == TriggerState.NORMAL) { return TaskState.NORMAL; } else if (triggerState == TriggerState.BLOCKED) { return TaskState.BLOCKED; } else { return TaskState.UNKNOWN; } }
Example #10
Source File: QuartzSchedulerMBeanImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public String getTriggerState(String triggerName, String triggerGroupName) throws Exception { try { TriggerKey triggerKey = triggerKey(triggerName, triggerGroupName); TriggerState ts = scheduler.getTriggerState(triggerKey); return ts.name(); } catch (Exception e) { throw newPlainException(e); } }
Example #11
Source File: XxlJobDynamicScheduler.java From open-capacity-platform with Apache License 2.0 | 5 votes |
/** * fill job info * * @param jobInfo */ public static void fillJobInfo(XxlJobInfo jobInfo) { // TriggerKey : name + group String group = String.valueOf(jobInfo.getJobGroup()); String name = String.valueOf(jobInfo.getId()); TriggerKey triggerKey = TriggerKey.triggerKey(name, group); try { Trigger trigger = scheduler.getTrigger(triggerKey); TriggerState triggerState = scheduler.getTriggerState(triggerKey); // parse params if (trigger!=null && trigger instanceof CronTriggerImpl) { String cronExpression = ((CronTriggerImpl) trigger).getCronExpression(); jobInfo.setJobCron(cronExpression); } //JobKey jobKey = new JobKey(jobInfo.getJobName(), String.valueOf(jobInfo.getJobGroup())); //JobDetail jobDetail = scheduler.getJobDetail(jobKey); //String jobClass = jobDetail.getJobClass().getName(); if (triggerState!=null) { jobInfo.setJobStatus(triggerState.name()); } } catch (SchedulerException e) { logger.error(e.getMessage(), e); } }
Example #12
Source File: Scheduler.java From mangooio with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private TriggerState getTriggerState(JobKey jobKey) throws SchedulerException { Objects.requireNonNull(this.quartzScheduler, Required.SCHEDULER.toString()); List<Trigger> triggers = (List<Trigger>) this.quartzScheduler.getTriggersOfJob(jobKey); Trigger trigger = triggers.get(0); return this.quartzScheduler.getTriggerState(trigger.getKey()); }
Example #13
Source File: SchedulerManager.java From SO with BSD 2-Clause "Simplified" License | 5 votes |
@Override public ResponseMessage pauseJobList() throws SchedulerException { ResponseMessage res = new ResponseMessage(); //Scheduler scheduler = new StdSchedulerFactory().getScheduler(); int count =0; log.debug(" ==============< executedJobList() > ======================"); for (String groupName : scheduler.getJobGroupNames()) { for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) { String jobName = jobKey.getName(); String jobGroup = jobKey.getGroup(); //get job's trigger @SuppressWarnings("unchecked") List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey); Trigger trigger = triggers.get(0); Date nextFireTime = trigger.getNextFireTime(); //[jobName] : PR-8ea4d232-6e0d-42cc-a7b1-7f1a1c03951c [groupName] : SoSchedulerGroup - Fri Sep 29 14:29:31 KST 2017 TriggerState triggerState = scheduler.getTriggerState(trigger.getKey()); if (triggerState.equals(TriggerState.NORMAL)) { //jobName으로 DB에서 Profile 정보 읽어오기 ProfileForDB profileForDB = profileDAO.retrieveProfile(jobName); if (profileForDB != null) { //profileList.add(profileForDB); scheduler.pauseJob(jobKey); count ++; log.debug(" === [jobName] : " + jobName + " [groupName] : " + jobGroup + " - " + nextFireTime + " = triggerState : " + triggerState.toString()); } } } } res.setMessage("Paused profile count= " + count); return res; }
Example #14
Source File: AbstractJobStoreTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testResetErrorTrigger() throws Exception { Date baseFireTimeDate = DateBuilder.evenMinuteDateAfterNow(); long baseFireTime = baseFireTimeDate.getTime(); // create and store a trigger OperableTrigger trigger1 = new SimpleTriggerImpl("trigger1", "triggerGroup1", this.fJobDetail.getName(), this.fJobDetail.getGroup(), new Date(baseFireTime + 200000), new Date(baseFireTime + 200000), 2, 2000); trigger1.computeFirstFireTime(null); this.fJobStore.storeTrigger(trigger1, false); long firstFireTime = new Date(trigger1.getNextFireTime().getTime()).getTime(); // pretend to fire it List<OperableTrigger> aqTs = this.fJobStore.acquireNextTriggers( firstFireTime + 10000, 1, 0L); assertEquals(trigger1.getKey(), aqTs.get(0).getKey()); List<TriggerFiredResult> fTs = this.fJobStore.triggersFired(aqTs); TriggerFiredResult ft = fTs.get(0); // get the trigger into error state this.fJobStore.triggeredJobComplete(ft.getTriggerFiredBundle().getTrigger(), ft.getTriggerFiredBundle().getJobDetail(), Trigger.CompletedExecutionInstruction.SET_TRIGGER_ERROR); TriggerState state = this.fJobStore.getTriggerState(trigger1.getKey()); assertEquals(TriggerState.ERROR, state); // test reset this.fJobStore.resetTriggerFromErrorState(trigger1.getKey()); state = this.fJobStore.getTriggerState(trigger1.getKey()); assertEquals(TriggerState.NORMAL, state); }
Example #15
Source File: AbstractJobStoreTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test @SuppressWarnings("deprecation") public void testTriggerStates() throws Exception { OperableTrigger trigger = new SimpleTriggerImpl("trigger1", "triggerGroup1", this.fJobDetail.getName(), this.fJobDetail.getGroup(), new Date(System.currentTimeMillis() + 100000), new Date(System.currentTimeMillis() + 200000), 2, 2000); trigger.computeFirstFireTime(null); assertEquals(TriggerState.NONE, this.fJobStore.getTriggerState(trigger.getKey())); this.fJobStore.storeTrigger(trigger, false); assertEquals(TriggerState.NORMAL, this.fJobStore.getTriggerState(trigger.getKey())); this.fJobStore.pauseTrigger(trigger.getKey()); assertEquals(TriggerState.PAUSED, this.fJobStore.getTriggerState(trigger.getKey())); this.fJobStore.resumeTrigger(trigger.getKey()); assertEquals(TriggerState.NORMAL, this.fJobStore.getTriggerState(trigger.getKey())); trigger = this.fJobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).get(0); assertNotNull(trigger); this.fJobStore.releaseAcquiredTrigger(trigger); trigger=this.fJobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).get(0); assertNotNull(trigger); assertTrue(this.fJobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).isEmpty()); }
Example #16
Source File: JobStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testResetErrorTrigger() throws Exception { JobDetail jobDetail = JobBuilder.newJob(MyJob.class).withIdentity("job1", "jobGroup1").storeDurably(true).build(); this.jobStore.storeJob(jobDetail, false); Date baseFireTimeDate = DateBuilder.evenMinuteDateAfterNow(); long baseFireTime = baseFireTimeDate.getTime(); // create and store a trigger OperableTrigger trigger1 = new SimpleTriggerImpl("trigger1", "triggerGroup1", jobDetail.getKey().getName(), jobDetail.getKey().getGroup(), new Date(baseFireTime + 200000), new Date(baseFireTime + 200000), 2, 2000); trigger1.computeFirstFireTime(null); jobStore.storeTrigger(trigger1, false); long firstFireTime = new Date(trigger1.getNextFireTime().getTime()).getTime(); // pretend to fire it List<OperableTrigger> aqTs = jobStore.acquireNextTriggers( firstFireTime + 10000, 1, 0L); assertEquals(trigger1.getKey(), aqTs.get(0).getKey()); List<TriggerFiredResult> fTs = jobStore.triggersFired(aqTs); TriggerFiredResult ft = fTs.get(0); // get the trigger into error state jobStore.triggeredJobComplete(ft.getTriggerFiredBundle().getTrigger(), ft.getTriggerFiredBundle().getJobDetail(), Trigger.CompletedExecutionInstruction.SET_TRIGGER_ERROR); TriggerState state = jobStore.getTriggerState(trigger1.getKey()); assertEquals(TriggerState.ERROR, state); // test reset jobStore.resetTriggerFromErrorState(trigger1.getKey()); state = jobStore.getTriggerState(trigger1.getKey()); assertEquals(TriggerState.NORMAL, state); }
Example #17
Source File: JobStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testTriggerStates() throws Exception { JobDetail jobDetail = JobBuilder.newJob(MyJob.class).withIdentity("job1", "jobGroup1").storeDurably(true).build(); this.jobStore.storeJob(jobDetail, false); OperableTrigger trigger = new SimpleTriggerImpl("trigger1", "triggerGroup1", jobDetail.getKey().getName(), jobDetail.getKey().getGroup(), new Date(System.currentTimeMillis() + 100000), new Date(System.currentTimeMillis() + 200000), 2, 2000); trigger.computeFirstFireTime(null); assertEquals(TriggerState.NONE, this.jobStore.getTriggerState(trigger.getKey())); this.jobStore.storeTrigger(trigger, false); assertEquals(TriggerState.NORMAL, this.jobStore.getTriggerState(trigger.getKey())); this.jobStore.pauseTrigger(trigger.getKey()); assertEquals(TriggerState.PAUSED, this.jobStore.getTriggerState(trigger.getKey())); this.jobStore.resumeTrigger(trigger.getKey()); assertEquals(TriggerState.NORMAL, this.jobStore.getTriggerState(trigger.getKey())); trigger = this.jobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).get(0); assertNotNull(trigger); this.jobStore.releaseAcquiredTrigger(trigger); trigger = this.jobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).get(0); assertNotNull(trigger); assertTrue(this.jobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).isEmpty()); }
Example #18
Source File: JobStoreImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override public TriggerState getTriggerState(final TriggerKey triggerKey) throws JobPersistenceException { return executeRead(db -> { TriggerEntity entity = triggerEntityAdapter.readByKey(db, triggerKey); if (entity == null) { return TriggerState.NONE; } // convert entity state to trigger state switch (entity.getState()) { case COMPLETE: return TriggerState.COMPLETE; case PAUSED: case PAUSED_BLOCKED: return TriggerState.PAUSED; case BLOCKED: return TriggerState.BLOCKED; case ERROR: return TriggerState.ERROR; default: return TriggerState.NORMAL; } }); }
Example #19
Source File: XxlJobDynamicScheduler.java From microservices-platform with Apache License 2.0 | 5 votes |
/** * fill job info * * @param jobInfo */ public static void fillJobInfo(XxlJobInfo jobInfo) { String group = String.valueOf(jobInfo.getJobGroup()); String name = String.valueOf(jobInfo.getId()); // trigger key TriggerKey triggerKey = TriggerKey.triggerKey(name, group); try { // trigger cron Trigger trigger = scheduler.getTrigger(triggerKey); if (trigger!=null && trigger instanceof CronTriggerImpl) { String cronExpression = ((CronTriggerImpl) trigger).getCronExpression(); jobInfo.setJobCron(cronExpression); } // trigger state TriggerState triggerState = scheduler.getTriggerState(triggerKey); if (triggerState!=null) { jobInfo.setJobStatus(triggerState.name()); } //JobKey jobKey = new JobKey(jobInfo.getJobName(), String.valueOf(jobInfo.getJobGroup())); //JobDetail jobDetail = scheduler.getJobDetail(jobKey); //String jobClass = jobDetail.getJobClass().getName(); } catch (SchedulerException e) { logger.error(e.getMessage(), e); } }
Example #20
Source File: SchedulerManager.java From SO with BSD 2-Clause "Simplified" License | 5 votes |
@Override public ResponseMessage pauseJobList() throws SchedulerException { ResponseMessage res = new ResponseMessage(); //Scheduler scheduler = new StdSchedulerFactory().getScheduler(); int count =0; log.debug(" ==============< executedJobList() > ======================"); for (String groupName : scheduler.getJobGroupNames()) { for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) { String jobName = jobKey.getName(); String jobGroup = jobKey.getGroup(); //get job's trigger @SuppressWarnings("unchecked") List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey); Trigger trigger = triggers.get(0); Date nextFireTime = trigger.getNextFireTime(); //[jobName] : PR-8ea4d232-6e0d-42cc-a7b1-7f1a1c03951c [groupName] : SoSchedulerGroup - Fri Sep 29 14:29:31 KST 2017 TriggerState triggerState = scheduler.getTriggerState(trigger.getKey()); if (triggerState.equals(TriggerState.NORMAL)) { //jobName으로 DB에서 Profile 정보 읽어오기 ProfileForDB profileForDB = profileDAO.retrieveProfile(jobName); if (profileForDB != null) { //profileList.add(profileForDB); scheduler.pauseJob(jobKey); count ++; log.debug(" === [jobName] : " + jobName + " [groupName] : " + jobGroup + " - " + nextFireTime + " = triggerState : " + triggerState.toString()); } } } } res.setMessage("Paused profile count= " + count); return res; }
Example #21
Source File: XxlJobDynamicScheduler.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
/** * fill job info * * @param jobInfo */ public static void fillJobInfo(XxlJobInfo jobInfo) { String group = String.valueOf(jobInfo.getJobGroup()); String name = String.valueOf(jobInfo.getId()); // trigger key TriggerKey triggerKey = TriggerKey.triggerKey(name, group); try { // trigger cron Trigger trigger = scheduler.getTrigger(triggerKey); if (trigger != null && trigger instanceof CronTriggerImpl) { String cronExpression = ((CronTriggerImpl) trigger).getCronExpression(); jobInfo.setJobCron(cronExpression); } // trigger state TriggerState triggerState = scheduler.getTriggerState(triggerKey); if (triggerState != null) { jobInfo.setJobStatus(triggerState.name()); } } catch (SchedulerException e) { logger.error(e.getMessage(), e); } }
Example #22
Source File: XxlJobDynamicScheduler.java From xmfcn-spring-cloud with Apache License 2.0 | 5 votes |
/** * fill job info * * @param jobInfo */ public static void fillJobInfo(XxlJobInfo jobInfo) { // TriggerKey : name + group String group = String.valueOf(jobInfo.getJobGroup()); String name = String.valueOf(jobInfo.getId()); TriggerKey triggerKey = TriggerKey.triggerKey(name, group); try { if(scheduler==null) { logger.error("scheduler 为空"); return; } Trigger trigger =scheduler.getTrigger(triggerKey); TriggerState triggerState = scheduler.getTriggerState(triggerKey); // parse params if (trigger!=null && trigger instanceof CronTriggerImpl) { String cronExpression = ((CronTriggerImpl) trigger).getCronExpression(); jobInfo.setJobCron(cronExpression); } //JobKey jobKey = new JobKey(jobInfo.getJobName(), String.valueOf(jobInfo.getJobGroup())); //JobDetail jobDetail = scheduler.getJobDetail(jobKey); //String jobClass = jobDetail.getJobClass().getName(); if (triggerState!=null) { jobInfo.setJobStatus(triggerState.name()); } } catch (SchedulerException e) { logger.error(e.getMessage(), e); } }
Example #23
Source File: RemoteScheduler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>. * </p> */ public TriggerState getTriggerState(TriggerKey triggerKey) throws SchedulerException { try { return getRemoteScheduler().getTriggerState(triggerKey); } catch (RemoteException re) { throw invalidateHandleCreateException( "Error communicating with remote scheduler.", re); } }
Example #24
Source File: JobStoreSupport.java From lams with GNU General Public License v2.0 | 5 votes |
public TriggerState getTriggerState(Connection conn, TriggerKey key) throws JobPersistenceException { try { String ts = getDelegate().selectTriggerState(conn, key); if (ts == null) { return TriggerState.NONE; } if (ts.equals(STATE_DELETED)) { return TriggerState.NONE; } if (ts.equals(STATE_COMPLETE)) { return TriggerState.COMPLETE; } if (ts.equals(STATE_PAUSED)) { return TriggerState.PAUSED; } if (ts.equals(STATE_PAUSED_BLOCKED)) { return TriggerState.PAUSED; } if (ts.equals(STATE_ERROR)) { return TriggerState.ERROR; } if (ts.equals(STATE_BLOCKED)) { return TriggerState.BLOCKED; } return TriggerState.NORMAL; } catch (SQLException e) { throw new JobPersistenceException( "Couldn't determine state of trigger (" + key + "): " + e.getMessage(), e); } }
Example #25
Source File: XxlJobDynamicScheduler.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
/** * fill job info * * @param jobInfo */ public static void fillJobInfo(XxlJobInfo jobInfo) { String group = String.valueOf(jobInfo.getJobGroup()); String name = String.valueOf(jobInfo.getId()); // trigger key TriggerKey triggerKey = TriggerKey.triggerKey(name, group); try { // trigger cron Trigger trigger = scheduler.getTrigger(triggerKey); if (trigger != null && trigger instanceof CronTriggerImpl) { String cronExpression = ((CronTriggerImpl) trigger).getCronExpression(); jobInfo.setJobCron(cronExpression); } // trigger state TriggerState triggerState = scheduler.getTriggerState(triggerKey); if (triggerState != null) { jobInfo.setJobStatus(triggerState.name()); } } catch (SchedulerException e) { logger.error(e.getMessage(), e); } }
Example #26
Source File: RemoteMBeanScheduler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>, * passing the <code>SchedulingContext</code> associated with this * instance. * </p> */ public TriggerState getTriggerState(TriggerKey triggerKey) throws SchedulerException { return TriggerState.valueOf((String)invoke( "getTriggerState", new Object[] { triggerKey.getName(), triggerKey.getGroup() }, new String[] { String.class.getName(), String.class.getName() })); }
Example #27
Source File: RAMJobStore.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Get the current state of the identified <code>{@link Trigger}</code>. * </p> * * @see TriggerState#NORMAL * @see TriggerState#PAUSED * @see TriggerState#COMPLETE * @see TriggerState#ERROR * @see TriggerState#BLOCKED * @see TriggerState#NONE */ public TriggerState getTriggerState(TriggerKey triggerKey) throws JobPersistenceException { synchronized(lock) { TriggerWrapper tw = triggersByKey.get(triggerKey); if (tw == null) { return TriggerState.NONE; } if (tw.state == TriggerWrapper.STATE_COMPLETE) { return TriggerState.COMPLETE; } if (tw.state == TriggerWrapper.STATE_PAUSED) { return TriggerState.PAUSED; } if (tw.state == TriggerWrapper.STATE_PAUSED_BLOCKED) { return TriggerState.PAUSED; } if (tw.state == TriggerWrapper.STATE_BLOCKED) { return TriggerState.BLOCKED; } if (tw.state == TriggerWrapper.STATE_ERROR) { return TriggerState.ERROR; } return TriggerState.NORMAL; } }
Example #28
Source File: JobServiceImpl.java From spring-boot-quartz-demo with MIT License | 5 votes |
/** * Get the current state of job */ public String getJobState(String jobName) { System.out.println("JobServiceImpl.getJobState()"); try { String groupKey = "SampleGroup"; JobKey jobKey = new JobKey(jobName, groupKey); Scheduler scheduler = schedulerFactoryBean.getScheduler(); JobDetail jobDetail = scheduler.getJobDetail(jobKey); List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobDetail.getKey()); if(triggers != null && triggers.size() > 0){ for (Trigger trigger : triggers) { TriggerState triggerState = scheduler.getTriggerState(trigger.getKey()); if (TriggerState.PAUSED.equals(triggerState)) { return "PAUSED"; }else if (TriggerState.BLOCKED.equals(triggerState)) { return "BLOCKED"; }else if (TriggerState.COMPLETE.equals(triggerState)) { return "COMPLETE"; }else if (TriggerState.ERROR.equals(triggerState)) { return "ERROR"; }else if (TriggerState.NONE.equals(triggerState)) { return "NONE"; }else if (TriggerState.NORMAL.equals(triggerState)) { return "SCHEDULED"; } } } } catch (SchedulerException e) { System.out.println("SchedulerException while checking job with name and group exist:"+e.getMessage()); e.printStackTrace(); } return null; }
Example #29
Source File: JobServiceImpl.java From fixflow with Apache License 2.0 | 5 votes |
/** * 根据枚举的触发器类型转成中文 * @return */ public String getTriggerStateByEmuType(TriggerState triggerState) { String type = ""; if(triggerState.toString().equals("BLOCKED")) { type = "锁定"; return type; } if(triggerState.toString().equals("COMPLETE")) { type = "完成"; return type; } if(triggerState.toString().equals("ERROR")) { type = "错误"; return type; } if(triggerState.toString().equals("NONE")) { type = "无"; return type; } if(triggerState.toString().equals("NORMAL")) { type = "普通"; return type; } if(triggerState.toString().equals("PAUSED")) { type = "暂停"; return type; } else { return type; } }
Example #30
Source File: ScheduleService.java From elasticsearch-quartz with Apache License 2.0 | 5 votes |
public TriggerState getTriggerState(final TriggerKey triggerKey) { try { return scheduler.getTriggerState(triggerKey); } catch (final SchedulerException e) { throw new QuartzSchedulerException(e); } }