aboutsummaryrefslogtreecommitdiffstats
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
parent4143155d835d2fcb291143e6863147dedfe367f4 (diff)
parent9b982666d6ddb6c964a1e539fea97231b5053f5b (diff)
Merge "Add participantType to participant class"
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java5
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java15
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java1
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java8
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java7
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java7
-rw-r--r--models/src/test/resources/providers/TestParticipant.json6
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java9
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java6
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java22
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java23
-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
18 files changed, 134 insertions, 68 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
index 67bcb5348..c7d85e4b6 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
@@ -31,6 +31,7 @@ import lombok.ToString;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
@@ -66,7 +67,7 @@ public class ControlLoopElement {
// A map indexed by the property name. Each map entry is the serialized value of the property,
// which can be deserialized into an instance of the type of the property.
- private Map<String, String> commonPropertiesMap = new LinkedHashMap<>();
+ private Map<String, ToscaProperty> propertiesMap = new LinkedHashMap<>();
/**
* Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
@@ -83,6 +84,6 @@ public class ControlLoopElement {
this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment;
this.description = otherElement.description;
this.clElementStatistics = otherElement.clElementStatistics;
- this.commonPropertiesMap = PfUtils.mapMap(otherElement.commonPropertiesMap, UnaryOperator.identity());
+ this.propertiesMap = PfUtils.mapMap(otherElement.propertiesMap, UnaryOperator.identity());
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java
index b9f4d6904..ae50b40ce 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java
@@ -30,6 +30,7 @@ import lombok.ToString;
import org.onap.policy.models.base.PfUtils;
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.ToscaProperty;
/**
* Class to represent a control loop element definition instance.
@@ -47,7 +48,7 @@ public class ControlLoopElementDefinition {
// A map indexed by the property name. Each map entry is the serialized value of the property,
// which can be deserialized into an instance of the type of the property.
- private Map<String, String> commonPropertiesMap = new LinkedHashMap<>();
+ private Map<String, ToscaProperty> commonPropertiesMap = new LinkedHashMap<>();
/**
* Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java
index 3130b6c2f..198cf1a16 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java
@@ -44,6 +44,9 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
@NonNull
private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN;
+ @NonNull
+ private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier();
+
@Override
public String getType() {
return definition.getName();
@@ -69,5 +72,6 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
this.definition = new ToscaConceptIdentifier(otherParticipant.definition);
this.participantState = otherParticipant.participantState;
this.healthStatus = otherParticipant.healthStatus;
+ this.participantType = otherParticipant.participantType;
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
index 4d49683bf..c8c26a8de 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
@@ -70,6 +70,11 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
private PfConceptKey definition;
// @formatter:on
+ @NotNull
+ @AttributeOverride(name = "name", column = @Column(name = "participant_type_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "participant_type_version"))
+ private PfConceptKey participantType;
+
@Column
@NotNull
private ParticipantState participantState;
@@ -125,6 +130,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
this.participantState = copyConcept.participantState;
this.healthStatus = copyConcept.healthStatus;
this.description = copyConcept.description;
+ this.participantType = copyConcept.participantType;
}
/**
@@ -146,6 +152,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
participant.setParticipantState(participantState);
participant.setHealthStatus(healthStatus);
participant.setDescription(description);
+ participant.setParticipantType(new ToscaConceptIdentifier(participantType));
return participant;
}
@@ -160,6 +167,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
this.setParticipantState(participant.getParticipantState());
this.setHealthStatus(participant.getHealthStatus());
this.setDescription(participant.getDescription());
+ this.participantType = participant.getParticipantType().asConceptKey();
}
@Override
@@ -167,6 +175,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
List<PfKey> keyList = getKey().getKeys();
keyList.add(definition);
+ keyList.add(participantType);
return keyList;
}
@@ -176,6 +185,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
key.clean();
definition.clean();
description = (description == null ? null : description.trim());
+ participantType.clean();
}
@Override
@@ -211,6 +221,11 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
return result;
}
+ result = ObjectUtils.compare(participantType, other.participantType);
+ if (result != 0) {
+ return result;
+ }
+
return ObjectUtils.compare(description, other.description);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java
index e2eb5154f..087292354 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java
@@ -247,6 +247,7 @@ class JpaParticipantTest {
testParticipant.setName("participant");
testParticipant.setVersion("0.0.1");
testParticipant.setDefinition(new ToscaConceptIdentifier("participantDefinitionName", "0.0.1"));
+ testParticipant.setParticipantType(new ToscaConceptIdentifier("participantTypeName", "0.0.1"));
return testParticipant;
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java
index 1b155a12a..ce56d582a 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java
@@ -36,6 +36,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
/**
* Test the copy constructor.
@@ -62,8 +63,11 @@ class ControlLoopUpdateTest {
clElement.setParticipantId(id);
clElement.setParticipantType(id);
- Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
- clElement.setCommonPropertiesMap(commonPropertiesMap);
+ ToscaProperty property = new ToscaProperty();
+ property.setName("test");
+ property.setType("testType");
+ Map<String, ToscaProperty> propertiesMap = Map.of("Prop1", property);
+ clElement.setPropertiesMap(propertiesMap);
ParticipantUpdates participantUpdates = new ParticipantUpdates();
participantUpdates.setParticipantId(id);
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
index f34777a70..b2bce05cc 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
@@ -42,6 +42,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant
import org.onap.policy.common.utils.coder.CoderException;
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.ToscaProperty;
class ParticipantStatusTest {
@@ -117,7 +118,11 @@ class ParticipantStatusTest {
ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
clDefinition.setClElementDefinitionId(id);
clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate);
- Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
+
+ ToscaProperty property = new ToscaProperty();
+ property.setName("test");
+ property.setType("testType");
+ Map<String, ToscaProperty> commonPropertiesMap = Map.of("Prop1", property);
clDefinition.setCommonPropertiesMap(commonPropertiesMap);
return clDefinition;
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java
index 6fe8604cf..d7023d0c1 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java
@@ -35,6 +35,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant
import org.onap.policy.common.utils.coder.CoderException;
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.ToscaProperty;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
@@ -89,7 +90,11 @@ class ParticipantUpdateTest {
ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
clDefinition.setClElementDefinitionId(id);
clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate);
- Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
+
+ ToscaProperty property = new ToscaProperty();
+ property.setName("test");
+ property.setType("testType");
+ Map<String, ToscaProperty> commonPropertiesMap = Map.of("Prop1", property);
clDefinition.setCommonPropertiesMap(commonPropertiesMap);
return clDefinition;
}
diff --git a/models/src/test/resources/providers/TestParticipant.json b/models/src/test/resources/providers/TestParticipant.json
index c6965ce62..4722ead9b 100644
--- a/models/src/test/resources/providers/TestParticipant.json
+++ b/models/src/test/resources/providers/TestParticipant.json
@@ -7,5 +7,9 @@
},
"participantState": "PASSIVE",
"healthStatus": "HEALTHY",
- "description": "A dummy PMSH participant1"
+ "description": "A dummy PMSH participant1",
+ "participantType":{
+ "name": "org.onap.domain.pmsh.PolicyControlLoopDefinition",
+ "version": "1.0.0"
+ }
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
index 891d67e2d..0cb4963ec 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
@@ -34,6 +34,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
/**
* This interface is used by participant implementations to use the participant intermediary.
@@ -57,6 +58,14 @@ public interface ParticipantIntermediaryApi {
List<Participant> getParticipants(String name, String version);
/**
+ * Get common properties of a controlloopelement.
+ *
+ * @param clElementDef the control loop element definition
+ * @return the common properties
+ */
+ Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef);
+
+ /**
* Update the state of a participant.
*
* @param definition the definition of the participant to update the state on
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
index aa1febadd..43ac3464c 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
@@ -40,6 +40,7 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.api.Participan
import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ControlLoopHandler;
import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.springframework.stereotype.Component;
/**
@@ -77,6 +78,11 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
}
@Override
+ public Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef) {
+ return participantHandler.getClElementDefinitionCommonProperties(clElementDef);
+ }
+
+ @Override
public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state) {
return participantHandler.updateParticipantState(definition, state);
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
index ab6d5bd83..40dc901db 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
@@ -22,6 +22,7 @@
package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -48,6 +49,7 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.Par
import org.onap.policy.models.base.PfModelException;
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.ToscaProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -298,7 +300,8 @@ public class ControlLoopHandler {
ToscaConceptIdentifier clElementDefId) {
for (var clElementDefinition : clElementDefinitions) {
- if (clElementDefinition.getClElementDefinitionId().equals(clElementDefId)) {
+ if (clElementDefId.getName().contains(
+ clElementDefinition.getClElementDefinitionId().getName())) {
return clElementDefinition.getControlLoopElementToscaNodeTemplate();
}
}
@@ -397,4 +400,21 @@ public class ControlLoopHandler {
controlLoops.setControlLoopList(new ArrayList<>(controlLoopMap.values()));
return controlLoops;
}
+
+ /**
+ * Get properties of a controlloopelement.
+ *
+ * @param id the control loop element id
+ * @return the instance properties
+ */
+ public Map<String, ToscaProperty> getClElementInstanceProperties(UUID id) {
+ Map<String, ToscaProperty> propertiesMap = new HashMap<>();
+ for (var controlLoop : controlLoopMap.values()) {
+ var element = controlLoop.getElements().get(id);
+ if (element != null) {
+ propertiesMap.putAll(element.getPropertiesMap());
+ }
+ }
+ return propertiesMap;
+ }
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
index 69f8febb8..ea7d84501 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
@@ -24,6 +24,7 @@ package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
import java.time.Instant;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -60,6 +61,7 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.comm.Participa
import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -206,6 +208,22 @@ public class ParticipantHandler {
}
/**
+ * Get common properties of a controlloopelement.
+ *
+ * @param clElementDef the control loop element definition
+ * @return the common properties
+ */
+ public Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef) {
+ Map<String, ToscaProperty> commonPropertiesMap = new HashMap<>();
+ clElementDefsOnThisParticipant.stream().forEach(definition -> {
+ if (definition.getClElementDefinitionId().equals(clElementDef)) {
+ commonPropertiesMap.putAll(definition.getCommonPropertiesMap());
+ }
+ });
+ return commonPropertiesMap;
+ }
+
+ /**
* Check if a participant message applies to this participant handler.
*
* @param participantMsg the message to check
@@ -284,15 +302,10 @@ public class ParticipantHandler {
LOGGER.debug("ParticipantUpdate message received for participantId {}",
participantUpdateMsg.getParticipantId());
- if (!participantUpdateMsg.appliesTo(participantType, participantId)) {
- return;
- }
-
if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) {
// This message is to commission the controlloop
for (ParticipantDefinition participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) {
if (participantDefinition.getParticipantType().equals(participantType)) {
- clElementDefsOnThisParticipant.clear();
clElementDefsOnThisParticipant.addAll(participantDefinition.getControlLoopElementDefinitionList());
break;
}
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()) {
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 bc1a3b70a..1bf445734 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
@@ -146,6 +146,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));