Examples of IJobUpdateSettings


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

    }

    @Override
    public Update newUpdate(IJobUpdateInstructions instructions, boolean rollingForward) {
      requireNonNull(instructions);
      IJobUpdateSettings settings = instructions.getSettings();
      checkArgument(
          settings.getMaxWaitToInstanceRunningMs() > 0,
          "Max wait to running must be positive.");
      checkArgument(
          settings.getMinWaitInInstanceRunningMs() > 0,
          "Min wait in running must be positive.");
      checkArgument(
          settings.getUpdateGroupSize() > 0,
          "Update group size must be positive.");

      Set<Integer> instances;
      Set<Integer> desiredInstances = instructions.isSetDesiredState()
          ? expandInstanceIds(ImmutableSet.of(instructions.getDesiredState()))
          : ImmutableSet.<Integer>of();

      if (settings.getUpdateOnlyTheseInstances().isEmpty()) {
        // In a full job update, the working set is the union of instance IDs before and after.
        instances =  ImmutableSet.copyOf(
            Sets.union(expandInstanceIds(instructions.getInitialState()), desiredInstances));
      } else {
        instances = Numbers.rangesToInstanceIds(settings.getUpdateOnlyTheseInstances());
      }

      ImmutableMap.Builder<Integer, StateEvaluator<Optional<IScheduledTask>>> evaluators =
          ImmutableMap.builder();
      for (int instanceId : instances) {
        Optional<ITaskConfig> desiredStateConfig;
        if (rollingForward) {
          desiredStateConfig = desiredInstances.contains(instanceId)
              ? Optional.of(instructions.getDesiredState().getTask())
              : Optional.<ITaskConfig>absent();
        } else {
          desiredStateConfig = getConfig(instanceId, instructions.getInitialState());
        }

        evaluators.put(
            instanceId,
            new InstanceUpdater(
                desiredStateConfig,
                settings.getMaxPerInstanceFailures(),
                Amount.of((long) settings.getMinWaitInInstanceRunningMs(), Time.MILLISECONDS),
                Amount.of((long) settings.getMaxWaitToInstanceRunningMs(), Time.MILLISECONDS),
                clock));
      }

      Ordering<Integer> updateOrder = rollingForward
          ? Ordering.<Integer>natural()
          : Ordering.<Integer>natural().reverse();

      UpdateStrategy<Integer> strategy = settings.isWaitForBatchCompletion()
          ? new BatchStrategy<>(updateOrder, settings.getUpdateGroupSize())
          : new QueueStrategy<>(updateOrder, settings.getUpdateGroupSize());
      JobUpdateStatus successStatus =
          rollingForward ? JobUpdateStatus.ROLLED_FORWARD : JobUpdateStatus.ROLLED_BACK;
      JobUpdateStatus failureStatus = rollingForward && settings.isRollbackOnFailure()
          ? JobUpdateStatus.ROLLING_BACK
          : JobUpdateStatus.FAILED;

      return new Update(
          new OneWayJobUpdater<>(
              strategy,
              settings.getMaxFailedInstances(),
              evaluators.build()),
          successStatus,
          failureStatus);
    }
View Full Code Here

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

    return storage.write(new MutateWork.Quiet<Response>() {
      @Override
      public Response apply(MutableStoreProvider storeProvider) {
        String updateId = uuidGenerator.createNew().toString();
        IJobUpdateSettings settings = request.getSettings();

        JobDiff diff = JobDiff.compute(
            storeProvider.getTaskStore(),
            job,
            JobDiff.asMap(request.getTaskConfig(), request.getInstanceCount()),
            settings.getUpdateOnlyTheseInstances());

        if (diff.isNoop()) {
          return addMessage(emptyResponse(), OK, NOOP_JOB_UPDATE_MESSAGE);
        }

        Set<Integer> invalidScope = diff.getOutOfScopeInstances(
            Numbers.rangesToInstanceIds(settings.getUpdateOnlyTheseInstances()));
        if (!invalidScope.isEmpty()) {
          return invalidResponse(
              "updateOnlyTheseInstances contains instances irrelevant to the update: "
                  + invalidScope);
        }

        JobUpdateInstructions instructions = new JobUpdateInstructions()
            .setSettings(settings.newBuilder())
            .setInitialState(buildInitialState(diff.getReplacedInstances()));
        if (!diff.getReplacementInstances().isEmpty()) {
          instructions.setDesiredState(
              new InstanceTaskConfig()
                  .setTask(request.getTaskConfig().newBuilder())
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.