diff options
16 files changed, 74 insertions, 21 deletions
diff --git a/common/src/main/resources/tosca/PolicyControlLoopElementType.yaml b/common/src/main/resources/tosca/PolicyControlLoopElementType.yaml index e584c2fce..bf66718ca 100644 --- a/common/src/main/resources/tosca/PolicyControlLoopElementType.yaml +++ b/common/src/main/resources/tosca/PolicyControlLoopElementType.yaml @@ -31,3 +31,9 @@ node_types: description: The policy that this control loop element is managing, if the policy ID is specified, the policy is either already in the Policy Framework database or is specified in the "policies" part of the TOSCA service template of the Control Loop definition + pdpGroup: + type: string + required: false + default: defaultGroup + description: The PDP group to which the policy should be deployed. This parameter is used when the policy is + deployed to PAP. The value defaults to the "defaultGroup", which always exists. diff --git a/common/src/test/resources/demo/Notes.txt b/common/src/test/resources/demo/Notes.txt index 777cdc0e1..43b75e915 100644 --- a/common/src/test/resources/demo/Notes.txt +++ b/common/src/test/resources/demo/Notes.txt @@ -6,9 +6,8 @@ $ docker run -p 3904:3904 --volume //c/Users/${USER}/Github/simulator/distributi Run DMaaP simulator using Maven Check out policy models -Go to policy/models/models-sim/models-sim-dmaap -mvn exec:java -Dexec.mainClass=org.onap.policy.models.sim.dmaap.startstop.Main -Dexec.args="-c src/main/resources/etc/DefaultConfig.json" - +Go to policy/models/models-sim/policy-models-simulators +mvn exec:java -Dexec.mainClass=org.onap.policy.models.simulators.Main -Dexec.args="src/test/resources/simParameters.json" Run CL from command line Go to clamp/runtime-controlloop diff --git a/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml index 44ba5b3e8..115170e2c 100644 --- a/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml @@ -28,7 +28,7 @@ participant: aaf: false intermediaryParameters: name: Participant parameters - reportingTimeInterval: 120000 + reportingTimeIntervalMs: 120000 description: Participant Description participantId: name: DCAEParticipant0 diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java index 4b6dcd619..a28a6ece1 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java @@ -172,7 +172,7 @@ public class CommonTestData { final Map<String, Object> map = new TreeMap<>(); if (!isEmpty) { map.put("name", "Participant parameters"); - map.put("reportingTimeInterval", TIME_INTERVAL); + map.put("reportingTimeIntervalMs", TIME_INTERVAL); map.put("description", DESCRIPTION); map.put("participantId", getParticipantId()); map.put("participantType", getParticipantId()); diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml index 9d3523737..68a1afd1a 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml @@ -10,7 +10,7 @@ participant: localChartDirectory: /var/helm-manager/local-charts infoFileName: CHART_INFO.json intermediaryParameters: - reportingTimeInterval: 120000 + reportingTimeIntervalMs: 120000 description: Participant Description participantId: name: K8sParticipant0 diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/parameters/CommonTestData.java index d8d477d1b..9255ee6dc 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/parameters/CommonTestData.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/parameters/CommonTestData.java @@ -99,7 +99,7 @@ public class CommonTestData { final Map<String, Object> map = new TreeMap<>(); if (!isEmpty) { map.put("name", "Participant parameters"); - map.put("reportingTimeInterval", TIME_INTERVAL); + map.put("reportingTimeIntervalMs", TIME_INTERVAL); map.put("description", DESCRIPTION); map.put("participantId", getParticipantId()); map.put("participantType", getParticipantId()); diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml index d4c7d7561..ef158ce97 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml @@ -9,7 +9,7 @@ participant: https: true allowSelfSignedCerts: true intermediaryParameters: - reportingTimeInterval: 120000 + reportingTimeIntervalMs: 120000 description: Participant Description participantId: name: org.onap.PM_Policy diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java index 4b4558b89..093ac190c 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java @@ -20,6 +20,8 @@ package org.onap.policy.clamp.controlloop.participant.policy.endtoend; +import static org.assertj.core.api.Assertions.assertThatCode; + import java.time.Instant; import java.util.Collections; import java.util.UUID; @@ -30,6 +32,8 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantResponseDetails; +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.ParticipantDeregisterAckListener; @@ -139,6 +143,20 @@ class ParticipantMessagesTest { } } + @Test + void testParticipantStatusHeartbeat() throws Exception { + final ParticipantStatus heartbeat = new ParticipantStatus(); + heartbeat.setMessage("ParticipantStatus message"); + heartbeat.setResponse(new ParticipantResponseDetails()); + heartbeat.setParticipantId(getParticipantId()); + synchronized (lockit) { + ParticipantMessagePublisher publisher = + new ParticipantMessagePublisher(Collections.singletonList(Mockito.mock(TopicSink.class))); + assertThatCode(() -> publisher.sendHeartbeat(heartbeat)).doesNotThrowAnyException(); + } + } + + private ToscaConceptIdentifier getParticipantId() { return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"); } diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java index 38861472c..a34c9cda5 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java @@ -99,7 +99,7 @@ public class CommonTestData { final Map<String, Object> map = new TreeMap<>(); if (!isEmpty) { map.put("name", "Participant parameters"); - map.put("reportingTimeInterval", TIME_INTERVAL); + map.put("reportingTimeIntervalMs", TIME_INTERVAL); map.put("description", DESCRIPTION); map.put("participantId", getParticipantId()); map.put("participantType", getParticipantId()); diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml index 5a9cf1497..917c50db4 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml @@ -13,7 +13,7 @@ server: participant: intermediaryParameters: - reportingTimeInterval: 120000 + reportingTimeIntervalMs: 120000 description: Participant Description participantId: name: org.onap.PM_CDS_Blueprint diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java index e85b3ebbe..9c41c8bcb 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java @@ -79,7 +79,7 @@ public class CommonTestData { final Map<String, Object> map = new TreeMap<>(); if (!isEmpty) { map.put("name", "Participant parameters"); - map.put("reportingTimeInterval", TIME_INTERVAL); + map.put("reportingTimeIntervalMs", TIME_INTERVAL); map.put("description", DESCRIPTION); map.put("participantId", getParticipantId()); map.put("participantType", getParticipantId()); 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 27b5389a5..4842c3edd 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; |