Search in sources :

Example 1 with Retryer

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);
}
Also used : Retryer(com.netflix.titus.common.util.retry.Retryer)

Example 2 with Retryer

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))));
}
Also used : Retryer(com.netflix.titus.common.util.retry.Retryer) BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask)

Example 3 with Retryer

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();
}
Also used : Retryer(com.netflix.titus.common.util.retry.Retryer) Test(org.junit.Test)

Example 4 with Retryer

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();
}
Also used : Retryer(com.netflix.titus.common.util.retry.Retryer) Test(org.junit.Test)

Example 5 with Retryer

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))));
}
Also used : Retryer(com.netflix.titus.common.util.retry.Retryer) BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask)

Aggregations

Retryer (com.netflix.titus.common.util.retry.Retryer)7 BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)2 ServiceJobTask (com.netflix.titus.api.jobmanager.model.job.ServiceJobTask)2 Test (org.junit.Test)2