Remove actor and recipe checks from ControlLoopCompiler.java
[policy/models.git] / models-interactions / model-impl / cds / src / main / java / org / onap / policy / cds / api / CdsProcessorListener.java
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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=========================================================
17  */
18
19 package org.onap.policy.cds.api;
20
21 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
22
23 /**
24  * <p>
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}.
27  * </p>
28  *
29  * <p>Here is a sample implementation of a listener:
30  * <pre>
31  * new CdsProcessorListener {
32  *
33  *     &#64;Override
34  *     public void onMessage(ExecutionServiceOutput message) {
35  *         log.info("Received notification from CDS: {}", message);
36  *     }
37  *
38  *     &#64;Override
39  *     public void onError(Throwable throwable) {
40  *         Status status = Status.fromThrowable(throwable);
41  *         log.error("Failed processing blueprint {}", status, throwable);
42  *     }
43  * }
44  * </pre>
45  * </p>
46  */
47 public interface CdsProcessorListener {
48
49     /**
50      * Implements the workflow upon receiving the message from the server side.
51      *
52      * <p>Note that the CDS client-server communication is configured to use a streaming approach, which means when
53      * client
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>
57      *
58      * @param message ExecutionServiceOutput received by the CDS grpc server
59      */
60     void onMessage(ExecutionServiceOutput message);
61
62     /**
63      * Implements the workflow when an error is received from the server side.
64      *
65      * @param throwable Throwable object received from CDS grpc server upon error
66      */
67     void onError(Throwable throwable);
68
69 }