Search in sources :

Example 6 with Page

use of com.netflix.titus.grpc.protogen.Page in project titus-control-plane by Netflix.

the class JobManagementSpringResource method findTasks.

@ApiOperation("Find tasks")
@GetMapping(path = "/tasks")
public TaskQueryResult findTasks(@RequestParam MultiValueMap<String, String> queryParameters, CallMetadataAuthentication authentication) {
    TaskQuery.Builder queryBuilder = TaskQuery.newBuilder();
    Page page = RestUtil.createPage(queryParameters);
    logPageNumberUsage(systemLog, authentication.getCallMetadata(), getClass().getSimpleName(), "findTasks", page);
    queryBuilder.setPage(page);
    queryBuilder.putAllFilteringCriteria(RestUtil.getFilteringCriteria(queryParameters));
    queryBuilder.addAllFields(RestUtil.getFieldsParameter(queryParameters));
    return Responses.fromSingleValueObservable(jobServiceGateway.findTasks(queryBuilder.build(), authentication.getCallMetadata()));
}
Also used : TaskQuery(com.netflix.titus.grpc.protogen.TaskQuery) Page(com.netflix.titus.grpc.protogen.Page) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 7 with Page

use of com.netflix.titus.grpc.protogen.Page in project titus-control-plane by Netflix.

the class LoadBalancerResource method getAllLoadBalancers.

@GET
@ApiOperation("Get all load balancers")
public GetAllLoadBalancersResult getAllLoadBalancers(@Context UriInfo info) {
    Page page = RestUtil.createPage(info.getQueryParameters());
    CallMetadata callMetadata = resolveCallMetadata();
    logPageNumberUsage(systemLog, callMetadata, getClass().getSimpleName(), "getAllLoadBalancers", page);
    return Responses.fromSingleValueObservable(loadBalancerService.getAllLoadBalancers(GetAllLoadBalancersRequest.newBuilder().setPage(page).build(), callMetadata));
}
Also used : CallMetadata(com.netflix.titus.api.model.callmetadata.CallMetadata) Page(com.netflix.titus.grpc.protogen.Page) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 8 with Page

use of com.netflix.titus.grpc.protogen.Page in project titus-control-plane by Netflix.

the class LoadBalancerSpringResource method getAllLoadBalancers.

@ApiOperation("Get all load balancers")
@GetMapping
public GetAllLoadBalancersResult getAllLoadBalancers(@RequestParam MultiValueMap<String, String> queryParameters, CallMetadataAuthentication authentication) {
    Page page = RestUtil.createPage(queryParameters);
    logPageNumberUsage(systemLog, authentication.getCallMetadata(), getClass().getSimpleName(), "getAllLoadBalancers", page);
    return Responses.fromSingleValueObservable(loadBalancerService.getAllLoadBalancers(GetAllLoadBalancersRequest.newBuilder().setPage(page).build(), authentication.getCallMetadata()));
}
Also used : Page(com.netflix.titus.grpc.protogen.Page) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 9 with Page

use of com.netflix.titus.grpc.protogen.Page in project titus-control-plane by Netflix.

the class LocalCacheQueryProcessorTest method testFindJobs.

@Test
public void testFindJobs() {
    Job<?> job1 = addToJobDataReplicator(newJobAndTasks("job1", 2)).getLeft();
    Job<?> job2 = addToJobDataReplicator(newJobAndTasks("job2", 4)).getLeft();
    Job<?> job3 = addToJobDataReplicator(newJobAndTasks("job3", 0)).getLeft();
    // Expect two pages
    JobQueryResult page1Result = processor.findJobs(JOB_QUERY_ALL_WITH_PAGE_SIZE_2);
    assertThat(page1Result.getItemsList()).hasSize(2);
    Page page2 = Page.newBuilder().setPageSize(2).setCursor(page1Result.getPagination().getCursor()).build();
    JobQueryResult page2Result = processor.findJobs(JobQuery.newBuilder().setPage(page2).build());
    assertThat(page2Result.getItemsList()).hasSize(1);
    assertThat(page2Result.getPagination().getHasMore()).isFalse();
    List<String> jobIds = CollectionsExt.merge(page1Result.getItemsList().stream().map(com.netflix.titus.grpc.protogen.Job::getId).collect(Collectors.toList()), page2Result.getItemsList().stream().map(com.netflix.titus.grpc.protogen.Job::getId).collect(Collectors.toList()));
    assertThat(jobIds).contains(job1.getId(), job2.getId(), job3.getId());
}
Also used : Page(com.netflix.titus.grpc.protogen.Page) Job(com.netflix.titus.api.jobmanager.model.job.Job) JobQueryResult(com.netflix.titus.grpc.protogen.JobQueryResult) Test(org.junit.Test)

Example 10 with Page

use of com.netflix.titus.grpc.protogen.Page 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));
}
Also used : CallMetadata(com.netflix.titus.api.model.callmetadata.CallMetadata) JobQuery(com.netflix.titus.grpc.protogen.JobQuery) Page(com.netflix.titus.grpc.protogen.Page) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Page (com.netflix.titus.grpc.protogen.Page)14 TaskQuery (com.netflix.titus.grpc.protogen.TaskQuery)7 JobQuery (com.netflix.titus.grpc.protogen.JobQuery)6 TaskQueryResult (com.netflix.titus.grpc.protogen.TaskQueryResult)6 Test (org.junit.Test)6 JobQueryResult (com.netflix.titus.grpc.protogen.JobQueryResult)5 ApiOperation (io.swagger.annotations.ApiOperation)5 CallMetadata (com.netflix.titus.api.model.callmetadata.CallMetadata)4 Task (com.netflix.titus.grpc.protogen.Task)4 BaseIntegrationTest (com.netflix.titus.master.integration.BaseIntegrationTest)4 IntegrationTest (com.netflix.titus.testkit.junit.category.IntegrationTest)4 JobFunctions (com.netflix.titus.api.jobmanager.model.job.JobFunctions)3 Job (com.netflix.titus.grpc.protogen.Job)3 HashSet (java.util.HashSet)3 List (java.util.List)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Image (com.netflix.titus.api.jobmanager.model.job.Image)2 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)2 JobGroupInfo (com.netflix.titus.api.jobmanager.model.job.JobGroupInfo)2