diff options
Diffstat (limited to 'participant')
25 files changed, 260 insertions, 407 deletions
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..a873f76b3 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 @@ -1,3 +1,5 @@ +server: + port: 8081 participant: name: ControlLoopParticipantDcae @@ -28,7 +30,7 @@ participant: aaf: false intermediaryParameters: name: Participant parameters - reportingTimeInterval: 120000 + reportingTimeIntervalMs: 120000 description: Participant Description participantId: name: DCAEParticipant0 @@ -37,15 +39,19 @@ participant: name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant version: 2.3.4 clampControlLoopTopics: - topicSources[0]: - topic: POLICY-CLRUNTIME-PARTICIPANT - servers[0]: ${topicServer:message-router} - topicCommInfrastructure: dmaap - fetchTimeout: 15000 - topicSinks[0]: - topic: POLICY-CLRUNTIME-PARTICIPANT - servers[0]: ${topicServer:message-router} - topicCommInfrastructure: dmaap + topicSources: + - + topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap + fetchTimeout: 15000 + topicSinks: + - + topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap checkCount: 10 secCount: 10 jsonBodyConsulPath: src/main/resources/parameters/consul.json diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/ParticipantDcaeTest.java index 3f5e42542..a3fcfdd9e 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/ParticipantDcaeTest.java @@ -32,8 +32,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockserver.integration.ClientAndServer; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.CommonTestData; import org.onap.policy.clamp.controlloop.participant.dcae.main.rest.TestListenerUtils; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopStateChangeListener; @@ -50,7 +50,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @TestPropertySource(locations = {"classpath:application_test.properties"}) -class PartecipantDcaeTest { +class ParticipantDcaeTest { private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; private static final String TOPIC = "my-topic"; @@ -103,74 +103,74 @@ class PartecipantDcaeTest { } @Test - void testParticipantControlLoopStateChangeMessageListener() { - ParticipantControlLoopStateChange participantControlLoopStateChangeMsg = + void testControlLoopStateChangeMessageListener() { + ControlLoopStateChange controlLoopStateChangeMsg = TestListenerUtils.createControlLoopStateChangeMsg(ControlLoopOrderedState.UNINITIALISED); - participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.PASSIVE); + controlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.PASSIVE); ControlLoopStateChangeListener clStateChangeListener = new ControlLoopStateChangeListener(participantHandler); - clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); - assertEquals(ControlLoopOrderedState.PASSIVE, participantControlLoopStateChangeMsg.getOrderedState()); + clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, controlLoopStateChangeMsg); + assertEquals(ControlLoopOrderedState.PASSIVE, controlLoopStateChangeMsg.getOrderedState()); - participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.RUNNING); - clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); - assertEquals(ControlLoopOrderedState.RUNNING, participantControlLoopStateChangeMsg.getOrderedState()); + controlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.RUNNING); + clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, controlLoopStateChangeMsg); + assertEquals(ControlLoopOrderedState.RUNNING, controlLoopStateChangeMsg.getOrderedState()); - participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.RUNNING); - clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); - assertEquals(ControlLoopOrderedState.RUNNING, participantControlLoopStateChangeMsg.getOrderedState()); + controlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.RUNNING); + clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, controlLoopStateChangeMsg); + assertEquals(ControlLoopOrderedState.RUNNING, controlLoopStateChangeMsg.getOrderedState()); } @Test void testControlLoopUpdateListener_ParticipantIdNoMatch() throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getParticipantId().setName("DummyName"); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getParticipantId().setName("DummyName"); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); // Verify the content in participantHandler - assertNotEquals(participantControlLoopUpdateMsg.getParticipantId().getName(), + assertNotEquals(controlLoopUpdateMsg.getParticipantId().getName(), participantHandler.getParticipantId().getName()); } @Test void testControlLoopUpdateListenerPassive() throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); // Verify the content in participantHandler - assertEquals(participantHandler.getParticipantId(), participantControlLoopUpdateMsg.getParticipantId()); + assertEquals(participantHandler.getParticipantId(), controlLoopUpdateMsg.getParticipantId()); assertEquals(1, participantHandler.getControlLoopHandler().getControlLoops().getControlLoopList().size()); } @Test void testControlLoopUpdateListenerUninitialised() throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED); ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); // Verify the content in participantHandler - assertEquals(participantHandler.getParticipantId(), participantControlLoopUpdateMsg.getParticipantId()); + assertEquals(participantHandler.getParticipantId(), controlLoopUpdateMsg.getParticipantId()); assertEquals(1, participantHandler.getControlLoopHandler().getControlLoops().getControlLoopList().size()); } @Test void testControlLoopUpdateListenerString() throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED); - - assertThat(participantControlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); - ParticipantControlLoopUpdate copyParticipantControlLoopUpdateMsg = - TestListenerUtils.createCopyControlLoopUpdateMsg(participantControlLoopUpdateMsg); - assertThat(copyParticipantControlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); - assertNotEquals(participantControlLoopUpdateMsg, copyParticipantControlLoopUpdateMsg); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED); + + assertThat(controlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); + ControlLoopUpdate copyControlLoopUpdateMsg = + TestListenerUtils.createCopyControlLoopUpdateMsg(controlLoopUpdateMsg); + assertThat(copyControlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); + assertNotEquals(controlLoopUpdateMsg, copyControlLoopUpdateMsg); } } 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-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java index 4579b52bf..bb1021db6 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java @@ -30,10 +30,9 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -88,35 +87,15 @@ public class TestListenerUtils { } /** - * Method to create ParticipantStateChange message from the arguments passed. - * - * @param participantState participant State - * - * @return ParticipantStateChange message - */ - public static ParticipantStateChange createParticipantStateChangeMsg(final ParticipantState participantState) { - final ParticipantStateChange participantStateChangeMsg = new ParticipantStateChange(); - ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(); - participantId.setName("DCAEParticipant0"); - participantId.setVersion("1.0.0"); - - participantStateChangeMsg.setParticipantId(participantId); - participantStateChangeMsg.setTimestamp(Instant.now()); - participantStateChangeMsg.setState(participantState); - - return participantStateChangeMsg; - } - - /** * Method to create ControlLoopStateChange message from the arguments passed. * * @param controlLoopOrderedState controlLoopOrderedState * - * @return ParticipantControlLoopStateChange message + * @return ControlLoopStateChange message */ - public static ParticipantControlLoopStateChange createControlLoopStateChangeMsg( + public static ControlLoopStateChange createControlLoopStateChangeMsg( final ControlLoopOrderedState controlLoopOrderedState) { - final ParticipantControlLoopStateChange participantClStateChangeMsg = new ParticipantControlLoopStateChange(); + final ControlLoopStateChange clStateChangeMsg = new ControlLoopStateChange(); ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); controlLoopId.setName("PMSHInstance0"); @@ -126,21 +105,21 @@ public class TestListenerUtils { participantId.setName("DCAEParticipant0"); participantId.setVersion("1.0.0"); - participantClStateChangeMsg.setControlLoopId(controlLoopId); - participantClStateChangeMsg.setParticipantId(participantId); - participantClStateChangeMsg.setTimestamp(Instant.now()); - participantClStateChangeMsg.setOrderedState(controlLoopOrderedState); + clStateChangeMsg.setControlLoopId(controlLoopId); + clStateChangeMsg.setParticipantId(participantId); + clStateChangeMsg.setTimestamp(Instant.now()); + clStateChangeMsg.setOrderedState(controlLoopOrderedState); - return participantClStateChangeMsg; + return clStateChangeMsg; } /** * Method to create ControlLoopUpdateMsg. * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message */ - public static ParticipantControlLoopUpdate createControlLoopUpdateMsg() { - final ParticipantControlLoopUpdate clUpdateMsg = new ParticipantControlLoopUpdate(); + public static ControlLoopUpdate createControlLoopUpdateMsg() { + final ControlLoopUpdate clUpdateMsg = new ControlLoopUpdate(); ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); controlLoopId.setName("PMSHInstance0"); controlLoopId.setVersion("1.0.0"); @@ -177,7 +156,6 @@ public class TestListenerUtils { controlLoop.setVersion("1.0.0"); controlLoop.setDefinition(controlLoopId); clUpdateMsg.setControlLoop(controlLoop); - clUpdateMsg.setControlLoopDefinition(toscaServiceTemplate); return clUpdateMsg; } @@ -185,10 +163,10 @@ public class TestListenerUtils { /** * Method to create a deep copy of ControlLoopUpdateMsg. * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message */ - public static ParticipantControlLoopUpdate createCopyControlLoopUpdateMsg(ParticipantControlLoopUpdate cpy) { - return new ParticipantControlLoopUpdate(cpy); + public static ControlLoopUpdate createCopyControlLoopUpdateMsg(ControlLoopUpdate cpy) { + return new ControlLoopUpdate(cpy); } /** @@ -215,18 +193,18 @@ public class TestListenerUtils { } /** - * Method to create ParticipantControlLoopUpdate using the arguments passed. + * Method to create ControlLoopUpdate using the arguments passed. * * @param jsonFilePath the path of the controlloop content * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message * @throws CoderException exception while reading the file to object */ - public static ParticipantControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) + public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = - CODER.decode(new File(jsonFilePath), ParticipantControlLoopUpdate.class); - return participantControlLoopUpdateMsg; + ControlLoopUpdate controlLoopUpdateMsg = + CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class); + return controlLoopUpdateMsg; } private static ToscaServiceTemplate testControlLoopRead() { 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..a27c33d44 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 @@ -19,15 +19,19 @@ participant: name: org.onap.k8s.controlloop.K8SControlLoopParticipant version: 2.3.4 clampControlLoopTopics: - topicSources[0]: - topic: POLICY-CLRUNTIME-PARTICIPANT - servers[0]: ${topicServer:message-router} - topicCommInfrastructure: dmaap - fetchTimeout: 15000 - topicSinks[0]: - topic: POLICY-CLRUNTIME-PARTICIPANT - servers[0]: ${topicServer:message-router} - topicCommInfrastructure: dmaap + topicSources: + - + topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap + fetchTimeout: 15000 + topicSinks: + - + topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap management: endpoints: 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..32cd28cd3 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 @@ -1,3 +1,5 @@ +server: + port: 8082 participant: policyApiParameters: @@ -9,7 +11,7 @@ participant: https: true allowSelfSignedCerts: true intermediaryParameters: - reportingTimeInterval: 120000 + reportingTimeIntervalMs: 120000 description: Participant Description participantId: name: org.onap.PM_Policy @@ -18,12 +20,16 @@ participant: name: org.onap.policy.controlloop.PolicyControlLoopParticipant version: 2.3.1 clampControlLoopTopics: - topicSources[0]: - topic: POLICY-CLRUNTIME-PARTICIPANT - servers[0]: ${topicServer:message-router} - topicCommInfrastructure: dmaap - fetchTimeout: 15000 - topicSinks[0]: - topic: POLICY-CLRUNTIME-PARTICIPANT - servers[0]: ${topicServer:message-router} - topicCommInfrastructure: dmaap + topicSources: + - + topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap + fetchTimeout: 15000 + topicSinks: + - + topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap 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/endtoend/ParticipantPolicyTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java index 45674f4c8..10563cde2 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java @@ -21,17 +21,14 @@ package org.onap.policy.clamp.controlloop.participant.policy.endtoend; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopStateChangeListener; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantUpdateListener; import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; import org.onap.policy.clamp.controlloop.participant.policy.main.utils.TestListenerUtils; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; @@ -55,16 +52,13 @@ class ParticipantPolicyTest { @Test void testUpdatePolicyTypes() { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); - - // Verify that the ToscaServicetemplate has policy_types - assertNotNull(participantControlLoopUpdateMsg.getControlLoopDefinition().getPolicyTypes()); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); synchronized (lockit) { ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); } // Verify the result of GET participants with what is stored assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName()); @@ -72,20 +66,13 @@ class ParticipantPolicyTest { @Test void testUpdatePolicies() throws Exception { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); - - // Add policies to the toscaServiceTemplate - TestListenerUtils.addPoliciesToToscaServiceTemplate(participantControlLoopUpdateMsg.getControlLoopDefinition()); - - // Verify that the ToscaServicetemplate has policies - assertNotNull( - participantControlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies()); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); synchronized (lockit) { ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); } // Verify the result of GET participants with what is stored assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName()); @@ -93,29 +80,22 @@ class ParticipantPolicyTest { @Test void testDeletePoliciesAndPolicyTypes() throws Exception { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); - - // Add policies to the toscaServiceTemplate - TestListenerUtils.addPoliciesToToscaServiceTemplate(participantControlLoopUpdateMsg.getControlLoopDefinition()); - - // Verify that the ToscaServicetemplate has policies - assertNotNull( - participantControlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies()); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); synchronized (lockit) { ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); } // Verify the result of GET participants with what is stored assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName()); ControlLoopStateChangeListener clStateChangeListener = new ControlLoopStateChangeListener(participantHandler); - ParticipantControlLoopStateChange participantControlLoopStateChangeMsg = + ControlLoopStateChange controlLoopStateChangeMsg = TestListenerUtils.createControlLoopStateChangeMsg(ControlLoopOrderedState.UNINITIALISED); - participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); + controlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.UNINITIALISED); + clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, controlLoopStateChangeMsg); // Verify the result of GET participants with what is stored assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName()); 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-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java index d439c9daf..fe7e17fd7 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java @@ -35,10 +35,9 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.CommonTestData; import org.onap.policy.common.utils.coder.Coder; @@ -100,35 +99,15 @@ public class TestListenerUtils { } /** - * Method to create ParticipantStateChange message from the arguments passed. - * - * @param participantState participant State - * - * @return ParticipantStateChange message - */ - public static ParticipantStateChange createParticipantStateChangeMsg(final ParticipantState participantState) { - final ParticipantStateChange participantStateChangeMsg = new ParticipantStateChange(); - ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(); - participantId.setName("org.onap.PM_Policy"); - participantId.setVersion("0.0.0"); - - participantStateChangeMsg.setParticipantId(participantId); - participantStateChangeMsg.setTimestamp(Instant.now()); - participantStateChangeMsg.setState(participantState); - - return participantStateChangeMsg; - } - - /** * Method to create ControlLoopStateChange message from the arguments passed. * * @param controlLoopOrderedState controlLoopOrderedState * - * @return ParticipantControlLoopStateChange message + * @return ControlLoopStateChange message */ - public static ParticipantControlLoopStateChange createControlLoopStateChangeMsg( + public static ControlLoopStateChange createControlLoopStateChangeMsg( final ControlLoopOrderedState controlLoopOrderedState) { - final ParticipantControlLoopStateChange participantClStateChangeMsg = new ParticipantControlLoopStateChange(); + final ControlLoopStateChange clStateChangeMsg = new ControlLoopStateChange(); ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); controlLoopId.setName("PMSHInstance0"); @@ -138,21 +117,21 @@ public class TestListenerUtils { participantId.setName("org.onap.PM_Policy"); participantId.setVersion("0.0.0"); - participantClStateChangeMsg.setControlLoopId(controlLoopId); - participantClStateChangeMsg.setParticipantId(participantId); - participantClStateChangeMsg.setTimestamp(Instant.now()); - participantClStateChangeMsg.setOrderedState(controlLoopOrderedState); + clStateChangeMsg.setControlLoopId(controlLoopId); + clStateChangeMsg.setParticipantId(participantId); + clStateChangeMsg.setTimestamp(Instant.now()); + clStateChangeMsg.setOrderedState(controlLoopOrderedState); - return participantClStateChangeMsg; + return clStateChangeMsg; } /** * Method to create ControlLoopUpdateMsg. * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message */ - public static ParticipantControlLoopUpdate createControlLoopUpdateMsg() { - final ParticipantControlLoopUpdate clUpdateMsg = new ParticipantControlLoopUpdate(); + public static ControlLoopUpdate createControlLoopUpdateMsg() { + final ControlLoopUpdate clUpdateMsg = new ControlLoopUpdate(); ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); controlLoopId.setName("PMSHInstance0"); controlLoopId.setVersion("1.0.0"); @@ -189,7 +168,6 @@ public class TestListenerUtils { controlLoop.setVersion("1.0.0"); controlLoop.setDefinition(controlLoopId); clUpdateMsg.setControlLoop(controlLoop); - clUpdateMsg.setControlLoopDefinition(toscaServiceTemplate); return clUpdateMsg; } @@ -211,11 +189,9 @@ public class TestListenerUtils { participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000)); participantUpdateMsg.setMessageId(UUID.randomUUID()); - ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate(); - toscaServiceTemplate.setName("serviceTemplate"); - toscaServiceTemplate.setDerivedFrom("parentServiceTemplate"); - toscaServiceTemplate.setDescription("Description of serviceTemplate"); - toscaServiceTemplate.setVersion("1.2.3"); + ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead(); + // Add policies to the toscaServiceTemplate + TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate); ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition(); clDefinition.setId(UUID.randomUUID()); @@ -257,18 +233,18 @@ public class TestListenerUtils { } /** - * Method to create ParticipantControlLoopUpdate using the arguments passed. + * Method to create ControlLoopUpdate using the arguments passed. * * @param jsonFilePath the path of the controlloop content * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message * @throws CoderException exception while reading the file to object */ - public static ParticipantControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) + public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = - CODER.decode(new File(jsonFilePath), ParticipantControlLoopUpdate.class); - return participantControlLoopUpdateMsg; + ControlLoopUpdate controlLoopUpdateMsg = + CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class); + return controlLoopUpdateMsg; } private static ToscaServiceTemplate testControlLoopRead() { 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..c26749b4d 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 @@ -5,7 +5,7 @@ spring: password: zb!XztG34 server: - port: 6969 + port: 8084 servlet: context-path: /onap/participantsim error: @@ -13,7 +13,7 @@ server: participant: intermediaryParameters: - reportingTimeInterval: 120000 + reportingTimeIntervalMs: 120000 description: Participant Description participantId: name: org.onap.PM_CDS_Blueprint @@ -22,12 +22,16 @@ participant: name: org.onap.PM_CDS_Blueprint version: 1.0.0 clampControlLoopTopics: - topicSources[0]: - topic: POLICY-CLRUNTIME-PARTICIPANT - servers[0]: ${topicServer:message-router} - topicCommInfrastructure: dmaap - fetchTimeout: 15000 - topicSinks[0]: - topic: POLICY-CLRUNTIME-PARTICIPANT - servers[0]: ${topicServer:message-router} - topicCommInfrastructure: dmaap + topicSources: + - + topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap + fetchTimeout: 15000 + topicSinks: + - + topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java index 0b63c395a..beb50da37 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java @@ -36,7 +36,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse; import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener; @@ -103,10 +103,10 @@ class ParticipantSimulatorTest { ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); } } 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-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java index 8aa40cbd5..999feb1e1 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java @@ -34,9 +34,8 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; @@ -98,52 +97,34 @@ public class TestListenerUtils { } /** - * Method to create ParticipantStateChange message from the arguments passed. - * - * @param participantState participant State - * - * @return ParticipantStateChange message - */ - public static ParticipantStateChange createParticipantStateChangeMsg(final ParticipantState participantState) { - final ParticipantStateChange participantStateChangeMsg = new ParticipantStateChange(); - ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0"); - - participantStateChangeMsg.setParticipantId(participantId); - participantStateChangeMsg.setTimestamp(Instant.now()); - participantStateChangeMsg.setState(participantState); - - return participantStateChangeMsg; - } - - /** * Method to create ControlLoopStateChange message from the arguments passed. * * @param controlLoopOrderedState controlLoopOrderedState * - * @return ParticipantControlLoopStateChange message + * @return ControlLoopStateChange message */ - public static ParticipantControlLoopStateChange createControlLoopStateChangeMsg( + public static ControlLoopStateChange createControlLoopStateChangeMsg( final ControlLoopOrderedState controlLoopOrderedState) { - final ParticipantControlLoopStateChange participantClStateChangeMsg = new ParticipantControlLoopStateChange(); + final ControlLoopStateChange clStateChangeMsg = new ControlLoopStateChange(); ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0"); - participantClStateChangeMsg.setControlLoopId(controlLoopId); - participantClStateChangeMsg.setParticipantId(participantId); - participantClStateChangeMsg.setTimestamp(Instant.now()); - participantClStateChangeMsg.setOrderedState(controlLoopOrderedState); + clStateChangeMsg.setControlLoopId(controlLoopId); + clStateChangeMsg.setParticipantId(participantId); + clStateChangeMsg.setTimestamp(Instant.now()); + clStateChangeMsg.setOrderedState(controlLoopOrderedState); - return participantClStateChangeMsg; + return clStateChangeMsg; } /** * Method to create ControlLoopUpdateMsg. * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message */ - public static ParticipantControlLoopUpdate createControlLoopUpdateMsg() { - final ParticipantControlLoopUpdate clUpdateMsg = new ParticipantControlLoopUpdate(); + public static ControlLoopUpdate createControlLoopUpdateMsg() { + final ControlLoopUpdate clUpdateMsg = new ControlLoopUpdate(); ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0"); @@ -177,24 +158,23 @@ public class TestListenerUtils { controlLoop.setVersion("1.0.0"); controlLoop.setDefinition(controlLoopId); clUpdateMsg.setControlLoop(controlLoop); - clUpdateMsg.setControlLoopDefinition(toscaServiceTemplate); return clUpdateMsg; } /** - * Method to create ParticipantControlLoopUpdate using the arguments passed. + * Method to create ControlLoopUpdate using the arguments passed. * * @param jsonFilePath the path of the controlloop content * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message * @throws CoderException exception while reading the file to object */ - public static ParticipantControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) + public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = - CODER.decode(new File(jsonFilePath), ParticipantControlLoopUpdate.class); - return participantControlLoopUpdateMsg; + ControlLoopUpdate controlLoopUpdateMsg = + CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class); + return controlLoopUpdateMsg; } private static ToscaServiceTemplate testControlLoopRead() { diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java index e46c6db1b..0b9110bd0 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java @@ -20,7 +20,7 @@ package org.onap.policy.clamp.controlloop.participant.intermediary.comm; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; import org.springframework.stereotype.Component; @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component; * Listener for Participant State Change messages sent by CLAMP. */ @Component -public class ControlLoopStateChangeListener extends ParticipantListener<ParticipantControlLoopStateChange> { +public class ControlLoopStateChangeListener extends ParticipantListener<ControlLoopStateChange> { /** * Constructs the object. @@ -36,7 +36,7 @@ public class ControlLoopStateChangeListener extends ParticipantListener<Particip * @param participantHandler the handler for managing the state of the participant */ public ControlLoopStateChangeListener(final ParticipantHandler participantHandler) { - super(ParticipantControlLoopStateChange.class, participantHandler, + super(ControlLoopStateChange.class, participantHandler, participantHandler::handleControlLoopStateChange); } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java index d15643e0f..56bc1fd9a 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java @@ -20,7 +20,7 @@ package org.onap.policy.clamp.controlloop.participant.intermediary.comm; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; import org.springframework.stereotype.Component; @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component; * Listener for Control Loop Update messages sent by CLAMP. */ @Component -public class ControlLoopUpdateListener extends ParticipantListener<ParticipantControlLoopUpdate> { +public class ControlLoopUpdateListener extends ParticipantListener<ControlLoopUpdate> { /** * Constructs the object. @@ -36,6 +36,6 @@ public class ControlLoopUpdateListener extends ParticipantListener<ParticipantCo * @param participantHandler the handler for managing the state of the participant */ public ControlLoopUpdateListener(final ParticipantHandler participantHandler) { - super(ParticipantControlLoopUpdate.class, participantHandler, participantHandler::handleControlLoopUpdate); + super(ControlLoopUpdate.class, participantHandler, participantHandler::handleControlLoopUpdate); } } 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/comm/ParticipantStateChangeListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStateChangeListener.java deleted file mode 100644 index ec6548a7c..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStateChangeListener.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.springframework.stereotype.Component; - -/** - * Listener for Participant State Change messages sent by CLAMP. - * - */ -@Component -public class ParticipantStateChangeListener extends ParticipantListener<ParticipantStateChange> { - - /** - * Constructs the object. - * - * @param participantHandler the handler for managing the state of the participant - */ - public ParticipantStateChangeListener(final ParticipantHandler participantHandler) { - super(ParticipantStateChange.class, participantHandler, participantHandler::handleParticipantStateChange); - } -} 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 50048ffc2..c9da1279d 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 @@ -31,11 +31,12 @@ import org.apache.commons.collections4.CollectionUtils; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; 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.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; 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.participant.intermediary.api.ControlLoopElementListener; @@ -130,7 +131,7 @@ public class ControlLoopHandler { * * @param stateChangeMsg the state change message */ - public void handleControlLoopStateChange(ParticipantControlLoopStateChange stateChangeMsg) { + public void handleControlLoopStateChange(ControlLoopStateChange stateChangeMsg) { if (stateChangeMsg.getControlLoopId() == null) { return; } @@ -177,7 +178,8 @@ public class ControlLoopHandler { * * @param updateMsg the update message */ - public void handleControlLoopUpdate(ParticipantControlLoopUpdate updateMsg) { + public void handleControlLoopUpdate(ControlLoopUpdate updateMsg, + Map<UUID, ControlLoopElementDefinition> clElementDefinitions) { if (!updateMsg.appliesTo(participantType, participantId)) { return; @@ -211,7 +213,8 @@ public class ControlLoopHandler { for (ControlLoopElementListener clElementListener : listeners) { try { for (ControlLoopElement element : updateMsg.getControlLoop().getElements().values()) { - clElementListener.controlLoopElementUpdate(element, updateMsg.getControlLoopDefinition()); + clElementListener.controlLoopElementUpdate(element, + clElementDefinitions.get(element.getId()).getControlLoopElementToscaServiceTemplate()); } } catch (PfModelException e) { LOGGER.debug("Control loop element update failed {}", updateMsg.getControlLoopId()); diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java index 0aa536746..f846b2d75 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java @@ -30,7 +30,6 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLo import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantDeregisterAckListener; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantHealthCheckListener; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantRegisterAckListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantStateChangeListener; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantUpdateListener; import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; @@ -120,16 +119,13 @@ public class IntermediaryActivator extends ServiceManagerContainer implements Cl private void registerMsgDispatcher() { MessageTypeDispatcher msgDispatcher = applicationContext.getBean(MessageTypeDispatcher.class); - msgDispatcher.register(ParticipantMessageType.PARTICIPANT_STATE_CHANGE.name(), - applicationContext.getBean(ParticipantStateChangeListener.class)); - msgDispatcher.register(ParticipantMessageType.PARTICIPANT_HEALTH_CHECK.name(), applicationContext.getBean(ParticipantHealthCheckListener.class)); - msgDispatcher.register(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_STATE_CHANGE.name(), + msgDispatcher.register(ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE.name(), applicationContext.getBean(ControlLoopStateChangeListener.class)); - msgDispatcher.register(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_UPDATE.name(), + msgDispatcher.register(ParticipantMessageType.CONTROL_LOOP_UPDATE.name(), applicationContext.getBean(ControlLoopUpdateListener.class)); msgDispatcher.register(ParticipantMessageType.PARTICIPANT_REGISTER_ACK.name(), 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..9daff7239 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 @@ -32,8 +32,8 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant 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; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck; @@ -42,7 +42,7 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti 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.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 +85,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(); } @@ -96,46 +97,6 @@ public class ParticipantHandler implements Closeable { } /** - * Method which handles a participant state change event from clamp. - * - * @param stateChangeMsg participant state change message - */ - public void handleParticipantStateChange(final ParticipantStateChange stateChangeMsg) { - - if (!stateChangeMsg.appliesTo(participantType, participantId)) { - return; - } - - var response = new ParticipantResponseDetails(stateChangeMsg); - - switch (stateChangeMsg.getState()) { - case PASSIVE: - handlePassiveState(response); - break; - case ACTIVE: - handleActiveState(response); - break; - case SAFE: - handleSafeState(response); - break; - case TEST: - handleTestState(response); - break; - case TERMINATED: - handleTerminatedState(response); - break; - default: - LOGGER.debug("StateChange message has no state, state is null {}", stateChangeMsg.getParticipantId()); - response.setResponseStatus(ParticipantResponseStatus.FAIL); - response.setResponseMessage( - "StateChange message has invalid state for participantId " + stateChangeMsg.getParticipantId()); - break; - } - - sender.sendResponse(response); - } - - /** * Method which handles a participant health check event from clamp. * * @param healthCheckMsg participant health check message @@ -153,8 +114,8 @@ public class ParticipantHandler implements Closeable { * * @param updateMsg the update message */ - public void handleControlLoopUpdate(ParticipantControlLoopUpdate updateMsg) { - controlLoopHandler.handleControlLoopUpdate(updateMsg); + public void handleControlLoopUpdate(ControlLoopUpdate updateMsg) { + controlLoopHandler.handleControlLoopUpdate(updateMsg, clElementDefsOnThisParticipant); } /** @@ -162,55 +123,10 @@ public class ParticipantHandler implements Closeable { * * @param stateChangeMsg the state change message */ - public void handleControlLoopStateChange(ParticipantControlLoopStateChange stateChangeMsg) { + public void handleControlLoopStateChange(ControlLoopStateChange stateChangeMsg) { controlLoopHandler.handleControlLoopStateChange(stateChangeMsg); } - /** - * Method to handle when the new state from participant is active. - * - * @param response participant response - */ - private void handleActiveState(final ParticipantResponseDetails response) { - handleStateChange(ParticipantState.ACTIVE, response); - } - - /** - * Method to handle when the new state from participant is passive. - * - * @param response participant response - */ - private void handlePassiveState(final ParticipantResponseDetails response) { - handleStateChange(ParticipantState.PASSIVE, response); - } - - /** - * Method to handle when the new state from participant is safe. - * - * @param response participant response - */ - private void handleSafeState(final ParticipantResponseDetails response) { - handleStateChange(ParticipantState.SAFE, response); - } - - /** - * Method to handle when the new state from participant is TEST. - * - * @param response participant response - */ - private void handleTestState(final ParticipantResponseDetails response) { - handleStateChange(ParticipantState.TEST, response); - } - - /** - * Method to handle when the new state from participant is Terminated. - * - * @param response participant response - */ - private void handleTerminatedState(final ParticipantResponseDetails response) { - handleStateChange(ParticipantState.TERMINATED, response); - } - private void handleStateChange(ParticipantState newParticipantState, ParticipantResponseDetails response) { if (state.equals(newParticipantState)) { response.setResponseStatus(ParticipantResponseStatus.SUCCESS); @@ -344,4 +260,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; |