Package org.apache.aurora.scheduler.cron

Examples of org.apache.aurora.scheduler.cron.CronJobManager


  @Test
  public void testJobsAreScheduled() throws Exception {
    auroraCronJob.execute(isA(JobExecutionContext.class));

    control.replay();
    final CronJobManager cronJobManager = injector.getInstance(CronJobManager.class);
    final Scheduler scheduler = injector.getInstance(Scheduler.class);

    storage.write(new Storage.MutateWork.NoResult.Quiet() {
      @Override
      public void execute(Storage.MutableStoreProvider storeProvider) {
        storeProvider.getJobStore().saveAcceptedJob(
            cronJobManager.getManagerKey(),
            CRON_JOB);
      }
    });

    final CountDownLatch cronRan = new CountDownLatch(1);
View Full Code Here


  }

  @Test
  public void testKillExistingDogpiles() throws Exception {
    // Test that a trigger for a job that hasn't finished running is ignored.
    final CronJobManager cronJobManager = injector.getInstance(CronJobManager.class);

    final CountDownLatch firstExecutionTriggered = new CountDownLatch(1);
    final CountDownLatch firstExecutionCompleted = new CountDownLatch(1);
    final CountDownLatch secondExecutionTriggered = new CountDownLatch(1);
    final CountDownLatch secondExecutionCompleted = new CountDownLatch(1);

    auroraCronJob.execute(isA(JobExecutionContext.class));
    expectLastCall().andAnswer(new IAnswer<Void>() {
      @Override
      public Void answer() throws Throwable {
        firstExecutionTriggered.countDown();
        firstExecutionCompleted.await();
        return null;
      }
    });
    auroraCronJob.execute(isA(JobExecutionContext.class));
    expectLastCall().andAnswer(new IAnswer<Object>() {
      @Override
      public Void answer() throws Throwable {
        secondExecutionTriggered.countDown();
        secondExecutionCompleted.await();
        return null;
      }
    });

    control.replay();

    boot();

    cronJobManager.createJob(SanitizedCronJob.fromUnsanitized(CRON_JOB));
    cronJobManager.startJobNow(JOB_KEY);
    firstExecutionTriggered.await();
    cronJobManager.startJobNow(JOB_KEY);
    assertEquals(1, secondExecutionTriggered.getCount());
    firstExecutionCompleted.countDown();
    secondExecutionTriggered.await();
    secondExecutionTriggered.countDown();
  }
View Full Code Here

  @Before
  public void setUp() {
    storage = MemStorage.newEmptyStorage();
    stateManager = createMock(StateManager.class);
    CronJobManager cronJobManager = createMock(CronJobManager.class);
    backoffHelper = createMock(BackoffHelper.class);

    auroraCronJob = new AuroraCronJob(
        new AuroraCronJob.Config(backoffHelper), storage, stateManager, cronJobManager);
    expect(cronJobManager.getManagerKey()).andStubReturn(MANAGER_ID);
  }
View Full Code Here

  @Test
  public void testJobsAreScheduled() throws Exception {
    auroraCronJob.execute(isA(JobExecutionContext.class));

    control.replay();
    final CronJobManager cronJobManager = injector.getInstance(CronJobManager.class);
    final Scheduler scheduler = injector.getInstance(Scheduler.class);

    storage.write(new Storage.MutateWork.NoResult.Quiet() {
      @Override
      public void execute(Storage.MutableStoreProvider storeProvider) {
        storeProvider.getJobStore().saveAcceptedJob(
            cronJobManager.getManagerKey(),
            CRON_JOB);
      }
    });

    final CountDownLatch cronRan = new CountDownLatch(1);
View Full Code Here

  }

  @Test
  public void testKillExistingDogpiles() throws Exception {
    // Test that a trigger for a job that hasn't finished running is ignored.
    final CronJobManager cronJobManager = injector.getInstance(CronJobManager.class);

    final CountDownLatch firstExecutionTriggered = new CountDownLatch(1);
    final CountDownLatch firstExecutionCompleted = new CountDownLatch(1);
    final CountDownLatch secondExecutionTriggered = new CountDownLatch(1);
    final CountDownLatch secondExecutionCompleted = new CountDownLatch(1);

    auroraCronJob.execute(isA(JobExecutionContext.class));
    expectLastCall().andAnswer(new IAnswer<Void>() {
      @Override
      public Void answer() throws Throwable {
        firstExecutionTriggered.countDown();
        firstExecutionCompleted.await();
        return null;
      }
    });
    auroraCronJob.execute(isA(JobExecutionContext.class));
    expectLastCall().andAnswer(new IAnswer<Object>() {
      @Override
      public Void answer() throws Throwable {
        secondExecutionTriggered.countDown();
        secondExecutionCompleted.await();
        return null;
      }
    });

    control.replay();

    boot();

    cronJobManager.createJob(SanitizedCronJob.fromUnsanitized(CRON_JOB));
    cronJobManager.startJobNow(JOB_KEY);
    firstExecutionTriggered.await();
    cronJobManager.startJobNow(JOB_KEY);
    assertEquals(1, secondExecutionTriggered.getCount());
    firstExecutionCompleted.countDown();
    secondExecutionTriggered.await();
    secondExecutionTriggered.countDown();
  }
View Full Code Here

TOP

Related Classes of org.apache.aurora.scheduler.cron.CronJobManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.