Examples of TaskMutation


Examples of org.apache.aurora.scheduler.storage.TaskStore.Mutable.TaskMutation

  @Test
  public void testMutate() {
    store.saveTasks(ImmutableSet.of(TASK_A, TASK_B, TASK_C, TASK_D));
    assertQueryResults(Query.statusScoped(RUNNING));

    store.mutateTasks(Query.taskScoped("a"), new TaskMutation() {
      @Override
      public IScheduledTask apply(IScheduledTask task) {
        return IScheduledTask.build(task.newBuilder().setStatus(RUNNING));
      }
    });

    assertQueryResults(
        Query.statusScoped(RUNNING),
        IScheduledTask.build(TASK_A.newBuilder().setStatus(RUNNING)));

    store.mutateTasks(Query.unscoped(), new TaskMutation() {
      @Override
      public IScheduledTask apply(IScheduledTask task) {
        return IScheduledTask.build(task.newBuilder().setStatus(ScheduleStatus.ASSIGNED));
      }
    });
View Full Code Here

Examples of org.apache.aurora.scheduler.storage.TaskStore.Mutable.TaskMutation

    store.deleteTasks(ImmutableSet.of(Tasks.id(b)));
    assertQueryResults(jimsJob, a);
    assertQueryResults(jimsJob2, c);
    assertQueryResults(joesJob, d);

    store.mutateTasks(jimsJob, new TaskMutation() {
      @Override
      public IScheduledTask apply(IScheduledTask task) {
        return IScheduledTask.build(task.newBuilder().setStatus(RUNNING));
      }
    });
View Full Code Here

Examples of org.apache.aurora.scheduler.storage.TaskStore.Mutable.TaskMutation

   */
  public static void backfill(final MutableStoreProvider storeProvider, final Clock clock) {
    backfillJobDefaults(storeProvider.getJobStore());

    LOG.info("Performing shard uniqueness sanity check.");
    storeProvider.getUnsafeTaskStore().mutateTasks(Query.unscoped(), new TaskMutation() {
      @Override
      public IScheduledTask apply(final IScheduledTask task) {
        ScheduledTask builder = task.newBuilder();
        ConfigurationManager.applyDefaultsIfUnset(builder.getAssignedTask().getTask());
        // TODO(ksweeney): Guarantee tasks pass current validation code here and quarantine if they
View Full Code Here

Examples of org.apache.aurora.scheduler.storage.TaskStore.Mutable.TaskMutation

          Optional<IScheduledTask> upToDateTask = Optional.fromNullable(
              Iterables.getOnlyElement(storeProvider.getTaskStore().fetchTasks(query), null));

          switch (sideEffect.getAction()) {
            case INCREMENT_FAILURES:
              storeProvider.getUnsafeTaskStore().mutateTasks(query, new TaskMutation() {
                @Override
                public IScheduledTask apply(IScheduledTask task) {
                  return IScheduledTask.build(
                      task.newBuilder().setFailureCount(task.getFailureCount() + 1));
                }
              });
              break;

            case SAVE_STATE:
              Preconditions.checkState(
                  upToDateTask.isPresent(),
                  "Operation expected task " + taskId + " to be present.");

              storeProvider.getUnsafeTaskStore().mutateTasks(query, new TaskMutation() {
                @Override
                public IScheduledTask apply(IScheduledTask task) {
                  ScheduledTask mutableTask = task.newBuilder();
                  mutableTask.setStatus(targetState.get());
                  mutableTask.addToTaskEvents(new TaskEvent()
View Full Code Here

Examples of org.apache.aurora.scheduler.storage.TaskStore.Mutable.TaskMutation

    backfillJobDefaults(storeProvider.getJobStore());

    // Backfilling job keys has to be done in a separate transaction to ensure follow up scoped
    // Query calls work against upgraded MemTaskStore, which does not support deprecated fields.
    LOG.info("Backfilling task config job keys.");
    storeProvider.getUnsafeTaskStore().mutateTasks(Query.unscoped(), new TaskMutation() {
      @Override
      public IScheduledTask apply(final IScheduledTask task) {
        ScheduledTask builder = task.newBuilder();
        populateJobKey(builder.getAssignedTask().getTask(), BACKFILLED_TASK_CONFIG_KEYS);
        return IScheduledTask.build(builder);
      }
    });

    LOG.info("Performing shard uniqueness sanity check.");
    storeProvider.getUnsafeTaskStore().mutateTasks(Query.unscoped(), new TaskMutation() {
      @Override
      public IScheduledTask apply(final IScheduledTask task) {
        ScheduledTask builder = task.newBuilder();
        ConfigurationManager.applyDefaultsIfUnset(builder.getAssignedTask().getTask());
        // TODO(ksweeney): Guarantee tasks pass current validation code here and quarantine if they
View Full Code Here

Examples of org.apache.aurora.scheduler.storage.TaskStore.Mutable.TaskMutation

      Optional<IScheduledTask> upToDateTask = Optional.fromNullable(
          Iterables.getOnlyElement(taskStore.fetchTasks(query), null));

      switch (sideEffect.getAction()) {
        case INCREMENT_FAILURES:
          taskStore.mutateTasks(query, new TaskMutation() {
            @Override
            public IScheduledTask apply(IScheduledTask task) {
              return IScheduledTask.build(
                  task.newBuilder().setFailureCount(task.getFailureCount() + 1));
            }
          });
          break;

        case SAVE_STATE:
          Preconditions.checkState(
              upToDateTask.isPresent(),
              "Operation expected task " + taskId + " to be present.");

          taskStore.mutateTasks(query, new TaskMutation() {
            @Override
            public IScheduledTask apply(IScheduledTask task) {
              ScheduledTask mutableTask = task.newBuilder();
              mutableTask.setStatus(targetState.get());
              mutableTask.addToTaskEvents(new TaskEvent()
View Full Code Here

Examples of org.apache.aurora.scheduler.storage.TaskStore.Mutable.TaskMutation

  @Test
  public void testMutate() {
    store.saveTasks(ImmutableSet.of(TASK_A, TASK_B, TASK_C, TASK_D));
    assertQueryResults(Query.statusScoped(RUNNING));

    store.mutateTasks(Query.taskScoped("a"), new TaskMutation() {
      @Override
      public IScheduledTask apply(IScheduledTask task) {
        return IScheduledTask.build(task.newBuilder().setStatus(RUNNING));
      }
    });

    assertQueryResults(
        Query.statusScoped(RUNNING),
        IScheduledTask.build(TASK_A.newBuilder().setStatus(RUNNING)));

    store.mutateTasks(Query.unscoped(), new TaskMutation() {
      @Override
      public IScheduledTask apply(IScheduledTask task) {
        return IScheduledTask.build(task.newBuilder().setStatus(ScheduleStatus.ASSIGNED));
      }
    });
View Full Code Here

Examples of org.apache.aurora.scheduler.storage.TaskStore.Mutable.TaskMutation

    store.deleteTasks(ImmutableSet.of(Tasks.id(b)));
    assertQueryResults(jimsJob, a);
    assertQueryResults(jimsJob2, c);
    assertQueryResults(joesJob, d);

    store.mutateTasks(jimsJob, new TaskMutation() {
      @Override
      public IScheduledTask apply(IScheduledTask task) {
        return IScheduledTask.build(task.newBuilder().setStatus(RUNNING));
      }
    });
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.