use of com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobManagementModelConverters.toCoreJob in project titus-control-plane by Netflix.
the class TaskEventsGenerator method buildEventStream.
private void buildEventStream() {
taskEvents = titusClient.getJobAndTaskUpdates().publishOn(scheduler).flatMap(jobOrTaskUpdate -> jobOrTaskUpdate.hasTask() ? Flux.just(jobOrTaskUpdate.getTask()) : Flux.empty()).map(task -> {
final Mono<Job> jobById = titusClient.getJobById(task.getJobId());
return Pair.of(task, jobById);
}).flatMap(taskMonoPair -> {
final Task task = taskMonoPair.getLeft();
return taskMonoPair.getRight().flatMap(job -> {
try {
final com.netflix.titus.api.jobmanager.model.job.Job coreJob = GrpcJobManagementModelConverters.toCoreJob(job);
final com.netflix.titus.api.jobmanager.model.job.Task coreTask = GrpcJobManagementModelConverters.toCoreTask(coreJob, task);
return Mono.just(TaskDocument.fromV3Task(coreTask, coreJob, ElasticSearchUtils.DATE_FORMAT, buildTaskContext(task)));
} catch (Exception e) {
// If the mapping fails, we do not want to break the pipeline, and possible cause an infinite number
// of retries, each failing on the same bad job/task record. Instead, we log the error.
titusRuntime.getCodeInvariants().unexpectedError(String.format("Cannot map Titus job/task to ES TaskDocument: job=%s, task=%s", job, task), e);
logger.warn("Cannot map Titus job/task to ES TaskDocument", e);
return Mono.empty();
}
}).flux();
}).doOnError(error -> logger.error("TitusClient event stream error", error)).retryWhen(TaskPublisherRetryUtil.buildRetryHandler(TaskPublisherRetryUtil.INITIAL_RETRY_DELAY_MS, TaskPublisherRetryUtil.MAX_RETRY_DELAY_MS, -1)).publish();
}
Aggregations