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/commissioning/CommissioningProvider.java14
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java17
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java2
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java61
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java2
5 files changed, 46 insertions, 50 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
index c2564887c..19d4afe11 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
@@ -21,13 +21,11 @@
package org.onap.policy.clamp.acm.runtime.commissioning;
-import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.ws.rs.core.Response.Status;
import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
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.messages.rest.commissioning.CommissioningResponse;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
@@ -118,7 +116,7 @@ public class CommissioningProvider {
*/
public CommissioningResponse updateCompositionDefinition(UUID compositionId, ToscaServiceTemplate serviceTemplate) {
- var automationCompositions = acProvider.getAutomationCompositions();
+ var automationCompositions = acProvider.getAcInstancesByCompositionId(compositionId);
var result = new BeanValidationResult("AutomationCompositions", automationCompositions);
for (var automationComposition : automationCompositions) {
if (!AutomationCompositionState.UNINITIALISED.equals(automationComposition.getState())) {
@@ -145,11 +143,11 @@ public class CommissioningProvider {
*/
public CommissioningResponse deleteAutomationCompositionDefinition(UUID compositionId) {
- if (verifyIfInstanceExists()) {
+ if (verifyIfInstanceExists(compositionId)) {
throw new PfModelRuntimeException(Status.BAD_REQUEST,
"Delete instances, to commission automation composition definitions");
}
- List<Participant> participantList = participantProvider.getParticipants();
+ var participantList = participantProvider.getParticipants();
if (!participantList.isEmpty()) {
supervisionHandler.handleSendDeCommissionMessage();
}
@@ -190,8 +188,8 @@ public class CommissioningProvider {
*
* @return true if exists instance
*/
- private boolean verifyIfInstanceExists() {
- return !acProvider.getAutomationCompositions().isEmpty();
+ private boolean verifyIfInstanceExists(UUID compositionId) {
+ return !acProvider.getAcInstancesByCompositionId(compositionId).isEmpty();
}
/**
@@ -200,6 +198,6 @@ public class CommissioningProvider {
* @return true if exists instance
*/
private boolean verifyIfDefinitionExists() {
- return !acDefinitionProvider.getAllServiceTemplates().isEmpty();
+ return !acDefinitionProvider.getAllAcDefinitions().isEmpty();
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
index df1f0ead4..2601a233b 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
@@ -126,17 +126,14 @@ public class AutomationCompositionInstantiationProvider {
private BeanValidationResult validateAutomationCompositions(AutomationCompositions automationCompositions) {
var result = new BeanValidationResult("AutomationCompositions", automationCompositions);
- var serviceTemplates = acDefinitionProvider.getAllServiceTemplates();
- if (serviceTemplates.isEmpty()) {
- result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID,
- "Commissioned automation composition definition not found"));
- return result;
- }
-
- var serviceTemplate = acDefinitionProvider.getAllServiceTemplates().get(0);
-
for (var automationComposition : automationCompositions.getAutomationCompositionList()) {
- result.addResult(AcmUtils.validateAutomationComposition(automationComposition, serviceTemplate));
+ var serviceTemplate = acDefinitionProvider.findAcDefinition(automationComposition.getCompositionId());
+ if (serviceTemplate.isEmpty()) {
+ result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID,
+ "Commissioned automation composition definition not found"));
+ } else {
+ result.addResult(AcmUtils.validateAutomationComposition(automationComposition, serviceTemplate.get()));
+ }
}
return result;
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
index 479d6cf6a..b01aca5e8 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
@@ -445,7 +445,7 @@ public class SupervisionHandler {
}
private int getFirstStartPhase(AutomationComposition automationComposition) {
- var toscaServiceTemplate = acDefinitionProvider.getAllServiceTemplates().get(0);
+ var toscaServiceTemplate = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId());
return ParticipantUtils.getFirstStartPhase(automationComposition, toscaServiceTemplate);
}
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 5f3bfb281..e2f8b6777 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
@@ -57,7 +57,7 @@ public class SupervisionScanner {
private final HandleCounter<ToscaConceptIdentifier> automationCompositionCounter = new HandleCounter<>();
private final HandleCounter<ToscaConceptIdentifier> participantStatusCounter = new HandleCounter<>();
private final HandleCounter<Pair<ToscaConceptIdentifier, ToscaConceptIdentifier>> participantUpdateCounter =
- new HandleCounter<>();
+ new HandleCounter<>();
private final Map<ToscaConceptIdentifier, Integer> phaseMap = new HashMap<>();
@@ -82,11 +82,12 @@ public class SupervisionScanner {
* @param acRuntimeParameterGroup the parameters for the automation composition runtime
*/
public SupervisionScanner(final AutomationCompositionProvider automationCompositionProvider,
- AcDefinitionProvider acDefinitionProvider,
- final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher,
- AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher,
- ParticipantProvider participantProvider, ParticipantStatusReqPublisher participantStatusReqPublisher,
- ParticipantUpdatePublisher participantUpdatePublisher, final AcRuntimeParameterGroup acRuntimeParameterGroup) {
+ AcDefinitionProvider acDefinitionProvider,
+ final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher,
+ AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher,
+ ParticipantProvider participantProvider, ParticipantStatusReqPublisher participantStatusReqPublisher,
+ ParticipantUpdatePublisher participantUpdatePublisher,
+ final AcRuntimeParameterGroup acRuntimeParameterGroup) {
this.automationCompositionProvider = automationCompositionProvider;
this.acDefinitionProvider = acDefinitionProvider;
this.automationCompositionStateChangePublisher = automationCompositionStateChangePublisher;
@@ -96,17 +97,17 @@ public class SupervisionScanner {
this.participantUpdatePublisher = participantUpdatePublisher;
automationCompositionCounter.setMaxRetryCount(
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
+ acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
automationCompositionCounter
- .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
+ .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
participantUpdateCounter.setMaxRetryCount(
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
+ acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
participantUpdateCounter
- .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxWaitMs());
+ .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxWaitMs());
participantStatusCounter.setMaxRetryCount(
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
+ acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
participantStatusCounter.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
}
@@ -130,13 +131,12 @@ public class SupervisionScanner {
}
try {
- var list = acDefinitionProvider.getAllServiceTemplates();
- if (list != null && !list.isEmpty()) {
- ToscaServiceTemplate toscaServiceTemplate = list.get(0);
-
- for (AutomationComposition automationComposition : automationCompositionProvider
- .getAutomationCompositions()) {
- scanAutomationComposition(automationComposition, toscaServiceTemplate, counterCheck);
+ var list = acDefinitionProvider.getAllAcDefinitions();
+ for (var acDefinition : list) {
+ var acList =
+ automationCompositionProvider.getAcInstancesByCompositionId(acDefinition.getCompositionId());
+ for (var automationComposition : acList) {
+ scanAutomationComposition(automationComposition, acDefinition.getServiceTemplate(), counterCheck);
}
}
} catch (PfModelException pfme) {
@@ -208,7 +208,7 @@ public class SupervisionScanner {
}
private void scanAutomationComposition(final AutomationComposition automationComposition,
- ToscaServiceTemplate toscaServiceTemplate, boolean counterCheck) throws PfModelException {
+ ToscaServiceTemplate toscaServiceTemplate, boolean counterCheck) throws PfModelException {
LOGGER.debug("scanning automation composition {} . . .", automationComposition.getKey().asIdentifier());
if (automationComposition.getState().equals(automationComposition.getOrderedState().asState())) {
@@ -226,7 +226,7 @@ public class SupervisionScanner {
var defaultMax = 0; // max startPhase
for (AutomationCompositionElement element : automationComposition.getElements().values()) {
ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()
- .get(element.getDefinition().getName());
+ .get(element.getDefinition().getName());
int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties());
defaultMin = Math.min(defaultMin, startPhase);
defaultMax = Math.max(defaultMax, startPhase);
@@ -239,7 +239,7 @@ public class SupervisionScanner {
if (completed) {
LOGGER.debug("automation composition scan: transition from state {} to {} completed",
- automationComposition.getState(), automationComposition.getOrderedState());
+ automationComposition.getState(), automationComposition.getOrderedState());
automationComposition.setState(automationComposition.getOrderedState().asState());
automationCompositionProvider.saveAutomationComposition(automationComposition);
@@ -248,21 +248,22 @@ public class SupervisionScanner {
clearFaultAndCounter(automationComposition);
} else {
LOGGER.debug("automation composition scan: transition from state {} to {} not completed",
- automationComposition.getState(), automationComposition.getOrderedState());
+ automationComposition.getState(), automationComposition.getOrderedState());
var nextSpNotCompleted =
- AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState())
- || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState())
- ? minSpNotCompleted
- : maxSpNotCompleted;
+ AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState())
+ || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState())
+ ? minSpNotCompleted
+ : maxSpNotCompleted;
var firstStartPhase =
- AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState())
- || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState()) ? defaultMin
- : defaultMax;
+ AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState())
+ || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState())
+ ? defaultMin
+ : defaultMax;
if (nextSpNotCompleted != phaseMap.getOrDefault(automationComposition.getKey().asIdentifier(),
- firstStartPhase)) {
+ firstStartPhase)) {
phaseMap.put(automationComposition.getKey().asIdentifier(), nextSpNotCompleted);
sendAutomationCompositionMsg(automationComposition, nextSpNotCompleted);
} else if (counterCheck) {
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
index 9beef51bb..61ab78fad 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
@@ -73,7 +73,7 @@ public class AutomationCompositionUpdatePublisher extends AbstractParticipantPub
automationCompositionUpdateMsg.setAutomationCompositionId(automationComposition.getKey().asIdentifier());
automationCompositionUpdateMsg.setMessageId(UUID.randomUUID());
automationCompositionUpdateMsg.setTimestamp(Instant.now());
- var toscaServiceTemplate = acDefinitionProvider.getAllServiceTemplates().get(0);
+ var toscaServiceTemplate = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId());
List<ParticipantUpdates> participantUpdates = new ArrayList<>();
for (AutomationCompositionElement element : automationComposition.getElements().values()) {