Search in sources :

Example 1 with CallbackCountDownLatch

use of com.netflix.titus.common.util.concurrency.CallbackCountDownLatch 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);
}
Also used : EmitterWithMultipleSubscriptions(com.netflix.titus.common.util.rx.EmitterWithMultipleSubscriptions) JobChangeNotification(com.netflix.titus.grpc.protogen.JobChangeNotification) JobManagementServiceGrpc(com.netflix.titus.grpc.protogen.JobManagementServiceGrpc) CallbackCountDownLatch(com.netflix.titus.common.util.concurrency.CallbackCountDownLatch) CountDownLatch(java.util.concurrent.CountDownLatch) CallbackCountDownLatch(com.netflix.titus.common.util.concurrency.CallbackCountDownLatch) Cell(com.netflix.titus.api.federation.model.Cell) CellConnectorUtil.callToCell(com.netflix.titus.federation.service.CellConnectorUtil.callToCell) JobManagementServiceStub(com.netflix.titus.grpc.protogen.JobManagementServiceGrpc.JobManagementServiceStub)

Aggregations

Cell (com.netflix.titus.api.federation.model.Cell)1 CallbackCountDownLatch (com.netflix.titus.common.util.concurrency.CallbackCountDownLatch)1 EmitterWithMultipleSubscriptions (com.netflix.titus.common.util.rx.EmitterWithMultipleSubscriptions)1 CellConnectorUtil.callToCell (com.netflix.titus.federation.service.CellConnectorUtil.callToCell)1 JobChangeNotification (com.netflix.titus.grpc.protogen.JobChangeNotification)1 JobManagementServiceGrpc (com.netflix.titus.grpc.protogen.JobManagementServiceGrpc)1 JobManagementServiceStub (com.netflix.titus.grpc.protogen.JobManagementServiceGrpc.JobManagementServiceStub)1 CountDownLatch (java.util.concurrent.CountDownLatch)1