Examples of ITaskConfig


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

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

    try {
      ITaskConfig populatedTaskConfig = SanitizedConfiguration.fromUnsanitized(
          IJobConfiguration.build(description)).getJobConfig().getTaskConfig();

      PopulateJobResult result = new PopulateJobResult()
          .setPopulatedDEPRECATED(ImmutableSet.of(populatedTaskConfig.newBuilder()))
          .setTaskConfig(populatedTaskConfig.newBuilder());

      return okResponse(Result.populateJobResult(result));
    } catch (TaskDescriptionException e) {
      return invalidResponse("Invalid configuration: " + e.getMessage());
    }
View Full Code Here

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

        Optional.fromNullable(Iterables.getOnlyElement(tasks, null))
            .transform(Tasks.SCHEDULED_TO_ASSIGNED);

    if (task.isPresent()) {
      if (task.get().getTask().newBuilder().equals(instanceRewrite.getOldTask())) {
        ITaskConfig newConfiguration = ITaskConfig.build(
            ConfigurationManager.applyDefaultsIfUnset(instanceRewrite.getRewrittenTask()));
        boolean changed = storeProvider.getUnsafeTaskStore().unsafeModifyInPlace(
            task.get().getTaskId(), newConfiguration);
        if (!changed) {
          error = Optional.of("Did not change " + task.get().getTaskId());
View Full Code Here

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

    requireNonNull(config);
    requireNonNull(session);
    checkNotBlank(config.getInstanceIds());
    final IJobKey jobKey = JobKeys.assertValid(IJobKey.build(config.getKey()));

    final ITaskConfig task;
    try {
      sessionValidator.checkAuthenticated(session, ImmutableSet.of(jobKey.getRole()));
      task = ConfigurationManager.validateAndPopulate(
          ITaskConfig.build(config.getTaskConfig()));
    } 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) {
        try {
          if (cronJobManager.hasJob(jobKey)) {
            return invalidResponse("Instances may not be added to cron jobs.");
          }

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

          ImmutableSet<IScheduledTask> currentTasks = storeProvider.getTaskStore().fetchTasks(
              Query.jobScoped(task.getJob()).active());

          validateTaskLimits(
              task,
              currentTasks.size() + config.getInstanceIdsSize(),
              quotaManager.checkInstanceAddition(task, config.getInstanceIdsSize()));
View Full Code Here

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

            final Query.Builder activeQuery = Query.jobScoped(key).active();
            Set<String> activeTasks =
                Tasks.ids(storeProvider.getTaskStore().fetchTasks(activeQuery));

            ITaskConfig task = cronJob.getSanitizedConfig().getJobConfig().getTaskConfig();
            Set<Integer> instanceIds = cronJob.getSanitizedConfig().getInstanceIds();
            if (activeTasks.isEmpty()) {
              stateManager.insertPendingTasks(storeProvider, task, instanceIds);

              return Optional.absent();
View Full Code Here

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

    });

    backfill();

    // Since task fields are backfilled with defaults, additional flags should be filled.
    ITaskConfig expected = ITaskConfig.build(new TaskConfig(storedTask)
        .setJob(JOB_KEY.newBuilder())
        .setProduction(false)
        .setMaxTaskFailures(1)
        .setExecutorConfig(EXECUTOR_CONFIG)
        .setConstraints(ImmutableSet.of(ConfigurationManager.hostLimitConstraint(1))));
View Full Code Here

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

  }

  @Test
  public void testRewriteShard() throws Exception {
    TaskConfig storedConfig = productionTask();
    ITaskConfig modifiedConfig = ITaskConfig.build(
        storedConfig.deepCopy().setExecutorConfig(new ExecutorConfig("aurora", "rewritten")));
    String taskId = "task_id";
    IScheduledTask storedTask = IScheduledTask.build(new ScheduledTask().setAssignedTask(
        new AssignedTask()
            .setTaskId(taskId)
            .setTask(storedConfig)));
    InstanceKey instanceKey = new InstanceKey(
        JobKeys.from(
            storedConfig.getOwner().getRole(),
            storedConfig.getEnvironment(),
            storedConfig.getJobName()).newBuilder(),
        0);

    expectAuth(ROOT, true);
    storageUtil.expectTaskFetch(
        Query.instanceScoped(IInstanceKey.build(instanceKey)).active(), storedTask);
    expect(storageUtil.taskStore.unsafeModifyInPlace(
        taskId,
        ITaskConfig.build(ConfigurationManager.applyDefaultsIfUnset(modifiedConfig.newBuilder()))))
        .andReturn(true);

    control.replay();

    RewriteConfigsRequest request = new RewriteConfigsRequest(
        ImmutableList.of(ConfigRewrite.instanceRewrite(
            new InstanceConfigRewrite(instanceKey, storedConfig, modifiedConfig.newBuilder()))));
    assertOkResponse(thrift.rewriteConfigs(request, SESSION));
  }
View Full Code Here

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

        .setKey(JOB_KEY.newBuilder());
  }

  @Test
  public void testAddInstances() throws Exception {
    ITaskConfig populatedTask = ITaskConfig.build(populatedTask());
    expectAuth(ROLE, true);
    expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
    lockManager.validateIfLocked(LOCK_KEY, Optional.of(LOCK));
    storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
    expect(taskIdGenerator.generate(populatedTask, 1))
        .andReturn(TASK_ID);
    expect(quotaManager.checkInstanceAddition(populatedTask, 1)).andReturn(ENOUGH_QUOTA);
    stateManager.insertPendingTasks(
        storageUtil.mutableStoreProvider,
        populatedTask,
        ImmutableSet.of(0));

    control.replay();

    // Validate key is populated during sanitizing.
    AddInstancesConfig config = createInstanceConfig(populatedTask.newBuilder());
    config.getTaskConfig().unsetJob();
    assertOkResponse(thrift.addInstances(config, LOCK.newBuilder(), SESSION));
  }
View Full Code Here

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

    assertOkResponse(thrift.addInstances(config, LOCK.newBuilder(), SESSION));
  }

  @Test
  public void testAddInstancesWithNullLock() throws Exception {
    ITaskConfig populatedTask = ITaskConfig.build(populatedTask());
    AddInstancesConfig config = createInstanceConfig(populatedTask.newBuilder());
    expectAuth(ROLE, true);
    expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
    lockManager.validateIfLocked(LOCK_KEY, Optional.<ILock>absent());
    storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
    expect(taskIdGenerator.generate(populatedTask, 1))
View Full Code Here

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

    assertResponse(LOCK_ERROR, thrift.addInstances(config, LOCK.newBuilder(), SESSION));
  }

  @Test
  public void testAddInstancesFailsTaskIdLength() throws Exception {
    ITaskConfig populatedTask = ITaskConfig.build(populatedTask());
    AddInstancesConfig config = createInstanceConfig(populatedTask.newBuilder());
    expectAuth(ROLE, true);
    expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
    lockManager.validateIfLocked(LOCK_KEY, Optional.of(LOCK));
    storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
    expect(quotaManager.checkInstanceAddition(anyObject(ITaskConfig.class), anyInt()))
View Full Code Here

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

    assertResponse(INVALID_REQUEST, thrift.addInstances(config, LOCK.newBuilder(), SESSION));
  }

  @Test
  public void testAddInstancesFailsQuotaCheck() throws Exception {
    ITaskConfig populatedTask = ITaskConfig.build(populatedTask());
    AddInstancesConfig config = createInstanceConfig(populatedTask.newBuilder());
    expectAuth(ROLE, true);
    expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
    lockManager.validateIfLocked(LOCK_KEY, Optional.of(LOCK));
    storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
    expect(taskIdGenerator.generate(populatedTask, 1))
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.