Package org.apache.aurora.gen

Examples of org.apache.aurora.gen.TaskConfig


   * @throws TaskDescriptionException If the task is invalid.
   */
  public static ITaskConfig validateAndPopulate(ITaskConfig config)
      throws TaskDescriptionException {

    TaskConfig builder = config.newBuilder();

    if (!builder.isSetRequestedPorts()) {
      builder.setRequestedPorts(ImmutableSet.<String>of());
    }

    maybeFillLinks(builder);

    if (!isGoodIdentifier(config.getJobName())) {
      throw new TaskDescriptionException(
          "Job name contains illegal characters: " + config.getJobName());
    }

    if (!isGoodIdentifier(config.getEnvironment())) {
      throw new TaskDescriptionException(
          "Environment contains illegal characters: " + config.getEnvironment());
    }

    if (config.isSetJob()) {
      if (!JobKeys.isValid(config.getJob())) {
        // Job key is set but invalid
        throw new TaskDescriptionException("Job key " + config.getJob() + " is invalid.");
      }

      if (!config.getJob().getRole().equals(config.getOwner().getRole())) {
        // Both owner and job key are set but don't match
        throw new TaskDescriptionException("Role must match job owner.");
      }
    } else {
      // TODO(maxim): Make sure both key and owner are populated to support older clients.
      // Remove in 0.7.0. (AURORA-749).
      // Job key is not set -> populate from owner, environment and name
      assertOwnerValidity(config.getOwner());
      builder.setJob(JobKeys.from(
          config.getOwner().getRole(),
          config.getEnvironment(),
          config.getJobName()).newBuilder());
    }

    if (!builder.isSetExecutorConfig()) {
      throw new TaskDescriptionException("Configuration may not be null");
    }

    // Maximize the usefulness of any thrown error message by checking required fields first.
    for (RequiredFieldValidator<?> validator : REQUIRED_FIELDS_VALIDATORS) {
View Full Code Here


  private IScheduledTask makeTask(String job, ScheduleStatus status, String host) {
    ScheduledTask task = new ScheduledTask()
        .setStatus(status)
        .setAssignedTask(new AssignedTask()
            .setTaskId(TASK_ID)
            .setTask(new TaskConfig()
                .setJob(new JobKey(ROLE_A, ENV, job))
                .setJobName(job)
                .setEnvironment(ENV)
                .setOwner(new Identity(ROLE_A, ROLE_A + "-user"))));
    if (Tasks.SLAVE_ASSIGNED_STATES.contains(status) || Tasks.isTerminated(status)) {
View Full Code Here

    ScheduledTask scheduledTask = new ScheduledTask()
        .setStatus(status)
        .setTaskEvents(ImmutableList.of(new TaskEvent(100, status)))
        .setAssignedTask(new AssignedTask()
            .setTaskId(id)
            .setTask(new TaskConfig()
                .setJob(new JobKey("role-" + id, "test", "job-" + id))
                .setJobName("job-" + id)
                .setEnvironment("test")
                .setExecutorConfig(new org.apache.aurora.gen.ExecutorConfig("AuroraExecutor", ""))
                .setOwner(new Identity("role-" + id, "user-" + id))));
View Full Code Here

        .setTaskEvents(ITaskEvent.toBuildersList(taskEvents))
        .setAssignedTask(new AssignedTask()
            .setTaskId("task_Id")
            .setSlaveHost("host")
            .setInstanceId(instanceId)
            .setTask(new TaskConfig()
                .setJob(new JobKey("role", "env", "job"))
                .setJobName("job")
                .setIsService(true)
                .setProduction(isProd)
                .setEnvironment("env")
View Full Code Here

    clock = new FakeClock();
  }

  @Test
  public void testRewriteSandboxDeleted() throws Exception {
    final TaskConfig storedTask = defaultTask();
    final TaskEvent expectedEvent = new TaskEvent(100, FINISHED);

    storage.write(new Storage.MutateWork.NoResult.Quiet() {
      @Override
      protected void execute(Storage.MutableStoreProvider storeProvider) {
View Full Code Here

        getTask(TASK_ID).getTaskEvents());
  }

  @Test
  public void testLoadTasksFromStorage() throws Exception {
    final TaskConfig storedTask = defaultTask();

    storage.write(new Storage.MutateWork.NoResult.Quiet() {
      @Override
      protected void execute(Storage.MutableStoreProvider storeProvider) {
        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(
            IScheduledTask.build(new ScheduledTask()
                .setStatus(PENDING)
                .setTaskEvents(ImmutableList.of(new TaskEvent(100, PENDING)))
                .setAssignedTask(new AssignedTask()
                    .setTaskId(TASK_ID)
                    .setInstanceId(0)
                    .setTask(storedTask)))));
      }
    });

    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

  @Test
  public void testShardUniquenessCorrection() throws Exception {
    final AtomicInteger taskId = new AtomicInteger();

    final TaskConfig task = defaultTask();
    SanitizedConfiguration job = makeJob(JOB_KEY, task, 10);
    final Set<IScheduledTask> badTasks = ImmutableSet.copyOf(Iterables.transform(
        job.getInstanceIds(),
        new Function<Integer, IScheduledTask>() {
          @Override
View Full Code Here

    assertEquals(expected.getJobConfig(), actual);
  }

  @Test
  public void testBackfillTaskJob() throws Exception {
    TaskConfig task = defaultTask();
    ConfigurationManager.applyDefaultsIfUnset(task);
    task.unsetJob();

    IScheduledTask noJobKey = IScheduledTask.build(new ScheduledTask()
        .setStatus(RUNNING)
        .setAssignedTask(new AssignedTask()
            .setInstanceId(0)
            .setTaskId("nojobkey")
            .setTask(task)));
    IScheduledTask nullJobKeyFields = IScheduledTask.build(new ScheduledTask()
        .setStatus(RUNNING)
        .setAssignedTask(new AssignedTask()
            .setInstanceId(1)
            .setTaskId("nulled_fields")
            .setTask(task.setJob(new JobKey()))));

    final Set<IScheduledTask> backfilledTasks = ImmutableSet.of(noJobKey, nullJobKeyFields);
    storage.write(new Storage.MutateWork.NoResult.Quiet() {
      @Override
      protected void execute(Storage.MutableStoreProvider storeProvider) {
View Full Code Here

  private static JobConfiguration makeJobConfig(IJobKey jobKey, TaskConfig task, int numTasks) {
    return new JobConfiguration()
        .setOwner(OWNER)
        .setKey(jobKey.newBuilder())
        .setInstanceCount(numTasks)
        .setTaskConfig(new TaskConfig(task)
            .setOwner(OWNER)
            .setEnvironment(jobKey.getEnvironment())
            .setJobName(jobKey.getName()));
  }
View Full Code Here

    return SanitizedConfiguration.fromUnsanitized(
        IJobConfiguration.build(makeJobConfig(jobKey, task, numTasks)));
  }

  private static TaskConfig defaultTask() {
    return new TaskConfig()
        .setOwner(OWNER)
        .setJobName(JOB_NAME)
        .setEnvironment(ENV)
        .setNumCpus(1.0)
        .setRamMb(ONE_GB)
View Full Code Here

TOP

Related Classes of org.apache.aurora.gen.TaskConfig

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.