summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-09-20 16:08:25 +0100
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-09-22 14:07:56 +0100
commit9b982666d6ddb6c964a1e539fea97231b5053f5b (patch)
treed3e5d8959002f73c420946e7553bb4fb0aae02b7 /runtime-controlloop/src
parentb428105b44d0504b05a0b93894bef97e5ab7e8b4 (diff)
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 <sirisha.manchikanti@est.tech> Change-Id: Ic9205aafe269ccc6dae0b3463fc6df5c47129e5d
Diffstat (limited to 'runtime-controlloop/src')
-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
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java1
5 files changed, 32 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 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<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()) {
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java
index 2ba321d36..9b64f9076 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java
@@ -139,6 +139,7 @@ class SupervisionScannerTest {
participant.setHealthStatus(ParticipantHealthStatus.HEALTHY);
participant.setParticipantState(ParticipantState.ACTIVE);
participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
+ participant.setParticipantType(new ToscaConceptIdentifier("ParticipantType1", "1.0.0"));
var participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
participantProvider.updateParticipants(List.of(participant));