use of com.netflix.titus.grpc.protogen.JobManagementServiceGrpc in project titus-control-plane by Netflix.
the class AggregatingJobServiceGateway method createJob.
@Override
public Observable<String> createJob(JobDescriptor jobDescriptor, CallMetadata callMetadata) {
Cell cell = router.routeKey(jobDescriptor).orElse(null);
if (cell == null) {
// This should never happen in a correctly setup system.
return Observable.error(new IllegalStateException("Internal system error. Routing rule not found"));
}
logger.debug("Routing JobDescriptor {} to Cell {}", jobDescriptor, cell);
Optional<JobManagementServiceStub> optionalClient = CellConnectorUtil.toStub(cell, cellConnector, JobManagementServiceGrpc::newStub);
if (!optionalClient.isPresent()) {
return Observable.error(TitusServiceException.cellNotFound(cell.getName()));
}
JobManagementServiceStub client = optionalClient.get();
JobDescriptor.Builder jobDescriptorBuilder = addStackName(jobDescriptor.toBuilder());
jobDescriptorBuilder = removeFederationAttributes(jobDescriptorBuilder);
jobDescriptorBuilder = addRoutingCell(jobDescriptorBuilder, cell);
JobDescriptor jd = jobDescriptorBuilder.build();
return createRequestObservable(emitter -> {
StreamObserver<JobId> streamObserver = GrpcUtil.createClientResponseObserver(emitter, jobId -> emitter.onNext(jobId.getId()), emitter::onError, emitter::onCompleted);
wrap(client, callMetadata).createJob(jd, streamObserver);
}, grpcConfiguration.getRequestTimeoutMs());
}
use of com.netflix.titus.grpc.protogen.JobManagementServiceGrpc in project titus-control-plane by Netflix.
the class AggregatingJobServiceGateway method observeJobs.
@Override
public Observable<JobChangeNotification> observeJobs(ObserveJobsQuery query, CallMetadata callMetadata) {
final Observable<JobChangeNotification> observable = createRequestObservable(delegate -> {
Emitter<JobChangeNotification> emitter = new EmitterWithMultipleSubscriptions<>(delegate);
Map<Cell, JobManagementServiceStub> clients = CellConnectorUtil.stubs(cellConnector, JobManagementServiceGrpc::newStub);
final CountDownLatch markersEmitted = new CallbackCountDownLatch(clients.size(), () -> emitter.onNext(buildJobSnapshotEndMarker()));
clients.forEach((cell, client) -> {
StreamObserver<JobChangeNotification> streamObserver = new FilterOutFirstMarker(emitter, markersEmitted);
wrapWithNoDeadline(client, callMetadata).observeJobs(query, streamObserver);
});
});
return observable.map(this::addStackName);
}
Aggregations