コード例 #1
0
  @Test
  public void testIndexRebuilds() throws Exception {
    IOHelper.deleteFile(schedulerStoreDir);

    JobSchedulerStoreImpl schedulerStore = createScheduler();
    broker = createBroker(schedulerStore);
    broker.start();
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
    Connection connection = cf.createConnection();
    connection.start();
    for (int i = 0; i < NUM_JOBS; ++i) {
      scheduleRepeating(connection);
    }
    connection.close();

    JobScheduler scheduler = schedulerStore.getJobScheduler("JMS");
    assertNotNull(scheduler);
    assertEquals(NUM_JOBS, scheduler.getAllJobs().size());

    broker.stop();

    IOHelper.delete(new File(schedulerStoreDir, "scheduleDB.data"));

    schedulerStore = createScheduler();
    broker = createBroker(schedulerStore);
    broker.start();

    scheduler = schedulerStore.getJobScheduler("JMS");
    assertNotNull(scheduler);
    assertEquals(NUM_JOBS, scheduler.getAllJobs().size());
  }
コード例 #2
0
  @Test
  public void testIndexRebuildsAfterSomeJobsExpire() throws Exception {
    IOHelper.deleteFile(schedulerStoreDir);

    JobSchedulerStoreImpl schedulerStore = createScheduler();
    broker = createBroker(schedulerStore);
    broker.start();
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
    Connection connection = cf.createConnection();
    connection.start();
    for (int i = 0; i < NUM_JOBS; ++i) {
      scheduleRepeating(connection);
      scheduleOneShot(connection);
    }
    connection.close();

    JobScheduler scheduler = schedulerStore.getJobScheduler("JMS");
    assertNotNull(scheduler);
    assertEquals(NUM_JOBS * 2, scheduler.getAllJobs().size());

    final JobScheduler awaitingOneShotTimeout = scheduler;
    assertTrue(
        "One shot jobs should time out",
        Wait.waitFor(
            new Wait.Condition() {

              @Override
              public boolean isSatisified() throws Exception {
                return awaitingOneShotTimeout.getAllJobs().size() == NUM_JOBS;
              }
            },
            TimeUnit.MINUTES.toMillis(2)));

    broker.stop();

    IOHelper.delete(new File(schedulerStoreDir, "scheduleDB.data"));

    schedulerStore = createScheduler();
    broker = createBroker(schedulerStore);
    broker.start();

    scheduler = schedulerStore.getJobScheduler("JMS");
    assertNotNull(scheduler);
    assertEquals(NUM_JOBS, scheduler.getAllJobs().size());
  }
コード例 #3
0
 protected JobSchedulerStoreImpl createScheduler() {
   JobSchedulerStoreImpl scheduler = new JobSchedulerStoreImpl();
   scheduler.setDirectory(schedulerStoreDir);
   scheduler.setJournalMaxFileLength(10 * 1024);
   return scheduler;
 }