Package org.apache.aurora.gen

Examples of org.apache.aurora.gen.ScheduledTask


    maintenance = injector.getInstance(MaintenanceController.class);
    eventSink = PubsubTestUtil.startPubsub(injector);
  }

  private static ScheduledTask makeTask(String host, String taskId) {
    return new ScheduledTask()
        .setStatus(RUNNING)
        .setAssignedTask(
            new AssignedTask()
                .setSlaveHost(host)
                .setTaskId(taskId)
View Full Code Here


                        .setOwner(new Identity().setRole("role").setUser("role"))));
  }

  @Test
  public void testMaintenanceCycle() {
    ScheduledTask task = makeTask(HOST_A, "taskA");

    expectMaintenanceModeChange(HOST_A, SCHEDULED);
    expectFetchTasksByHost(HOST_A, ImmutableSet.of(task));
    expect(stateManager.changeState(
        Tasks.id(task),
        Optional.<ScheduleStatus>absent(),
        ScheduleStatus.DRAINING,
        MaintenanceControllerImpl.DRAINING_MESSAGE))
        .andReturn(true);
    expectMaintenanceModeChange(HOST_A, DRAINING);
    expect(storageUtil.attributeStore.getHostAttributes(HOST_A)).andReturn(Optional.of(
        IHostAttributes.build(new HostAttributes().setHost(HOST_A).setMode(DRAINING))));
    // TaskA is FINISHED and therefore no longer active
    expectFetchTasksByHost(HOST_A, ImmutableSet.<ScheduledTask>of());
    expectMaintenanceModeChange(HOST_A, DRAINED);
    expectMaintenanceModeChange(HOST_A, NONE);

    control.replay();

    assertStatus(HOST_A, SCHEDULED, maintenance.startMaintenance(A));
    assertStatus(HOST_A, DRAINING, maintenance.drain(A));
    eventSink.post(
        TaskStateChange.transition(IScheduledTask.build(task.setStatus(FINISHED)), RUNNING));
    assertStatus(HOST_A, NONE, maintenance.endMaintenance(A));
  }
View Full Code Here

  }

  @Test
  public void testPreempted() throws Exception {
    schedulingFilter = createMock(SchedulingFilter.class);
    ScheduledTask lowPriority = makeTask(USER_A, JOB_A, TASK_ID_A);
    runOnHost(lowPriority, HOST_A);

    ScheduledTask highPriority = makeTask(USER_A, JOB_A, TASK_ID_B, 100);
    clock.advance(PREEMPTION_DELAY);

    expectNoOffers();

    expectGetPendingTasks(highPriority);
View Full Code Here

  }

  @Test
  public void testLowestPriorityPreempted() throws Exception {
    schedulingFilter = createMock(SchedulingFilter.class);
    ScheduledTask lowPriority = makeTask(USER_A, JOB_A, TASK_ID_A, 10);
    runOnHost(lowPriority, HOST_A);

    ScheduledTask lowerPriority = makeTask(USER_A, JOB_A, TASK_ID_B, 1);
    runOnHost(lowerPriority, HOST_A);

    ScheduledTask highPriority = makeTask(USER_A, JOB_A, TASK_ID_C, 100);
    clock.advance(PREEMPTION_DELAY);

    expectNoOffers();

    expectGetPendingTasks(highPriority);
View Full Code Here

    assertNearest();
  }

  private IScheduledTask makeTask() {
    return IScheduledTask.build(
        new ScheduledTask().setAssignedTask(new AssignedTask().setTaskId(TASK)));
  }
View Full Code Here

  }

  @Test
  public void testOnePreemptableTask() throws Exception {
    schedulingFilter = createMock(SchedulingFilter.class);
    ScheduledTask highPriority = makeTask(USER_A, JOB_A, TASK_ID_A, 100);
    runOnHost(highPriority, HOST_A);

    ScheduledTask lowerPriority = makeTask(USER_A, JOB_A, TASK_ID_B, 99);
    runOnHost(lowerPriority, HOST_A);

    ScheduledTask lowestPriority = makeTask(USER_A, JOB_A, TASK_ID_C, 1);
    runOnHost(lowestPriority, HOST_A);

    ScheduledTask pendingPriority = makeTask(USER_A, JOB_A, TASK_ID_D, 98);
    clock.advance(PREEMPTION_DELAY);

    expectNoOffers();

    expectGetPendingTasks(pendingPriority);
View Full Code Here

  @Test
  public void testStateChanged() {
    vetoed(ALMOST);
    assertNearest(ALMOST);
    IScheduledTask task = IScheduledTask.build(new ScheduledTask()
        .setStatus(ScheduleStatus.ASSIGNED)
        .setAssignedTask(new AssignedTask().setTaskId(TASK)));
    nearest.stateChanged(TaskStateChange.transition(task, ScheduleStatus.PENDING));
    assertNearest();
  }
View Full Code Here

  }

  @Test
  public void testHigherPriorityRunning() throws Exception {
    schedulingFilter = createMock(SchedulingFilter.class);
    ScheduledTask highPriority = makeTask(USER_A, JOB_A, TASK_ID_B, 100);
    runOnHost(highPriority, HOST_A);

    ScheduledTask task = makeTask(USER_A, JOB_A, TASK_ID_A);
    clock.advance(PREEMPTION_DELAY);

    expectNoOffers();

    expectGetPendingTasks(task);
View Full Code Here

    expectUpdateStateOnTransitionTo(PENDING, ASSIGNED, STARTING, FINISHED);
  }

  @Test
  public void testHonorsMaxFailures() {
    ScheduledTask task = makeTask(false);
    task.getAssignedTask().getTask().setMaxTaskFailures(10);
    task.setFailureCount(8);
    stateMachine = makeStateMachine(task);
    expectUpdateStateOnTransitionTo(PENDING, ASSIGNED, STARTING, RUNNING);
    legalTransition(FAILED, Action.SAVE_STATE, Action.RESCHEDULE, Action.INCREMENT_FAILURES);

    ScheduledTask rescheduled = task.deepCopy();
    rescheduled.setFailureCount(9);
    stateMachine = makeStateMachine(rescheduled);
    expectUpdateStateOnTransitionTo(PENDING, ASSIGNED, STARTING, RUNNING);
    legalTransition(FAILED, Action.SAVE_STATE, Action.INCREMENT_FAILURES);
  }
View Full Code Here

  @Test
  public void testProductionPreemptingNonproduction() throws Exception {
    schedulingFilter = createMock(SchedulingFilter.class);
    // Use a very low priority for the production task to show that priority is irrelevant.
    ScheduledTask p1 = makeProductionTask(USER_A, JOB_A, TASK_ID_A + "_p1", -1000);
    ScheduledTask a1 = makeTask(USER_A, JOB_A, TASK_ID_B + "_a1", 100);
    runOnHost(a1, HOST_A);

    clock.advance(PREEMPTION_DELAY);

    expectNoOffers();
View Full Code Here

TOP

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

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.