use of com.netflix.titus.common.util.retry.Retryer in project titus-control-plane by Netflix.
the class MaxManyRetryers method retry.
@Override
public Retryer retry() {
Retryer[] newRetryers = new Retryer[retryers.length];
for (int i = 0; i < retryers.length; i++) {
Retryer next = retryers[i].retry();
if (next instanceof NeverRetryer) {
return NeverRetryer.INSTANCE;
}
newRetryers[i] = next;
}
return new MaxManyRetryers(newRetryers);
}
use of com.netflix.titus.common.util.retry.Retryer in project titus-control-plane by Netflix.
the class CreateOrReplaceBatchTaskActions method createOriginalTaskChangeAction.
private static TitusChangeAction createOriginalTaskChangeAction(Job<BatchJobExt> job, int index, JobStore jobStore, VersionSupplier versionSupplier, Clock clock, Map<String, String> taskContext) {
Retryer newRetryer = JobFunctions.retryer(job);
BatchJobTask newTask = createNewBatchTask(job, index, clock.wallTime(), versionSupplier, taskContext);
return TitusChangeAction.newAction("createOrReplaceTask").id(newTask.getId()).trigger(Trigger.Reconciler).summary(String.format("Creating new task at index %d in DB store: %s", newTask.getIndex(), newTask.getId())).changeWithModelUpdates(self -> jobStore.storeTask(newTask).andThen(Observable.just(createNewTaskModelAction(self, newTask, Optional.empty(), newRetryer))));
}
use of com.netflix.titus.common.util.retry.Retryer in project titus-control-plane by Netflix.
the class MaxManyRetryersTest method testMany.
@Test
public void testMany() {
// 10 / 1 (the expected delay of the first and the second retryer at this stage)
Retryer first = Retryers.max(Retryers.interval(10, TimeUnit.MILLISECONDS, 4), Retryers.exponentialBackoff(1, 100, TimeUnit.MILLISECONDS));
assertThat(first.getDelayMs()).contains(10L);
// 10 / 2
Retryer second = first.retry();
assertThat(second.getDelayMs()).contains(10L);
// 10 / 4
Retryer third = second.retry();
assertThat(third.getDelayMs()).contains(10L);
// 10 / 8
Retryer fourth = third.retry();
assertThat(fourth.getDelayMs()).contains(10L);
// 10 / 16
Retryer fifth = fourth.retry();
assertThat(fifth.getDelayMs()).contains(16L);
// retry limit reached
Retryer sixth = fifth.retry();
assertThat(sixth.getDelayMs()).isEmpty();
}
use of com.netflix.titus.common.util.retry.Retryer in project titus-control-plane by Netflix.
the class MaxManyRetryersTest method testClosed.
@Test
public void testClosed() {
Retryer retryer = Retryers.max(Retryers.interval(10, TimeUnit.MILLISECONDS, 4), Retryers.never());
assertThat(retryer.getDelayMs()).isEmpty();
}
use of com.netflix.titus.common.util.retry.Retryer in project titus-control-plane by Netflix.
the class CreateOrReplaceBatchTaskActions method createResubmittedTaskChangeAction.
private static TitusChangeAction createResubmittedTaskChangeAction(EntityHolder jobHolder, EntityHolder taskHolder, JobServiceRuntime context, JobStore jobStore, VersionSupplier versionSupplier, Clock clock, Map<String, String> taskContext) {
BatchJobTask oldTask = taskHolder.getEntity();
long timeInStartedState = JobFunctions.getTimeInState(oldTask, TaskState.Started, clock).orElse(0L);
Retryer nextTaskRetryer = timeInStartedState >= context.getConfiguration().getTaskRetryerResetTimeMs() ? JobFunctions.retryer(jobHolder.getEntity()) : TaskRetryers.getNextTaskRetryer(context::getSystemRetryer, jobHolder.getEntity(), taskHolder);
BatchJobTask newTask = createBatchTaskReplacement(jobHolder.getEntity(), oldTask, versionSupplier, clock, taskContext);
String summary = String.format("Replacing task at index %d (resubmit=%d) in DB store: old=%s, new=%s", oldTask.getIndex(), newTask.getResubmitNumber(), oldTask.getId(), newTask.getId());
return TitusChangeAction.newAction("createOrReplaceTask").id(newTask.getId()).trigger(Trigger.Reconciler).summary(summary).changeWithModelUpdates(self -> jobStore.replaceTask(oldTask, newTask).andThen(Observable.just(createTaskResubmitModelActions(self, oldTask, newTask, nextTaskRetryer))));
}
Aggregations