예제 #1
0
 /**
  * When triggered, records an inactive task state change.
  *
  * @param change Event when a task changes state.
  */
 @Subscribe
 public void recordStateChange(TaskStateChange change) {
   if (Tasks.isTerminated(change.getNewState())) {
     long timeoutBasis =
         change.isTransition()
             ? clock.nowMillis()
             : Iterables.getLast(change.getTask().getTaskEvents()).getTimestamp();
     registerInactiveTask(
         Tasks.getJob(change.getTask()), change.getTaskId(), calculateTimeout(timeoutBasis));
   }
 }
예제 #2
0
 @VisibleForTesting
 long calculateTimeout(long taskEventTimestampMillis) {
   return Math.max(
       settings.minRetentionThresholdMillis,
       settings.pruneThresholdMillis - Math.max(0, clock.nowMillis() - taskEventTimestampMillis));
 }
예제 #3
0
 @Override
 public boolean apply(IScheduledTask task) {
   return Tasks.getLatestEvent(task).getTimestamp()
       <= clock.nowMillis() - settings.minRetentionThresholdMillis;
 }