private Runnable getDeferredEvaluator(final IInstanceKey instance, final IJobUpdateKey key) {
   return () ->
       storage.write(
           (NoResult.Quiet)
               storeProvider -> {
                 IJobUpdateSummary summary =
                     getOnlyMatch(storeProvider.getJobUpdateStore(), queryByUpdate(key));
                 JobUpdateStatus status = summary.getState().getStatus();
                 // Suppress this evaluation if the updater is not currently active.
                 if (JobUpdateStateMachine.isActive(status)) {
                   UpdateFactory.Update update = updates.get(instance.getJobKey());
                   try {
                     evaluateUpdater(
                         storeProvider,
                         update,
                         summary,
                         ImmutableMap.of(
                             instance.getInstanceId(),
                             getActiveInstance(
                                 storeProvider.getTaskStore(),
                                 instance.getJobKey(),
                                 instance.getInstanceId())));
                   } catch (UpdateStateException e) {
                     throw Throwables.propagate(e);
                   }
                 }
               });
 }
 private void instanceChanged(final IInstanceKey instance, final Optional<IScheduledTask> state) {
   storage.write(
       (NoResult.Quiet)
           storeProvider -> {
             IJobKey job = instance.getJobKey();
             UpdateFactory.Update update = updates.get(job);
             if (update != null) {
               if (update.getUpdater().containsInstance(instance.getInstanceId())) {
                 LOG.info("Forwarding task change for " + InstanceKeys.toString(instance));
                 try {
                   evaluateUpdater(
                       storeProvider,
                       update,
                       getOnlyMatch(storeProvider.getJobUpdateStore(), queryActiveByJob(job)),
                       ImmutableMap.of(instance.getInstanceId(), state));
                 } catch (UpdateStateException e) {
                   throw Throwables.propagate(e);
                 }
               } else {
                 LOG.info(
                     "Instance "
                         + instance
                         + " is not part of active update for "
                         + JobKeys.canonicalString(job));
               }
             }
           });
 }
    @Override
    public Amount<Long, Time> getReevaluationDelay(
        IInstanceKey instance,
        IJobUpdateInstructions instructions,
        MutableStoreProvider storeProvider,
        StateManager stateManager,
        JobUpdateStatus status) {

      LOG.info("Adding instance " + instance + " while " + status);
      ITaskConfig replacement =
          getTargetConfig(instructions, status == ROLLING_FORWARD, instance.getInstanceId());
      stateManager.insertPendingTasks(
          storeProvider, replacement, ImmutableSet.of(instance.getInstanceId()));
      return Amount.of(
          (long) instructions.getSettings().getMaxWaitToInstanceRunningMs(), Time.MILLISECONDS);
    }