Search in sources :

Example 1 with RemoveLoadBalancerRequest

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

the class AggregatingLoadbalancerService method removeLoadBalancer.

@Override
public Completable removeLoadBalancer(RemoveLoadBalancerRequest removeLoadBalancerRequest, CallMetadata callMetadata) {
    JobId jobId = JobId.newBuilder().setId(removeLoadBalancerRequest.getJobId()).build();
    final Observable<Empty> responseObservable = jobManagementServiceHelper.findJobInAllCells(jobId.getId(), callMetadata).flatMap(response -> singleCellCall(response.getCell(), (client, responseObserver) -> client.removeLoadBalancer(removeLoadBalancerRequest, responseObserver), callMetadata));
    return responseObservable.toCompletable();
}
Also used : Completable(rx.Completable) GetJobLoadBalancersResult(com.netflix.titus.grpc.protogen.GetJobLoadBalancersResult) GetAllLoadBalancersRequest(com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest) GrpcJobQueryModelConverters.toPagination(com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobQueryModelConverters.toPagination) AddLoadBalancerRequest(com.netflix.titus.grpc.protogen.AddLoadBalancerRequest) GetAllLoadBalancersResult(com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult) StringExt(com.netflix.titus.common.util.StringExt) PageAggregationUtil.takeCombinedPage(com.netflix.titus.federation.service.PageAggregationUtil.takeCombinedPage) Singleton(javax.inject.Singleton) Observable(rx.Observable) Inject(javax.inject.Inject) Empty(com.google.protobuf.Empty) CallMetadataResolver(com.netflix.titus.runtime.endpoint.metadata.CallMetadataResolver) StreamObserver(io.grpc.stub.StreamObserver) TitusServiceException(com.netflix.titus.api.service.TitusServiceException) Pair(com.netflix.titus.common.util.tuple.Pair) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) PageAggregationUtil.combinePagination(com.netflix.titus.federation.service.PageAggregationUtil.combinePagination) BiConsumer(java.util.function.BiConsumer) GrpcModelConverters(com.netflix.titus.runtime.loadbalancer.GrpcModelConverters) RemoveLoadBalancerRequest(com.netflix.titus.grpc.protogen.RemoveLoadBalancerRequest) LoadBalancerCursors(com.netflix.titus.runtime.loadbalancer.LoadBalancerCursors) CallMetadata(com.netflix.titus.api.model.callmetadata.CallMetadata) JobLoadBalancer(com.netflix.titus.api.loadbalancer.model.JobLoadBalancer) Cell(com.netflix.titus.api.federation.model.Cell) Pagination(com.netflix.titus.grpc.protogen.Pagination) GrpcUtil.createWrappedStub(com.netflix.titus.runtime.endpoint.common.grpc.GrpcUtil.createWrappedStub) Collectors(java.util.stream.Collectors) LoadBalancerServiceStub(com.netflix.titus.grpc.protogen.LoadBalancerServiceGrpc.LoadBalancerServiceStub) List(java.util.List) CellConnectorUtil.callToCell(com.netflix.titus.federation.service.CellConnectorUtil.callToCell) LoadBalancerServiceGrpc(com.netflix.titus.grpc.protogen.LoadBalancerServiceGrpc) GrpcJobQueryModelConverters.emptyGrpcPagination(com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobQueryModelConverters.emptyGrpcPagination) AbstractStub(io.grpc.stub.AbstractStub) LoadBalancerService(com.netflix.titus.runtime.service.LoadBalancerService) JobId(com.netflix.titus.grpc.protogen.JobId) Empty(com.google.protobuf.Empty) JobId(com.netflix.titus.grpc.protogen.JobId)

Example 2 with RemoveLoadBalancerRequest

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

the class LoadBalancerTests method removeLoadBalancerFromJob.

/**
 * Common testing helper that removes a load balancer id from a job. The helper ensures the
 * gRPC request was successful.
 */
public static void removeLoadBalancerFromJob(String jobId, LoadBalancerId loadBalancerId, BiConsumer<RemoveLoadBalancerRequest, TestStreamObserver<Empty>> removeLoadBalancers) {
    RemoveLoadBalancerRequest request = RemoveLoadBalancerRequest.newBuilder().setJobId(jobId).setLoadBalancerId(loadBalancerId).build();
    TestStreamObserver<Empty> removeResponse = new TestStreamObserver<>();
    removeLoadBalancers.accept(request, removeResponse);
    assertThatCode(removeResponse::awaitDone).doesNotThrowAnyException();
    assertThat(removeResponse.hasError()).isFalse();
}
Also used : Empty(com.google.protobuf.Empty) TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) RemoveLoadBalancerRequest(com.netflix.titus.grpc.protogen.RemoveLoadBalancerRequest)

Example 3 with RemoveLoadBalancerRequest

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

the class LoadBalancerSpringResourceTest method testRemoveLoadBalancer.

@Test
public void testRemoveLoadBalancer() throws Exception {
    RemoveLoadBalancerRequest forwardedRequest = RemoveLoadBalancerRequest.newBuilder().setJobId(JOB_ID).setLoadBalancerId(LoadBalancerId.newBuilder().setId(LOAD_BALANCER_ID).build()).build();
    when(serviceMock.removeLoadBalancer(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Completable.complete());
    SpringMockMvcUtil.doDelete(mockMvc, "/api/v3/loadBalancers", "jobId", JOB_ID, "loadBalancerId", LOAD_BALANCER_ID);
    verify(serviceMock, times(1)).removeLoadBalancer(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
Also used : RemoveLoadBalancerRequest(com.netflix.titus.grpc.protogen.RemoveLoadBalancerRequest) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Aggregations

RemoveLoadBalancerRequest (com.netflix.titus.grpc.protogen.RemoveLoadBalancerRequest)3 Empty (com.google.protobuf.Empty)2 Cell (com.netflix.titus.api.federation.model.Cell)1 JobLoadBalancer (com.netflix.titus.api.loadbalancer.model.JobLoadBalancer)1 CallMetadata (com.netflix.titus.api.model.callmetadata.CallMetadata)1 TitusServiceException (com.netflix.titus.api.service.TitusServiceException)1 StringExt (com.netflix.titus.common.util.StringExt)1 Pair (com.netflix.titus.common.util.tuple.Pair)1 CellConnectorUtil.callToCell (com.netflix.titus.federation.service.CellConnectorUtil.callToCell)1 PageAggregationUtil.combinePagination (com.netflix.titus.federation.service.PageAggregationUtil.combinePagination)1 PageAggregationUtil.takeCombinedPage (com.netflix.titus.federation.service.PageAggregationUtil.takeCombinedPage)1 GrpcConfiguration (com.netflix.titus.federation.startup.GrpcConfiguration)1 AddLoadBalancerRequest (com.netflix.titus.grpc.protogen.AddLoadBalancerRequest)1 GetAllLoadBalancersRequest (com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest)1 GetAllLoadBalancersResult (com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult)1 GetJobLoadBalancersResult (com.netflix.titus.grpc.protogen.GetJobLoadBalancersResult)1 JobId (com.netflix.titus.grpc.protogen.JobId)1 LoadBalancerServiceGrpc (com.netflix.titus.grpc.protogen.LoadBalancerServiceGrpc)1 LoadBalancerServiceStub (com.netflix.titus.grpc.protogen.LoadBalancerServiceGrpc.LoadBalancerServiceStub)1 Pagination (com.netflix.titus.grpc.protogen.Pagination)1