summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src
diff options
context:
space:
mode:
authorwaynedunican <wayne.dunican@est.tech>2021-07-07 08:01:31 +0100
committerWayne Dunican <wayne.dunican@est.tech>2021-07-21 13:54:43 +0100
commitd99f6bd53c34745a95818c62eca2571f72a5f248 (patch)
tree5ac61cb801e052b5d66812ea5a7dbe3385569de1 /participant/participant-intermediary/src
parent931424fc681b1d41afbba98a190253283f9a6eba (diff)
Send ParticipantStatus heartbeat messages to controlloop runtime
Issue-ID: POLICY-3418 Change-Id: I957b0ff42ff617fb20ba4134770b43007415a49b Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java16
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java10
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java17
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java5
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java2
5 files changed, 40 insertions, 10 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java
index 1bfce1374..1741d9514 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java
@@ -67,18 +67,13 @@ public class MessageSender extends TimerTask implements Closeable {
// Kick off the timer
timerPool = makeTimerPool();
- timerPool.scheduleAtFixedRate(this, 0, interval, TimeUnit.SECONDS);
+ timerPool.scheduleAtFixedRate(this, 0, interval, TimeUnit.MILLISECONDS);
}
@Override
public void run() {
LOGGER.debug("Sent heartbeat to CLAMP");
-
- var response = new ParticipantResponseDetails();
-
- response.setResponseTo(null);
- response.setResponseStatus(ParticipantResponseStatus.PERIODIC);
- response.setResponseMessage("Periodic response from participant");
+ this.sendHeartbeat();
}
@Override
@@ -161,6 +156,13 @@ public class MessageSender extends TimerTask implements Closeable {
}
/**
+ * Dispatch a heartbeat for this participant.
+ */
+ public void sendHeartbeat() {
+ publisher.sendHeartbeat(participantHandler.makeHeartbeat());
+ }
+
+ /**
* Update ControlLoopElement statistics. The control loop elements listening will be
* notified to retrieve statistics from respective controlloop elements, and controlloopelements
* data on the handler will be updated.
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java
index 9e1b84620..051f00095 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java
@@ -90,4 +90,14 @@ public class ParticipantMessagePublisher {
topicSinkClient.send(participantUpdateAck);
LOGGER.debug("Sent Participant Update Ack message to CLAMP - {}", participantUpdateAck);
}
+
+ /**
+ * Method to send Participant heartbeat to clamp on demand.
+ *
+ * @param participantStatus the Participant Status
+ */
+ public void sendHeartbeat(final ParticipantStatus participantStatus) {
+ topicSinkClient.send(participantStatus);
+ LOGGER.debug("Sent Participant heartbeat to CLAMP - {}", participantStatus);
+ }
}
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 a8913c1f0..c94d5ad80 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
@@ -43,6 +43,7 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantResponseDetails;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantResponseStatus;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
+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.participant.intermediary.comm.MessageSender;
@@ -85,7 +86,8 @@ public class ParticipantHandler implements Closeable {
this.participantType = parameters.getIntermediaryParameters().getParticipantType();
this.participantId = parameters.getIntermediaryParameters().getParticipantId();
this.sender =
- new MessageSender(this, publisher, parameters.getIntermediaryParameters().getReportingTimeInterval());
+ new MessageSender(this, publisher,
+ parameters.getIntermediaryParameters().getReportingTimeIntervalMs());
this.controlLoopHandler = new ControlLoopHandler(parameters.getIntermediaryParameters(), sender);
this.participantStatistics = new ParticipantStatistics();
}
@@ -344,4 +346,17 @@ public class ParticipantHandler implements Closeable {
sender.sendParticipantUpdateAck(participantUpdateAck);
}
+
+ /**
+ * Method to send heartbeat to controlloop runtime.
+ */
+ public ParticipantStatus makeHeartbeat() {
+ ParticipantStatus heartbeat = new ParticipantStatus();
+ heartbeat.setParticipantId(participantId);
+ heartbeat.setParticipantStatistics(participantStatistics);
+ heartbeat.setParticipantType(participantType);
+ heartbeat.setHealthStatus(healthStatus);
+ heartbeat.setMessage("Participant heartbeat message sent from -> " + participantId.getName());
+ return heartbeat;
+ }
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
index 5627abfe6..fdc451e6b 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.controlloop.participant.intermediary.parameters;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Positive;
import lombok.Getter;
import lombok.Setter;
import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
@@ -50,7 +51,9 @@ public class ParticipantIntermediaryParameters {
private ToscaConceptIdentifier participantType;
// The time interval for periodic reporting of status to the CLAMP control loop server
- private long reportingTimeInterval;
+ @Valid
+ @Positive
+ private long reportingTimeIntervalMs;
@NotNull
@ParameterGroupConstraint
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java
index 93ba15846..9353cde81 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java
@@ -68,7 +68,7 @@ public class CommonTestData {
map.put("participantId", getParticipantId());
map.put("description", DESCRIPTION);
map.put("participantType", getParticipantId());
- map.put("reportingTimeInterval", TIME_INTERVAL);
+ map.put("reportingTimeIntervalMs", TIME_INTERVAL);
map.put("clampControlLoopTopics", getTopicParametersMap(false));
return map;