Search in sources :

Example 11 with TaskRelocationStatus

use of com.netflix.titus.api.relocation.model.TaskRelocationStatus in project titus-control-plane by Netflix.

the class TaskEvictionStepTest method testSuccessfulEviction.

@Test
public void testSuccessfulEviction() {
    Job<BatchJobExt> job = TestDataFactory.newBatchJob("job1", 1, newSelfManagedDisruptionBudget(1_000));
    relocationConnectorStubs.addJob(job);
    relocationConnectorStubs.setQuota("job1", 1);
    Task task = jobOperations.getTasks().get(0);
    relocationConnectorStubs.place(TestDataFactory.REMOVABLE_INSTANCE_GROUP_ID, task);
    TaskRelocationPlan taskRelocationPlan = oneMigrationPlan().toBuilder().withTaskId(task.getId()).build();
    Map<String, TaskRelocationStatus> result = step.evict(Collections.singletonMap(task.getId(), taskRelocationPlan));
    assertThat(result).hasSize(1);
    TaskRelocationStatus relocationStatus = result.get(task.getId());
    assertThat(relocationStatus.getTaskId()).isEqualTo(task.getId());
    assertThat(relocationStatus.getStatusCode()).isEqualTo(TaskRelocationStatus.STATUS_CODE_TERMINATED);
    assertThat(relocationStatus.getTaskRelocationPlan()).isEqualTo(taskRelocationPlan);
}
Also used : Task(com.netflix.titus.api.jobmanager.model.job.Task) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) TaskRelocationStatus(com.netflix.titus.api.relocation.model.TaskRelocationStatus) TaskRelocationPlan(com.netflix.titus.api.relocation.model.TaskRelocationPlan) AbstractTaskRelocationTest(com.netflix.titus.supplementary.relocation.AbstractTaskRelocationTest) Test(org.junit.Test)

Example 12 with TaskRelocationStatus

use of com.netflix.titus.api.relocation.model.TaskRelocationStatus in project titus-control-plane by Netflix.

the class JooqTaskRelocationResultStore method removeFromCache.

/**
 * Remove from cache garbage collected entries.
 */
void removeFromCache(List<Pair<String, Long>> toRemove) {
    toRemove.forEach(p -> {
        String taskId = p.getLeft();
        long timestamp = p.getRight();
        TaskRelocationStatus status = statusesByTaskId.getIfPresent(taskId);
        if (status != null && status.getTimestamp() == timestamp) {
            statusesByTaskId.invalidate(taskId);
        }
    });
}
Also used : TaskRelocationStatus(com.netflix.titus.api.relocation.model.TaskRelocationStatus)

Aggregations

TaskRelocationStatus (com.netflix.titus.api.relocation.model.TaskRelocationStatus)12 Test (org.junit.Test)5 AbstractTaskRelocationTest (com.netflix.titus.supplementary.relocation.AbstractTaskRelocationTest)4 TaskRelocationPlan (com.netflix.titus.api.relocation.model.TaskRelocationPlan)3 Stopwatch (com.google.common.base.Stopwatch)2 Optional (java.util.Optional)2 Task (com.netflix.titus.api.jobmanager.model.job.Task)1 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)1 TaskRelocationState (com.netflix.titus.api.relocation.model.TaskRelocationStatus.TaskRelocationState)1 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)1 DateTimeExt (com.netflix.titus.common.util.DateTimeExt)1 ExceptionExt (com.netflix.titus.common.util.ExceptionExt)1 CodeInvariants (com.netflix.titus.common.util.code.CodeInvariants)1 ReactorExt (com.netflix.titus.common.util.rx.ReactorExt)1 Clock (com.netflix.titus.common.util.time.Clock)1 TaskRelocationExecutions (com.netflix.titus.grpc.protogen.TaskRelocationExecutions)1 EvictionServiceClient (com.netflix.titus.runtime.connector.eviction.EvictionServiceClient)1 RelocationGrpcModelConverters.toGrpcTaskRelocationExecutions (com.netflix.titus.runtime.relocation.endpoint.RelocationGrpcModelConverters.toGrpcTaskRelocationExecutions)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 Duration (java.time.Duration)1