Search in sources :

Example 1 with BluePrintProcessingServiceStub

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub in project so by onap.

the class CDSProcessingHandler method process.

CountDownLatch process(ExecutionServiceInput request, ManagedChannel channel) {
    ActionIdentifiers header = request.getActionIdentifiers();
    log.info("Processing blueprint({}:{}) for action({})", header.getBlueprintVersion(), header.getBlueprintName(), header.getActionName());
    final CountDownLatch finishLatch = new CountDownLatch(1);
    final BluePrintProcessingServiceStub asyncStub = BluePrintProcessingServiceGrpc.newStub(channel);
    final StreamObserver<ExecutionServiceOutput> responseObserver = new StreamObserver<ExecutionServiceOutput>() {

        @Override
        public void onNext(ExecutionServiceOutput output) {
            listener.onMessage(output);
        }

        @Override
        public void onError(Throwable t) {
            listener.onError(t);
            finishLatch.countDown();
        }

        @Override
        public void onCompleted() {
            log.info("Completed blueprint({}:{}) for action({})", header.getBlueprintVersion(), header.getBlueprintName(), header.getBlueprintVersion());
            finishLatch.countDown();
        }
    };
    final StreamObserver<ExecutionServiceInput> requestObserver = asyncStub.process(responseObserver);
    try {
        // Send our message to CDS backend for processing
        requestObserver.onNext(request);
        // Mark the end of requests
        requestObserver.onCompleted();
    } catch (RuntimeException e) {
        requestObserver.onError(e);
    }
    return finishLatch;
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) ExecutionServiceOutput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput) CountDownLatch(java.util.concurrent.CountDownLatch) ActionIdentifiers(org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers) BluePrintProcessingServiceStub(org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput)

Aggregations

StreamObserver (io.grpc.stub.StreamObserver)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ActionIdentifiers (org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers)1 BluePrintProcessingServiceStub (org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub)1 ExecutionServiceInput (org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput)1 ExecutionServiceOutput (org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput)1