aboutsummaryrefslogtreecommitdiffstats
path: root/tosca-controlloop/models/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'tosca-controlloop/models/src/main')
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java2
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java31
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java13
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java4
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java3
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java45
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java36
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java14
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java27
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java44
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java4
11 files changed, 124 insertions, 99 deletions
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java
index 014323090..4ef9bdcd9 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java
@@ -26,10 +26,12 @@ import java.util.UUID;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
+import lombok.ToString;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@NoArgsConstructor
@Data
+@ToString
public class ClElementStatistics implements Serializable {
private static final long serialVersionUID = 3284285693112271055L;
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java
index 417e02a5a..d0d79274c 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java
@@ -20,14 +20,17 @@
package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
+import java.util.stream.Collectors;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
-import org.apache.commons.collections4.CollectionUtils;
-import org.onap.policy.models.base.PfKey;
+import org.apache.commons.collections4.MapUtils;
+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.ToscaEntity;
@@ -40,7 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
@EqualsAndHashCode(callSuper = true)
public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop> {
@NonNull
- private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_NAME);
+ private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
@NonNull
private ControlLoopState state = ControlLoopState.UNINITIALISED;
@@ -48,7 +51,7 @@ public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop>
@NonNull
private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED;
- private List<ControlLoopElement> elements;
+ private Map<UUID, ControlLoopElement> elements;
@Override
public String getType() {
@@ -70,7 +73,7 @@ public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop>
this.definition = new ToscaConceptIdentifier(otherControlLoop.definition);
this.state = otherControlLoop.state;
this.orderedState = otherControlLoop.orderedState;
- this.elements = PfUtils.mapList(otherControlLoop.elements, ControlLoopElement::new);
+ this.elements = PfUtils.mapMap(otherControlLoop.elements, ControlLoopElement::new);
}
@Override
@@ -86,25 +89,25 @@ public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop>
public void setCascadedOrderedState(final ControlLoopOrderedState orderedState) {
this.orderedState = orderedState;
- if (CollectionUtils.isEmpty(elements)) {
+ if (MapUtils.isEmpty(elements)) {
return;
}
- elements.forEach(element -> element.setOrderedState(orderedState));
+ elements.values().forEach(element -> element.setOrderedState(orderedState));
}
/**
- * Find the element with a given UUID for the control loop.
+ * Get a list of control loop element statistics.
*
- * @param id the UUID to search for
- * @return the element or null if its not found
+ * @param controlLoop the control loop
+ * @return List of ClElementStatistics
*/
-
- public ControlLoopElement getElement(final UUID id) {
- if (CollectionUtils.isEmpty(elements)) {
+ public List<ClElementStatistics> getControlLoopElementStatisticsList(final ControlLoop controlLoop) {
+ if (MapUtils.isEmpty(controlLoop.elements)) {
return null;
}
- return elements.stream().filter(element -> id.equals(element.getId())).findAny().orElse(null);
+ return controlLoop.elements.values().stream().map(ControlLoopElement::getClElementStatistics)
+ .collect(Collectors.toList());
}
}
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
index a8d317c2b..83f062c74 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
@@ -25,7 +25,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.ToString;
-import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
@@ -39,10 +39,13 @@ public class ControlLoopElement {
private UUID id = UUID.randomUUID();
@NonNull
- private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_NAME);
+ private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
@NonNull
- private ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_NAME);
+ private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
+
+ @NonNull
+ private ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
@NonNull
private ControlLoopState state = ControlLoopState.UNINITIALISED;
@@ -52,6 +55,8 @@ public class ControlLoopElement {
private String description;
+ private ClElementStatistics clElementStatistics;
+
/**
* Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
*
@@ -60,9 +65,11 @@ public class ControlLoopElement {
public ControlLoopElement(final ControlLoopElement otherElement) {
this.id = otherElement.id;
this.definition = new ToscaConceptIdentifier(otherElement.definition);
+ this.participantType = new ToscaConceptIdentifier(otherElement.participantType);
this.participantId = new ToscaConceptIdentifier(otherElement.participantId);
this.state = otherElement.state;
this.orderedState = otherElement.orderedState;
this.description = otherElement.description;
+ this.clElementStatistics = otherElement.clElementStatistics;
}
}
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java
index 43ad49b7c..3130b6c2f 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java
@@ -24,7 +24,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
-import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
@@ -36,7 +36,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
@EqualsAndHashCode(callSuper = true)
public class Participant extends ToscaEntity implements Comparable<Participant> {
@NonNull
- private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_NAME);
+ private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
@NonNull
private ParticipantState participantState = ParticipantState.UNKNOWN;
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java
index ec5dbb32c..c5ce99677 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java
@@ -24,7 +24,6 @@ import java.io.Serializable;
import java.util.List;
import java.util.UUID;
import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
@@ -190,6 +189,6 @@ public class JpaClElementStatistics extends PfConcept implements PfAuthorative<C
final JpaClElementStatistics other = (JpaClElementStatistics) otherConcept;
return new CompareToBuilder().append(this.key, other.key).append(this.state, other.state)
- .append(this.clElementUptime, other.clElementUptime).toComparison();
+ .append(this.clElementUptime, other.clElementUptime).toComparison();
}
}
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
index 3f54ac2bb..cac405abd 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
@@ -20,21 +20,21 @@
package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
-import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
-import java.util.stream.Collectors;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.UUID;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
-import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToMany;
+import javax.persistence.ManyToMany;
import javax.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -96,16 +96,9 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
private String description;
// @formatter:off
- @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @CollectionTable(joinColumns = {
- @JoinColumn(name = "controlLoopParentKeyName", referencedColumnName = "parentKeyName"),
- @JoinColumn(name = "controlLoopParentKeyVersion", referencedColumnName = "parentKeyVersion"),
- @JoinColumn(name = "controlLoopParentLocalName", referencedColumnName = "parentLocalName"),
- @JoinColumn(name = "controlLoopLocalUUID", referencedColumnName = "localUUID")
- })
- // @formatter:on
+ @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@NotNull
- private List<@NotNull @Valid JpaControlLoopElement> elements;
+ private Map<@NotNull UUID, @NotNull @Valid JpaControlLoopElement> elements;
/**
* The Default Constructor creates a {@link JpaControlLoop} object with a null key.
@@ -120,7 +113,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
* @param key the key
*/
public JpaControlLoop(@NonNull final PfConceptKey key) {
- this(key, new PfConceptKey(), ControlLoopState.UNINITIALISED, new ArrayList<>());
+ this(key, new PfConceptKey(), ControlLoopState.UNINITIALISED, new LinkedHashMap<>());
}
/**
@@ -132,7 +125,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
* @param elements the elements of the control looop in participants
*/
public JpaControlLoop(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition,
- @NonNull final ControlLoopState state, @NonNull final List<JpaControlLoopElement> elements) {
+ @NonNull final ControlLoopState state, @NonNull final Map<UUID, JpaControlLoopElement> elements) {
this.key = key;
this.definition = definition;
this.state = state;
@@ -151,7 +144,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
this.state = copyConcept.state;
this.orderedState = copyConcept.orderedState;
this.description = copyConcept.description;
- this.elements = PfUtils.mapList(copyConcept.elements, JpaControlLoopElement::new, new ArrayList<>(0));
+ this.elements = PfUtils.mapMap(copyConcept.elements, JpaControlLoopElement::new, new LinkedHashMap<>(0));
}
/**
@@ -173,9 +166,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
controlLoop.setState(state);
controlLoop.setOrderedState(orderedState != null ? orderedState : state.asOrderedState());
controlLoop.setDescription(description);
-
- controlLoop
- .setElements(elements.stream().map(JpaControlLoopElement::toAuthorative).collect(Collectors.toList()));
+ controlLoop.setElements(PfUtils.mapMap(elements, JpaControlLoopElement::toAuthorative, new LinkedHashMap<>(0)));
return controlLoop;
}
@@ -191,12 +182,12 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
this.orderedState = controlLoop.getOrderedState();
this.description = controlLoop.getDescription();
- this.elements = new ArrayList<>(controlLoop.getElements().size());
- for (ControlLoopElement element : controlLoop.getElements()) {
+ this.elements = new LinkedHashMap<>(controlLoop.getElements().size());
+ for (Entry<UUID, ControlLoopElement> elementEntry : controlLoop.getElements().entrySet()) {
JpaControlLoopElement jpaControlLoopElement = new JpaControlLoopElement();
- jpaControlLoopElement.setKey(new PfReferenceKey(getKey(), element.getId().toString()));
- jpaControlLoopElement.fromAuthorative(element);
- this.elements.add(jpaControlLoopElement);
+ jpaControlLoopElement.setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString()));
+ jpaControlLoopElement.fromAuthorative(elementEntry.getValue());
+ this.elements.put(elementEntry.getKey(), jpaControlLoopElement);
}
}
@@ -206,7 +197,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
keyList.add(definition);
- for (JpaControlLoopElement element : elements) {
+ for (JpaControlLoopElement element : elements.values()) {
keyList.addAll(element.getKeys());
}
@@ -219,7 +210,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
definition.clean();
description = (description == null ? null : description.trim());
- for (JpaControlLoopElement element : elements) {
+ for (JpaControlLoopElement element : elements.values()) {
element.clean();
}
}
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java
index 042cb16e1..911a52089 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java
@@ -23,7 +23,6 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concept
import java.util.List;
import java.util.UUID;
import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
@@ -67,20 +66,19 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co
// @formatter:off
@VerifyKey
@NotNull
- @AttributeOverrides({
- @AttributeOverride(name = "name", column = @Column(name = "definition_name")),
- @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
- }
- )
+ @AttributeOverride(name = "name", column = @Column(name = "definition_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
private PfConceptKey definition;
@VerifyKey
@NotNull
- @AttributeOverrides({
- @AttributeOverride(name = "name", column = @Column(name = "participant_name")),
- @AttributeOverride(name = "version", column = @Column(name = "participant_version"))
- }
- )
+ @AttributeOverride(name = "name", column = @Column(name = "participant_type_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "participant_type_version"))
+ private PfConceptKey participantType;
+
+ @NotNull
+ @AttributeOverride(name = "name", column = @Column(name = "participant_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "participant_version"))
private PfConceptKey participantId;
// @formatter:on
@@ -116,14 +114,14 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co
*
* @param key the key
* @param definition the TOSCA definition of the control loop element
- * @param participantId the TOSCA definition of the participant running the control loop element
+ * @param participantType the TOSCA definition of the participant running the control loop element
* @param state the state of the control loop
*/
public JpaControlLoopElement(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey definition,
- @NonNull final PfConceptKey participantId, @NonNull final ControlLoopState state) {
+ @NonNull final PfConceptKey participantType, @NonNull final ControlLoopState state) {
this.key = key;
this.definition = definition;
- this.participantId = participantId;
+ this.participantType = participantType;
this.state = state;
}
@@ -136,6 +134,7 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co
super(copyConcept);
this.key = new PfReferenceKey(copyConcept.key);
this.definition = new PfConceptKey(copyConcept.definition);
+ this.participantType = new PfConceptKey(copyConcept.participantType);
this.participantId = new PfConceptKey(copyConcept.participantId);
this.state = copyConcept.state;
this.orderedState = copyConcept.orderedState;
@@ -157,6 +156,7 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co
element.setId(UUID.fromString(getKey().getLocalName()));
element.setDefinition(new ToscaConceptIdentifier(definition));
+ element.setParticipantType(new ToscaConceptIdentifier(participantType));
element.setParticipantId(new ToscaConceptIdentifier(participantId));
element.setState(state);
element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState());
@@ -173,6 +173,7 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co
}
this.definition = element.getDefinition().asConceptKey();
+ this.participantType = element.getParticipantType().asConceptKey();
this.participantId = element.getParticipantId().asConceptKey();
this.state = element.getState();
this.orderedState = element.getOrderedState();
@@ -184,6 +185,7 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co
List<PfKey> keyList = getKey().getKeys();
keyList.add(definition);
+ keyList.add(participantType);
keyList.add(participantId);
return keyList;
@@ -193,6 +195,7 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co
public void clean() {
key.clean();
definition.clean();
+ participantType.clean();
participantId.clean();
if (description != null) {
@@ -223,6 +226,11 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co
return result;
}
+ result = participantType.compareTo(other.participantType);
+ if (result != 0) {
+ return result;
+ }
+
result = participantId.compareTo(other.participantId);
if (result != 0) {
return result;
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
index c09658f80..8a06cbf1e 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
@@ -62,10 +62,10 @@ public class ClElementStatisticsProvider extends AbstractModelsProvider {
* @throws PfModelException on errors creating clElement statistics
*/
public List<ClElementStatistics> createClElementStatistics(
- @NonNull final List<ClElementStatistics> clElementStatisticsList) throws PfModelException {
+ @NonNull final List<ClElementStatistics> clElementStatisticsList) throws PfModelException {
BeanValidationResult validationResult =
- new BeanValidationResult("control loop element statistics list", clElementStatisticsList);
+ new BeanValidationResult("control loop element statistics list", clElementStatisticsList);
for (ClElementStatistics clElementStatistics : clElementStatisticsList) {
JpaClElementStatistics jpaClElementStatistics = new JpaClElementStatistics();
jpaClElementStatistics.fromAuthorative(clElementStatistics);
@@ -118,7 +118,7 @@ public class ClElementStatisticsProvider extends AbstractModelsProvider {
* @throws PfModelException on errors getting clElement statistics
*/
public List<ClElementStatistics> getClElementStatistics(final String name, final String version, final String id,
- final Instant timestamp) throws PfModelException {
+ final Instant timestamp) throws PfModelException {
List<ClElementStatistics> clElementStatistics = new ArrayList<>(1);
if (name != null && version != null && timestamp != null && id != null) {
clElementStatistics.add(getPfDao()
@@ -146,11 +146,9 @@ public class ClElementStatisticsProvider extends AbstractModelsProvider {
* @throws PfModelException on errors getting policies
*/
public List<ClElementStatistics> getFilteredClElementStatistics(final String name, final String version,
- final Instant startTimeStamp,
- final Instant endTimeStamp,
- Map<String, Object> filterMap,
- final String sortOrder, final int getRecordNum) {
+ final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap,
+ final String sortOrder, final int getRecordNum) {
return asClElementStatisticsList(getPfDao().getFiltered(JpaClElementStatistics.class, name, version,
- startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum));
+ startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum));
}
}
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
index ebb81942b..6b075278c 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
@@ -62,12 +62,12 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
* @throws PfModelException on errors getting participant statistics
*/
public List<ParticipantStatistics> getParticipantStatistics(final String name, final String version,
- final Instant timestamp) throws PfModelException {
+ final Instant timestamp) throws PfModelException {
if (name != null && version != null && timestamp != null) {
List<ParticipantStatistics> participantStatistics = new ArrayList<>(1);
participantStatistics.add(getPfDao()
- .get(JpaParticipantStatistics.class, new PfTimestampKey(name, version, timestamp)).toAuthorative());
+ .get(JpaParticipantStatistics.class, new PfTimestampKey(name, version, timestamp)).toAuthorative());
return participantStatistics;
} else if (name != null) {
return getFilteredParticipantStatistics(name, version, timestamp, null, null,
@@ -90,14 +90,11 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
* @throws PfModelException on errors getting policies
*/
public List<ParticipantStatistics> getFilteredParticipantStatistics(final String name, final String version,
- final Instant startTimeStamp,
- final Instant endTimeStamp,
- Map<String, Object> filterMap,
- final String sortOrder,
- final int getRecordNum) {
+ final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap,
+ final String sortOrder, final int getRecordNum) {
return asParticipantStatisticsList(getPfDao().getFiltered(JpaParticipantStatistics.class, name, version,
- startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum));
+ startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum));
}
@@ -109,10 +106,10 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
* @throws PfModelException on errors creating participant statistics
*/
public List<ParticipantStatistics> createParticipantStatistics(
- @NonNull final List<ParticipantStatistics> participantStatisticsList) throws PfModelException {
+ @NonNull final List<ParticipantStatistics> participantStatisticsList) throws PfModelException {
BeanValidationResult validationResult =
- new BeanValidationResult("participant statistics List", participantStatisticsList);
+ new BeanValidationResult("participant statistics List", participantStatisticsList);
for (ParticipantStatistics participantStatistics : participantStatisticsList) {
JpaParticipantStatistics jpaParticipantStatistics = new JpaParticipantStatistics();
@@ -137,9 +134,9 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
for (ParticipantStatistics participantStatisticsItem : participantStatisticsList) {
JpaParticipantStatistics jpaParticipantStatistics = getPfDao().get(JpaParticipantStatistics.class,
- new PfTimestampKey(participantStatisticsItem.getParticipantId().getName(),
- participantStatisticsItem.getParticipantId().getVersion(),
- participantStatisticsItem.getTimeStamp()));
+ new PfTimestampKey(participantStatisticsItem.getParticipantId().getName(),
+ participantStatisticsItem.getParticipantId().getVersion(),
+ participantStatisticsItem.getTimeStamp()));
participantStatistics.add(jpaParticipantStatistics.toAuthorative());
}
@@ -154,9 +151,9 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
* @return the participant statistics list
*/
private List<ParticipantStatistics> asParticipantStatisticsList(
- List<JpaParticipantStatistics> jpaParticipantStatisticsList) {
+ List<JpaParticipantStatistics> jpaParticipantStatisticsList) {
return jpaParticipantStatisticsList.stream().map(JpaParticipantStatistics::toAuthorative)
- .collect(Collectors.toList());
+ .collect(Collectors.toList());
}
}
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java
index 4b27e0df3..3ca4d3d34 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java
@@ -30,8 +30,8 @@ import lombok.ToString;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
- * Class to represent the base class for various messages that will be exchanged between
- * the control loop runtime and participants.
+ * Class to represent the base class for various messages that will be exchanged between the control loop runtime and
+ * participants.
*/
@Getter
@Setter
@@ -43,18 +43,22 @@ public class ParticipantMessage {
private UUID messageId = UUID.randomUUID();
/**
- * Time-stamp, in milliseconds, when the message was created. Defaults to the current
- * time.
+ * Time-stamp, in milliseconds, when the message was created. Defaults to the current time.
*/
private Instant timestamp = Instant.now();
/**
- * Participant ID, or {@code null} for state-change broadcast messages.
+ * Participant Type, or {@code null} for messages from participants.
+ */
+ private ToscaConceptIdentifier participantType;
+
+ /**
+ * Participant ID, or {@code null} for messages from participants.
*/
private ToscaConceptIdentifier participantId;
/**
- * Control loop ID. For state-change messages, this may be {@code null}.
+ * Control loop ID, or {@code null} for messages to participants.
*/
private ToscaConceptIdentifier controlLoopId;
@@ -68,30 +72,42 @@ public class ParticipantMessage {
}
/**
- * Constructs the object, making a deep copy. Does <i>not</i> copy the request id or
- * the time stamp.
+ * Constructs the object, making a deep copy. Does <i>not</i> copy the request id or the time stamp.
*
* @param source source from which to copy
*/
public ParticipantMessage(final ParticipantMessage source) {
this.messageType = source.messageType;
+ this.participantType = source.participantType;
this.participantId = source.participantId;
this.controlLoopId = source.controlLoopId;
}
/**
- * Determines if this message applies to this participant.
+ * Determines if this message applies to this participant type.
*
+ * @param participantType type of the participant to match against
* @param participantId id of the participant to match against
* @return {@code true} if this message applies to this participant, {@code false} otherwise
*/
- public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantId) {
- if (participantId.equals(this.participantId)) {
+ public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType,
+ @NonNull final ToscaConceptIdentifier participantId) {
+ // Broadcast message to all participants
+ if (this.participantType == null) {
+ return true;
+ }
+
+ // Broadcast message to all control loop elements on this participant
+ if (participantType.equals(this.participantType) && this.participantId == null) {
+ return true;
+ }
+
+ // Targeted message at this specific participant
+ if (participantType.equals(this.participantType) && participantId.equals(this.participantId)) {
return true;
}
- // false: message included a participant ID, but it does not match
- // true: its a broadcast message
- return this.participantId == null;
+ // Message is not for this participant
+ return false;
}
}
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java
index b7140d4b8..5b9284243 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java
@@ -26,6 +26,7 @@ import lombok.ToString;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
/**
* Class to represent the PARTICIPANT_STATUS message that all the participants send to the control loop runtime.
@@ -44,6 +45,9 @@ public class ParticipantStatus extends ParticipantMessage {
// Control Loops on the participant
private ControlLoops controlLoops;
+ // Participant statistics
+ private ParticipantStatistics participantStatistics;
+
// Description. May be left {@code null}.
private String message;