summaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-acm/src/main')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java6
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java10
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionPartecipantScanner.java93
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java113
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java43
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java70
6 files changed, 148 insertions, 187 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
index 3e79e78c1..5fcb3837f 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
@@ -79,7 +79,7 @@ public class SupervisionAcHandler {
AcmUtils.setCascadedState(automationComposition, DeployState.UNDEPLOYING, LockState.NONE);
automationCompositionProvider.updateAutomationComposition(automationComposition);
var startPhase = ParticipantUtils.getFirstStartPhase(automationComposition, acDefinition.getServiceTemplate());
- automationCompositionStateChangePublisher.undeploy(automationComposition, startPhase, true);
+ automationCompositionStateChangePublisher.send(automationComposition, startPhase, true);
}
/**
@@ -92,7 +92,7 @@ public class SupervisionAcHandler {
AcmUtils.setCascadedState(automationComposition, DeployState.DEPLOYED, LockState.UNLOCKING);
automationCompositionProvider.updateAutomationComposition(automationComposition);
var startPhase = ParticipantUtils.getFirstStartPhase(automationComposition, acDefinition.getServiceTemplate());
- automationCompositionStateChangePublisher.unlock(automationComposition, startPhase, true);
+ automationCompositionStateChangePublisher.send(automationComposition, startPhase, true);
}
/**
@@ -105,7 +105,7 @@ public class SupervisionAcHandler {
AcmUtils.setCascadedState(automationComposition, DeployState.DEPLOYED, LockState.LOCKING);
automationCompositionProvider.updateAutomationComposition(automationComposition);
var startPhase = ParticipantUtils.getFirstStartPhase(automationComposition, acDefinition.getServiceTemplate());
- automationCompositionStateChangePublisher.lock(automationComposition, startPhase, true);
+ automationCompositionStateChangePublisher.send(automationComposition, startPhase, true);
}
/**
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java
index 8d1f98388..ef50a633e 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java
@@ -43,6 +43,7 @@ public class SupervisionAspect implements Closeable {
private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionAspect.class);
private final SupervisionScanner supervisionScanner;
+ private final SupervisionPartecipantScanner partecipantScanner;
private ThreadPoolExecutor executor =
new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
@@ -52,7 +53,12 @@ public class SupervisionAspect implements Closeable {
initialDelayString = "${runtime.participantParameters.heartBeatMs}")
public void schedule() {
LOGGER.info("Add scheduled scanning");
- executor.execute(() -> supervisionScanner.run(true));
+ executor.execute(this::executeScan);
+ }
+
+ private void executeScan() {
+ supervisionScanner.run(true);
+ partecipantScanner.run();
}
/**
@@ -68,7 +74,7 @@ public class SupervisionAspect implements Closeable {
@Before("@annotation(MessageIntercept) && args(participantStatusMessage,..)")
public void handleParticipantStatus(ParticipantStatus participantStatusMessage) {
- executor.execute(() -> supervisionScanner.handleParticipantStatus(participantStatusMessage.getParticipantId()));
+ executor.execute(() -> partecipantScanner.handleParticipantStatus(participantStatusMessage.getParticipantId()));
}
@Override
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionPartecipantScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionPartecipantScanner.java
new file mode 100644
index 000000000..b396e629c
--- /dev/null
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionPartecipantScanner.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.runtime.supervision;
+
+import java.util.UUID;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is used to scan the automation compositions in the database and check if they are in the correct state.
+ */
+@Component
+public class SupervisionPartecipantScanner {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionPartecipantScanner.class);
+
+ private final HandleCounter<UUID> participantStatusCounter = new HandleCounter<>();
+
+ private final ParticipantProvider participantProvider;
+
+ /**
+ * Constructor for instantiating SupervisionPartecipantScanner.
+ *
+ * @param participantProvider the Participant Provider
+ * @param acRuntimeParameterGroup the parameters for the automation composition runtime
+ */
+ public SupervisionPartecipantScanner(
+ final ParticipantProvider participantProvider,
+ final AcRuntimeParameterGroup acRuntimeParameterGroup) {
+ this.participantProvider = participantProvider;
+
+ participantStatusCounter.setMaxRetryCount(
+ acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
+ participantStatusCounter.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
+ }
+
+ /**
+ * Run Scanning.
+ */
+ public void run() {
+ LOGGER.debug("Scanning participans in the database . . .");
+
+ for (var participant : participantProvider.getParticipants()) {
+ scanParticipantStatus(participant);
+ }
+
+ LOGGER.debug("Participans scan complete . . .");
+ }
+
+ private void scanParticipantStatus(Participant participant) {
+ var id = participant.getParticipantId();
+ if (participantStatusCounter.isFault(id)) {
+ LOGGER.debug("report Participant fault");
+ return;
+ }
+ if (participantStatusCounter.getDuration(id) > participantStatusCounter.getMaxWaitMs()
+ && !participantStatusCounter.count(id)) {
+ LOGGER.debug("report Participant fault");
+ participantStatusCounter.setFault(id);
+ participant.setParticipantState(ParticipantState.OFF_LINE);
+ participantProvider.updateParticipant(participant);
+ }
+ }
+
+ /**
+ * handle participant Status message.
+ */
+ public void handleParticipantStatus(UUID id) {
+ participantStatusCounter.clear(id);
+ }
+}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
index 68ec44dc0..7ee7267e2 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
@@ -29,13 +29,11 @@ import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionDeployPublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
+import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,15 +47,12 @@ public class SupervisionScanner {
private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class);
private final HandleCounter<UUID> automationCompositionCounter = new HandleCounter<>();
- private final HandleCounter<UUID> participantStatusCounter = new HandleCounter<>();
-
private final Map<UUID, Integer> phaseMap = new HashMap<>();
private final AutomationCompositionProvider automationCompositionProvider;
private final AcDefinitionProvider acDefinitionProvider;
private final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher;
private final AutomationCompositionDeployPublisher automationCompositionDeployPublisher;
- private final ParticipantProvider participantProvider;
/**
* Constructor for instantiating SupervisionScanner.
@@ -66,29 +61,22 @@ public class SupervisionScanner {
* @param acDefinitionProvider the Policy Models Provider
* @param automationCompositionStateChangePublisher the AutomationComposition StateChange Publisher
* @param automationCompositionDeployPublisher the AutomationCompositionUpdate Publisher
- * @param participantProvider the Participant Provider
* @param acRuntimeParameterGroup the parameters for the automation composition runtime
*/
public SupervisionScanner(final AutomationCompositionProvider automationCompositionProvider,
- AcDefinitionProvider acDefinitionProvider,
- final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher,
- AutomationCompositionDeployPublisher automationCompositionDeployPublisher,
- ParticipantProvider participantProvider,
- final AcRuntimeParameterGroup acRuntimeParameterGroup) {
+ final AcDefinitionProvider acDefinitionProvider,
+ final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher,
+ final AutomationCompositionDeployPublisher automationCompositionDeployPublisher,
+ final AcRuntimeParameterGroup acRuntimeParameterGroup) {
this.automationCompositionProvider = automationCompositionProvider;
this.acDefinitionProvider = acDefinitionProvider;
this.automationCompositionStateChangePublisher = automationCompositionStateChangePublisher;
this.automationCompositionDeployPublisher = automationCompositionDeployPublisher;
- this.participantProvider = participantProvider;
automationCompositionCounter.setMaxRetryCount(
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
+ acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
automationCompositionCounter
- .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
-
- participantStatusCounter.setMaxRetryCount(
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
- participantStatusCounter.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
+ .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
}
/**
@@ -99,12 +87,6 @@ public class SupervisionScanner {
public void run(boolean counterCheck) {
LOGGER.debug("Scanning automation compositions in the database . . .");
- if (counterCheck) {
- for (var participant : participantProvider.getParticipants()) {
- scanParticipantStatus(participant);
- }
- }
-
var list = acDefinitionProvider.getAllAcDefinitions();
for (var acDefinition : list) {
var acList = automationCompositionProvider.getAcInstancesByCompositionId(acDefinition.getCompositionId());
@@ -116,33 +98,12 @@ public class SupervisionScanner {
LOGGER.debug("Automation composition scan complete . . .");
}
- private void scanParticipantStatus(Participant participant) {
- var id = participant.getParticipantId();
- if (participantStatusCounter.isFault(id)) {
- LOGGER.debug("report Participant fault");
- return;
- }
- if (participantStatusCounter.getDuration(id) > participantStatusCounter.getMaxWaitMs()
- && !participantStatusCounter.count(id)) {
- LOGGER.debug("report Participant fault");
- participantStatusCounter.setFault(id);
- participant.setParticipantState(ParticipantState.OFF_LINE);
- participantProvider.updateParticipant(participant);
- }
- }
-
- /**
- * handle participant Status message.
- */
- public void handleParticipantStatus(UUID id) {
- participantStatusCounter.clear(id);
- }
-
private void scanAutomationComposition(final AutomationComposition automationComposition,
- ToscaServiceTemplate toscaServiceTemplate, boolean counterCheck) {
+ ToscaServiceTemplate serviceTemplate, boolean counterCheck) {
LOGGER.debug("scanning automation composition {} . . .", automationComposition.getInstanceId());
- if (automationComposition.getState().equals(automationComposition.getOrderedState().asState())) {
+ if (!AcmUtils.isInTransitionalState(automationComposition.getDeployState(),
+ automationComposition.getLockState())) {
LOGGER.debug("automation composition {} scanned, OK", automationComposition.getInstanceId());
// Clear missed report counter on automation composition
@@ -156,12 +117,12 @@ public class SupervisionScanner {
var defaultMin = 1000; // min startPhase
var defaultMax = 0; // max startPhase
for (var element : automationComposition.getElements().values()) {
- var toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()
- .get(element.getDefinition().getName());
+ var toscaNodeTemplate = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates()
+ .get(element.getDefinition().getName());
int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties());
defaultMin = Math.min(defaultMin, startPhase);
defaultMax = Math.max(defaultMax, startPhase);
- if (!element.getState().equals(element.getOrderedState().asState())) {
+ if (AcmUtils.isInTransitionalState(element.getDeployState(), element.getLockState())) {
completed = false;
minSpNotCompleted = Math.min(minSpNotCompleted, startPhase);
maxSpNotCompleted = Math.max(maxSpNotCompleted, startPhase);
@@ -169,36 +130,35 @@ public class SupervisionScanner {
}
if (completed) {
- LOGGER.debug("automation composition scan: transition from state {} to {} completed",
- automationComposition.getState(), automationComposition.getOrderedState());
+ LOGGER.debug("automation composition scan: transition state {} {} ", automationComposition.getDeployState(),
+ automationComposition.getLockState());
- automationComposition.setState(automationComposition.getOrderedState().asState());
+ var deployState = automationComposition.getDeployState();
+ automationComposition.setDeployState(AcmUtils.deployCompleted(deployState));
+ automationComposition
+ .setLockState(AcmUtils.lockCompleted(deployState, automationComposition.getLockState()));
automationCompositionProvider.updateAutomationComposition(automationComposition);
// Clear missed report counter on automation composition
clearFaultAndCounter(automationComposition);
} else {
LOGGER.debug("automation composition scan: transition from state {} to {} not completed",
- automationComposition.getState(), automationComposition.getOrderedState());
+ automationComposition.getDeployState(), automationComposition.getLockState());
- var nextSpNotCompleted =
- AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState())
- || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState())
- ? minSpNotCompleted
- : maxSpNotCompleted;
+ var isForward =
+ AcmUtils.isForward(automationComposition.getDeployState(), automationComposition.getLockState());
- var firstStartPhase =
- AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState())
- || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState())
- ? defaultMin
- : defaultMax;
+ var nextSpNotCompleted = isForward ? minSpNotCompleted : maxSpNotCompleted;
+ var firstStartPhase = isForward ? defaultMin : defaultMax;
if (nextSpNotCompleted != phaseMap.getOrDefault(automationComposition.getInstanceId(), firstStartPhase)) {
phaseMap.put(automationComposition.getInstanceId(), nextSpNotCompleted);
- sendAutomationCompositionMsg(automationComposition, nextSpNotCompleted);
+ sendAutomationCompositionMsg(automationComposition, serviceTemplate, nextSpNotCompleted,
+ firstStartPhase == nextSpNotCompleted);
} else if (counterCheck) {
phaseMap.put(automationComposition.getInstanceId(), nextSpNotCompleted);
- handleCounter(automationComposition, nextSpNotCompleted);
+ handleCounter(automationComposition, serviceTemplate, nextSpNotCompleted,
+ firstStartPhase == nextSpNotCompleted);
}
}
}
@@ -208,7 +168,8 @@ public class SupervisionScanner {
phaseMap.remove(automationComposition.getInstanceId());
}
- private void handleCounter(AutomationComposition automationComposition, int startPhase) {
+ private void handleCounter(AutomationComposition automationComposition, ToscaServiceTemplate serviceTemplate,
+ int startPhase, boolean firstStartPhase) {
var instanceId = automationComposition.getInstanceId();
if (automationCompositionCounter.isFault(instanceId)) {
LOGGER.debug("report AutomationComposition fault");
@@ -218,7 +179,7 @@ public class SupervisionScanner {
if (automationCompositionCounter.getDuration(instanceId) > automationCompositionCounter.getMaxWaitMs()) {
if (automationCompositionCounter.count(instanceId)) {
phaseMap.put(instanceId, startPhase);
- sendAutomationCompositionMsg(automationComposition, startPhase);
+ sendAutomationCompositionMsg(automationComposition, serviceTemplate, startPhase, firstStartPhase);
} else {
LOGGER.debug("report AutomationComposition fault");
automationCompositionCounter.setFault(instanceId);
@@ -226,13 +187,15 @@ public class SupervisionScanner {
}
}
- private void sendAutomationCompositionMsg(AutomationComposition automationComposition, int startPhase) {
- if (AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState())) {
+ private void sendAutomationCompositionMsg(AutomationComposition automationComposition,
+ ToscaServiceTemplate serviceTemplate, int startPhase, boolean firstStartPhase) {
+ if (DeployState.DEPLOYING.equals(automationComposition.getDeployState())) {
LOGGER.debug("retry message AutomationCompositionUpdate");
- automationCompositionDeployPublisher.send(automationComposition, startPhase);
+ automationCompositionDeployPublisher.send(automationComposition, serviceTemplate, startPhase,
+ firstStartPhase);
} else {
LOGGER.debug("retry message AutomationCompositionStateChange");
- automationCompositionStateChangePublisher.send(automationComposition, startPhase);
+ automationCompositionStateChangePublisher.send(automationComposition, startPhase, firstStartPhase);
}
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
index cc4a05939..2628f030d 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
@@ -36,7 +36,6 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeploy;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
-import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -53,53 +52,13 @@ import org.springframework.stereotype.Component;
public class AutomationCompositionDeployPublisher extends AbstractParticipantPublisher<AutomationCompositionDeploy> {
private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionDeployPublisher.class);
- private final AcDefinitionProvider acDefinitionProvider;
-
- /**
- * Send AutomationCompositionDeploy to Participant.
- *
- * @param automationComposition the AutomationComposition
- */
- @Timed(value = "publisher.automation_composition_deploy",
- description = "AUTOMATION_COMPOSITION_DEPLOY messages published")
- public void send(AutomationComposition automationComposition) {
- send(automationComposition, 0);
- }
-
- /**
- * Send AutomationCompositionDeploy to Participant.
- *
- * @param automationComposition the AutomationComposition
- * @param startPhase the Start Phase
- */
- @Timed(value = "publisher.automation_composition_deploy",
- description = "AUTOMATION_COMPOSITION_DEPLOY messages published")
- public void send(AutomationComposition automationComposition, int startPhase) {
- var acDeployMsg = new AutomationCompositionDeploy();
- acDeployMsg.setCompositionId(automationComposition.getCompositionId());
- acDeployMsg.setStartPhase(startPhase);
- acDeployMsg.setAutomationCompositionId(automationComposition.getInstanceId());
- acDeployMsg.setMessageId(UUID.randomUUID());
- acDeployMsg.setTimestamp(Instant.now());
- var toscaServiceTemplate =
- acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()).getServiceTemplate();
-
- List<ParticipantDeploy> participantDeploys = new ArrayList<>();
- for (var element : automationComposition.getElements().values()) {
- element.setToscaServiceTemplateFragment(AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate));
- AcmUtils.prepareParticipantUpdate(element, participantDeploys);
- }
- acDeployMsg.setParticipantUpdatesList(participantDeploys);
-
- LOGGER.debug("AutomationCompositionDeploy message sent {}", acDeployMsg);
- super.send(acDeployMsg);
- }
/**
* Send AutomationCompositionDeploy to Participant.
*
* @param automationComposition the AutomationComposition
* @param startPhase the Start Phase
+ * @param firstStartPhase true if the first StartPhase
*/
@Timed(value = "publisher.automation_composition_deploy",
description = "AUTOMATION_COMPOSITION_DEPLOY messages published")
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java
index 56a62e13b..e59c2ac18 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java
@@ -24,8 +24,7 @@ import io.micrometer.core.annotation.Timed;
import java.util.UUID;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder;
+import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.springframework.stereotype.Component;
/**
@@ -36,7 +35,7 @@ public class AutomationCompositionStateChangePublisher
extends AbstractParticipantPublisher<AutomationCompositionStateChange> {
/**
- * Send undeploy message to to Participant.
+ * Send AutomationCompositionStateChange message to to Participant.
*
* @param automationComposition the AutomationComposition
* @param startPhase the startPhase
@@ -44,75 +43,16 @@ public class AutomationCompositionStateChangePublisher
@Timed(
value = "publisher.automation_composition_state_change",
description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
- public void undeploy(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase) {
- send(automationComposition, startPhase, firstStartPhase, DeployOrder.UNDEPLOY, LockOrder.NONE);
- }
-
- /**
- * Send unlock message to to Participant.
- *
- * @param automationComposition the AutomationComposition
- * @param startPhase the startPhase
- */
- @Timed(
- value = "publisher.automation_composition_state_change",
- description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
- public void unlock(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase) {
- send(automationComposition, startPhase, firstStartPhase, DeployOrder.NONE, LockOrder.UNLOCK);
- }
-
- /**
- * Send lock message to to Participant.
- *
- * @param automationComposition the AutomationComposition
- * @param startPhase the startPhase
- */
- @Timed(
- value = "publisher.automation_composition_state_change",
- description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
- public void lock(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase) {
- send(automationComposition, startPhase, firstStartPhase, DeployOrder.NONE, LockOrder.LOCK);
- }
-
- /**
- * Send undeploy message to to Participant.
- *
- * @param automationComposition the AutomationComposition
- * @param startPhase the startPhase
- * @param deployOrder the DeployOrder
- * @param lockOrder the LockOrder
- */
- private void send(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase,
- DeployOrder deployOrder, LockOrder lockOrder) {
+ public void send(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase) {
var acsc = new AutomationCompositionStateChange();
acsc.setCompositionId(automationComposition.getCompositionId());
acsc.setAutomationCompositionId(automationComposition.getInstanceId());
acsc.setMessageId(UUID.randomUUID());
- acsc.setDeployOrderedState(deployOrder);
- acsc.setLockOrderedState(lockOrder);
+ acsc.setDeployOrderedState(AcmUtils.stateDeployToOrder(automationComposition.getDeployState()));
+ acsc.setLockOrderedState(AcmUtils.stateLockToOrder(automationComposition.getLockState()));
acsc.setStartPhase(startPhase);
acsc.setFirstStartPhase(firstStartPhase);
super.send(acsc);
}
-
- /**
- * Send AutomationCompositionStateChange to Participant.
- *
- * @param automationComposition the AutomationComposition
- * @param startPhase the startPhase
- */
- @Timed(
- value = "publisher.automation_composition_state_change",
- description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
- public void send(AutomationComposition automationComposition, int startPhase) {
- var acsc = new AutomationCompositionStateChange();
- acsc.setCompositionId(automationComposition.getCompositionId());
- acsc.setAutomationCompositionId(automationComposition.getInstanceId());
- acsc.setMessageId(UUID.randomUUID());
- acsc.setOrderedState(automationComposition.getOrderedState());
- acsc.setStartPhase(startPhase);
-
- super.send(acsc);
- }
}