summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src/main/java/org
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2021-09-23 14:45:33 +0000
committerGerrit Code Review <gerrit@onap.org>2021-09-23 14:45:33 +0000
commit6bcadaa32d556a623fb1908f08c8611786d615d6 (patch)
tree38609e9e8a5ff444c11a9ce888fb57410344aaf6 /runtime-controlloop/src/main/java/org
parent4143155d835d2fcb291143e6863147dedfe367f4 (diff)
parent9b982666d6ddb6c964a1e539fea97231b5053f5b (diff)
Merge "Add participantType to participant class"
Diffstat (limited to 'runtime-controlloop/src/main/java/org')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java41
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java23
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java2
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java19
4 files changed, 31 insertions, 54 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
index 0b7bc9a26..472348ac3 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
@@ -40,6 +40,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType;
@@ -108,23 +109,13 @@ public class CommissioningProvider {
synchronized (lockit) {
modelsProvider.createServiceTemplate(serviceTemplate);
List<Participant> participantList =
- participantProvider.getParticipants(null,
- null);
-
- if (participantList != null) {
- for (Participant participant: participantList) {
- var participantType = new ToscaConceptIdentifier();
- participantType.setName(participant.getType());
- participantType.setVersion(participant.getTypeVersion());
-
- var participantUpdate = new ParticipantUpdate();
- participantUpdate.setParticipantId(participant.getDefinition());
- participantUpdate.setParticipantType(participantType);
-
- this.supervisionHandler.handleSendCommissionMessage(participantUpdate);
- }
+ participantProvider.getParticipants(null, null);
+ if (!participantList.isEmpty()) {
+ this.supervisionHandler.handleSendCommissionMessage(
+ getCommonOrInstancePropertiesFromNodeTypes(true,
+ serviceTemplate.getName(),
+ serviceTemplate.getVersion()));
}
-
}
var response = new CommissioningResponse();
@@ -159,21 +150,9 @@ public class CommissioningProvider {
List<Participant> participantList =
participantProvider.getParticipants(null,
null);
-
- if (participantList != null) {
- for (Participant participant : participantList) {
- var participantType = new ToscaConceptIdentifier();
- participantType.setName(participant.getType());
- participantType.setVersion(participant.getTypeVersion());
-
- var participantUpdate = new ParticipantUpdate();
- participantUpdate.setParticipantId(participant.getDefinition());
- participantUpdate.setParticipantType(participantType);
-
- this.supervisionHandler.handleSendDeCommissionMessage(participantUpdate);
- }
+ if (!participantList.isEmpty()) {
+ this.supervisionHandler.handleSendDeCommissionMessage();
}
-
modelsProvider.deleteServiceTemplate(name, version);
}
@@ -342,7 +321,7 @@ public class CommissioningProvider {
* @return the node types with common or instance properties
* @throws PfModelException on errors getting node type properties
*/
- private Map<String, ToscaNodeType> getCommonOrInstancePropertiesFromNodeTypes(boolean common, String name,
+ public Map<String, ToscaNodeType> getCommonOrInstancePropertiesFromNodeTypes(boolean common, String name,
String version) throws PfModelException {
var serviceTemplates = new ToscaServiceTemplates();
serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
index c4ca568f7..1747bbd3c 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
@@ -52,6 +52,7 @@ import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantReg
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -149,8 +150,7 @@ public class SupervisionHandler {
participantRegisterAckPublisher.send(participantRegisterMessage.getMessageId(),
participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType());
- participantUpdatePublisher.send(participantRegisterMessage.getParticipantId(),
- participantRegisterMessage.getParticipantType(), true);
+ participantUpdatePublisher.send(null, true);
}
/**
@@ -209,25 +209,19 @@ public class SupervisionHandler {
/**
* Send commissioning update message to dmaap.
*
- * @param participantUpdateMessage the ParticipantUpdate message to send
*/
- public void handleSendCommissionMessage(ParticipantUpdate participantUpdateMessage) {
- LOGGER.debug("Participant update message being sent {}", participantUpdateMessage);
-
- participantUpdatePublisher.send(participantUpdateMessage.getParticipantId(),
- participantUpdateMessage.getParticipantType(), true);
+ public void handleSendCommissionMessage(Map<String, ToscaNodeType> commonPropertiesMap) {
+ LOGGER.debug("Participant update message being sent {}");
+ participantUpdatePublisher.send(commonPropertiesMap, true);
}
/**
* Send decommissioning update message to dmaap.
*
- * @param participantUpdateMessage the ParticipantUpdate message to send
*/
- public void handleSendDeCommissionMessage(ParticipantUpdate participantUpdateMessage) {
- LOGGER.debug("Participant update message being sent {}", participantUpdateMessage);
-
- participantUpdatePublisher.send(participantUpdateMessage.getParticipantId(),
- participantUpdateMessage.getParticipantType(), false);
+ public void handleSendDeCommissionMessage() {
+ LOGGER.debug("Participant update message being sent");
+ participantUpdatePublisher.send(null, false);
}
/**
@@ -429,6 +423,7 @@ public class SupervisionHandler {
participant.setName(participantStatusMessage.getParticipantId().getName());
participant.setVersion(participantStatusMessage.getParticipantId().getVersion());
participant.setDefinition(participantStatusMessage.getParticipantId());
+ participant.setParticipantType(participantStatusMessage.getParticipantType());
participant.setParticipantState(participantStatusMessage.getState());
participant.setHealthStatus(participantStatusMessage.getHealthStatus());
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
index 0c49ce14f..684711677 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
@@ -156,7 +156,7 @@ public class SupervisionScanner {
if (participantUpdateCounter.count(id)) {
LOGGER.debug("retry message ParticipantUpdate");
- participantUpdatePublisher.send(id.getLeft(), id.getRight(), true);
+ participantUpdatePublisher.send(null, true);
} else {
LOGGER.debug("report Participant Update fault");
participantUpdateCounter.setFault(id);
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
index fe46297f1..0f6cc7cbc 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
@@ -25,6 +25,7 @@ package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
@@ -34,6 +35,7 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,14 +55,9 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
/**
* Send ParticipantUpdate to Participant.
*
- * @param participantId the participant Id
- * @param participantType the participant Type
*/
- public void send(ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType,
- boolean commissionFlag) {
+ public void send(Map<String, ToscaNodeType> commonPropertiesMap, boolean commissionFlag) {
var message = new ParticipantUpdate();
- message.setParticipantId(participantId);
- message.setParticipantType(participantType);
message.setTimestamp(Instant.now());
ToscaServiceTemplate toscaServiceTemplate = null;
@@ -82,7 +79,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
var clParticipantType =
ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties());
prepareParticipantDefinitionUpdate(clParticipantType, toscaInputEntry.getKey(),
- toscaInputEntry.getValue(), participantDefinitionUpdates);
+ toscaInputEntry.getValue(), participantDefinitionUpdates, commonPropertiesMap);
}
}
}
@@ -99,11 +96,17 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
}
private void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier clParticipantType, String entryKey,
- ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates) {
+ ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates,
+ Map<String, ToscaNodeType> commonPropertiesMap) {
var clDefinition = new ControlLoopElementDefinition();
clDefinition.setClElementDefinitionId(new ToscaConceptIdentifier(entryKey, entryValue.getVersion()));
clDefinition.setControlLoopElementToscaNodeTemplate(entryValue);
+ ToscaNodeType nodeType = commonPropertiesMap.get(entryValue.getType());
+ if (nodeType != null) {
+ clDefinition.setCommonPropertiesMap(nodeType.getProperties());
+ }
+
List<ControlLoopElementDefinition> controlLoopElementDefinitionList = new ArrayList<>();
if (participantDefinitionUpdates.isEmpty()) {