Search in sources :

Example 1 with BluePrintProcessingServiceImplBase

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

the class GrpcNettyServer method start.

@PostConstruct
public void start() throws IOException {
    final BluePrintProcessingServiceImplBase blueprintPrcessorImpl = new BluePrintProcessingServiceImplBase() {

        @Override
        public StreamObserver<ExecutionServiceInput> process(StreamObserver<ExecutionServiceOutput> responseObserver) {
            responseObserverRef.set(responseObserver);
            StreamObserver<ExecutionServiceInput> requestObserver = new StreamObserver<ExecutionServiceInput>() {

                @Override
                public void onNext(ExecutionServiceInput message) {
                    detailedMessages.add(message);
                    logger.info("Message received: {}", message);
                    ExecutionServiceOutput executionServiceOutput = ExecutionServiceOutput.newBuilder().setActionIdentifiers(message.getActionIdentifiers()).setStatus(Status.newBuilder().setEventType(EventType.EVENT_COMPONENT_EXECUTED).build()).build();
                    responseObserverRef.get().onNext(executionServiceOutput);
                    logger.info("Message sent: {}", executionServiceOutput);
                }

                @Override
                public void onError(Throwable t) {
                    responseObserverRef.get().onError(t);
                }

                @Override
                public void onCompleted() {
                    allRequestsDelivered.countDown();
                    responseObserverRef.get().onCompleted();
                }
            };
            return requestObserver;
        }
    };
    grpcCleanup.register(ServerBuilder.forPort(Integer.valueOf(port)).directExecutor().addService(blueprintPrcessorImpl).build().start());
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) ExecutionServiceOutput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput) BluePrintProcessingServiceImplBase(org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) PostConstruct(javax.annotation.PostConstruct)

Example 2 with BluePrintProcessingServiceImplBase

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

the class CDSProcessingClientTest method setUp.

@Before
public void setUp() throws Exception {
    String serverName = InProcessServerBuilder.generateName();
    grpcCleanup.register(InProcessServerBuilder.forName(serverName).fallbackHandlerRegistry(serviceRegistry).directExecutor().build().start());
    handler = new CDSProcessingHandler(listener);
    client = new CDSProcessingClient(InProcessChannelBuilder.forName(serverName).directExecutor().build(), handler);
    final BluePrintProcessingServiceImplBase routeChatImpl = new BluePrintProcessingServiceImplBase() {

        @Override
        public StreamObserver<ExecutionServiceInput> process(StreamObserver<ExecutionServiceOutput> responseObserver) {
            responseObserverRef.set(responseObserver);
            StreamObserver<ExecutionServiceInput> requestObserver = new StreamObserver<ExecutionServiceInput>() {

                @Override
                public void onNext(ExecutionServiceInput message) {
                    messagesDelivered.add(message.getActionIdentifiers().getActionName());
                }

                @Override
                public void onError(Throwable t) {
                }

                @Override
                public void onCompleted() {
                    allRequestsDelivered.countDown();
                }
            };
            return requestObserver;
        }
    };
    serviceRegistry.addService(routeChatImpl);
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) BluePrintProcessingServiceImplBase(org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) Before(org.junit.Before)

Aggregations

StreamObserver (io.grpc.stub.StreamObserver)2 BluePrintProcessingServiceImplBase (org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase)2 ExecutionServiceInput (org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput)2 PostConstruct (javax.annotation.PostConstruct)1 Before (org.junit.Before)1 ExecutionServiceOutput (org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput)1