Package org.apache.aurora.scheduler.storage.entities

Examples of org.apache.aurora.scheduler.storage.entities.IJobConfiguration


    this(SanitizedConfiguration.fromUnsanitized(unsanitized));
  }

  private SanitizedCronJob(SanitizedConfiguration config) throws CronException {
    final IJobConfiguration job = config.getJobConfig();
    if (!hasCronSchedule(job)) {
      throw new CronException(String.format(
          "Not a valid cron job, %s has no cron schedule", JobKeys.canonicalString(job.getKey())));
    }

    Optional<CrontabEntry> entry = CrontabEntry.tryParse(job.getCronSchedule());
    if (!entry.isPresent()) {
      throw new CronException("Invalid cron schedule: " + job.getCronSchedule());
    }

    this.config = config;
    this.crontabEntry = entry.get();
  }
View Full Code Here


    LOG.info(
        String.format("Deleted cron job %s from storage.", JobKeys.canonicalString(jobKey)));
  }

  private void saveJob(SanitizedCronJob cronJob, JobStore.Mutable jobStore) {
    IJobConfiguration config = cronJob.getSanitizedConfig().getJobConfig();

    jobStore.saveAcceptedJob(getManagerKey(), config);
    LOG.info(String.format(
        "Saved new cron job %s to storage.", JobKeys.canonicalString(config.getKey())));
  }
View Full Code Here

    scheduler.createJob(job);
  }

  @Test(expected = ScheduleException.class)
  public void testFilterFailRejectsAddInstances() throws Exception {
    IJobConfiguration job = makeJob(KEY_A, 1).getJobConfig();
    expect(quotaManager.checkQuota(anyObject(ITaskConfig.class), anyInt()))
        .andReturn(NOT_ENOUGH_QUOTA);

    control.replay();

    buildScheduler();
    scheduler.addInstances(job.getKey(), ImmutableSet.of(1), job.getTaskConfig());
  }
View Full Code Here

    scheduler.addInstances(job.getKey(), ImmutableSet.of(1), job.getTaskConfig());
  }

  @Test(expected = ScheduleException.class)
  public void testMaxJobCheckFailsForAddInstances() throws Exception {
    IJobConfiguration job = makeJob(KEY_A, 1).getJobConfig();

    control.replay();
    buildScheduler();

    scheduler.addInstances(
        job.getKey(),
        ContiguousSet.create(Range.closed(0, SchedulerCoreImpl.MAX_TASKS_PER_JOB.get()),
            DiscreteDomain.integers()),
        job.getTaskConfig());
  }
View Full Code Here

    }.run();
  }

  @Test
  public void testSaveAcceptedJob() throws Exception {
    final IJobConfiguration jobConfig =
        IJobConfiguration.build(new JobConfiguration().setKey(new JobKey("owner", "env", "jake")));
    final String managerId = "CRON";
    new MutationFixture() {
      @Override
      protected void setupExpectations() throws Exception {
        storageUtil.expectWriteOperation();
        storageUtil.jobStore.saveAcceptedJob(managerId, jobConfig);
        streamMatcher.expectTransaction(
            Op.saveAcceptedJob(new SaveAcceptedJob(managerId, jobConfig.newBuilder())))
            .andReturn(position);
      }

      @Override
      protected void performMutations(MutableStoreProvider storeProvider) {
View Full Code Here

    assertEquals(ImmutableSet.<IJobConfiguration>of(), store.fetchJobs(MANAGER_2));
  }

  @Test
  public void testJobStoreSameEnvironment() {
    IJobConfiguration templateConfig = makeJob("labrat");
    JobConfiguration prodBuilder = templateConfig.newBuilder();
    prodBuilder.getKey().setEnvironment("prod");
    IJobConfiguration prod = IJobConfiguration.build(prodBuilder);
    JobConfiguration stagingBuilder = templateConfig.newBuilder();
    stagingBuilder.getKey().setEnvironment("staging");
    IJobConfiguration staging = IJobConfiguration.build(stagingBuilder);

    store.saveAcceptedJob(MANAGER_1, prod);
    store.saveAcceptedJob(MANAGER_1, staging);

    assertNull(store.fetchJob(
        MANAGER_1,
        IJobKey.build(templateConfig.getKey().newBuilder().setEnvironment("test"))).orNull());
    assertEquals(prod, store.fetchJob(MANAGER_1, prod.getKey()).orNull());
    assertEquals(staging, store.fetchJob(MANAGER_1, staging.getKey()).orNull());

    store.removeJob(prod.getKey());
    assertNull(store.fetchJob(MANAGER_1, prod.getKey()).orNull());
    assertEquals(staging, store.fetchJob(MANAGER_1, staging.getKey()).orNull());
  }
View Full Code Here

    return response;
  }

  @Test
  public void testPopulateJobConfig() throws Exception {
    IJobConfiguration job = IJobConfiguration.build(makeJob());
    control.replay();

    assertOkResponse(thrift.populateJobConfig(job.newBuilder()));
  }
View Full Code Here

    assertOkResponse(thrift.populateJobConfig(job.newBuilder()));
  }

  @Test
  public void testCreateJobNoLock() throws Exception {
    IJobConfiguration job = IJobConfiguration.build(makeJob());
    expectAuth(ROLE, true);
    scheduler.createJob(SanitizedConfiguration.fromUnsanitized(job));
    lockManager.validateIfLocked(LOCK_KEY, Optional.<ILock>absent());

    control.replay();

    assertOkResponse(thrift.createJob(job.newBuilder(), DEFAULT_LOCK, SESSION));
  }
View Full Code Here

    assertOkResponse(thrift.createJob(job.newBuilder(), DEFAULT_LOCK, SESSION));
  }

  @Test
  public void testCreateJobWithLock() throws Exception {
    IJobConfiguration job = IJobConfiguration.build(makeJob());
    expectAuth(ROLE, true);
    scheduler.createJob(SanitizedConfiguration.fromUnsanitized(job));
    lockManager.validateIfLocked(LOCK_KEY, Optional.of(LOCK));

    control.replay();

    assertOkResponse(thrift.createJob(job.newBuilder(), LOCK.newBuilder(), SESSION));
  }
View Full Code Here

    assertOkResponse(thrift.createJob(job.newBuilder(), LOCK.newBuilder(), SESSION));
  }

  @Test
  public void testCreateJobWithLockFails() throws Exception {
    IJobConfiguration job = IJobConfiguration.build(makeJob());
    expectAuth(ROLE, true);
    lockManager.validateIfLocked(LOCK_KEY, Optional.of(LOCK));
    expectLastCall().andThrow(new LockException("Invalid lock"));

    control.replay();

    assertResponse(LOCK_ERROR, thrift.createJob(job.newBuilder(), LOCK.newBuilder(), SESSION));
  }
View Full Code Here

TOP

Related Classes of org.apache.aurora.scheduler.storage.entities.IJobConfiguration

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.