use of com.netflix.titus.grpc.protogen.TaskRelocationPlans in project titus-control-plane by Netflix.
the class TaskRelocationIntegrationTest method findRelocationPlan.
private Optional<TaskRelocationPlan> findRelocationPlan(String taskId) {
TaskRelocationPlans plans;
try {
TestStreamObserver<TaskRelocationPlans> events = new TestStreamObserver<>();
client.getCurrentTaskRelocationPlans(TaskRelocationQuery.getDefaultInstance(), events);
plans = events.getLast();
} catch (Exception e) {
if (e.getMessage().contains("Relocation workflow not ready yet")) {
return Optional.empty();
}
throw new RuntimeException(e);
}
Optional<TaskRelocationPlan> taskPlan = plans.getPlansList().stream().filter(p -> p.getTaskId().equals(taskId)).findFirst();
if (taskPlan.isPresent()) {
return taskPlan;
}
// Check if already processed
try {
TestStreamObserver<TaskRelocationExecution> events = new TestStreamObserver<>();
client.getTaskRelocationResult(RelocationTaskId.newBuilder().setId(taskId).build(), events);
return Optional.of(events.getLast().getTaskRelocationPlan());
} catch (Exception e) {
Status status = Status.fromThrowable(e);
if (status.getCode() == Status.Code.NOT_FOUND) {
return Optional.empty();
}
throw new RuntimeException(e);
}
}
Aggregations