2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2023 Nordix Foundation.
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.clamp.acm.runtime.supervision.comm;
23 import io.micrometer.core.annotation.Timed;
24 import java.util.UUID;
25 import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
26 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
27 import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
28 import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder;
29 import org.springframework.stereotype.Component;
32 * This class is used to send AutomationCompositionStateChangePublisher messages to participants on DMaaP.
35 public class AutomationCompositionStateChangePublisher
36 extends AbstractParticipantPublisher<AutomationCompositionStateChange> {
39 * Send undeploy message to to Participant.
41 * @param automationComposition the AutomationComposition
42 * @param startPhase the startPhase
45 value = "publisher.automation_composition_state_change",
46 description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
47 public void undeploy(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase) {
48 send(automationComposition, startPhase, firstStartPhase, DeployOrder.UNDEPLOY, LockOrder.NONE);
52 * Send unlock message to to Participant.
54 * @param automationComposition the AutomationComposition
55 * @param startPhase the startPhase
58 value = "publisher.automation_composition_state_change",
59 description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
60 public void unlock(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase) {
61 send(automationComposition, startPhase, firstStartPhase, DeployOrder.NONE, LockOrder.UNLOCK);
65 * Send lock message to to Participant.
67 * @param automationComposition the AutomationComposition
68 * @param startPhase the startPhase
71 value = "publisher.automation_composition_state_change",
72 description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
73 public void lock(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase) {
74 send(automationComposition, startPhase, firstStartPhase, DeployOrder.NONE, LockOrder.LOCK);
78 * Send undeploy message to to Participant.
80 * @param automationComposition the AutomationComposition
81 * @param startPhase the startPhase
82 * @param deployOrder the DeployOrder
83 * @param lockOrder the LockOrder
85 private void send(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase,
86 DeployOrder deployOrder, LockOrder lockOrder) {
87 var acsc = new AutomationCompositionStateChange();
88 acsc.setCompositionId(automationComposition.getCompositionId());
89 acsc.setAutomationCompositionId(automationComposition.getInstanceId());
90 acsc.setMessageId(UUID.randomUUID());
91 acsc.setDeployOrderedState(deployOrder);
92 acsc.setLockOrderedState(lockOrder);
93 acsc.setStartPhase(startPhase);
94 acsc.setFirstStartPhase(firstStartPhase);
100 * Send AutomationCompositionStateChange to Participant.
102 * @param automationComposition the AutomationComposition
103 * @param startPhase the startPhase
106 value = "publisher.automation_composition_state_change",
107 description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
108 public void send(AutomationComposition automationComposition, int startPhase) {
109 var acsc = new AutomationCompositionStateChange();
110 acsc.setCompositionId(automationComposition.getCompositionId());
111 acsc.setAutomationCompositionId(automationComposition.getInstanceId());
112 acsc.setMessageId(UUID.randomUUID());
113 acsc.setOrderedState(automationComposition.getOrderedState());
114 acsc.setStartPhase(startPhase);