use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class JobManagementResource method findJobs.
@GET
@ApiOperation("Find jobs")
@Path("/jobs")
public JobQueryResult findJobs(@Context UriInfo info) {
MultivaluedMap<String, String> queryParameters = info.getQueryParameters(true);
JobQuery.Builder queryBuilder = JobQuery.newBuilder();
Page page = RestUtil.createPage(queryParameters);
CallMetadata callMetadata = resolveCallMetadata();
logPageNumberUsage(systemLog, callMetadata, getClass().getSimpleName(), "findJobs", page);
queryBuilder.setPage(page);
queryBuilder.putAllFilteringCriteria(RestUtil.getFilteringCriteria(queryParameters));
queryBuilder.addAllFields(RestUtil.getFieldsParameter(queryParameters));
return Responses.fromSingleValueObservable(jobServiceGateway.findJobs(queryBuilder.build(), callMetadata));
}
use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class GatewayJobServiceGateway method findTasks.
@Override
public Observable<TaskQueryResult> findTasks(TaskQuery taskQuery, CallMetadata callMetadata) {
Map<String, String> filteringCriteriaMap = taskQuery.getFilteringCriteriaMap();
Set<String> v3JobIds = new HashSet<>(StringExt.splitByComma(filteringCriteriaMap.getOrDefault("jobIds", "")));
boolean needsMigrationFilter = "true".equalsIgnoreCase(filteringCriteriaMap.getOrDefault("needsMigration", "false"));
// "needsMigration" query is served from the local job and relocation cache.
if (needsMigrationFilter) {
PageResult<Task> pageResult = needsMigrationQueryHandler.findTasks(GrpcJobQueryModelConverters.toJobQueryCriteria(taskQuery), toPage(taskQuery.getPage()));
TaskQueryResult taskQueryResult = TaskQueryResult.newBuilder().setPagination(toGrpcPagination(pageResult.getPagination())).addAllItems(taskDataInjector.injectIntoTasks(pageResult.getItems())).build();
return Observable.just(taskQueryResult);
}
Set<String> taskStates = Sets.newHashSet(StringExt.splitByComma(taskQuery.getFilteringCriteriaMap().getOrDefault("taskStates", "")));
Observable<TaskQueryResult> observable;
if (v3JobIds.isEmpty()) {
// Active task set only
observable = newActiveTaskQueryAction(taskQuery, callMetadata);
} else {
if (!taskStates.contains(TaskState.Finished.name())) {
// Active task set only
observable = newActiveTaskQueryAction(taskQuery, callMetadata);
} else {
Page page = taskQuery.getPage();
boolean nextPageByNumber = StringExt.isEmpty(page.getCursor()) && page.getPageNumber() > 0;
if (nextPageByNumber) {
// In this case we ask for active and archived tasks using a page number > 0. Because of that
// we have to fetch as much tasks from master as we can. Tasks that we do not fetch, will not be
// visible to the client.
TaskQuery largePageQuery = taskQuery.toBuilder().setPage(taskQuery.getPage().toBuilder().setPageNumber(0).setPageSize(gatewayConfiguration.getMaxTaskPageSize())).build();
observable = newActiveTaskQueryAction(largePageQuery, callMetadata);
} else {
observable = newActiveTaskQueryAction(taskQuery, callMetadata);
}
observable = observable.flatMap(result -> retrieveArchivedTasksForJobs(v3JobIds, taskQuery).map(archivedTasks -> combineTaskResults(taskQuery, result, archivedTasks)));
}
}
return observable.timeout(tunablesConfiguration.getRequestTimeoutMs(), TimeUnit.MILLISECONDS).map(queryResult -> taskDataInjector.injectIntoTaskQueryResult(queryResult));
}
use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class AggregatingAutoScalingService method updateAutoScalingPolicy.
@Override
public Completable updateAutoScalingPolicy(UpdatePolicyRequest request, CallMetadata callMetadata) {
ScalingPolicyID policyId = request.getPolicyId();
Observable<Empty> observable = getScalingPolicyInAllCells(policyId, callMetadata).flatMap(response -> singleCellCall(response.getCell(), (client, responseObserver) -> client.updateAutoScalingPolicy(request, responseObserver), callMetadata));
return observable.toCompletable();
}
use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class AggregatingAutoScalingService method deleteAutoScalingPolicy.
@Override
public Completable deleteAutoScalingPolicy(DeletePolicyRequest request, CallMetadata callMetadata) {
ScalingPolicyID policyId = request.getId();
Observable<Empty> observable = getScalingPolicyInAllCells(policyId, callMetadata).flatMap(response -> singleCellCall(response.getCell(), (client, responseObserver) -> client.deleteAutoScalingPolicy(request, responseObserver), callMetadata));
return observable.toCompletable();
}
use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class SpringCallMetadataInterceptorTest method expectDebug.
private void expectDebug(boolean expectedDebug) throws Exception {
interceptor.preHandle(request, response, new Object());
CallMetadata callMetadata = expectCallMetadataAuthentication();
assertThat(callMetadata.isDebug()).isEqualTo(expectedDebug);
}
Aggregations