Package org.apache.aurora.gen

Examples of org.apache.aurora.gen.JobConfiguration


    if (job.getInstanceCount() <= 0) {
      throw new TaskDescriptionException("Shard count must be positive.");
    }

    JobConfiguration builder = job.newBuilder();

    assertOwnerValidity(job.getOwner());

    if (!JobKeys.isValid(job.getKey())) {
      throw new TaskDescriptionException("Job key " + job.getKey() + " is invalid.");
    }
    if (!job.getKey().getRole().equals(job.getOwner().getRole())) {
      throw new TaskDescriptionException("Role in job key must match job owner.");
    }
    if (!isGoodIdentifier(job.getKey().getRole())) {
      throw new TaskDescriptionException(
          "Job role contains illegal characters: " + job.getKey().getRole());
    }
    if (!isGoodIdentifier(job.getKey().getEnvironment())) {
      throw new TaskDescriptionException(
          "Job environment contains illegal characters: " + job.getKey().getEnvironment());
    }
    if (!isGoodIdentifier(job.getKey().getName())) {
      throw new TaskDescriptionException(
          "Job name contains illegal characters: " + job.getKey().getName());
    }

    builder.setTaskConfig(
        validateAndPopulate(ITaskConfig.build(builder.getTaskConfig())).newBuilder());

    // Only one of [service=true, cron_schedule] may be set.
    if (!StringUtils.isEmpty(job.getCronSchedule()) && builder.getTaskConfig().isIsService()) {
      throw new TaskDescriptionException(
          "A service task may not be run on a cron schedule: " + builder);
    }

    return IJobConfiguration.build(builder);
View Full Code Here


  private static SanitizedConfiguration makeJob(
      IJobKey jobKey,
      TaskConfig task,
      int numTasks) throws TaskDescriptionException  {

    JobConfiguration job = new JobConfiguration()
        .setOwner(makeIdentity(jobKey.newBuilder()))
        .setKey(jobKey.newBuilder())
        .setInstanceCount(numTasks)
        .setTaskConfig(new TaskConfig(task)
          .setOwner(makeIdentity(jobKey.newBuilder()))
View Full Code Here

    assertCreateAllowed(ImmutableMap.of("createJob", true));
  }

  @Test
  public void testFlaggedMethodDisabled() throws Exception {
    JobConfiguration job = new JobConfiguration();
    SessionKey session = new SessionKey();

    control.replay();

    Iface thrift = getIface(ImmutableMap.of("createJob", false));
View Full Code Here

    control.replay();
    getIface(ImmutableMap.of("notamethod", true));
  }

  private void assertCreateAllowed(Map<String, Boolean> toggledMethods) throws Exception {
    JobConfiguration job = new JobConfiguration();
    Response response = new Response();
    expect(mockThrift.createJob(job, null, SESSION_KEY)).andReturn(response);

    control.replay();
View Full Code Here

    }
  }

  @Test
  public void testApplyDefaultsIfUnsetUnsanitized() {
    JobConfiguration copy = UNSANITIZED_JOB_CONFIGURATION.deepCopy();

    ConfigurationManager.applyDefaultsIfUnset(copy);
    assertTrue(copy.isSetKey());
    assertEquals(DEFAULT_ENVIRONMENT, copy.getKey().getEnvironment());
  }
View Full Code Here

    }));
  }

  @Test
  public void testCreateJobFailsNoExecutorConfig() throws Exception {
    JobConfiguration job = makeJob();
    job.getTaskConfig().unsetExecutorConfig();
    expectAuth(ROLE, true);
    control.replay();

    Response response = thrift.createJob(job, LOCK.newBuilder(), SESSION);
    assertResponse(INVALID_REQUEST, response);
View Full Code Here

    assertMessageMatches(response, "Configuration may not be null");
  }

  @Test
  public void testCreateHomogeneousJobNoShards() throws Exception {
    JobConfiguration job = makeJob();
    job.setInstanceCount(0);
    job.unsetInstanceCount();
    expectAuth(ROLE, true);

    control.replay();

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

  }

  @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();
View Full Code Here

            "hostA",
            ImmutableSet.of(new Attribute("attr", ImmutableSet.of("value"))))));
    snapshot.setJobs(ImmutableSet.of(
        new StoredJob(
            "jobManager",
            new JobConfiguration().setKey(new JobKey("owner", "env", "jobA")))));
    snapshot.setQuotaConfigurations(
        ImmutableSet.of(new QuotaConfiguration("roleA", new ResourceAggregate(10, 1024, 1024))));
    snapshot.setSchedulerMetadata(new SchedulerMetadata().setFrameworkId("frameworkId"));
    snapshot.setTasks(ImmutableSet.of(new ScheduledTask()));
    return snapshot;
View Full Code Here

            new QuotaConfiguration("steve", ResourceAggregates.none().newBuilder()));
    IHostAttributes attribute = IHostAttributes.build(new HostAttributes("host",
        ImmutableSet.of(new Attribute("attr", ImmutableSet.of("value")))));
    StoredJob job = new StoredJob(
        "jobManager",
        new JobConfiguration().setKey(new JobKey("owner", "env", "name")));
    String frameworkId = "framework_id";
    ILock lock = ILock.build(new Lock()
        .setKey(LockKey.job(JobKeys.from("testRole", "testEnv", "testJob").newBuilder()))
        .setToken("lockId")
        .setUser("testUser")
View Full Code Here

TOP

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

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.