use of com.netflix.titus.grpc.protogen.AddLoadBalancerRequest in project titus-control-plane by Netflix.
the class AggregatingLoadbalancerService method addLoadBalancer.
@Override
public Completable addLoadBalancer(AddLoadBalancerRequest request, CallMetadata callMetadata) {
JobId jobId = JobId.newBuilder().setId(request.getJobId()).build();
final Observable<Empty> responseObservable = jobManagementServiceHelper.findJobInAllCells(jobId.getId(), callMetadata).flatMap(response -> singleCellCall(response.getCell(), (client, responseObserver) -> client.addLoadBalancer(request, responseObserver), callMetadata));
return responseObservable.toCompletable();
}
use of com.netflix.titus.grpc.protogen.AddLoadBalancerRequest in project titus-control-plane by Netflix.
the class LoadBalancerTests method putLoadBalancersPerJob.
/**
* Common testing helper that adds a specified number of random load balancer ids to
* a specified number of jobs. The helper ensures the gRPC request was successful and
* returns the job ids and load balancer ids as a map.
*/
public static Map<String, Set<LoadBalancerId>> putLoadBalancersPerJob(int numJobs, int numLoadBalancersPerJob, BiConsumer<AddLoadBalancerRequest, TestStreamObserver<Empty>> putLoadBalancer) {
// Create job entries
Map<String, Set<LoadBalancerId>> jobIdToLoadBalancersMap = new ConcurrentHashMap<>();
for (int i = 1; i <= numJobs; i++) {
jobIdToLoadBalancersMap.put("Titus-" + i, new HashSet<>());
}
// For each job, insert load balancers
jobIdToLoadBalancersMap.forEach((jobId, loadBalancerSet) -> {
for (int i = 0; i < numLoadBalancersPerJob; i++) {
LoadBalancerId loadBalancerId = LoadBalancerId.newBuilder().setId(RandomStringUtils.randomAlphanumeric(10)).build();
AddLoadBalancerRequest request = AddLoadBalancerRequest.newBuilder().setJobId(jobId).setLoadBalancerId(loadBalancerId).build();
TestStreamObserver<Empty> addResponse = new TestStreamObserver<>();
putLoadBalancer.accept(request, addResponse);
assertThatCode(addResponse::awaitDone).doesNotThrowAnyException();
assertThat(addResponse.hasError()).isFalse();
loadBalancerSet.add(loadBalancerId);
}
});
return jobIdToLoadBalancersMap;
}
use of com.netflix.titus.grpc.protogen.AddLoadBalancerRequest in project titus-control-plane by Netflix.
the class LoadBalancerSpringResourceTest method testAddLoadBalancer.
@Test
public void testAddLoadBalancer() throws Exception {
AddLoadBalancerRequest forwardedRequest = AddLoadBalancerRequest.newBuilder().setJobId(JOB_ID).setLoadBalancerId(LoadBalancerId.newBuilder().setId(LOAD_BALANCER_ID).build()).build();
when(serviceMock.addLoadBalancer(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Completable.complete());
SpringMockMvcUtil.doPost(mockMvc, "/api/v3/loadBalancers", Optional.empty(), Optional.empty(), Optional.of(new String[] { "jobId", JOB_ID, "loadBalancerId", LOAD_BALANCER_ID }));
verify(serviceMock, times(1)).addLoadBalancer(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
Aggregations