Search in sources :

Example 1 with RelocationEvent

use of com.netflix.titus.grpc.protogen.RelocationEvent in project titus-control-plane by Netflix.

the class RelocationGrpcModelConverters method toGrpcRelocationEvent.

public static Optional<RelocationEvent> toGrpcRelocationEvent(TaskRelocationEvent coreEvent) {
    RelocationEvent grpcEvent = null;
    if (coreEvent.equals(TaskRelocationEvent.newSnapshotEndEvent())) {
        grpcEvent = RelocationEvent.newBuilder().setSnapshotEnd(RelocationEvent.SnapshotEnd.getDefaultInstance()).build();
    } else if (coreEvent instanceof TaskRelocationPlanUpdateEvent) {
        TaskRelocationPlanUpdateEvent updateEvent = (TaskRelocationPlanUpdateEvent) coreEvent;
        grpcEvent = RelocationEvent.newBuilder().setTaskRelocationPlanUpdateEvent(RelocationEvent.TaskRelocationPlanUpdateEvent.newBuilder().setPlan(toGrpcTaskRelocationPlan(updateEvent.getPlan()))).build();
    } else if (coreEvent instanceof TaskRelocationPlanRemovedEvent) {
        TaskRelocationPlanRemovedEvent removedEvent = (TaskRelocationPlanRemovedEvent) coreEvent;
        grpcEvent = RelocationEvent.newBuilder().setTaskRelocationPlanRemoveEvent(RelocationEvent.TaskRelocationPlanRemoveEvent.newBuilder().setTaskId(removedEvent.getTaskId())).build();
    }
    return Optional.ofNullable(grpcEvent);
}
Also used : TaskRelocationPlanRemovedEvent(com.netflix.titus.api.relocation.model.event.TaskRelocationPlanRemovedEvent) TaskRelocationEvent(com.netflix.titus.api.relocation.model.event.TaskRelocationEvent) RelocationEvent(com.netflix.titus.grpc.protogen.RelocationEvent) TaskRelocationPlanUpdateEvent(com.netflix.titus.api.relocation.model.event.TaskRelocationPlanUpdateEvent)

Example 2 with RelocationEvent

use of com.netflix.titus.grpc.protogen.RelocationEvent in project titus-control-plane by Netflix.

the class TaskRelocationIntegrationTest method testEvents.

@Test(timeout = 60_000)
public void testEvents() throws InterruptedException {
    TestStreamObserver<RelocationEvent> events = new TestStreamObserver<>();
    client.observeRelocationEvents(TaskRelocationQuery.getDefaultInstance(), events);
    RelocationEvent firstEvent = events.takeNext(30, TimeUnit.SECONDS);
    assertThat(firstEvent).isNotNull();
    assertThat(firstEvent.getEventCase()).isEqualTo(EventCase.SNAPSHOTEND);
    Task task = createAndPlaceOneTaskJob(TestDataFactory.REMOVABLE_INSTANCE_GROUP_ID);
    relocationConnectorStubs.setQuota(task.getJobId(), 1);
    RelocationEvent secondEvent = events.takeNext(30, TimeUnit.SECONDS);
    assertThat(secondEvent).isNotNull();
    assertThat(secondEvent.getEventCase()).isEqualTo(EventCase.TASKRELOCATIONPLANUPDATEEVENT);
    RelocationEvent thirdEvent = events.takeNext(30, TimeUnit.SECONDS);
    assertThat(thirdEvent).isNotNull();
    assertThat(thirdEvent.getEventCase()).isEqualTo(EventCase.TASKRELOCATIONPLANREMOVEEVENT);
}
Also used : Task(com.netflix.titus.api.jobmanager.model.job.Task) TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) RelocationEvent(com.netflix.titus.grpc.protogen.RelocationEvent) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Aggregations

RelocationEvent (com.netflix.titus.grpc.protogen.RelocationEvent)2 Task (com.netflix.titus.api.jobmanager.model.job.Task)1 TaskRelocationEvent (com.netflix.titus.api.relocation.model.event.TaskRelocationEvent)1 TaskRelocationPlanRemovedEvent (com.netflix.titus.api.relocation.model.event.TaskRelocationPlanRemovedEvent)1 TaskRelocationPlanUpdateEvent (com.netflix.titus.api.relocation.model.event.TaskRelocationPlanUpdateEvent)1 TestStreamObserver (com.netflix.titus.testkit.grpc.TestStreamObserver)1 IntegrationTest (com.netflix.titus.testkit.junit.category.IntegrationTest)1 Test (org.junit.Test)1