aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-controlloop/src/main/java')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java49
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java28
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java25
3 files changed, 90 insertions, 12 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 ba632f9cc..74b5394f4 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
@@ -34,8 +34,12 @@ import javax.ws.rs.core.Response.Status;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
+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.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType;
@@ -63,6 +67,8 @@ public class CommissioningProvider {
private final PolicyModelsProvider modelsProvider;
private final ControlLoopProvider clProvider;
private final ObjectMapper mapper = new ObjectMapper();
+ private final ParticipantProvider participantProvider;
+ private final SupervisionHandler supervisionHandler;
private static final Object lockit = new Object();
@@ -72,9 +78,14 @@ public class CommissioningProvider {
* @param modelsProvider the PolicyModelsProvider
* @param clProvider the ControlLoopProvider
*/
- public CommissioningProvider(PolicyModelsProvider modelsProvider, ControlLoopProvider clProvider) {
+ public CommissioningProvider(PolicyModelsProvider modelsProvider,
+ ControlLoopProvider clProvider,
+ SupervisionHandler supervisionHandler,
+ ParticipantProvider participantProvider) {
this.modelsProvider = modelsProvider;
this.clProvider = clProvider;
+ this.supervisionHandler = supervisionHandler;
+ this.participantProvider = participantProvider;
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
}
@@ -95,6 +106,24 @@ 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);
+ }
+ }
+
}
var response = new CommissioningResponse();
@@ -126,6 +155,24 @@ public class CommissioningProvider {
}
synchronized (lockit) {
+ 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);
+ }
+ }
+
modelsProvider.deleteServiceTemplate(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 0e2ff5ca9..7cc5d7fee 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
@@ -21,7 +21,6 @@
package org.onap.policy.clamp.controlloop.runtime.supervision;
import java.util.List;
-import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
@@ -35,6 +34,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopStateChangePublisher;
@@ -141,7 +141,7 @@ public class SupervisionHandler {
participantRegisterAckPublisher.send(participantRegisterMessage.getMessageId());
participantUpdatePublisher.send(participantRegisterMessage.getParticipantId(),
- participantRegisterMessage.getParticipantType());
+ participantRegisterMessage.getParticipantType(), true);
}
/**
@@ -166,6 +166,30 @@ 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);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
* Supervise a control loop, performing whatever actions need to be performed on the control loop.
*
* @param controlLoop the control loop to supervises
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 5edf528b8..d5dc4a6d0 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
@@ -22,22 +22,21 @@ package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
-import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
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.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -51,7 +50,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdatePublisher.class);
private static final String CONTROL_LOOP_ELEMENT = "ControlLoopElement";
- private final CommissioningProvider commissioningProvider;
+ private final PolicyModelsProvider modelsProvider;
private static final Coder CODER = new StandardCoder();
/**
@@ -60,7 +59,8 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
* @param participantId the participant Id
* @param participantType the participant Type
*/
- public void send(ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType) {
+ public void send(ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType,
+ boolean commissionFlag) {
var message = new ParticipantUpdate();
message.setParticipantId(participantId);
message.setParticipantType(participantType);
@@ -68,7 +68,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
ToscaServiceTemplate toscaServiceTemplate;
try {
- toscaServiceTemplate = commissioningProvider.getToscaServiceTemplate(null, null);
+ toscaServiceTemplate = modelsProvider.getServiceTemplateList(null, null).get(0);
} catch (PfModelException pfme) {
LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme);
return;
@@ -91,8 +91,15 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
}
}
- message.setParticipantDefinitionUpdates(participantDefinitionUpdates);
- message.setToscaServiceTemplate(toscaServiceTemplate);
+ if (commissionFlag) {
+ // Commission the controlloop but sending participantdefinitions to participants
+ message.setParticipantDefinitionUpdates(participantDefinitionUpdates);
+ message.setToscaServiceTemplate(toscaServiceTemplate);
+ } else {
+ // DeCommission the controlloop but deleting participantdefinitions on participants
+ message.setParticipantDefinitionUpdates(null);
+ message.setToscaServiceTemplate(null);
+ }
LOGGER.debug("Participant Update sent {}", message);
super.send(message);
}
@@ -127,7 +134,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
private ParticipantDefinition getParticipantDefinition(ControlLoopElementDefinition clDefinition,
ToscaConceptIdentifier clParticipantId,
List<ControlLoopElementDefinition> controlLoopElementDefinitionList) {
- ParticipantDefinition participantDefinition = new ParticipantDefinition();
+ var participantDefinition = new ParticipantDefinition();
participantDefinition.setParticipantId(clParticipantId);
controlLoopElementDefinitionList.add(clDefinition);
participantDefinition.setControlLoopElementDefinitionList(controlLoopElementDefinitionList);