当前位置: 首页>>代码示例>>Java>>正文


Java ObjectAlreadyExistsException类代码示例

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


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

示例1: triggerJob

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
/**
 * <p>
 * Trigger the identified <code>{@link org.quartz.Job}</code> (execute it
 * now) - with a non-volatile trigger.
 * </p>
 */
@SuppressWarnings("deprecation")
public void triggerJob(JobKey jobKey, JobDataMap data) throws SchedulerException {
    validateState();

    OperableTrigger trig = (OperableTrigger) newTrigger().withIdentity(newTriggerId(), Scheduler.DEFAULT_GROUP).forJob(jobKey).build();
    trig.computeFirstFireTime(null);
    if(data != null) {
        trig.setJobDataMap(data);
    }

    boolean collision = true;
    while (collision) {
        try {
            resources.getJobStore().storeTrigger(trig, false);
            collision = false;
        } catch (ObjectAlreadyExistsException oaee) {
            trig.setKey(new TriggerKey(newTriggerId(), Scheduler.DEFAULT_GROUP));
        }
    }

    notifySchedulerThread(trig.getNextFireTime().getTime());
    notifySchedulerListenersSchduled(trig);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:QuartzScheduler.java

示例2: triggerJob

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
/**
 * <p>
 * Trigger the identified <code>{@link org.quartz.Job}</code> (execute it
 * now) - with a non-volatile trigger.
 * </p>
 */
public void triggerJob(SchedulingContext ctxt, String jobName,
        String groupName, JobDataMap data) throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    Trigger trig = new org.quartz.SimpleTrigger(newTriggerId(),
            Scheduler.DEFAULT_MANUAL_TRIGGERS, jobName, groupName,
            new Date(), null, 0, 0);
    trig.setVolatility(false);
    trig.computeFirstFireTime(null);
    if(data != null) {
        trig.setJobDataMap(data);
    }

    boolean collision = true;
    while (collision) {
        try {
            resources.getJobStore().storeTrigger(ctxt, trig, false);
            collision = false;
        } catch (ObjectAlreadyExistsException oaee) {
            trig.setName(newTriggerId());
        }
    }

    notifySchedulerThread(trig.getNextFireTime().getTime());
    notifySchedulerListenersSchduled(trig);
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:37,代码来源:QuartzScheduler.java

示例3: triggerJobWithVolatileTrigger

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
/**
 * <p>
 * Trigger the identified <code>{@link org.quartz.Job}</code> (execute it
 * now) - with a volatile trigger.
 * </p>
 */
public void triggerJobWithVolatileTrigger(SchedulingContext ctxt,
        String jobName, String groupName, JobDataMap data) throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    Trigger trig = new org.quartz.SimpleTrigger(newTriggerId(),
            Scheduler.DEFAULT_MANUAL_TRIGGERS, jobName, groupName,
            new Date(), null, 0, 0);
    trig.setVolatility(true);
    trig.computeFirstFireTime(null);
    if(data != null) {
        trig.setJobDataMap(data);
    }
    
    boolean collision = true;
    while (collision) {
        try {
            resources.getJobStore().storeTrigger(ctxt, trig, false);
            collision = false;
        } catch (ObjectAlreadyExistsException oaee) {
            trig.setName(newTriggerId());
        }
    }

    notifySchedulerThread(trig.getNextFireTime().getTime());
    notifySchedulerListenersSchduled(trig);
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:37,代码来源:QuartzScheduler.java

示例4: scheduleJob

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
private void scheduleJob(final JobDetail jobDetail, final Trigger trigger) throws SchedulerException {
    final boolean triggerExists = (this.scheduler.getTrigger(trigger.getKey()) != null);

    this.scheduler.addJob(jobDetail, true);

    if (triggerExists) {
        this.scheduler.rescheduleJob(trigger.getKey(), trigger);

    } else {
        try {
            this.scheduler.scheduleJob(trigger);

        } catch (ObjectAlreadyExistsException ex) {
            LOG.debug("Unexpectedly found existing trigger, assumably due to cluster race condition: " +
                    ex.getMessage() + " - can safely be ignored");

            this.scheduler.rescheduleJob(trigger.getKey(), trigger);
        }
    }
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:21,代码来源:QuartzScheduledJobRegistrar.java

示例5: storeJob

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
private void storeJob(final ODatabaseDocumentTx db, final JobDetail jobDetail, final boolean replaceExisting)
    throws JobPersistenceException
{
  log.debug("Store job: jobDetail={}, replaceExisting={}", jobDetail, replaceExisting);

  JobDetailEntity entity = jobDetailEntityAdapter.readByKey(db, jobDetail.getKey());
  if (entity == null) {
    // no existing entity, add new one
    entity = new JobDetailEntity(jobDetail);
    jobDetailEntityAdapter.addEntity(db, entity);
  }
  else {
    // otherwise entity exists, maybe replace if allowed
    if (replaceExisting) {
      entity.setValue(jobDetail);
      jobDetailEntityAdapter.editEntity(db, entity);
    }
    else {
      throw new ObjectAlreadyExistsException(jobDetail);
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:23,代码来源:JobStoreImpl.java

示例6: storeJob

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
@Override
public void storeJob(final JobDetail job, boolean replaceExisting)
  throws ObjectAlreadyExistsException, JobPersistenceException {

  final JobDetail newJob = (JobDetail) job.clone();
  final JobKey newJobKey = newJob.getKey();

  if (jobsByKey.containsKey(newJobKey) && !replaceExisting) {
    throw new ObjectAlreadyExistsException(newJob);
  }

  jobsByKey.lock(newJobKey, 5, TimeUnit.SECONDS);
  try {
    jobsByKey.set(newJobKey, newJob);
    jobsByGroup.put(newJobKey.getGroup(), newJobKey);
  } finally {
    try {
      jobsByKey.unlock(newJobKey);
    } catch (IllegalMonitorStateException ex) {
      LOG.warn("Error unlocking since it is already released.", ex);
    }
  }
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:24,代码来源:HazelcastJobStore.java

示例7: testStoreTriggerReplacesTrigger

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

  JobDetail job = buildJob("replacesTrigJob99", "replacesTrigJobGroup");
  jobStore.storeJob(job, false);

  OperableTrigger tr = buildTrigger("stReplacesTrigger1", "stReplacesTriggerGroup", job, new Date().getTime());
  tr.setCalendarName(null);

  jobStore.storeTrigger(tr, false);
  assertEquals(jobStore.retrieveTrigger(tr.getKey()), tr);

  try {
    jobStore.storeTrigger(tr, false);
    fail("an attempt to store duplicate trigger succeeded");
  } catch (ObjectAlreadyExistsException ex) {
    // expected
  }

  tr.setCalendarName("QQ");
  jobStore.storeTrigger(tr, true);
  assertEquals(jobStore.retrieveTrigger(tr.getKey()), tr);
  assertEquals(jobStore.retrieveTrigger(tr.getKey()).getCalendarName(), "QQ", "StoreJob doesn't replace triggers");
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:26,代码来源:HazelcastJobStoreTest.java

示例8: testRemoveTrigger

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
@Test
public void testRemoveTrigger()
  throws ObjectAlreadyExistsException,
  JobPersistenceException {

  JobDetail storeJob = storeJob(buildJob("job"));
  OperableTrigger trigger1 = buildTrigger(storeJob);
  TriggerKey triggerKey = trigger1.getKey();
  jobStore.storeTrigger(trigger1, false);
  OperableTrigger retrieveTrigger = retrieveTrigger(trigger1.getKey());
  assertNotNull(retrieveTrigger);
  boolean removeTrigger = jobStore.removeTrigger(triggerKey);
  assertTrue(removeTrigger);
  retrieveTrigger = retrieveTrigger(trigger1.getKey());
  assertNull(retrieveTrigger);
  removeTrigger = jobStore.removeTrigger(triggerKey);
  assertFalse(removeTrigger);

  Trigger.TriggerState triggerState = jobStore.getTriggerState(triggerKey);
  assertEquals(triggerState, Trigger.TriggerState.NONE);
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:22,代码来源:HazelcastJobStoreTest.java

示例9: testTriggerCheckExists

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
@Test
public void testTriggerCheckExists()
  throws ObjectAlreadyExistsException,
  JobPersistenceException {

  OperableTrigger trigger1 = buildTrigger();
  TriggerKey triggerKey = trigger1.getKey();

  boolean checkExists = jobStore.checkExists(triggerKey);
  assertFalse(checkExists);

  jobStore.storeTrigger(trigger1, false);

  checkExists = jobStore.checkExists(triggerKey);
  assertTrue(checkExists);
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:17,代码来源:HazelcastJobStoreTest.java

示例10: testReplaceTrigger

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
@Test
public void testReplaceTrigger()
  throws ObjectAlreadyExistsException,
  JobPersistenceException {

  OperableTrigger trigger1 = buildTrigger();

  jobStore.storeTrigger(trigger1, false);

  OperableTrigger newTrigger = buildTrigger();

  TriggerKey triggerKey = trigger1.getKey();
  boolean replaceTrigger = jobStore.replaceTrigger(triggerKey, (OperableTrigger) newTrigger);
  assertTrue(replaceTrigger);
  OperableTrigger retrieveTrigger = jobStore.retrieveTrigger(triggerKey);
  assertEquals(retrieveTrigger, newTrigger);
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:18,代码来源:HazelcastJobStoreTest.java

示例11: testRemoveCalendar

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
@Test
public void testRemoveCalendar()
  throws ObjectAlreadyExistsException,
  JobPersistenceException {

  String calName = "calendar1";
  storeCalendar(calName);

  Calendar retrieveCalendar = jobStore.retrieveCalendar(calName);
  assertNotNull(retrieveCalendar);
  boolean calendarExisted = jobStore.removeCalendar(calName);
  assertTrue(calendarExisted);
  retrieveCalendar = jobStore.retrieveCalendar(calName);
  assertNull(retrieveCalendar);
  calendarExisted = jobStore.removeCalendar(calName);
  assertFalse(calendarExisted);

}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:19,代码来源:HazelcastJobStoreTest.java

示例12: testGetJobGroupNames

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
@Test
public void testGetJobGroupNames()
  throws ObjectAlreadyExistsException,
  JobPersistenceException {

  JobDetail buildJob = buildJob("job40", "group1");
  storeJob(buildJob);
  storeJob(buildJob("job41", "group2"));
  List<String> jobGroupNames = jobStore.getJobGroupNames();
  assertEquals(jobGroupNames.size(), 2);
  assertTrue(jobGroupNames.contains("group1"));
  assertTrue(jobGroupNames.contains("group2"));

  jobStore.removeJob(buildJob.getKey());

  jobGroupNames = jobStore.getJobGroupNames();
  assertEquals(jobGroupNames.size(), 1);
  assertTrue(jobGroupNames.contains("group2"));
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:20,代码来源:HazelcastJobStoreTest.java

示例13: testResumeTrigger

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
@Test
public void testResumeTrigger()
  throws ObjectAlreadyExistsException,
  JobPersistenceException {

  OperableTrigger trigger = buildTrigger();
  jobStore.storeTrigger(trigger, false);
  TriggerKey triggerKey = trigger.getKey();
  Trigger.TriggerState triggerState = jobStore.getTriggerState(triggerKey);
  assertEquals(triggerState, Trigger.TriggerState.NORMAL);
  jobStore.pauseTrigger(triggerKey);
  triggerState = jobStore.getTriggerState(triggerKey);
  assertEquals(triggerState, Trigger.TriggerState.PAUSED);

  jobStore.resumeTrigger(triggerKey);
  triggerState = jobStore.getTriggerState(triggerKey);
  assertEquals(triggerState, Trigger.TriggerState.NORMAL);
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:19,代码来源:HazelcastJobStoreTest.java

示例14: testPauseJob

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
@Test
public void testPauseJob()
  throws ObjectAlreadyExistsException,
  JobPersistenceException {

  JobDetail jobDetail = buildAndStoreJob();
  OperableTrigger trigger = buildTrigger(jobDetail);
  jobStore.storeTrigger(trigger, false);
  Trigger.TriggerState triggerState = jobStore.getTriggerState(trigger.getKey());
  assertEquals(triggerState, Trigger.TriggerState.NORMAL);

  jobStore.pauseJob(jobDetail.getKey());

  triggerState = jobStore.getTriggerState(trigger.getKey());
  assertEquals(triggerState, Trigger.TriggerState.PAUSED);
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:17,代码来源:HazelcastJobStoreTest.java

示例15: testResumeJob

import org.quartz.ObjectAlreadyExistsException; //导入依赖的package包/类
@Test
public void testResumeJob()
  throws ObjectAlreadyExistsException,
  JobPersistenceException {

  JobDetail jobDetail = buildAndStoreJob();
  OperableTrigger trigger = buildTrigger(jobDetail);
  jobStore.storeTrigger(trigger, false);

  Trigger.TriggerState triggerState = jobStore.getTriggerState(trigger.getKey());
  assertEquals(triggerState, Trigger.TriggerState.NORMAL);

  jobStore.pauseJob(jobDetail.getKey());

  triggerState = jobStore.getTriggerState(trigger.getKey());
  assertEquals(triggerState, Trigger.TriggerState.PAUSED);

  jobStore.resumeJob(jobDetail.getKey());

  triggerState = jobStore.getTriggerState(trigger.getKey());
  assertEquals(triggerState, Trigger.TriggerState.NORMAL);
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:23,代码来源:HazelcastJobStoreTest.java


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