Examples of SanitizedConfiguration


Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

    int numTasks = 10;

    control.replay();
    buildScheduler();

    SanitizedConfiguration job = makeJob(KEY_A, numTasks);
    scheduler.createJob(job);
    assertTaskCount(numTasks);

    Set<IScheduledTask> tasks = Storage.Util.consistentFetchTasks(storage, Query.jobScoped(KEY_A));
    assertEquals(numTasks, tasks.size());
    for (IScheduledTask state : tasks) {
      assertEquals(PENDING, state.getStatus());
      assertTrue(state.getAssignedTask().isSetTaskId());
      assertFalse(state.getAssignedTask().isSetSlaveId());
      assertEquals(
          validateAndPopulate(job.getJobConfig()).getTaskConfig(),
          state.getAssignedTask().getTask());
    }
    Set<Integer> expectedInstanceIds =
        ContiguousSet.create(Range.closedOpen(0, numTasks), DiscreteDomain.integers());
    assertEquals(
View Full Code Here

Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

    // TODO(ksweeney): Deprecate this as part of AURORA-423.

    control.replay();
    buildScheduler();

    SanitizedConfiguration job = SanitizedConfiguration.fromUnsanitized(
        IJobConfiguration.build(makeJob(KEY_A, 1).getJobConfig().newBuilder().setCronSchedule("")));
    scheduler.createJob(job);
    assertTaskCount(1);
  }
View Full Code Here

Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

    scheduler.createJob(makeJob(KEY_A, 1));
  }

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

    control.replay();
View Full Code Here

Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

  @Test
  public void testCreateHomogeneousJob() throws Exception {
    JobConfiguration job = makeJob();
    job.setInstanceCount(2);
    expectAuth(ROLE, true);
    SanitizedConfiguration sanitized =
        SanitizedConfiguration.fromUnsanitized(IJobConfiguration.build(job));
    lockManager.validateIfLocked(LOCK_KEY, Optional.<ILock>absent());
    assertEquals(2, sanitized.getTaskConfigs().size());
    scheduler.createJob(sanitized);
    control.replay();

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

Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

            ConfigurationManager.hostLimitConstraint(1),
            ConfigurationManager.rackLimitConstraint(1)))
        .setMaxTaskFailures(1)
        .setEnvironment(DEFAULT_ENVIRONMENT);

    scheduler.createJob(new SanitizedConfiguration(IJobConfiguration.build(sanitized)));
    lockManager.validateIfLocked(LOCK_KEY, Optional.<ILock>absent());

    control.replay();

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

Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

  @Test
  public void testShardUniquenessCorrection() throws Exception {

    final AtomicInteger taskId = new AtomicInteger();

    SanitizedConfiguration job = makeJob(JOB_KEY, defaultTask(), 10);
    final Set<IScheduledTask> badTasks = ImmutableSet.copyOf(Iterables.transform(
        job.getTaskConfigs().values(),
        new Function<ITaskConfig, IScheduledTask>() {
          @Override
          public IScheduledTask apply(ITaskConfig task) {
            return IScheduledTask.build(new ScheduledTask()
                .setStatus(RUNNING)
View Full Code Here

Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

    } catch (AuthFailedException e) {
      return addMessage(response, AUTH_FAILED, e);
    }

    try {
      SanitizedConfiguration sanitized = SanitizedConfiguration.fromUnsanitized(job);

      lockManager.validateIfLocked(
          ILockKey.build(LockKey.job(jobKey.newBuilder())),
          Optional.fromNullable(mutableLock).transform(ILock.FROM_BUILDER));
View Full Code Here

Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

    } catch (AuthFailedException e) {
      return addMessage(response, AUTH_FAILED, e);
    }

    try {
      SanitizedConfiguration sanitized = SanitizedConfiguration.fromUnsanitized(job);

      lockManager.validateIfLocked(
          ILockKey.build(LockKey.job(jobKey.newBuilder())),
          Optional.fromNullable(mutableLock).transform(ILock.FROM_BUILDER));

      if (!sanitized.isCron()) {
        LOG.info("Invalid attempt to schedule non-cron job "
            + sanitized.getJobConfig().getKey()
            + " with cron.");
        response.setResponseCode(INVALID_REQUEST);
        return addMessage(
            response,
            "Job " + sanitized.getJobConfig().getKey() + " has no cron schedule");
      }
      try {
        // TODO(mchucarroll): Merge CronJobManager.createJob/updateJob
        if (cronJobManager.hasJob(sanitized.getJobConfig().getKey())) {
          // The job already has a schedule: so update it.
          cronJobManager.updateJob(SanitizedCronJob.from(sanitized));
        } else {
          cronJobManager.createJob(SanitizedCronJob.from(sanitized));
        }
View Full Code Here

Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

  public Response populateJobConfig(JobConfiguration description) {
    requireNonNull(description);

    Response response = Util.emptyResponse();
    try {
      SanitizedConfiguration sanitized =
          SanitizedConfiguration.fromUnsanitized(IJobConfiguration.build(description));

      PopulateJobResult result = new PopulateJobResult()
          .setPopulated(ITaskConfig.toBuildersSet(sanitized.getTaskConfigs().values()));

      response.setResult(Result.populateJobResult(result));
      response.setResponseCode(OK);
    } catch (TaskDescriptionException e) {
      addMessage(response, INVALID_REQUEST, "Invalid configuration: " + e.getMessage());
View Full Code Here

Examples of org.apache.aurora.scheduler.configuration.SanitizedConfiguration

      @Nullable final Lock mutableLock,
      SessionKey session) {

    requireNonNull(session);

    final SanitizedConfiguration sanitized;
    try {
      sessionValidator.checkAuthenticated(
          session,
          ImmutableSet.of(mutableJob.getKey().getRole()));
      sanitized = SanitizedConfiguration.fromUnsanitized(IJobConfiguration.build(mutableJob));
    } catch (AuthFailedException e) {
      return errorResponse(AUTH_FAILED, e);
    } catch (TaskDescriptionException e) {
      return errorResponse(INVALID_REQUEST, e);
    }

    return storage.write(new MutateWork.Quiet<Response>() {
      @Override
      public Response apply(MutableStoreProvider storeProvider) {
        final IJobConfiguration job = sanitized.getJobConfig();

        try {
          lockManager.validateIfLocked(
              ILockKey.build(LockKey.job(job.getKey().newBuilder())),
              Optional.fromNullable(mutableLock).transform(ILock.FROM_BUILDER));

          if (!storeProvider.getTaskStore().fetchTasks(
              Query.jobScoped(job.getKey()).active()).isEmpty()
              || cronJobManager.hasJob(job.getKey())) {

            return invalidResponse("Job already exists: " + JobKeys.canonicalString(job.getKey()));
          }

          ITaskConfig template = sanitized.getJobConfig().getTaskConfig();
          int count = sanitized.getJobConfig().getInstanceCount();

          validateTaskLimits(template, count, quotaManager.checkInstanceAddition(template, count));

          // TODO(mchucarroll): deprecate cron as a part of create/kill job.(AURORA-454)
          if (sanitized.isCron()) {
            LOG.warning("Deprecated behavior: scheduling job " + job.getKey()
                + " with cron via createJob (AURORA_454)");
            cronJobManager.createJob(SanitizedCronJob.from(sanitized));
          } else {
            LOG.info("Launching " + count + " tasks.");
            stateManager.insertPendingTasks(
                storeProvider,
                template,
                sanitized.getInstanceIds());
          }
          return okEmptyResponse();
        } catch (LockException e) {
          return errorResponse(LOCK_ERROR, e);
        } catch (CronException | TaskValidationException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.