From 9b982666d6ddb6c964a1e539fea97231b5053f5b Mon Sep 17 00:00:00 2001 From: Sirisha_Manchikanti Date: Mon, 20 Sep 2021 16:08:25 +0100 Subject: Add participantType to participant class Add participantType to participant class, cascade common and instance properties from runtime to participants Issue-ID: POLICY-3576 Signed-off-by: Sirisha_Manchikanti Change-Id: Ic9205aafe269ccc6dae0b3463fc6df5c47129e5d --- .../commissioning/CommissioningProvider.java | 41 ++++++---------------- .../runtime/supervision/SupervisionHandler.java | 23 +++++------- .../runtime/supervision/SupervisionScanner.java | 2 +- .../comm/ParticipantUpdatePublisher.java | 19 +++++----- 4 files changed, 31 insertions(+), 54 deletions(-) (limited to 'runtime-controlloop/src/main/java/org/onap') 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 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 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 getCommonOrInstancePropertiesFromNodeTypes(boolean common, String name, + public Map 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 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 d13d66c5d..fde94bc0d 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 @@ -144,7 +144,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 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 participantDefinitionUpdates) { + ToscaNodeTemplate entryValue, List participantDefinitionUpdates, + Map 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 controlLoopElementDefinitionList = new ArrayList<>(); if (participantDefinitionUpdates.isEmpty()) { -- cgit 1.2.3-korg