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}.
30 * Here is a sample implementation of a listener:
33 * new CdsProcessorListener {
36 * public void onMessage(ExecutionServiceOutput message) {
37 * log.info("Received notification from CDS: {}", message);
41 * public void onError(Throwable throwable) {
42 * Status status = Status.fromThrowable(throwable);
43 * log.error("Failed processing blueprint {}", status, throwable);
49 public interface CdsProcessorListener {
52 * Implements the workflow upon receiving the message from the server side.
54 * <p>Note that the CDS client-server communication is configured to use a streaming approach, which means when a
55 * client sends an event, the server can reply with multiple sub-responses until full completion of the processing.
56 * Hence, it is up to the implementation of this method to process the received message using the
57 * getStatus().getEventType() method of {@link ExecutionServiceOutput}
59 * @param message ExecutionServiceOutput received by the CDS grpc server
61 void onMessage(ExecutionServiceOutput message);
64 * Implements the workflow when an error is received from the server side.
66 * @param throwable Throwable object received from CDS grpc server upon error
68 void onError(Throwable throwable);