2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Bell Canada. All rights reserved.
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.controlloop.actor.cds;
21 import java.util.concurrent.CompletableFuture;
22 import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
23 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
24 import org.onap.policy.cds.api.CdsProcessorListener;
25 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
26 import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * CDS Actor service-manager implementation.
33 public class CdsActorServiceManager implements CdsProcessorListener {
35 private static final Logger LOGGER = LoggerFactory.getLogger(CdsActorServiceManager.class);
37 private final CompletableFuture<OperationOutcome> future;
39 private final OperationOutcome outcome;
42 * Constructs the object.
44 * @param outcome the operation outcome to populate
45 * @param future the future to complete
47 public CdsActorServiceManager(OperationOutcome outcome, CompletableFuture<OperationOutcome> future) {
48 this.outcome = outcome;
56 public void onMessage(final ExecutionServiceOutput message) {
57 LOGGER.info("Received notification from CDS: {}", message);
58 EventType eventType = message.getStatus().getEventType();
60 case EVENT_COMPONENT_PROCESSING:
61 LOGGER.info("CDS is processing the message: {}", message);
63 case EVENT_COMPONENT_EXECUTED:
64 outcome.setResult(OperationResult.SUCCESS);
65 outcome.setResponse(message);
66 future.complete(outcome);
69 outcome.setResult(OperationResult.FAILURE);
70 outcome.setResponse(message);
71 future.complete(outcome);
80 public void onError(final Throwable throwable) {
81 future.completeExceptionally(throwable);