use of com.netflix.titus.grpc.protogen.Task in project titus-control-plane by Netflix.
the class CellWithFixedTasksService method findTasks.
@Override
public void findTasks(TaskQuery request, StreamObserver<TaskQueryResult> responseObserver) {
Pair<List<Task>, Pagination> page = PaginationUtil.takePageWithCursor(toPage(request.getPage()), getTasksList(), JobManagerCursors.taskCursorOrderComparator(), JobManagerCursors::taskIndexOf, JobManagerCursors::newTaskCursorFrom);
Set<String> fieldsFilter = new HashSet<>(request.getFieldsList());
if (!fieldsFilter.isEmpty()) {
fieldsFilter.add("id");
page = page.mapLeft(tasks -> tasks.stream().map(task -> ProtobufExt.copy(task, fieldsFilter)).collect(Collectors.toList()));
}
TaskQueryResult result = TaskQueryResult.newBuilder().addAllItems(page.getLeft()).setPagination(toGrpcPagination(page.getRight())).build();
responseObserver.onNext(result);
responseObserver.onCompleted();
}
use of com.netflix.titus.grpc.protogen.Task in project titus-control-plane by Netflix.
the class CellWithFixedTasksService method findTask.
@Override
public void findTask(TaskId request, StreamObserver<Task> responseObserver) {
Task task = tasksIndex.get(request.getId());
if (task == null) {
responseObserver.onError(NOT_FOUND.asRuntimeException());
return;
}
responseObserver.onNext(task);
responseObserver.onCompleted();
}
use of com.netflix.titus.grpc.protogen.Task in project titus-control-plane by Netflix.
the class LocalCacheQueryProcessor method findTasks.
public TaskQueryResult findTasks(TaskQuery taskQuery) {
JobQueryCriteria<TaskStatus.TaskState, JobDescriptor.JobSpecCase> queryCriteria = GrpcJobQueryModelConverters.toJobQueryCriteria(taskQuery);
Page page = toPage(taskQuery.getPage());
List<com.netflix.titus.api.jobmanager.model.job.Task> matchingTasks = findMatchingTasks(queryCriteria);
PageResult<com.netflix.titus.api.jobmanager.model.job.Task> pageResult = JobManagerCursors.newCoreTaskPaginationEvaluator().takePage(page, matchingTasks);
Set<String> fields = newFieldsFilter(taskQuery.getFieldsList(), TASK_MINIMUM_FIELD_SET);
List<Task> grpcTasks = pageResult.getItems().stream().map(task -> {
Task grpcTask = GrpcJobManagementModelConverters.toGrpcTask(task, logStorageInfo);
if (!fields.isEmpty()) {
grpcTask = ProtobufExt.copy(grpcTask, fields);
}
return grpcTask;
}).collect(Collectors.toList());
return TaskQueryResult.newBuilder().setPagination(toGrpcPagination(pageResult.getPagination())).addAllItems(grpcTasks).build();
}
use of com.netflix.titus.grpc.protogen.Task in project titus-control-plane by Netflix.
the class LocalCacheQueryProcessor method findMatchingTasks.
private List<com.netflix.titus.api.jobmanager.model.job.Task> findMatchingTasks(JobQueryCriteria<TaskStatus.TaskState, JobDescriptor.JobSpecCase> queryCriteria) {
JobSnapshot jobSnapshot = jobDataReplicator.getCurrent();
Map<String, Job<?>> jobsById = jobSnapshot.getJobMap();
V3TaskQueryCriteriaEvaluator queryFilter = new V3TaskQueryCriteriaEvaluator(queryCriteria, titusRuntime);
List<com.netflix.titus.api.jobmanager.model.job.Task> matchingTasks = new ArrayList<>();
jobsById.forEach((jobId, job) -> {
Map<String, com.netflix.titus.api.jobmanager.model.job.Task> tasks = jobSnapshot.getTasks(jobId);
if (!CollectionsExt.isNullOrEmpty(tasks)) {
tasks.forEach((taskId, task) -> {
Pair<Job<?>, com.netflix.titus.api.jobmanager.model.job.Task> jobTaskPair = Pair.of(job, task);
if (queryFilter.test(jobTaskPair)) {
matchingTasks.add(task);
}
});
}
});
return matchingTasks;
}
use of com.netflix.titus.grpc.protogen.Task in project titus-control-plane by Netflix.
the class TaskDataInjectorTest method testFindTaskWithoutRelocationDeadline.
@Test
public void testFindTaskWithoutRelocationDeadline() {
when(relocationDataReplicator.getCurrent()).thenReturn(TaskRelocationSnapshot.empty());
Task merged = Observable.just(TASK1).map(taskDataInjector::injectIntoTask).toBlocking().first();
assertThat(merged.getMigrationDetails().getNeedsMigration()).isFalse();
}
Aggregations