• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TriggerState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.quartz.Trigger.TriggerState的典型用法代码示例。如果您正苦于以下问题:Java TriggerState类的具体用法?Java TriggerState怎么用?Java TriggerState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TriggerState类属于org.quartz.Trigger包,在下文中一共展示了TriggerState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: triggerStateEN2CN

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
/**
 * 将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 "无";
    }
}
 
开发者ID:quartzweb,项目名称:quartz-web,代码行数:21,代码来源:QuartzUtils.java


示例2: quartzTriggerStateToTriggerStatus

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
private static TriggerStatus quartzTriggerStateToTriggerStatus(Trigger quartzTrigger, TriggerState quartzTriggerState) {
    if (quartzTrigger != null && quartzTrigger.getJobDataMap().containsKey(Constants.JOB_EXCEPTION)) {
        return TriggerStatus.ERROR;
    }

    if (quartzTriggerState == null) {
        return null;
    }

    switch (quartzTriggerState) {
        case PAUSED:
            return TriggerStatus.PAUSED;
        case COMPLETE:
            return TriggerStatus.COMPLETE;
        case ERROR:
            return TriggerStatus.ERROR;
        case NORMAL:
        case BLOCKED:
            return TriggerStatus.ACTIVE;
        default:
            return null;
    }
}
 
开发者ID:taboola,项目名称:taboola-cronyx,代码行数:24,代码来源:QuartzSchedulerServiceImpl.java


示例3: getAllJobs

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
/**
 * 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());
            jobs.add(new io.mangoo.models.Job(TriggerState.PAUSED == triggerState ? false : true, jobKey.getName(), trigger.getDescription(), trigger.getNextFireTime(), trigger.getPreviousFireTime()));
        }
    } catch (SchedulerException e) {
        throw new MangooSchedulerException(e);
    }
    
    return jobs;
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:25,代码来源:Scheduler.java


示例4: changeState

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:25,代码来源:Scheduler.java


示例5: testPauseJob

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testPauseJob() throws MangooSchedulerException, SchedulerException {
    //given
    JobKey jobKey = scheduler.getJobKey("jobs.InfoJob");
    
    //when
    scheduler.pauseJob("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.PAUSED));
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:17,代码来源:SchedulerTest.java


示例6: testResumeJob

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
@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));
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:17,代码来源:SchedulerTest.java


示例7: getTriggerState

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:RedisLabs,项目名称:redis-quartz,代码行数:27,代码来源:RedisJobStore.java


示例8: triggerStateToTaskState

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
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;
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:18,代码来源:AbstractQuartzTaskManager.java


示例9: testRemoveTrigger

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
@Test
public void testRemoveTrigger() throws ObjectAlreadyExistsException,
    JobPersistenceException {
  JobDetail storeJob = storeJob(buildJob("job"));
  Trigger trigger1 = buildTrigger(storeJob);
  TriggerKey triggerKey = trigger1.getKey();
  storeTrigger(trigger1);
  Trigger retrieveTrigger = retrieveTrigger(trigger1.getKey());
  assertThat(retrieveTrigger).isNotNull();
  boolean removeTrigger = jobStore.removeTrigger(triggerKey);
  assertThat(removeTrigger).isTrue();
  retrieveTrigger = retrieveTrigger(trigger1.getKey());
  assertThat(retrieveTrigger).isNull();
  removeTrigger = jobStore.removeTrigger(triggerKey);
  assertThat(removeTrigger).isFalse();

  TriggerState triggerState = jobStore.getTriggerState(triggerKey);
  assertThat(triggerState).isEqualTo(TriggerState.NONE);
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:20,代码来源:TestHazelcastJobStore.java


示例10: testResumeTrigger

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
@Test
public void testResumeTrigger() throws ObjectAlreadyExistsException,
    JobPersistenceException {
  Trigger trigger = buildTrigger();
  storeTrigger(trigger);
  TriggerKey triggerKey = trigger.getKey();
  TriggerState triggerState = jobStore.getTriggerState(triggerKey);
  assertThat(triggerState).isEqualTo(TriggerState.NORMAL);
  jobStore.pauseTrigger(triggerKey);
  triggerState = jobStore.getTriggerState(triggerKey);
  assertThat(triggerState).isEqualTo(TriggerState.PAUSED);

  jobStore.resumeTrigger(triggerKey);
  triggerState = jobStore.getTriggerState(triggerKey);
  assertThat(triggerState).isEqualTo(TriggerState.NORMAL);
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:17,代码来源:TestHazelcastJobStore.java


示例11: testResumeTriggerWithPausedJobs

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
@Test
public void testResumeTriggerWithPausedJobs()
    throws ObjectAlreadyExistsException, JobPersistenceException {
  JobDetail job1 = buildJob("job", "group3");
  storeJob(job1);
  Trigger trigger5 = buildTrigger(job1);
  storeTrigger(trigger5);

  assertThat(jobStore.getTriggerState(trigger5.getKey())).isEqualTo(
      TriggerState.NORMAL);
  jobStore.pauseJobs(GroupMatcher.jobGroupEquals("group3"));
  jobStore.resumeTriggers(GroupMatcher.triggerGroupEquals(trigger5.getKey()
      .getGroup()));
  assertThat(jobStore.getTriggerState(trigger5.getKey())).isEqualTo(
      TriggerState.PAUSED);
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:17,代码来源:TestHazelcastJobStore.java


示例12: testResumeJob

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
@Test
public void testResumeJob() throws ObjectAlreadyExistsException,
    JobPersistenceException {
  JobDetail jobDetail = buildAndStoreJob();
  Trigger trigger = buildTrigger(jobDetail);
  storeTrigger(trigger);
  TriggerState triggerState = jobStore.getTriggerState(trigger.getKey());
  assertThat(triggerState).isEqualTo(TriggerState.NORMAL);

  jobStore.pauseJob(jobDetail.getKey());

  triggerState = jobStore.getTriggerState(trigger.getKey());
  assertThat(triggerState).isEqualTo(TriggerState.PAUSED);

  jobStore.resumeJob(jobDetail.getKey());

  triggerState = jobStore.getTriggerState(trigger.getKey());
  assertThat(triggerState).isEqualTo(TriggerState.NORMAL);
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:20,代码来源:TestHazelcastJobStore.java


示例13: testPauseAll

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
@Test
public void testPauseAll() throws ObjectAlreadyExistsException,
    JobPersistenceException {
  Trigger trigger = buildAndStoreTrigger();
  Trigger trigger2 = buildTrigger("trigger2", "group2", buildAndStoreJob());
  storeTrigger(trigger2);
  assertThat(jobStore.getTriggerState(trigger.getKey())).isEqualTo(
      TriggerState.NORMAL);

  jobStore.pauseAll();

  assertThat(jobStore.getPausedTriggerGroups()).containsOnly(
      trigger.getKey().getGroup(), trigger2.getKey().getGroup());

  Trigger trigger3 = buildAndStoreTrigger();

  assertThat(jobStore.getTriggerState(trigger.getKey())).isEqualTo(
      TriggerState.PAUSED);
  assertThat(jobStore.getTriggerState(trigger2.getKey())).isEqualTo(
      TriggerState.PAUSED);
  assertThat(jobStore.getTriggerState(trigger3.getKey())).isEqualTo(
      TriggerState.PAUSED);
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:24,代码来源:TestHazelcastJobStore.java


示例14: getAllJobDetail

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
public List<TaskScheduled> getAllJobDetail() {
    List<TaskScheduled> result = new LinkedList<TaskScheduled>();
    try {
        GroupMatcher<JobKey> matcher = GroupMatcher.jobGroupContains("");
        Set<JobKey> jobKeys = scheduler.getJobKeys(matcher);
        for (JobKey jobKey : jobKeys) {
            JobDetail jobDetail = scheduler.getJobDetail(jobKey);
            List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
            for (Trigger trigger : triggers) {
                TaskScheduled job = new TaskScheduled();
                job.setTaskName(jobKey.getName());
                job.setTaskGroup(jobKey.getGroup());
                TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
                job.setStatus(triggerState.name());
                if (trigger instanceof CronTrigger) {
                    CronTrigger cronTrigger = (CronTrigger)trigger;
                    String cronExpression = cronTrigger.getCronExpression();
                    job.setTaskCron(cronExpression);
                }
                job.setPreviousFireTime(trigger.getPreviousFireTime());
                job.setNextFireTime(trigger.getNextFireTime());
                JobDataMap jobDataMap = trigger.getJobDataMap();
                job.setTaskType(jobDataMap.getString("taskType"));
                job.setTargetSystem(jobDataMap.getString("targetSystem"));
                job.setTargetObject(jobDataMap.getString("targetObject"));
                job.setTargetMethod(jobDataMap.getString("targetMethod"));
                job.setContactName(jobDataMap.getString("contactName"));
                job.setContactEmail(jobDataMap.getString("contactEmail"));
                job.setTaskDesc(jobDetail.getDescription());
                String jobClass = jobDetail.getJobClass().getSimpleName();
                if (jobClass.equals("StatefulJob")) {
                    job.setJobType("statefulJob");
                } else if (jobClass.equals("DefaultJob")) {
                    job.setJobType("job");
                }
                result.add(job);
            }
        }
    } catch (Exception e) {
        logger.error("Try to load All JobDetail cause error : ", e);
    }
    return result;
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:44,代码来源:SchedulerManager.java


示例15: getJobState

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:javabypatel,项目名称:spring-boot-quartz-demo,代码行数:40,代码来源:JobServiceImpl.java


示例16: getTriggerState

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
/**
 * <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;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:44,代码来源:RAMJobStore.java


示例17: getTriggerState

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
/**
 * <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() }));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:RemoteMBeanScheduler.java


示例18: getTriggerState

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:JobStoreSupport.java


示例19: getTriggerState

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
/**
 * <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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:RemoteScheduler.java


示例20: getTriggerState

import org.quartz.Trigger.TriggerState; //导入依赖的package包/类
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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:QuartzSchedulerMBeanImpl.java



注:本文中的org.quartz.Trigger.TriggerState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ChunkedInputStream类代码示例发布时间:2022-05-21
下一篇:
Java KeyIndexableGraph类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap