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);
}
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);
}
Aggregations