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

Java TriggerFiredResult类代码示例

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

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



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

示例1: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void triggersFired() throws Exception {
    // store some jobs with triggers
    Map<JobDetail, Set<? extends Trigger>> jobsAndTriggers = getJobsAndTriggers(2, 2, 2, 2, "* * * * * ?");
    jobStore.storeCalendar("testCalendar", new WeeklyCalendar(), false, true);
    jobStore.storeJobsAndTriggers(jobsAndTriggers, false);

    List<OperableTrigger> acquiredTriggers = jobStore.acquireNextTriggers(System.currentTimeMillis() - 1000, 500, 4000);
    assertThat(acquiredTriggers, hasSize(16));

    // ensure that all triggers are in the NORMAL state and have been ACQUIRED
    for (Map.Entry<JobDetail, Set<? extends Trigger>> jobDetailSetEntry : jobsAndTriggers.entrySet()) {
        for (Trigger trigger : jobDetailSetEntry.getValue()) {
            assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger.getKey()));
            String triggerHashKey = schema.triggerHashKey(trigger.getKey());
            assertThat(jedis.zscore(schema.triggerStateKey(RedisTriggerState.ACQUIRED), triggerHashKey), not(nullValue()));
        }
    }

    Set<? extends OperableTrigger> triggers = (Set<? extends  OperableTrigger>) new ArrayList<>(jobsAndTriggers.entrySet()).get(0).getValue();
    List<TriggerFiredResult> triggerFiredResults = jobStore.triggersFired(new ArrayList<>(triggers));
    assertThat(triggerFiredResults, hasSize(4));
}
 
开发者ID:jlinn,项目名称:quartz-redis-jobstore,代码行数:25,代码来源:StoreTriggerTest.java


示例2: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
@Override
public List<TriggerFiredResult> triggersFired(List<OperableTrigger> triggers) throws JobPersistenceException {
    if (logger.isInfoEnabled()) {
        logger.info("Triggers fired " + triggers.size());
        logger.trace(triggers);
    }

    List<CouchDbTrigger> couchdbTriggers = fetchCouchDbTriggers(triggers);
    Map<String, Calendar> triggerCalendars = fetchCalendars(triggers);
    Map<JobKey, JobDetail> jobDetailMap = fetchJobDetails(triggers);

    List<TriggerFiredResult> firedResults = new ArrayList<TriggerFiredResult>();
    List<CouchDbTrigger> firedTriggers = triggerStore.triggersFired(couchdbTriggers, triggerCalendars);
    for (CouchDbTrigger firedTrigger : firedTriggers) {

        Date prevFireTime = find(couchdbTriggers, firedTrigger.getKey()).getPreviousFireTime();
        Calendar calendar = triggerCalendars.get(firedTrigger.getCalendarName());
        JobDetail job = jobDetailMap.get(firedTrigger.getJobKey());

        TriggerFiredBundle triggerFiredBundle = buildTriggerFiredBundle(firedTrigger, prevFireTime, calendar, job);
        firedResults.add(new TriggerFiredResult(triggerFiredBundle));
    }
    return firedResults;
}
 
开发者ID:motech,项目名称:quartz-couchdb-store,代码行数:25,代码来源:CouchDbStore.java


示例3: shouldFireTriggers

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
@Test
public void shouldFireTriggers() throws JobPersistenceException {
    final String triggerName = id("fuuid1");
    SimpleTriggerImpl trigger = (SimpleTriggerImpl) newTrigger()
            .withIdentity(triggerName, "borgroup1")
            .forJob(JobKey.jobKey("fooid", "bargroup"))
            .startAt(new Date(2010 - 1900, 10, 20))
            .withSchedule(simpleSchedule()
                    .withIntervalInMinutes(2)
                    .repeatForever())
            .build();
    trigger.computeFirstFireTime(null);
    couchdbStore.storeTrigger(trigger, false);

    List<TriggerFiredResult> firedResults = couchdbStore.triggersFired(Arrays.<OperableTrigger>asList(trigger));

    assertEquals(1, firedResults.size());
    assertEquals(TriggerKey.triggerKey(triggerName, "borgroup1"), firedResults.get(0).getTriggerFiredBundle().getTrigger().getKey());
}
 
开发者ID:motech,项目名称:quartz-couchdb-store,代码行数:20,代码来源:CouchDbTriggerStoreIT.java


示例4: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
@Override
public List<TriggerFiredResult> triggersFired(List<OperableTrigger> triggers) throws JobPersistenceException {
  try {
    return realJobStore.triggersFired(triggers);
  } catch (RejoinException e) {
    throw new JobPersistenceException("Trigger fire marking failed due to client rejoin", e);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AbstractTerracottaJobStore.java


示例5: testTriggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
@Test
public void testTriggersFired()
  throws Exception {

  long baseFireTime = DateBuilder.newDate().build().getTime();

  JobDetail newJob = JobBuilder.newJob(NoOpJob.class).withIdentity("job1", "testTriggersFired").build();

  jobStore.storeJob(newJob, false);

  OperableTrigger trigger1 = buildAndComputeTrigger("triggerFired1",
      "triggerFiredGroup",
      newJob,
      baseFireTime + 100,
      baseFireTime + 100);

  jobStore.storeTrigger(trigger1, false);

  long firstFireTime = new Date(trigger1.getNextFireTime().getTime()).getTime();

  List<OperableTrigger> acquiredTriggers = jobStore.acquireNextTriggers(firstFireTime + 500, 1, 0L);
  assertEquals(acquiredTriggers.size(), 1);

  List<TriggerFiredResult> triggerFired = jobStore.triggersFired(acquiredTriggers);
  assertEquals(triggerFired.size(), 1);

  assertTrue(jobStore.checkExists(trigger1.getKey()));
  assertEquals(jobStore.getTriggerState(trigger1.getKey()), Trigger.TriggerState.COMPLETE);
  jobStore.removeTrigger(trigger1.getKey());
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:31,代码来源:HazelcastJobStoreTest.java


示例6: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
@Override
public List<TriggerFiredResult> triggersFired(final List<OperableTrigger> triggers) throws JobPersistenceException {
  return clusteredJobStore.triggersFired(triggers);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:PlainTerracottaJobStore.java


示例7: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
/**
 * <p>
 * Inform the <code>JobStore</code> that the scheduler is now firing the
 * given <code>Trigger</code> (executing its associated <code>Job</code>),
 * that it had previously acquired (reserved).
 * </p>
 */
public List<TriggerFiredResult> triggersFired(List<OperableTrigger> firedTriggers) {

    synchronized (lock) {
        List<TriggerFiredResult> results = new ArrayList<TriggerFiredResult>();

        for (OperableTrigger trigger : firedTriggers) {
            TriggerWrapper tw = triggersByKey.get(trigger.getKey());
            // was the trigger deleted since being acquired?
            if (tw == null || tw.trigger == null) {
                continue;
            }
            // was the trigger completed, paused, blocked, etc. since being acquired?
            if (tw.state != TriggerWrapper.STATE_ACQUIRED) {
                continue;
            }

            Calendar cal = null;
            if (tw.trigger.getCalendarName() != null) {
                cal = retrieveCalendar(tw.trigger.getCalendarName());
                if(cal == null)
                    continue;
            }
            Date prevFireTime = trigger.getPreviousFireTime();
            // in case trigger was replaced between acquiring and firing
            timeTriggers.remove(tw);
            // call triggered on our copy, and the scheduler's copy
            tw.trigger.triggered(cal);
            trigger.triggered(cal);
            //tw.state = TriggerWrapper.STATE_EXECUTING;
            tw.state = TriggerWrapper.STATE_WAITING;

            TriggerFiredBundle bndle = new TriggerFiredBundle(retrieveJob(
                    tw.jobKey), trigger, cal,
                    false, new Date(), trigger.getPreviousFireTime(), prevFireTime,
                    trigger.getNextFireTime());

            JobDetail job = bndle.getJobDetail();

            if (job.isConcurrentExectionDisallowed()) {
                ArrayList<TriggerWrapper> trigs = getTriggerWrappersForJob(job.getKey());
                for (TriggerWrapper ttw : trigs) {
                    if (ttw.state == TriggerWrapper.STATE_WAITING) {
                        ttw.state = TriggerWrapper.STATE_BLOCKED;
                    }
                    if (ttw.state == TriggerWrapper.STATE_PAUSED) {
                        ttw.state = TriggerWrapper.STATE_PAUSED_BLOCKED;
                    }
                    timeTriggers.remove(ttw);
                }
                blockedJobs.add(job.getKey());
            } else if (tw.trigger.getNextFireTime() != null) {
                synchronized (lock) {
                    timeTriggers.add(tw);
                }
            }

            results.add(new TriggerFiredResult(bndle));
        }
        return results;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:69,代码来源:RAMJobStore.java


示例8: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
/**
 * Inform the <code>JobStore</code> that the scheduler is now firing the
 * given <code>Trigger</code> (executing its associated <code>Job</code>),
 * that it had previously acquired (reserved).
 *
 * @param triggers a list of triggers
 * @param jedis    a thread-safe Redis connection
 * @return may return null if all the triggers or their calendars no longer exist, or
 * if the trigger was not successfully put into the 'executing'
 * state.  Preference is to return an empty list if none of the triggers
 * could be fired.
 */
@Override
public List<TriggerFiredResult> triggersFired(List<OperableTrigger> triggers, JedisCluster jedis) throws JobPersistenceException, ClassNotFoundException {
    List<TriggerFiredResult> results = new ArrayList<>();
    for (OperableTrigger trigger : triggers) {
        final String triggerHashKey = redisSchema.triggerHashKey(trigger.getKey());
        logger.debug(String.format("Trigger %s fired.", triggerHashKey));
        Boolean triggerExistsResponse = jedis.exists(triggerHashKey);
        Double triggerAcquiredResponse = jedis.zscore(redisSchema.triggerStateKey(RedisTriggerState.ACQUIRED), triggerHashKey);
        if (!triggerExistsResponse || triggerAcquiredResponse == null) {
            // the trigger does not exist or the trigger is not acquired
            if (!triggerExistsResponse) {
                logger.debug(String.format("Trigger %s does not exist.", triggerHashKey));
            } else {
                logger.debug(String.format("Trigger %s was not acquired.", triggerHashKey));
            }
            continue;
        }
        Calendar calendar = null;
        final String calendarName = trigger.getCalendarName();
        if (calendarName != null) {
            calendar = retrieveCalendar(calendarName, jedis);
            if (calendar == null) {
                continue;
            }
        }

        final Date previousFireTime = trigger.getPreviousFireTime();
        trigger.triggered(calendar);

        JobDetail job = retrieveJob(trigger.getJobKey(), jedis);
        TriggerFiredBundle triggerFiredBundle = new TriggerFiredBundle(job, trigger, calendar, false, new Date(), previousFireTime, previousFireTime, trigger.getNextFireTime());

        // handling jobs for which concurrent execution is disallowed
        if (isJobConcurrentExecutionDisallowed(job.getJobClass())) {
            final String jobHashKey = redisSchema.jobHashKey(trigger.getJobKey());
            final String jobTriggerSetKey = redisSchema.jobTriggersSetKey(job.getKey());
            for (String nonConcurrentTriggerHashKey : jedis.smembers(jobTriggerSetKey)) {
                Double score = jedis.zscore(redisSchema.triggerStateKey(RedisTriggerState.WAITING), nonConcurrentTriggerHashKey);
                if (score != null) {
                    setTriggerState(RedisTriggerState.BLOCKED, score, nonConcurrentTriggerHashKey, jedis);
                } else {
                    score = jedis.zscore(redisSchema.triggerStateKey(RedisTriggerState.PAUSED), nonConcurrentTriggerHashKey);
                    if (score != null) {
                        setTriggerState(RedisTriggerState.PAUSED_BLOCKED, score, nonConcurrentTriggerHashKey, jedis);
                    }
                }
            }
            jedis.set(redisSchema.jobBlockedKey(job.getKey()), schedulerInstanceId);
            jedis.sadd(redisSchema.blockedJobsSet(), jobHashKey);
        }

        // release the fired trigger
        if (trigger.getNextFireTime() != null) {
            final long nextFireTime = trigger.getNextFireTime().getTime();
            jedis.hset(triggerHashKey, TRIGGER_NEXT_FIRE_TIME, Long.toString(nextFireTime));
            logger.debug(String.format("Releasing trigger %s with next fire time %s. Setting state to WAITING.", triggerHashKey, nextFireTime));
            setTriggerState(RedisTriggerState.WAITING, (double) nextFireTime, triggerHashKey, jedis);
        } else {
            jedis.hset(triggerHashKey, TRIGGER_NEXT_FIRE_TIME, "");
            unsetTriggerState(triggerHashKey, jedis);
        }

        results.add(new TriggerFiredResult(triggerFiredBundle));
    }
    return results;
}
 
开发者ID:jlinn,项目名称:quartz-redis-jobstore,代码行数:79,代码来源:RedisClusterStorage.java


示例9: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
@Override
public List<TriggerFiredResult> triggersFired(List<OperableTrigger> triggers)
		throws JobPersistenceException {
     List<TriggerFiredResult> results = new ArrayList<>();
     try (Jedis jedis = pool.getResource()) {
        lockPool.acquire();
		
		for (OperableTrigger trigger : triggers) {
			String triggerHashKey = createTriggerHashKey(trigger.getKey().getGroup(), trigger.getKey().getName());
			log.debug("trigger: " + triggerHashKey + " fired");
			
			if (!jedis.exists(triggerHashKey))
				continue; // the trigger does not exist
			
			if (jedis.zscore(RedisTriggerState.ACQUIRED.getKey(), triggerHashKey) == null)
				continue; // the trigger is not acquired

           Calendar cal = null;
			if (trigger.getCalendarName() != null) {
              String calendarName = trigger.getCalendarName();
				cal = retrieveCalendar(calendarName, jedis);
                   if(cal == null)
                       continue;
               }
               
               Date prevFireTime = trigger.getPreviousFireTime();
               trigger.triggered(cal);

               TriggerFiredBundle bundle = new TriggerFiredBundle(retrieveJob(trigger.getJobKey(), jedis), trigger, cal, false, new Date(), trigger.getPreviousFireTime(), prevFireTime, trigger.getNextFireTime());
               
               // handling job concurrent execution disallowed
               String jobHashKey = createJobHashKey(trigger.getJobKey().getGroup(), trigger.getJobKey().getName());
               if (isJobConcurrentExectionDisallowed(jedis.hget(jobHashKey, JOB_CLASS))) {
               	String jobTriggerSetKey = createJobTriggersSetKey(trigger.getJobKey().getGroup(), trigger.getJobKey().getName());
               	Set<String> nonConcurrentTriggerHashKeys = jedis.smembers(jobTriggerSetKey);
               	for (String nonConcurrentTriggerHashKey : nonConcurrentTriggerHashKeys) {
               		Double score = jedis.zscore(RedisTriggerState.WAITING.getKey(), nonConcurrentTriggerHashKey);
               		if (score != null) {
               			setTriggerState(RedisTriggerState.BLOCKED, score, nonConcurrentTriggerHashKey);
               		} else {
               			score = jedis.zscore(RedisTriggerState.PAUSED.getKey(), nonConcurrentTriggerHashKey);
               			if (score != null)
               				setTriggerState(RedisTriggerState.PAUSED_BLOCKED, score, nonConcurrentTriggerHashKey);
               		}                			
               	}
               	
               	jedis.hset(jobHashKey, BLOCKED_BY, instanceId);
               	jedis.hset(jobHashKey, BLOCK_TIME, Long.toString(System.currentTimeMillis()));
               	jedis.sadd(BLOCKED_JOBS_SET, jobHashKey);
               }
               
               // releasing the fired trigger
       		if (trigger.getNextFireTime() != null) {
       			jedis.hset(triggerHashKey, NEXT_FIRE_TIME, Long.toString(trigger.getNextFireTime().getTime()));
       			setTriggerState(RedisTriggerState.WAITING, (double)trigger.getNextFireTime().getTime(), triggerHashKey);
       		} else {
       			jedis.hset(triggerHashKey, NEXT_FIRE_TIME, "");
       			unsetTriggerState(triggerHashKey);
       		}
               
               results.add(new TriggerFiredResult(bundle));			
		}
     } catch (JobPersistenceException | ClassNotFoundException | InterruptedException ex) {
		log.error("could not acquire next triggers", ex);
		throw new JobPersistenceException(ex.getMessage(), ex.getCause());
	} finally {
        lockPool.release();
	}
	return results;		
}
 
开发者ID:RedisLabs,项目名称:redis-quartz,代码行数:71,代码来源:RedisJobStore.java


示例10: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
@Override
public List<TriggerFiredResult> triggersFired(
    List<OperableTrigger> firedTriggers) throws JobPersistenceException {
  List<TriggerFiredResult> results = new ArrayList<>();

  for (OperableTrigger trigger : firedTriggers) {
    TriggerWrapper tw = triggersByKey.get(trigger.getKey());
    // was the trigger deleted since being acquired?
    if (tw == null || tw.trigger == null) {
      continue;
    }
    // was the trigger completed, paused, blocked, etc. since being acquired?
    if (tw.getState() != ACQUIRED) {
      continue;
    }

    Calendar cal = null;
    if (tw.trigger.getCalendarName() != null) {
      cal = retrieveCalendar(tw.trigger.getCalendarName());
      if (cal == null) {
        continue;
      }
    }
    Date prevFireTime = trigger.getPreviousFireTime();
    // call triggered on our copy, and the scheduler's copy
    tw.trigger.triggered(cal);
    trigger.triggered(cal);
    // tw.state = TriggerWrapper.STATE_EXECUTING;

    TriggerFiredBundle bndle = new TriggerFiredBundle(retrieveJob(tw.jobKey),
        trigger, cal, false, new Date(), trigger.getPreviousFireTime(),
        prevFireTime, trigger.getNextFireTime());

    JobDetail job = bndle.getJobDetail();

    if (job.isConcurrentExectionDisallowed()) {
      ArrayList<TriggerWrapper> trigs = getTriggerWrappersForJob(job.getKey());
      for (TriggerWrapper ttw : trigs) {
        if (ttw.getState() == WAITING) {
          ttw = newTriggerWrapper(ttw, BLOCKED);
        }
        if (ttw.getState() == PAUSED) {
          ttw = newTriggerWrapper(ttw, BLOCKED);
        }
      }
    }

    results.add(new TriggerFiredResult(bndle));
  }
  return results;
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:52,代码来源:HazelcastJobStore.java


示例11: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
@Override
public List<TriggerFiredResult> triggersFired(List<OperableTrigger> operableTriggers) throws JobPersistenceException {
    return null;  //To change body of implemented methods use File | Settings | File Templates.
}
 
开发者ID:mdaley,项目名称:quartz-dynamodb,代码行数:5,代码来源:DynamoDbJobStore.java


示例12: triggersFired

import org.quartz.spi.TriggerFiredResult; //导入依赖的package包/类
/**
 * Inform the <code>JobStore</code> that the scheduler is now firing the
 * given <code>Trigger</code> (executing its associated <code>Job</code>),
 * that it had previously acquired (reserved).
 * @param triggers a list of triggers
 * @param jedis a thread-safe Redis connection
 * @return may return null if all the triggers or their calendars no longer exist, or
 * if the trigger was not successfully put into the 'executing'
 * state.  Preference is to return an empty list if none of the triggers
 * could be fired.
 */
public abstract List<TriggerFiredResult> triggersFired(List<OperableTrigger> triggers, T jedis) throws JobPersistenceException, ClassNotFoundException;
 
开发者ID:jlinn,项目名称:quartz-redis-jobstore,代码行数:13,代码来源:AbstractRedisStorage.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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