2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Bell Canada.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=========================================================
19 package org.onap.policy.cds.api;
21 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
25 * In order for the caller of {@link org.onap.policy.cds.client.CdsProcessorGrpcClient} to manage the callback to handle
26 * the received messages appropriately, it needs to implement {@link CdsProcessorListener}.
29 * <p>Here is a sample implementation of a listener:
31 * new CdsProcessorListener {
34 * public void onMessage(ExecutionServiceOutput message) {
35 * log.info("Received notification from CDS: {}", message);
39 * public void onError(Throwable throwable) {
40 * Status status = Status.fromThrowable(throwable);
41 * log.error("Failed processing blueprint {}", status, throwable);
47 public interface CdsProcessorListener {
50 * Implements the workflow upon receiving the message from the server side.
52 * <p>Note that the CDS client-server communication is configured to use a streaming approach, which means when
54 * sends an event, the server can reply with multiple sub-responses until full completion of the processing. Hence,
55 * it is up to the implementation of this method to process the received message using {@link
56 * ExecutionServiceOutput#getStatus()#getEventType()}</p>
58 * @param message ExecutionServiceOutput received by the CDS grpc server
60 void onMessage(ExecutionServiceOutput message);
63 * Implements the workflow when an error is received from the server side.
65 * @param throwable Throwable object received from CDS grpc server upon error
67 void onError(Throwable throwable);