summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/src/main/java/org/onap/policy/clamp/controlloop/common/ControlLoopConstants.java32
-rw-r--r--common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java94
-rw-r--r--common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java107
-rw-r--r--common/src/main/java/org/onap/policy/clamp/controlloop/common/handler/ControlLoopHandler.java110
-rw-r--r--common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java142
-rw-r--r--common/src/main/resources/examples/controlloop/KubernetesHelm.yaml169
-rw-r--r--common/src/main/resources/examples/controlloop/PMSH/consul_call_body.json62
-rw-r--r--common/src/main/resources/examples/controlloop/PMSH/consul_url.txt1
-rw-r--r--common/src/main/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml176
-rw-r--r--common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json123
-rw-r--r--common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml64
-rw-r--r--common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml264
-rw-r--r--common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.json2808
-rw-r--r--common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml2619
-rw-r--r--common/src/main/resources/examples/controlloop/PMSubscriptionHandling.yaml3314
-rw-r--r--common/src/main/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml455
-rw-r--r--common/src/main/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml83
-rw-r--r--common/src/main/resources/examples/controlloop/original/cloop_base_types.yaml210
-rw-r--r--common/src/main/resources/examples/controlloop/original/cloop_dcae_example.yaml50
-rw-r--r--common/src/main/resources/examples/controlloop/original/cloop_dcae_types.yaml140
-rw-r--r--common/src/main/resources/examples/controlloop/original/cloop_other_types.yaml63
-rw-r--r--common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java84
-rw-r--r--common/src/test/java/org/onap/policy/clamp/controlloop/common/handler/ControlLoopHandlerTest.java54
-rw-r--r--common/src/test/java/org/onap/policy/clamp/controlloop/common/handler/DummyControlLoopHandler.java63
-rw-r--r--common/src/test/resources/demo/Notes.txt39
-rw-r--r--common/src/test/resources/demo/config/DEMO.postman_collection.json302
-rw-r--r--common/src/test/resources/demo/config/PolicyAPIConfig.json53
-rw-r--r--common/src/test/resources/demo/config/PolicyParticipantConfig.json53
-rw-r--r--common/src/test/resources/demo/config/RuntimeConfig.json79
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java53
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java33
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java113
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java75
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java44
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java63
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java47
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java73
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java47
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java61
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java52
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java33
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java194
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java258
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java251
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java220
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java237
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java154
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java248
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java195
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java159
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java56
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java36
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChange.java56
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdate.java63
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheck.java56
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java113
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java56
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java64
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java42
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChange.java56
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java76
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java37
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java35
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java38
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java35
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java38
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java67
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java62
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java81
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java102
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java65
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java84
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java189
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java300
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java296
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java193
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java253
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java62
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java115
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java160
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java154
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java109
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java83
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java48
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java58
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChangeTest.java61
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdateTest.java71
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheckTest.java61
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java103
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java35
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java61
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChangeTest.java61
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java62
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java59
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java60
-rw-r--r--models/src/test/resources/META-INF/persistence.xml138
-rw-r--r--models/src/test/resources/json/ControlLoopElementNoOrderedState.json13
-rw-r--r--models/src/test/resources/json/ControlLoopNoOrderedState.json12
-rw-r--r--models/src/test/resources/providers/TestClElementStatistics.json24
-rw-r--r--models/src/test/resources/providers/TestControlLoops.json142
-rw-r--r--models/src/test/resources/providers/TestParticipant.json11
-rw-r--r--models/src/test/resources/providers/TestParticipantStatistics.json32
-rw-r--r--models/src/test/resources/providers/UpdateControlLoops.json73
-rw-r--r--participant/participant-impl/participant-impl-dcae/pom.xml19
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java154
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java140
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java46
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java197
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/DcaeHandler.java82
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/DcaeProvider.java133
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameterHandler.java78
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java93
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/Main.java151
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/ParticipantDcaeActivator.java58
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/ParticipantDcaeCommandLineArguments.java151
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/ExternalComponent.java35
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/ExternalComponentState.java34
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/Loop.java36
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/resources/config/DCAEParticipantConfig.json71
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/resources/version.txt4
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java128
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java294
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameterHandler.java102
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameters.java90
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java255
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/TestMain.java151
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/TestParticipantDcaeActivator.java94
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/InvalidParameters.json3
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/MinimumParametersH2.json61
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/NoParameters.json2
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestCLParams.json160
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParameters.json71
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParametersStd.json71
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json81
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/logback-test.xml42
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml452
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/rest/status.json3918
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java159
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/PolicyHandler.java100
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/PolicyProvider.java57
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameterHandler.java79
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java49
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/Main.java141
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/ParticipantPolicyActivator.java57
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/ParticipantPolicyCommandLineArguments.java145
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml79
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/resources/config/PolicyParticipantConfig.json31
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/resources/version.txt4
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/TestPolicyHandler.java134
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java221
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameterHandler.java98
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameters.java106
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/TestMain.java143
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/TestParticipantPolicyActivator.java88
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java343
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/InvalidParameters.json3
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/MinimumParametersH2.json53
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/NoParameters.json2
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestCLParams.yaml161
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParameters.json53
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParametersStd.json53
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json73
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/logback-test.xml42
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policies/vCPE.policies.optimization.input.tosca.yaml348
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Match.yaml8
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Naming.yaml102
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Optimization.yaml33
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.Common.yaml28
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml16
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Filter.yaml66
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml26
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml24
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml27
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.Common.yaml143
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml26
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml14
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml50
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml132
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml128
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml19
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.tcagen2.yaml161
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Apex.yaml203
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Drools.yaml118
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Xacml.yaml20
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Resource.yaml25
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Service.yaml17
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml33
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml58
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml105
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml68
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml32
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml30
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml46
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml26
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml36
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_control_loop_tosca.yaml614
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameterHandler.java78
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java51
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java38
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RestController.java130
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/Main.java141
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/ParticipantSimulatorActivator.java75
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/ParticipantSimulatorCommandLineArguments.java151
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationHandler.java81
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java129
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java195
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java192
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/CDSParticipantConfig.json31
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/DCAEParticipantConfig.json31
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/PolicyParticipantConfig.json31
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt4
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/intermediary/TestControlLoopUpdateListener.java91
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java249
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameterHandler.java120
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java110
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/CommonParticipantRestServer.java227
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RestControllerTest.java95
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java258
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestSimulationRestController.java186
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/TestMain.java117
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/TestParticipantSimulatorActivator.java89
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/EmptyParameters.json0
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/InvalidParameters.json3
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/NoParameters.json2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParameters.json61
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParametersStd.json61
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json81
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml452
-rw-r--r--participant/participant-impl/pom.xml8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java62
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java139
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryFactory.java38
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java133
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java68
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java67
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java162
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantHealthCheckListener.java69
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStateChangeListener.java68
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusPublisher.java63
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java323
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java165
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java235
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java58
-rw-r--r--participant/pom.xml32
-rw-r--r--pom.xml70
-rw-r--r--runtime-controlloop/pom.xml48
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java81
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java208
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java360
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java276
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java82
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java416
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java55
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java77
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java59
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java53
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java54
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/ControlLoopAafFilter.java38
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java115
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java186
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java151
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java156
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java84
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java273
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java371
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java450
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java116
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java75
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java75
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java74
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java53
-rw-r--r--runtime-controlloop/src/main/resources/META-INF/persistence.xml121
-rw-r--r--runtime-controlloop/src/main/resources/version.txt4
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java216
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java202
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java370
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java149
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java322
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestControllerTest.java71
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivatorTest.java82
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/MainTest.java157
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java264
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java237
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java63
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java263
-rw-r--r--runtime-controlloop/src/test/resources/META-INF/persistence.xml159
-rw-r--r--runtime-controlloop/src/test/resources/parameters/CommissioningConfig.json20
-rw-r--r--runtime-controlloop/src/test/resources/parameters/EmptyParameters.json0
-rw-r--r--runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json79
-rw-r--r--runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json31
-rw-r--r--runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_sim.json43
-rw-r--r--runtime-controlloop/src/test/resources/parameters/InvalidParameters.json3
-rw-r--r--runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json59
-rw-r--r--runtime-controlloop/src/test/resources/parameters/NoParameters.json2
-rw-r--r--runtime-controlloop/src/test/resources/parameters/TestParameters.json79
-rw-r--r--runtime-controlloop/src/test/resources/parameters/TestParametersMariaDB.json79
-rw-r--r--runtime-controlloop/src/test/resources/parameters/Unreadable.json78
-rw-r--r--runtime-controlloop/src/test/resources/parameters/logback-test.xml42
-rw-r--r--runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json142
-rw-r--r--runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json142
-rw-r--r--runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsNotFound.json142
-rw-r--r--runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsUpdate.json142
-rw-r--r--runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json142
-rw-r--r--runtime-controlloop/src/test/resources/rest/controlloops/PassiveCommand.json13
-rw-r--r--runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics.json44
-rw-r--r--runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json13
-rw-r--r--runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics.json46
-rw-r--r--runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json16
-rw-r--r--runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml221
-rw-r--r--runtime-controlloop/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml452
-rw-r--r--runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml221
-rw-r--r--runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh31
-rw-r--r--runtime/pom.xml2
318 files changed, 45962 insertions, 1 deletions
diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/ControlLoopConstants.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/ControlLoopConstants.java
new file mode 100644
index 000000000..aa8b720bc
--- /dev/null
+++ b/common/src/main/java/org/onap/policy/clamp/controlloop/common/ControlLoopConstants.java
@@ -0,0 +1,32 @@
+/*
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.common;
+
+/**
+ * Names of various items contained in the Registry.
+ */
+public class ControlLoopConstants {
+
+ // Registry keys
+ public static final String REG_CLRUNTIME_ACTIVATOR = "object:activator/clruntime";
+
+ private ControlLoopConstants() {
+ super();
+ }
+}
diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java
new file mode 100644
index 000000000..05b913b22
--- /dev/null
+++ b/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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.common.exception;
+
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import lombok.ToString;
+import org.onap.policy.models.errors.concepts.ErrorResponse;
+import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
+import org.onap.policy.models.errors.concepts.ErrorResponseUtils;
+
+/**
+ * This class is a base exception from which all control loop exceptions are sub classes.
+ */
+@Getter
+@ToString
+public class ControlLoopException extends Exception implements ErrorResponseInfo {
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ // The error response of the exception
+ private final ErrorResponse errorResponse = new ErrorResponse();
+
+ // The object on which the exception was thrown
+ private final transient Object object;
+
+ /**
+ * Instantiates a new control loop exception.
+ *
+ * @param statusCode the return code for the exception
+ * @param message the message on the exception
+ */
+ public ControlLoopException(final Response.Status statusCode, final String message) {
+ this(statusCode, message, null);
+ }
+
+ /**
+ * Instantiates a new control loop exception.
+ *
+ * @param statusCode the return code for the exception
+ * @param message the message on the exception
+ * @param object the object that the exception was thrown on
+ */
+ public ControlLoopException(final Response.Status statusCode, final String message, final Object object) {
+ super(message);
+ errorResponse.setResponseCode(statusCode);
+ ErrorResponseUtils.getExceptionMessages(errorResponse, this);
+ this.object = object;
+ }
+
+ /**
+ * Instantiates a new control loop exception.
+ *
+ * @param statusCode the return code for the exception
+ * @param message the message on the exception
+ * @param exception the exception that caused this exception
+ */
+ public ControlLoopException(final Response.Status statusCode, final String message, final Exception exception) {
+ this(statusCode, message, exception, null);
+ }
+
+ /**
+ * Instantiates a new exception.
+ *
+ * @param statusCode the return code for the exception
+ * @param message the message on the exception
+ * @param exception the exception that caused this exception
+ * @param object the object that the exception was thrown on
+ */
+ public ControlLoopException(final Response.Status statusCode, final String message, final Exception exception,
+ final Object object) {
+ super(message, exception);
+ errorResponse.setResponseCode(statusCode);
+ ErrorResponseUtils.getExceptionMessages(errorResponse, this);
+ this.object = object;
+ }
+}
diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java
new file mode 100644
index 000000000..b110a4362
--- /dev/null
+++ b/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java
@@ -0,0 +1,107 @@
+/*-
+ * ============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.common.exception;
+
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import lombok.ToString;
+import org.onap.policy.models.errors.concepts.ErrorResponse;
+import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
+import org.onap.policy.models.errors.concepts.ErrorResponseUtils;
+
+/**
+ * This class is a base control loop run time exception from which all control loop run time exceptions are sub classes.
+ */
+@Getter
+@ToString
+public class ControlLoopRuntimeException extends RuntimeException implements ErrorResponseInfo {
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ // The error response of the exception
+ private final ErrorResponse errorResponse = new ErrorResponse();
+
+ // The object on which the exception was thrown
+ private final transient Object object;
+
+ /**
+ * Instantiates a new control loop runtime exception.
+ *
+ * @param statusCode the return code for the exception
+ * @param message the message on the exception
+ */
+ public ControlLoopRuntimeException(final Response.Status statusCode, final String message) {
+ this(statusCode, message, null);
+ }
+
+ /**
+ * Instantiates a new control loop runtime exception.
+ *
+ * @param statusCode the return code for the exception
+ * @param message the message on the exception
+ * @param object the object that the exception was thrown on
+ */
+ public ControlLoopRuntimeException(final Response.Status statusCode, final String message, final Object object) {
+ super(message);
+ this.object = object;
+ errorResponse.setResponseCode(statusCode);
+ ErrorResponseUtils.getExceptionMessages(errorResponse, this);
+ }
+
+ /**
+ * Instantiates a new control loop runtime exception.
+ *
+ * @param statusCode the return code for the exception
+ * @param message the message on the exception
+ * @param exception the exception that caused this control loop exception
+ */
+ public ControlLoopRuntimeException(final Response.Status statusCode, final String message,
+ final Exception exception) {
+ this(statusCode, message, exception, null);
+ }
+
+ /**
+ * Instantiates a new model runtime exception from a ControlLoopException instance.
+ *
+ * @param exception the exception that caused this control loop exception
+ */
+ public ControlLoopRuntimeException(final ControlLoopException exception) {
+ super(exception.getMessage(), exception);
+ this.object = exception.getObject();
+ errorResponse.setResponseCode(exception.getErrorResponse().getResponseCode());
+ ErrorResponseUtils.getExceptionMessages(errorResponse, this);
+ }
+
+ /**
+ * Instantiates a new control loop runtime exception.
+ *
+ * @param statusCode the return code for the exception
+ * @param message the message on the exception
+ * @param exception the exception that caused this control loop exception
+ * @param object the object that the exception was thrown on
+ */
+ public ControlLoopRuntimeException(final Response.Status statusCode, final String message,
+ final Exception exception, final Object object) {
+ super(message, exception);
+ this.object = object;
+ errorResponse.setResponseCode(statusCode);
+ ErrorResponseUtils.getExceptionMessages(errorResponse, this);
+ }
+}
diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/handler/ControlLoopHandler.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/handler/ControlLoopHandler.java
new file mode 100644
index 000000000..1bbe5662f
--- /dev/null
+++ b/common/src/main/java/org/onap/policy/clamp/controlloop/common/handler/ControlLoopHandler.java
@@ -0,0 +1,110 @@
+/*-
+ * ============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.common.handler;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import lombok.Getter;
+import lombok.NonNull;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+
+/**
+ * Abstract class for handlers for sub components in the control loop system
+ *
+ * <p>Instances are effectively singletons that are started at system start.
+ */
+public abstract class ControlLoopHandler {
+ @Getter
+ private final PolicyModelsProviderParameters databaseProviderParameters;
+
+ /**
+ * Create a handler.
+ *
+ * @param databaseProviderParameters the parameters for access to the database
+ */
+ protected ControlLoopHandler(@NonNull PolicyModelsProviderParameters databaseProviderParameters) {
+ this.databaseProviderParameters = databaseProviderParameters;
+
+ Registry.register(this.getClass().getName(), this);
+ }
+
+ public void close() {
+ Registry.unregister(this.getClass().getName());
+ }
+
+ /**
+ * Get the provider classes that are used in instantiation.
+ *
+ * @return the provider classes
+ */
+ public Set<Class<?>> getProviderClasses() {
+ // No REST interfaces are the default
+ return new HashSet<>();
+ }
+
+ /**
+ * Start any topic message listeners for this handler.
+ *
+ * @param msgDispatcher the message dispatcher with which to register the listener
+ */
+ public void startAndRegisterListeners(MessageTypeDispatcher msgDispatcher) {
+ // Start and register listeners
+ }
+
+ /**
+ * Start any topic message publishers for this handler.
+ *
+ * @param topicSinks the topic sinks on which the publisher can publish
+ */
+ public void startAndRegisterPublishers(List<TopicSink> topicSinks) {
+ // Start and register publishers
+ }
+
+ /**
+ * Stop any topic message publishers for this handler.
+ */
+ public void stopAndUnregisterPublishers() {
+ // Stop and unregister publishers
+ }
+
+ /**
+ * Stop any topic message listeners for this handler.
+ *
+ * @param msgDispatcher the message dispatcher from which to unregister the listener
+ */
+ public void stopAndUnregisterListeners(MessageTypeDispatcher msgDispatcher) {
+ // Stop and unregister listeners
+ }
+
+ /**
+ * Start any providers for this handler.
+ */
+ public abstract void startProviders();
+
+ /**
+ * Stop any providers for this handler.
+ */
+ public abstract void stopProviders();
+}
diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java
new file mode 100644
index 000000000..3ef3d4cb0
--- /dev/null
+++ b/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java
@@ -0,0 +1,142 @@
+/*-
+ * ============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.common.startstop;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import javax.ws.rs.core.Response;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+
+/**
+ * This class reads and handles command line parameters.
+ *
+ */
+public class CommonCommandLineArguments {
+ private static final String FILE_MESSAGE_PREAMBLE = " file \"";
+ private static final int HELP_LINE_LENGTH = 120;
+
+ /**
+ * Construct the options for the policy participant.
+ */
+ public CommonCommandLineArguments(final Options options) {
+ //@formatter:off
+ options.addOption(Option.builder("h")
+ .longOpt("help")
+ .desc("outputs the usage of this command")
+ .required(false)
+ .type(Boolean.class)
+ .build());
+ options.addOption(Option.builder("v")
+ .longOpt("version")
+ .desc("outputs the version of policy participant")
+ .required(false)
+ .type(Boolean.class)
+ .build());
+ options.addOption(Option.builder("c")
+ .longOpt("config-file")
+ .desc("the full path to the configuration file to use, "
+ + "the configuration file must be a Json file containing the "
+ + "policy participant parameters")
+ .hasArg()
+ .argName("CONFIG_FILE")
+ .required(false)
+ .type(String.class)
+ .build());
+ //@formatter:on
+ }
+
+ /**
+ * Validate the command line options.
+ *
+ * @throws ControlLoopException on command argument validation errors
+ */
+ public void validate(final String configurationFilePath) throws ControlLoopException {
+ validateReadableFile("policy participant configuration", configurationFilePath);
+ }
+
+ /**
+ * Print version information for policy participant.
+ *
+ * @return the version string
+ */
+ public String version() {
+ return ResourceUtils.getResourceAsString("version.txt");
+ }
+
+ /**
+ * Print help information for policy participant.
+ *
+ * @param mainClassName the main class name
+ * @return the help string
+ */
+ public String help(final String mainClassName, final Options options) {
+ final HelpFormatter helpFormatter = new HelpFormatter();
+ final StringWriter stringWriter = new StringWriter();
+ final PrintWriter printWriter = new PrintWriter(stringWriter);
+
+ helpFormatter.printHelp(printWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0,
+ 0, "");
+
+ return stringWriter.toString();
+ }
+
+ /**
+ * Validate readable file.
+ *
+ * @param fileTag the file tag
+ * @param fileName the file name
+ * @throws ControlLoopException on the file name passed as a parameter
+ */
+ private void validateReadableFile(final String fileTag, final String fileName) throws ControlLoopException {
+ if (StringUtils.isEmpty(fileName)) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ fileTag + " file was not specified as an argument");
+ }
+
+ // The file name refers to a resource on the local file system
+ final URL fileUrl = ResourceUtils.getUrl4Resource(fileName);
+ if (fileUrl == null) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
+ }
+
+ final File theFile = new File(fileUrl.getPath());
+ if (!theFile.exists()) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
+ }
+ if (!theFile.isFile()) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is not a normal file");
+ }
+ if (!theFile.canRead()) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is ureadable");
+ }
+ }
+}
diff --git a/common/src/main/resources/examples/controlloop/KubernetesHelm.yaml b/common/src/main/resources/examples/controlloop/KubernetesHelm.yaml
new file mode 100644
index 000000000..2a5f76082
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/KubernetesHelm.yaml
@@ -0,0 +1,169 @@
+# ============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=========================================================
+
+tosca_definitions_version: tosca_simple_yaml_1_3
+data_types:
+ onap.datatypes.ToscaConceptIdentifier:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ required: true
+ version:
+ type: string
+ required: true
+node_types:
+ org.onap.policy.clamp.controlloop.Participant:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ org.onap.policy.clamp.controlloop.ControlLoopElement:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ participant_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.ControlLoop:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ elements:
+ type: list
+ required: true
+ entry_schema:
+ type: onap.datatypes.ToscaConceptIdentifier
+ org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ chart:
+ type: string
+ requred: true
+ configs:
+ type: list
+ required: false
+ requirements:
+ type: string
+ requred: false
+ templates:
+ type: list
+ required: false
+ entry_schema:
+ values:
+ type: string
+ requred: true
+topology_template:
+ node_templates:
+ org.onap.k8s.controlloop.K8SControlLoopParticipant:
+ version: 2.3.4
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for K8S
+ properties:
+ provider: ONAP
+ org.onap.domain.database.Postgres_K8SMicroserviceControlLoopElement:
+ # See https://github.com/onap/oom/tree/master/kubernetes/common/postgres
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the K8S microservice for Postgres
+ properties:
+ provider: ONAP
+ participant_id:
+ name: org.onap.k8s.controlloop.K8SControlLoopParticipant
+ version: 2.3.4
+ chart:
+ apiVersion: v1
+ description: ONAP Postgres Server
+ name: postgres
+ version: 7.0.0
+ configs:
+ - name: pg_hba.conf
+ value: <Contents of pg_hba.conf>
+ - name: setup.sql
+ value: <Contents of setup.sql>
+ requirements:
+ dependencies:
+ - name: common
+ version: ~7.x-0
+ repository: 'file://../common'
+ - name: repositoryGenerator
+ version: ~7.x-0
+ repository: 'file://../repositoryGenerator'
+ templates:
+ - name: first_template_file
+ value: <first_template_file>
+ - name: And so on
+ values:
+ <The Values>
+ org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement:
+ # See https://github.com/stakater-charts/helloworld/tree/master/helloworld
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the K8S microservice for Hello World
+ properties:
+ provider: ONAP
+ participant_id:
+ name: org.onap.k8s.controlloop.K8SControlLoopParticipant
+ version: 2.3.4
+ chart:
+ apiVersion: v1
+ name: helloworld
+ description: helloworld chart that runs on kubernetes
+ version: 1.0.0
+ keywords:
+ - helloworld
+ - kubernetes
+ home: https://github.com/stakater-charts/helloworld
+ maintainers:
+ - name: Stakater
+ email: stakater@aurorasolutions.io
+ values:
+ kubernetes:
+ host: https://kubernetes.default
+ helloworld:
+ namespace: default
+ image:
+ name: tutum/hello-world
+ tag: latest
+ pullPolicy: IfNotPresent
+ service:
+ ingressClass: internal-ingress
+ org.onap.domain.sample.Postgres_HelloWorld_ControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Postgres and Hello World
+ properties:
+ provider: ONAP
+ elements:
+ - name: org.onap.domain.database.Postgres_K8SMicroserviceControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement
+ version: 1.2.3
diff --git a/common/src/main/resources/examples/controlloop/PMSH/consul_call_body.json b/common/src/main/resources/examples/controlloop/PMSH/consul_call_body.json
new file mode 100644
index 000000000..9118e9a6f
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSH/consul_call_body.json
@@ -0,0 +1,62 @@
+{
+ "subscription": {
+ "subscriptionName": "subscriptiona",
+ "administrativeState": "UNLOCKED",
+ "fileBasedGP": 15,
+ "fileLocation": "/pm/pm.xml",
+ "nfFilter": {
+ "nfNames": [
+ "^pnf1.*"
+ ],
+ "modelInvariantIDs": [
+ "5845y423-g654-6fju-po78-8n53154532k6",
+ "7129e420-d396-4efb-af02-6b83499b12f8"
+ ],
+ "modelVersionIDs": [
+ "e80a6ae3-cafd-4d24-850d-e14c084a5ca9"
+ ]
+ },
+ "measurementGroups": [
+ {
+ "measurementGroup": {
+ "measurementTypes": [
+ {
+ "measurementType": "countera"
+ },
+ {
+ "measurementType": "counterb"
+ }
+ ],
+ "managedObjectDNsBasic": [
+ {
+ "DN": "dna"
+ },
+ {
+ "DN": "dnb"
+ }
+ ]
+ }
+ },
+ {
+ "measurementGroup": {
+ "measurementTypes": [
+ {
+ "measurementType": "counterc"
+ },
+ {
+ "measurementType": "counterd"
+ }
+ ],
+ "managedObjectDNsBasic": [
+ {
+ "DN": "dnc"
+ },
+ {
+ "DN": "dnd"
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/common/src/main/resources/examples/controlloop/PMSH/consul_url.txt b/common/src/main/resources/examples/controlloop/PMSH/consul_url.txt
new file mode 100644
index 000000000..e90ded1c6
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSH/consul_url.txt
@@ -0,0 +1 @@
+http://consul:31321/v1/kv/dcae-pmsh:policy \ No newline at end of file
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml b/common/src/main/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml
new file mode 100644
index 000000000..7cdc6d5b9
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml
@@ -0,0 +1,176 @@
+#
+# ============LICENSE_START=======================================================
+# Copyright (C) 2020 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=========================================================
+#
+
+tosca_definitions_version: cloudify_dsl_1_3
+
+imports:
+ - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml
+ # - plugin:k8splugin?version=>=3.4.3,<4.0.0
+ - plugin:k8splugin?version=3.7.0
+ - plugin:pgaas?version=1.3.0
+ - plugin:clamppolicyplugin?version=1.1.0
+inputs:
+ tag_version:
+ type: string
+ description: Docker image to be used
+ default: 'nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2'
+ replicas:
+ type: integer
+ description: Number of instances
+ default: 1
+ operational_policy_name:
+ type: string
+ default: 'pmsh-operational-policy'
+ control_loop_name:
+ type: string
+ default: 'pmsh-control-loop'
+ pmsh_publish_topic_name:
+ type: string
+ default: 'unauthenticated.DCAE_CL_OUTPUT'
+ policy_feedback_topic_name:
+ type: string
+ default: 'unauthenticated.PMSH_CL_INPUT'
+ aai_notification_topic_name:
+ type: string
+ default: 'AAI-EVENT'
+ publisher_client_role:
+ type: string
+ description: Client role to request secure access to topic
+ default: 'org.onap.dcae.pmPublisher'
+ subscriber_client_role:
+ type: string
+ description: Client role to request secure access to topic
+ default: 'org.onap.dcae.pmSubscriber'
+ dcae_location:
+ type: string
+ description: DCAE location for the subscriber, used to set up routing
+ default: 'san-francisco'
+ cpu_limit:
+ type: string
+ default: '1000m'
+ cpu_request:
+ type: string
+ default: '1000m'
+ memory_limit:
+ type: string
+ default: '1024Mi'
+ memory_request:
+ type: string
+ default: '1024Mi'
+ pgaas_cluster_name:
+ type: string
+ default: 'dcae-pg-primary.onap'
+ enable_tls:
+ type: boolean
+ default: true
+ protocol:
+ type: string
+ description: PMSH protocol. If enable_tls is false, set to http
+ default: 'https'
+ policy_model_id:
+ type: 'string'
+ default: 'onap.policies.monitoring.dcae-pm-subscription-handler'
+ policy_id:
+ type: 'string'
+ default: 'onap.policies.monitoring.dcae-pm-subscription-handler'
+node_templates:
+ pgaasvm:
+ type: dcae.nodes.pgaas.database
+ properties:
+ writerfqdn: { get_input: pgaas_cluster_name }
+ name: 'pmsh'
+ pmsh:
+ type: dcae.nodes.ContainerizedServiceComponentUsingDmaap
+ interfaces:
+ cloudify.interfaces.lifecycle:
+ create:
+ inputs:
+ ports:
+ - '8443:0'
+ envs:
+ PMSH_PG_URL:
+ { get_attribute: [ pgaasvm, admin, host ] }
+ PMSH_PG_PASSWORD:
+ { get_attribute: [ pgaasvm, admin, password ] }
+ PMSH_PG_USERNAME:
+ { get_attribute: [ pgaasvm, admin, user ] }
+ PMSH_DB_NAME:
+ { get_attribute: [ pgaasvm, admin, database ] }
+
+ relationships:
+ - target: pmsh-policy
+ type: cloudify.relationships.depends_on
+
+ properties:
+ service_component_type: 'dcae-pmsh'
+ service_component_name_override: 'dcae-pmsh'
+ application_config:
+ enable_tls: { get_input: enable_tls }
+ aaf_identity: 'dcae@dcae.onap.org'
+ aaf_password: 'demo123456!'
+ operational_policy_name: { get_input: operational_policy_name }
+ control_loop_name: { get_input: control_loop_name }
+ cert_path: '/opt/app/pmsh/etc/certs/cert.pem'
+ key_path: '/opt/app/pmsh/etc/certs/key.pem'
+ ca_cert_path: '/opt/app/pmsh/etc/certs/cacert.pem'
+ streams_publishes:
+ policy_pm_publisher:
+ type: message_router
+ dmaap_info:
+ #topic_url: {concat: ["https://message-router:3905/events/", { get_input: pmsh_publish_topic_name }]}
+ topic_url: { concat: [ "http://message-router:3904/events/", { get_input: pmsh_publish_topic_name } ] }
+ streams_subscribes:
+ policy_pm_subscriber:
+ type: message_router
+ dmaap_info:
+ #topic_url: {concat: ["https://message-router:3905/events/", { get_input: policy_feedback_topic_name }]}
+ topic_url: {concat: ["http://message-router:3904/events/", { get_input: policy_feedback_topic_name }]}
+ aai_subscriber:
+ type: message_router
+ dmaap_info:
+ #topic_url: {concat: ["https://message-router:3905/events/", { get_input: aai_notification_topic_name }]}
+ topic_url: {concat: ["http://message-router:3904/events/", { get_input: aai_notification_topic_name }]}
+ resource_config:
+ limits:
+ cpu: { get_input: cpu_limit }
+ memory: { get_input: memory_limit }
+ requests:
+ cpu: { get_input: cpu_request }
+ memory: { get_input: memory_request }
+ docker_config:
+ healthcheck:
+ endpoint: /healthcheck
+ interval: 15s
+ timeout: 1s
+ type: { get_input: protocol }
+ image: { get_input: tag_version }
+ replicas: { get_input: replicas }
+ log_info:
+ log_directory: '/var/log/ONAP/dcaegen2/services/pmsh'
+ tls_info:
+ cert_directory: '/opt/app/pmsh/etc/certs'
+ use_tls: { get_input: enable_tls }
+ pmsh-policy:
+ type: clamp.nodes.policy
+ properties:
+ policy_model_id:
+ get_input: policy_model_id
+ policy_id:
+ get_input: policy_id
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json b/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json
new file mode 100644
index 000000000..5b64b5b6f
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json
@@ -0,0 +1,123 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
+ "topology_template": {
+ "policies": [
+ {
+ "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test": {
+ "type": "onap.policies.monitoring.dcae-pm-subscription-handler",
+ "type_version": "1.0.0",
+ "properties": {
+ "pmsh_policy": {
+ "measurementGroups": [
+ {
+ "measurementGroup": {
+ "onap.datatypes.monitoring.measurementGroup": {
+ "measurementTypes": [
+ {
+ "measurementType": {
+ "onap.datatypes.monitoring.measurementType": {
+ "measurementType": "countera"
+ }
+ }
+ },
+ {
+ "measurementType": {
+ "onap.datatypes.monitoring.measurementType": {
+ "measurementType": "counterb"
+ }
+ }
+ }
+ ],
+ "managedObjectDNsBasic": [
+ {
+ "managedObjectDNsBasic": {
+ "onap.datatypes.monitoring.managedObjectDNsBasic": {
+ "DN": "dna"
+ }
+ }
+ },
+ {
+ "managedObjectDNsBasic": {
+ "onap.datatypes.monitoring.managedObjectDNsBasic": {
+ "DN": "dnb"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "measurementGroup": {
+ "onap.datatypes.monitoring.measurementGroup": {
+ "measurementTypes": [
+ {
+ "measurementType": {
+ "onap.datatypes.monitoring.measurementType": {
+ "measurementType": "counterc"
+ }
+ }
+ },
+ {
+ "measurementType": {
+ "onap.datatypes.monitoring.measurementType": {
+ "measurementType": "counterd"
+ }
+ }
+ }
+ ],
+ "managedObjectDNsBasic": [
+ {
+ "managedObjectDNsBasic": {
+ "onap.datatypes.monitoring.managedObjectDNsBasic": {
+ "DN": "dnc"
+ }
+ }
+ },
+ {
+ "managedObjectDNsBasic": {
+ "onap.datatypes.monitoring.managedObjectDNsBasic": {
+ "DN": "dnd"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "fileBasedGP": 15,
+ "fileLocation": "/pm/pm.xml",
+ "subscriptionName": "subscriptiona",
+ "administrativeState": "UNLOCKED",
+ "nfFilter": {
+ "onap.datatypes.monitoring.nfFilter": {
+ "modelVersionIDs": [
+ "e80a6ae3-cafd-4d24-850d-e14c084a5ca9"
+ ],
+ "modelInvariantIDs": [
+ "5845y423-g654-6fju-po78-8n53154532k6",
+ "7129e420-d396-4efb-af02-6b83499b12f8"
+ ],
+ "modelNames": [],
+ "nfNames": [
+ "\"^pnf1.*\""
+ ]
+ }
+ }
+ }
+ },
+ "name": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test",
+ "policy-version": "1.0.0"
+ }
+ }
+ }
+ ]
+ },
+ "name": "ToscaServiceTemplateSimple",
+ "version": "1.0.0",
+ "metadata": {}
+}
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml b/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml
new file mode 100644
index 000000000..6021f36bc
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml
@@ -0,0 +1,64 @@
+---
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+name: ToscaServiceTemplateSimple
+version: 1.0.0
+metadata: {}
+topology_template:
+ policies:
+ - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test:
+ type: onap.policies.monitoring.dcae-pm-subscription-handler
+ type_version: 1.0.0
+ name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test
+ version: 1.0.0
+ metadata:
+ policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test
+ policy-version: 1.0.0
+ properties:
+ pmsh_policy:
+ fileBasedGP: 15
+ fileLocation: "/pm/pm.xml"
+ subscriptionName: subscriptiona
+ administrativeState: UNLOCKED
+ nfFilter:
+ onap.datatypes.monitoring.nfFilter:
+ modelVersionIDs:
+ - e80a6ae3-cafd-4d24-850d-e14c084a5ca9
+ modelInvariantIDs:
+ - 5845y423-g654-6fju-po78-8n53154532k6
+ - 7129e420-d396-4efb-af02-6b83499b12f8
+ modelNames: []
+ nfNames:
+ - '"^pnf1.*"'
+ measurementGroups:
+ - measurementGroup:
+ onap.datatypes.monitoring.measurementGroup:
+ measurementTypes:
+ - measurementType:
+ onap.datatypes.monitoring.measurementType:
+ measurementType: countera
+ - measurementType:
+ onap.datatypes.monitoring.measurementType:
+ measurementType: counterb
+ managedObjectDNsBasic:
+ - managedObjectDNsBasic:
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ DN: dna
+ - managedObjectDNsBasic:
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ DN: dnb
+ - measurementGroup:
+ onap.datatypes.monitoring.measurementGroup:
+ measurementTypes:
+ - measurementType:
+ onap.datatypes.monitoring.measurementType:
+ measurementType: counterc
+ - measurementType:
+ onap.datatypes.monitoring.measurementType:
+ measurementType: counterd
+ managedObjectDNsBasic:
+ - managedObjectDNsBasic:
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ DN: dnc
+ - managedObjectDNsBasic:
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ DN: dnd
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml b/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml
new file mode 100644
index 000000000..e282bf5ba
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml
@@ -0,0 +1,264 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+name: ToscaServiceTemplateSimple
+version: 1.0.0
+metadata: {}
+policy_types:
+ onap.policies.Monitoring:
+ derived_from: tosca.policies.Root
+ description: a base policy type for all policies that govern monitoring provisioning
+ version: 1.0.0
+ name: onap.policies.Monitoring
+ onap.policies.monitoring.dcae-pm-subscription-handler:
+ name: onap.policies.monitoring.dcae-pm-subscription-handler
+ version: 1.0.0
+ derived_from: onap.policies.Monitoring
+ metadata: {}
+ properties:
+ pmsh_policy:
+ name: pmsh_policy
+ type: onap.datatypes.monitoring.subscription
+ typeVersion: 0.0.0
+ description: PMSH Policy JSON
+ required: false
+ constraints: []
+ metadata: {}
+data_types:
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ name: onap.datatypes.monitoring.managedObjectDNsBasic
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ constraints: []
+ properties:
+ DN:
+ name: DN
+ type: string
+ typeVersion: 0.0.0
+ description: Managed object distinguished name
+ required: true
+ constraints: []
+ metadata: {}
+ onap.datatypes.monitoring.managedObjectDNsBasics:
+ name: onap.datatypes.monitoring.managedObjectDNsBasics
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ constraints: []
+ properties:
+ managedObjectDNsBasic:
+ name: managedObjectDNsBasic
+ type: map
+ typeVersion: 0.0.0
+ description: Managed object distinguished name object
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.managedObjectDNsBasic
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ onap.datatypes.monitoring.measurementGroup:
+ name: onap.datatypes.monitoring.measurementGroup
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ constraints: []
+ properties:
+ measurementTypes:
+ name: measurementTypes
+ type: list
+ typeVersion: 0.0.0
+ description: List of measurement types
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementTypes
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ managedObjectDNsBasic:
+ name: managedObjectDNsBasic
+ type: list
+ typeVersion: 0.0.0
+ description: List of managed object distinguished names
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.managedObjectDNsBasics
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ onap.datatypes.monitoring.measurementGroups:
+ name: onap.datatypes.monitoring.measurementGroups
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ constraints: []
+ properties:
+ measurementGroup:
+ name: measurementGroup
+ type: map
+ typeVersion: 0.0.0
+ description: Measurement Group
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementGroup
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ onap.datatypes.monitoring.measurementType:
+ name: onap.datatypes.monitoring.measurementType
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ constraints: []
+ properties:
+ measurementType:
+ name: measurementType
+ type: string
+ typeVersion: 0.0.0
+ description: Measurement type
+ required: true
+ constraints: []
+ metadata: {}
+ onap.datatypes.monitoring.measurementTypes:
+ name: onap.datatypes.monitoring.measurementTypes
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ constraints: []
+ properties:
+ measurementType:
+ name: measurementType
+ type: map
+ typeVersion: 0.0.0
+ description: Measurement type object
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementType
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ onap.datatypes.monitoring.nfFilter:
+ name: onap.datatypes.monitoring.nfFilter
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ constraints: []
+ properties:
+ modelNames:
+ name: modelNames
+ type: list
+ typeVersion: 0.0.0
+ description: List of model names
+ required: true
+ constraints: []
+ entry_schema:
+ type: string
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ modelInvariantIDs:
+ name: modelInvariantIDs
+ type: list
+ typeVersion: 0.0.0
+ description: List of model invariant IDs
+ required: true
+ constraints: []
+ entry_schema:
+ type: string
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ modelVersionIDs:
+ name: modelVersionIDs
+ type: list
+ typeVersion: 0.0.0
+ description: List of model version IDs
+ required: true
+ constraints: []
+ entry_schema:
+ type: string
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ nfNames:
+ name: nfNames
+ type: list
+ typeVersion: 0.0.0
+ description: List of network functions
+ required: true
+ constraints: []
+ entry_schema:
+ type: string
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ onap.datatypes.monitoring.subscription:
+ name: onap.datatypes.monitoring.subscription
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ constraints: []
+ properties:
+ measurementGroups:
+ name: measurementGroups
+ type: list
+ typeVersion: 0.0.0
+ description: Measurement Groups
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementGroups
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ fileBasedGP:
+ name: fileBasedGP
+ type: integer
+ typeVersion: 0.0.0
+ description: File based granularity period
+ required: true
+ constraints: []
+ metadata: {}
+ fileLocation:
+ name: fileLocation
+ type: string
+ typeVersion: 0.0.0
+ description: ROP file location
+ required: true
+ constraints: []
+ metadata: {}
+ subscriptionName:
+ name: subscriptionName
+ type: string
+ typeVersion: 0.0.0
+ description: Name of the subscription
+ required: true
+ constraints: []
+ metadata: {}
+ administrativeState:
+ name: administrativeState
+ type: string
+ typeVersion: 0.0.0
+ description: State of the subscription
+ required: true
+ constraints:
+ - valid_values:
+ - LOCKED
+ - UNLOCKED
+ metadata: {}
+ nfFilter:
+ name: nfFilter
+ type: map
+ typeVersion: 0.0.0
+ description: Network function filter
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.nfFilter
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.json b/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.json
new file mode 100644
index 000000000..6bd681d71
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.json
@@ -0,0 +1,2808 @@
+{
+ "tosca_definitions_version":"tosca_simple_yaml_1_1_0",
+ "topology_template":{
+ "policies":[
+ {
+ "operational.apex.pmcontrol":{
+ "type":"onap.policies.controlloop.operational.Apex",
+ "type_version":"1.0.0",
+ "version":"1.0.0",
+ "metadata":{
+ "policy-id":"operational.apex.pmcontrol",
+ "policy-version":1
+ },
+ "properties":{
+ "engineServiceParameters":{
+ "name":"MyApexEngine",
+ "version":"0.0.1",
+ "id":45,
+ "instanceCount":2,
+ "deploymentPort":12561,
+ "policy_type_impl":{
+ "apexPolicyModel":{
+ "key":{
+ "name":"PMControlPolicy",
+ "version":"0.0.1"
+ },
+ "keyInformation":{
+ "key":{
+ "name":"PMControlPolicy_KeyInfo",
+ "version":"0.0.1"
+ },
+ "keyInfoMap":{
+ "entry":[
+ {
+ "key":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "UUID":"6e5fa19b-14df-37e3-a4ae-8c537e861a82",
+ "description":"Generated description for concept referred to by key \"CDSActionIdentifiersType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSCreateResponseEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateResponseEvent",
+ "version":"0.0.1"
+ },
+ "UUID":"14b29e38-ac75-3273-aa4e-8583c0aa7dad",
+ "description":"Generated description for concept referred to by key \"CDSCreateResponseEvent:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSCreateResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "UUID":"04573f8f-e772-30a5-b1d9-d7318d4a1e13",
+ "description":"Generated description for concept referred to by key \"CDSCreateResponsePayloadType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSCreateResponsePolicy",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateResponsePolicy",
+ "version":"0.0.1"
+ },
+ "UUID":"e126c965-fc09-3bfe-8f55-70f380a4a49c",
+ "description":"Generated description for concept referred to by key \"CDSCreateResponsePolicy:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSCreateResponseTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateResponseTask",
+ "version":"0.0.1"
+ },
+ "UUID":"6165ee82-afd2-3aab-a517-f00b3f2461d2",
+ "description":"Generated description for concept referred to by key \"CDSCreateResponseTask:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSCreateSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "UUID":"8350ac5e-c157-38b9-9614-a0f93a830e60",
+ "description":"Generated description for concept referred to by key \"CDSCreateSubscriptionPayloadType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSCreateSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "UUID":"cfa325ba-226b-3a31-9183-ec43e2b6e9a2",
+ "description":"Generated description for concept referred to by key \"CDSCreateSubscriptionRequestEvent:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteResponseEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteResponseEvent",
+ "version":"0.0.1"
+ },
+ "UUID":"8be9c0fa-7437-3841-aff2-b3cec6ae3bd8",
+ "description":"Generated description for concept referred to by key \"CDSDeleteResponseEvent:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "UUID":"3fbfe0c9-152e-34d3-a504-09cd13c058d0",
+ "description":"Generated description for concept referred to by key \"CDSDeleteResponsePayloadType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteResponsePolicy",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteResponsePolicy",
+ "version":"0.0.1"
+ },
+ "UUID":"a780251c-edd5-3132-b865-04313246b43c",
+ "description":"Generated description for concept referred to by key \"CDSDeleteResponsePolicy:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteResponseTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteResponseTask",
+ "version":"0.0.1"
+ },
+ "UUID":"afce4555-3aa3-3521-a7d8-ee8cdf0d3efc",
+ "description":"Generated description for concept referred to by key \"CDSDeleteResponseTask:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "UUID":"12658406-9147-3c9d-a38c-5ad5e30b092b",
+ "description":"Generated description for concept referred to by key \"CDSDeleteSubscriptionPayloadType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "UUID":"24380c95-9289-36e6-8cbf-0edefa15ccd9",
+ "description":"Generated description for concept referred to by key \"CDSDeleteSubscriptionRequestEvent:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSRequestCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSRequestCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "UUID":"35590ac0-062c-39f1-8786-b4ff716e30b1",
+ "description":"Generated description for concept referred to by key \"CDSRequestCommonHeaderType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSResponseCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSResponseCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "UUID":"dd7e1805-885a-350b-aaf9-ed541321ae3c",
+ "description":"Generated description for concept referred to by key \"CDSResponseCommonHeaderType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSResponseStatusEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSResponseStatusEvent",
+ "version":"0.0.1"
+ },
+ "UUID":"7986e21b-32f7-302e-9554-31f21b673493",
+ "description":"Generated description for concept referred to by key \"CDSResponseStatusEvent:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CDSResponseStatusType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSResponseStatusType",
+ "version":"0.0.1"
+ },
+ "UUID":"92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa",
+ "description":"Generated description for concept referred to by key \"CDSResponseStatusType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CreateSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CreateSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "UUID":"92162397-1a8e-3a3f-a469-d2af7700af4a",
+ "description":"Generated description for concept referred to by key \"CreateSubscriptionPayloadEvent:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CreateSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CreateSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "UUID":"bc0c69f0-52ed-38ea-b468-ae4a6fd1730d",
+ "description":"Generated description for concept referred to by key \"CreateSubscriptionPayloadTask:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"CreateSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CreateSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "UUID":"89cb75e9-f06c-30d3-b4ff-698d45f63869",
+ "description":"Generated description for concept referred to by key \"CreateSubscriptionRequestTask:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"DeleteSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"DeleteSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "UUID":"994fa441-04ab-33bb-832d-1cd12ab5d074",
+ "description":"Generated description for concept referred to by key \"DeleteSubscriptionPayloadEvent:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"DeleteSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"DeleteSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "UUID":"0f519117-5fea-3e4b-941f-8f778100465f",
+ "description":"Generated description for concept referred to by key \"DeleteSubscriptionPayloadTask:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"DeleteSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"DeleteSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "UUID":"acb772fe-d442-39e3-98f9-b1080caf4150",
+ "description":"Generated description for concept referred to by key \"DeleteSubscriptionRequestTask:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"MRResponseEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"MRResponseEvent",
+ "version":"0.0.1"
+ },
+ "UUID":"13c747a3-6bae-3bcf-9c80-b152e01dc194",
+ "description":"Generated description for concept referred to by key \"MRResponseEvent:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMControlPolicy",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMControlPolicy",
+ "version":"0.0.1"
+ },
+ "UUID":"acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4",
+ "description":"Generated description for concept referred to by key \"PMControlPolicy:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMControlPolicy_Albums",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMControlPolicy_Albums",
+ "version":"0.0.1"
+ },
+ "UUID":"b38ad204-c2c8-32f4-9b5a-dda0aeb0145b",
+ "description":"Generated description for concept referred to by key \"PMControlPolicy_Albums:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMControlPolicy_Events",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMControlPolicy_Events",
+ "version":"0.0.1"
+ },
+ "UUID":"be3871a0-c42a-3113-a066-82d192840eca",
+ "description":"Generated description for concept referred to by key \"PMControlPolicy_Events:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMControlPolicy_KeyInfo",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMControlPolicy_KeyInfo",
+ "version":"0.0.1"
+ },
+ "UUID":"ced37634-28a4-3178-b7f6-2980794927b0",
+ "description":"Generated description for concept referred to by key \"PMControlPolicy_KeyInfo:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMControlPolicy_Policies",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMControlPolicy_Policies",
+ "version":"0.0.1"
+ },
+ "UUID":"be3d180d-ef9c-3a75-8e9c-84271a038bed",
+ "description":"Generated description for concept referred to by key \"PMControlPolicy_Policies:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMControlPolicy_Schemas",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMControlPolicy_Schemas",
+ "version":"0.0.1"
+ },
+ "UUID":"e61973f1-189c-39e5-82f6-0d3afe298a20",
+ "description":"Generated description for concept referred to by key \"PMControlPolicy_Schemas:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMControlPolicy_Tasks",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMControlPolicy_Tasks",
+ "version":"0.0.1"
+ },
+ "UUID":"5658adb3-2962-30a3-a241-fae75bb8eb4a",
+ "description":"Generated description for concept referred to by key \"PMControlPolicy_Tasks:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ },
+ "UUID":"c2bd6f0d-6854-317a-9be2-97c08338428c",
+ "description":"Generated description for concept referred to by key \"PMSubscriptionAlbum:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMSubscriptionOutputEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMSubscriptionOutputEvent",
+ "version":"0.0.1"
+ },
+ "UUID":"992b7819-9f69-3aa0-bb0f-6e45ea15ce05",
+ "description":"Generated description for concept referred to by key \"PMSubscriptionOutputEvent:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"PMSubscriptionType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMSubscriptionType",
+ "version":"0.0.1"
+ },
+ "UUID":"73c1c397-4fc3-357f-93b6-a8ad707fbaae",
+ "description":"Generated description for concept referred to by key \"PMSubscriptionType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"ReceiveEventPolicy",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"ReceiveEventPolicy",
+ "version":"0.0.1"
+ },
+ "UUID":"568b7345-9de1-36d3-b6a3-9b857e6809a1",
+ "description":"Generated description for concept referred to by key \"ReceiveEventPolicy:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"ReceiveSubscriptionTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"ReceiveSubscriptionTask",
+ "version":"0.0.1"
+ },
+ "UUID":"f596afc8-100c-35eb-92c8-352355ea457d",
+ "description":"Generated description for concept referred to by key \"ReceiveSubscriptionTask:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"SimpleIntType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"SimpleIntType",
+ "version":"0.0.1"
+ },
+ "UUID":"153791fd-ae0a-36a7-88a5-309a7936415d",
+ "description":"Generated description for concept referred to by key \"SimpleIntType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "UUID":"8a4957cf-9493-3a76-8c22-a208e23259af",
+ "description":"Generated description for concept referred to by key \"SimpleStringType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"SubscriptionStatusType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"SubscriptionStatusType",
+ "version":"0.0.1"
+ },
+ "UUID":"597643b1-9db1-31ce-85d0-e1c63c43b30b",
+ "description":"Generated description for concept referred to by key \"SubscriptionStatusType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"SubscriptionType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"SubscriptionType",
+ "version":"0.0.1"
+ },
+ "UUID":"184547bb-7d64-3cb2-a273-d7185102c5ce",
+ "description":"Generated description for concept referred to by key \"SubscriptionType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "UUID":"6a8cc68e-dfc8-3403-9c6d-071c886b319c",
+ "description":"Generated description for concept referred to by key \"UUIDType:0.0.1\""
+ }
+ },
+ {
+ "key":{
+ "name":"pmsh-operational-policy",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"pmsh-operational-policy",
+ "version":"0.0.1"
+ },
+ "UUID":"fdf2c9ff-6422-3ea6-b6b6-49b12116265d",
+ "description":"Generated description for concept referred to by key \"pmsh-operational-policy:0.0.1\""
+ }
+ }
+ ]
+ }
+ },
+ "policies":{
+ "key":{
+ "name":"PMControlPolicy_Policies",
+ "version":"0.0.1"
+ },
+ "policyMap":{
+ "entry":[
+ {
+ "key":{
+ "name":"CDSCreateResponsePolicy",
+ "version":"0.0.1"
+ },
+ "value":{
+ "policyKey":{
+ "name":"CDSCreateResponsePolicy",
+ "version":"0.0.1"
+ },
+ "template":"Freestyle",
+ "state":{
+ "entry":[
+ {
+ "key":"CDSCreateResponseState",
+ "value":{
+ "stateKey":{
+ "parentKeyName":"CDSCreateResponsePolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"NULL",
+ "localName":"CDSCreateResponseState"
+ },
+ "trigger":{
+ "name":"CDSCreateResponseEvent",
+ "version":"0.0.1"
+ },
+ "stateOutputs":{
+ "entry":[
+ {
+ "key":"ResponseOutput",
+ "value":{
+ "key":{
+ "parentKeyName":"CDSCreateResponsePolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CDSCreateResponseState",
+ "localName":"ResponseOutput"
+ },
+ "outgoingEvent":{
+ "name":"CDSResponseStatusEvent",
+ "version":"0.0.1"
+ },
+ "nextState":{
+ "parentKeyName":"NULL",
+ "parentKeyVersion":"0.0.0",
+ "parentLocalName":"NULL",
+ "localName":"NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference":[
+
+ ],
+ "taskSelectionLogic":{
+ "key":"NULL",
+ "logicFlavour":"UNDEFINED",
+ "logic":""
+ },
+ "stateFinalizerLogicMap":{
+ "entry":[
+
+ ]
+ },
+ "defaultTask":{
+ "name":"CDSCreateResponseTask",
+ "version":"0.0.1"
+ },
+ "taskReferences":{
+ "entry":[
+ {
+ "key":{
+ "name":"CDSCreateResponseTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "parentKeyName":"CDSCreateResponsePolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CDSCreateResponseState",
+ "localName":"CDSCreateResponsePolicy"
+ },
+ "outputType":"DIRECT",
+ "output":{
+ "parentKeyName":"CDSCreateResponsePolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CDSCreateResponseState",
+ "localName":"ResponseOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "firstState":"CDSCreateResponseState"
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteResponsePolicy",
+ "version":"0.0.1"
+ },
+ "value":{
+ "policyKey":{
+ "name":"CDSDeleteResponsePolicy",
+ "version":"0.0.1"
+ },
+ "template":"Freestyle",
+ "state":{
+ "entry":[
+ {
+ "key":"CDSDeleteResponseState",
+ "value":{
+ "stateKey":{
+ "parentKeyName":"CDSDeleteResponsePolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"NULL",
+ "localName":"CDSDeleteResponseState"
+ },
+ "trigger":{
+ "name":"CDSDeleteResponseEvent",
+ "version":"0.0.1"
+ },
+ "stateOutputs":{
+ "entry":[
+ {
+ "key":"ResponseOutput",
+ "value":{
+ "key":{
+ "parentKeyName":"CDSDeleteResponsePolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CDSDeleteResponseState",
+ "localName":"ResponseOutput"
+ },
+ "outgoingEvent":{
+ "name":"CDSResponseStatusEvent",
+ "version":"0.0.1"
+ },
+ "nextState":{
+ "parentKeyName":"NULL",
+ "parentKeyVersion":"0.0.0",
+ "parentLocalName":"NULL",
+ "localName":"NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference":[
+
+ ],
+ "taskSelectionLogic":{
+ "key":"NULL",
+ "logicFlavour":"UNDEFINED",
+ "logic":""
+ },
+ "stateFinalizerLogicMap":{
+ "entry":[
+
+ ]
+ },
+ "defaultTask":{
+ "name":"CDSDeleteResponseTask",
+ "version":"0.0.1"
+ },
+ "taskReferences":{
+ "entry":[
+ {
+ "key":{
+ "name":"CDSDeleteResponseTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "parentKeyName":"CDSDeleteResponsePolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CDSDeleteResponseState",
+ "localName":"CDSDeleteResponsePolicy"
+ },
+ "outputType":"DIRECT",
+ "output":{
+ "parentKeyName":"CDSDeleteResponsePolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CDSDeleteResponseState",
+ "localName":"ResponseOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "firstState":"CDSDeleteResponseState"
+ }
+ },
+ {
+ "key":{
+ "name":"ReceiveEventPolicy",
+ "version":"0.0.1"
+ },
+ "value":{
+ "policyKey":{
+ "name":"ReceiveEventPolicy",
+ "version":"0.0.1"
+ },
+ "template":"Freestyle",
+ "state":{
+ "entry":[
+ {
+ "key":"CreateOrDeleteState",
+ "value":{
+ "stateKey":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"NULL",
+ "localName":"CreateOrDeleteState"
+ },
+ "trigger":{
+ "name":"PMSubscriptionOutputEvent",
+ "version":"0.0.1"
+ },
+ "stateOutputs":{
+ "entry":[
+ {
+ "key":"CreateSubscriptionPayload",
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CreateOrDeleteState",
+ "localName":"CreateSubscriptionPayload"
+ },
+ "outgoingEvent":{
+ "name":"CreateSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "nextState":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"NULL",
+ "localName":"CreateSubscription"
+ }
+ }
+ },
+ {
+ "key":"DeleteSubscriptionPayload",
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CreateOrDeleteState",
+ "localName":"DeleteSubscriptionPayload"
+ },
+ "outgoingEvent":{
+ "name":"DeleteSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "nextState":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"NULL",
+ "localName":"DeleteSubscription"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskSelectionLogic":{
+ "key":"TaskSelectionLogic",
+ "logicFlavour":"JAVASCRIPT",
+ "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toString()\n\nexecutor.logger.info(\"Change Type is \" + changeType)\n\nif (\"CREATE\".equals(changeType)) {\n executor.logger.info(\"Choosing to create a subscription\")\n executor.subject.getTaskKey(\"CreateSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n}\nelse if (\"DELETE\".equals(changeType)) {\n executor.logger.info(\"Choosing to delete a subscription\")\n executor.subject.getTaskKey(\"DeleteSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n}\n\n//var returnValue = executor.isTrue;\ntrue;"
+ },
+ "stateFinalizerLogicMap":{
+ "entry":[
+
+ ]
+ },
+ "defaultTask":{
+ "name":"CreateSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "taskReferences":{
+ "entry":[
+ {
+ "key":{
+ "name":"CreateSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CreateOrDeleteState",
+ "localName":"ReceiveEventPolicy"
+ },
+ "outputType":"DIRECT",
+ "output":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CreateOrDeleteState",
+ "localName":"CreateSubscriptionPayload"
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"DeleteSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CreateOrDeleteState",
+ "localName":"ReceiveEventPolicy"
+ },
+ "outputType":"DIRECT",
+ "output":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CreateOrDeleteState",
+ "localName":"DeleteSubscriptionPayload"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":"CreateSubscription",
+ "value":{
+ "stateKey":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"NULL",
+ "localName":"CreateSubscription"
+ },
+ "trigger":{
+ "name":"CreateSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "stateOutputs":{
+ "entry":[
+ {
+ "key":"IssueCreateSubscriptionRequestOutput",
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CreateSubscription",
+ "localName":"IssueCreateSubscriptionRequestOutput"
+ },
+ "outgoingEvent":{
+ "name":"CDSCreateSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "nextState":{
+ "parentKeyName":"NULL",
+ "parentKeyVersion":"0.0.0",
+ "parentLocalName":"NULL",
+ "localName":"NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskSelectionLogic":{
+ "key":"NULL",
+ "logicFlavour":"UNDEFINED",
+ "logic":""
+ },
+ "stateFinalizerLogicMap":{
+ "entry":[
+
+ ]
+ },
+ "defaultTask":{
+ "name":"CreateSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "taskReferences":{
+ "entry":[
+ {
+ "key":{
+ "name":"CreateSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CreateSubscription",
+ "localName":"ReceiveEventPolicy"
+ },
+ "outputType":"DIRECT",
+ "output":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"CreateSubscription",
+ "localName":"IssueCreateSubscriptionRequestOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":"DeleteSubscription",
+ "value":{
+ "stateKey":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"NULL",
+ "localName":"DeleteSubscription"
+ },
+ "trigger":{
+ "name":"DeleteSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "stateOutputs":{
+ "entry":[
+ {
+ "key":"IssueDeleteSubscriptionRequestOutput",
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"DeleteSubscription",
+ "localName":"IssueDeleteSubscriptionRequestOutput"
+ },
+ "outgoingEvent":{
+ "name":"CDSDeleteSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "nextState":{
+ "parentKeyName":"NULL",
+ "parentKeyVersion":"0.0.0",
+ "parentLocalName":"NULL",
+ "localName":"NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskSelectionLogic":{
+ "key":"NULL",
+ "logicFlavour":"UNDEFINED",
+ "logic":""
+ },
+ "stateFinalizerLogicMap":{
+ "entry":[
+
+ ]
+ },
+ "defaultTask":{
+ "name":"DeleteSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "taskReferences":{
+ "entry":[
+ {
+ "key":{
+ "name":"DeleteSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"DeleteSubscription",
+ "localName":"ReceiveEventPolicy"
+ },
+ "outputType":"DIRECT",
+ "output":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"DeleteSubscription",
+ "localName":"IssueDeleteSubscriptionRequestOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":"ReceiveSubscriptionState",
+ "value":{
+ "stateKey":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"NULL",
+ "localName":"ReceiveSubscriptionState"
+ },
+ "trigger":{
+ "name":"pmsh-operational-policy",
+ "version":"0.0.1"
+ },
+ "stateOutputs":{
+ "entry":[
+ {
+ "key":"ReceivePMSubscriptionOutput",
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"ReceiveSubscriptionState",
+ "localName":"ReceivePMSubscriptionOutput"
+ },
+ "outgoingEvent":{
+ "name":"PMSubscriptionOutputEvent",
+ "version":"0.0.1"
+ },
+ "nextState":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"NULL",
+ "localName":"CreateOrDeleteState"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskSelectionLogic":{
+ "key":"NULL",
+ "logicFlavour":"UNDEFINED",
+ "logic":""
+ },
+ "stateFinalizerLogicMap":{
+ "entry":[
+
+ ]
+ },
+ "defaultTask":{
+ "name":"ReceiveSubscriptionTask",
+ "version":"0.0.1"
+ },
+ "taskReferences":{
+ "entry":[
+ {
+ "key":{
+ "name":"ReceiveSubscriptionTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"ReceiveSubscriptionState",
+ "localName":"ReceiveEventPolicy"
+ },
+ "outputType":"DIRECT",
+ "output":{
+ "parentKeyName":"ReceiveEventPolicy",
+ "parentKeyVersion":"0.0.1",
+ "parentLocalName":"ReceiveSubscriptionState",
+ "localName":"ReceivePMSubscriptionOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "firstState":"ReceiveSubscriptionState"
+ }
+ }
+ ]
+ }
+ },
+ "tasks":{
+ "key":{
+ "name":"PMControlPolicy_Tasks",
+ "version":"0.0.1"
+ },
+ "taskMap":{
+ "entry":[
+ {
+ "key":{
+ "name":"CDSCreateResponseTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateResponseTask",
+ "version":"0.0.1"
+ },
+ "inputFields":{
+ "entry":[
+ {
+ "key":"actionIdentifiers",
+ "value":{
+ "key":"actionIdentifiers",
+ "fieldSchemaKey":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"commonHeader",
+ "value":{
+ "key":"commonHeader",
+ "fieldSchemaKey":{
+ "name":"CDSResponseCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSCreateResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"status",
+ "value":{
+ "key":"status",
+ "fieldSchemaKey":{
+ "name":"CDSResponseStatusType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "outputFields":{
+ "entry":[
+ {
+ "key":"status",
+ "value":{
+ "key":"status",
+ "fieldSchemaKey":{
+ "name":"SubscriptionStatusType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "taskParameters":{
+ "entry":[
+
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskLogic":{
+ "key":"TaskLogic",
+ "logicFlavour":"JAVASCRIPT",
+ "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar commonHeader = executor.inFields.get(\"commonHeader\")\nvar response = executor.inFields.get(\"payload\")\nvar albumID = commonHeader.get(\"requestId\")\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\nvar responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\nresponseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\nresponseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\nresponseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\nvar status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\nexecutor.logger.info(\"RESPONSE STATUS = \" + status)\n\nif(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n} else {\n responseStatus.put(\"message\", \"failed\")\n}\n\nexecutor.outFields.put(\"status\", responseStatus)\n\n//var returnValue = executor.isTrue;\ntrue;"
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteResponseTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteResponseTask",
+ "version":"0.0.1"
+ },
+ "inputFields":{
+ "entry":[
+ {
+ "key":"actionIdentifiers",
+ "value":{
+ "key":"actionIdentifiers",
+ "fieldSchemaKey":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"commonHeader",
+ "value":{
+ "key":"commonHeader",
+ "fieldSchemaKey":{
+ "name":"CDSResponseCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSDeleteResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"status",
+ "value":{
+ "key":"status",
+ "fieldSchemaKey":{
+ "name":"CDSResponseStatusType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "outputFields":{
+ "entry":[
+ {
+ "key":"status",
+ "value":{
+ "key":"status",
+ "fieldSchemaKey":{
+ "name":"SubscriptionStatusType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "taskParameters":{
+ "entry":[
+
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskLogic":{
+ "key":"TaskLogic",
+ "logicFlavour":"JAVASCRIPT",
+ "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar commonHeader = executor.inFields.get(\"commonHeader\")\nvar response = executor.inFields.get(\"payload\")\nvar albumID = commonHeader.get(\"requestId\")\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\nvar responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\nresponseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\nresponseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\nresponseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\nvar status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\nexecutor.logger.info(\"RESPONSE STATUS = \" + status)\n\nif(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n} else {\n responseStatus.put(\"message\", \"failed\")\n}\n\nexecutor.outFields.put(\"status\", responseStatus)\n\n//var returnValue = executor.isTrue;\ntrue;"
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"CreateSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CreateSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "inputFields":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "outputFields":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSCreateSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "taskParameters":{
+ "entry":[
+
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskLogic":{
+ "key":"TaskLogic",
+ "logicFlavour":"JAVASCRIPT",
+ "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\nvar payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\npayloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\npayloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\npayloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\npayloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\npayloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\npayloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\nvar payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\npayloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\nvar payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\npayload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\nexecutor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;"
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"CreateSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CreateSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "inputFields":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSCreateSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "outputFields":{
+ "entry":[
+ {
+ "key":"actionIdentifiers",
+ "value":{
+ "key":"actionIdentifiers",
+ "fieldSchemaKey":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"commonHeader",
+ "value":{
+ "key":"commonHeader",
+ "fieldSchemaKey":{
+ "name":"CDSRequestCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSCreateSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "taskParameters":{
+ "entry":[
+
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskLogic":{
+ "key":"TaskLogic",
+ "logicFlavour":"JAVASCRIPT",
+ "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\nvar blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\nvar blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\nvar payload = executor.inFields.get(\"payload\")\nvar actionName = changeType + \"-subscription\"\n\nvar commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\ncommonHeader.put(\"originatorId\", \"sdnc\");\ncommonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\ncommonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\nvar actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\nactionIdentifiers.put(\"actionName\", actionName);\nactionIdentifiers.put(\"blueprintName\", blueprintName);\nactionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\nactionIdentifiers.put(\"mode\", \"sync\");\n\nexecutor.outFields.put(\"commonHeader\", commonHeader);\nexecutor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;"
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"DeleteSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"DeleteSubscriptionPayloadTask",
+ "version":"0.0.1"
+ },
+ "inputFields":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "outputFields":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSDeleteSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "taskParameters":{
+ "entry":[
+
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskLogic":{
+ "key":"TaskLogic",
+ "logicFlavour":"JAVASCRIPT",
+ "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\nvar payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\npayloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\npayloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\npayloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\npayloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\npayloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\npayloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\nvar payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\npayloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\nvar payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\npayload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\nexecutor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;"
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"DeleteSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"DeleteSubscriptionRequestTask",
+ "version":"0.0.1"
+ },
+ "inputFields":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSDeleteSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "outputFields":{
+ "entry":[
+ {
+ "key":"actionIdentifiers",
+ "value":{
+ "key":"actionIdentifiers",
+ "fieldSchemaKey":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"commonHeader",
+ "value":{
+ "key":"commonHeader",
+ "fieldSchemaKey":{
+ "name":"CDSRequestCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSDeleteSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "taskParameters":{
+ "entry":[
+
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskLogic":{
+ "key":"TaskLogic",
+ "logicFlavour":"JAVASCRIPT",
+ "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\nvar blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\nvar blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\nvar payload = executor.inFields.get(\"payload\")\nvar actionName = changeType + \"-subscription\"\n\nvar commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\ncommonHeader.put(\"originatorId\", \"sdnc\");\ncommonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\ncommonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\nvar actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\nactionIdentifiers.put(\"actionName\", actionName);\nactionIdentifiers.put(\"blueprintName\", blueprintName);\nactionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\nactionIdentifiers.put(\"mode\", \"sync\");\n\nexecutor.outFields.put(\"commonHeader\", commonHeader);\nexecutor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;"
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"ReceiveSubscriptionTask",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"ReceiveSubscriptionTask",
+ "version":"0.0.1"
+ },
+ "inputFields":{
+ "entry":[
+ {
+ "key":"blueprintName",
+ "value":{
+ "key":"blueprintName",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"blueprintVersion",
+ "value":{
+ "key":"blueprintVersion",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"changeType",
+ "value":{
+ "key":"changeType",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"closedLoopControlName",
+ "value":{
+ "key":"closedLoopControlName",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"nfName",
+ "value":{
+ "key":"nfName",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"policyName",
+ "value":{
+ "key":"policyName",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"subscription",
+ "value":{
+ "key":"subscription",
+ "fieldSchemaKey":{
+ "name":"SubscriptionType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "outputFields":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ },
+ "taskParameters":{
+ "entry":[
+
+ ]
+ },
+ "contextAlbumReference":[
+ {
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ }
+ ],
+ "taskLogic":{
+ "key":"TaskLogic",
+ "logicFlavour":"JAVASCRIPT",
+ "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nvar uuidType = java.util.UUID;\n\nexecutor.logger.info(executor.subject.id);\n\n//albumID will be used to fetch info from our album later\nvar albumID = uuidType.randomUUID();\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").getSchemaHelper().createNewInstance();\nvar returnValue = true;\n\nif(executor.inFields.get(\"policyName\") != null) {\n executor.logger.info(\"nfName in receive sub event \" + executor.inFields.get(\"nfName\"));\n\n var changeType = executor.inFields.get(\"changeType\")\n var nfName = executor.inFields.get(\"nfName\")\n var policyName = executor.inFields.get(\"policyName\")\n var closedLoopControlName = executor.inFields.get(\"closedLoopControlName\")\n var subscription = executor.inFields.get(\"subscription\")\n var blueprintName = executor.inFields.get(\"blueprintName\")\n var blueprintVersion = executor.inFields.get(\"blueprintVersion\")\n\n pmSubscriptionInfo.put(\"nfName\", executor.inFields.get(\"nfName\"));\n pmSubscriptionInfo.put(\"changeType\", executor.inFields.get(\"changeType\"))\n pmSubscriptionInfo.put(\"policyName\", executor.inFields.get(\"policyName\"))\n pmSubscriptionInfo.put(\"closedLoopControlName\", executor.inFields.get(\"closedLoopControlName\"))\n pmSubscriptionInfo.put(\"subscription\", subscription)\n pmSubscriptionInfo.put(\"blueprintName\", blueprintName)\n pmSubscriptionInfo.put(\"blueprintVersion\", blueprintVersion)\n\n\n executor.getContextAlbum(\"PMSubscriptionAlbum\").put(albumID.toString(), pmSubscriptionInfo);\n\n executor.outFields.put(\"albumID\", albumID)\n} else {\n executor.message = \"Received invalid event\"\n returnValue = false;\n}\n\nreturnValue;"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "events":{
+ "key":{
+ "name":"PMControlPolicy_Events",
+ "version":"0.0.1"
+ },
+ "eventMap":{
+ "entry":[
+ {
+ "key":{
+ "name":"CDSCreateResponseEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateResponseEvent",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"CDS",
+ "target":"APEX",
+ "parameter":{
+ "entry":[
+ {
+ "key":"actionIdentifiers",
+ "value":{
+ "key":"actionIdentifiers",
+ "fieldSchemaKey":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"commonHeader",
+ "value":{
+ "key":"commonHeader",
+ "fieldSchemaKey":{
+ "name":"CDSResponseCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSCreateResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"status",
+ "value":{
+ "key":"status",
+ "fieldSchemaKey":{
+ "name":"CDSResponseStatusType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"CDSCreateSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"APEX",
+ "target":"APEX",
+ "parameter":{
+ "entry":[
+ {
+ "key":"actionIdentifiers",
+ "value":{
+ "key":"actionIdentifiers",
+ "fieldSchemaKey":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"commonHeader",
+ "value":{
+ "key":"commonHeader",
+ "fieldSchemaKey":{
+ "name":"CDSRequestCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSCreateSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteResponseEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteResponseEvent",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"CDS",
+ "target":"APEX",
+ "parameter":{
+ "entry":[
+ {
+ "key":"actionIdentifiers",
+ "value":{
+ "key":"actionIdentifiers",
+ "fieldSchemaKey":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"commonHeader",
+ "value":{
+ "key":"commonHeader",
+ "fieldSchemaKey":{
+ "name":"CDSResponseCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSDeleteResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"status",
+ "value":{
+ "key":"status",
+ "fieldSchemaKey":{
+ "name":"CDSResponseStatusType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteSubscriptionRequestEvent",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"APEX",
+ "target":"APEX",
+ "parameter":{
+ "entry":[
+ {
+ "key":"actionIdentifiers",
+ "value":{
+ "key":"actionIdentifiers",
+ "fieldSchemaKey":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"commonHeader",
+ "value":{
+ "key":"commonHeader",
+ "fieldSchemaKey":{
+ "name":"CDSRequestCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSDeleteSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"CDSResponseStatusEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSResponseStatusEvent",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"APEX",
+ "target":"DCAE",
+ "parameter":{
+ "entry":[
+ {
+ "key":"status",
+ "value":{
+ "key":"status",
+ "fieldSchemaKey":{
+ "name":"SubscriptionStatusType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"CreateSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CreateSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"APEX",
+ "target":"APEX",
+ "parameter":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSCreateSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"DeleteSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"DeleteSubscriptionPayloadEvent",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"APEX",
+ "target":"APEX",
+ "parameter":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"payload",
+ "value":{
+ "key":"payload",
+ "fieldSchemaKey":{
+ "name":"CDSDeleteSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"MRResponseEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"MRResponseEvent",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"DCAE",
+ "target":"APEX",
+ "parameter":{
+ "entry":[
+ {
+ "key":"count",
+ "value":{
+ "key":"count",
+ "fieldSchemaKey":{
+ "name":"SimpleIntType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"serverTimeMs",
+ "value":{
+ "key":"serverTimeMs",
+ "fieldSchemaKey":{
+ "name":"SimpleIntType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"PMSubscriptionOutputEvent",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMSubscriptionOutputEvent",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"APEX",
+ "target":"APEX",
+ "parameter":{
+ "entry":[
+ {
+ "key":"albumID",
+ "value":{
+ "key":"albumID",
+ "fieldSchemaKey":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key":{
+ "name":"pmsh-operational-policy",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"pmsh-operational-policy",
+ "version":"0.0.1"
+ },
+ "nameSpace":"org.onap.policy.apex.onap.pmcontrol",
+ "source":"DCAE",
+ "target":"APEX",
+ "parameter":{
+ "entry":[
+ {
+ "key":"blueprintName",
+ "value":{
+ "key":"blueprintName",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"blueprintVersion",
+ "value":{
+ "key":"blueprintVersion",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"changeType",
+ "value":{
+ "key":"changeType",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"closedLoopControlName",
+ "value":{
+ "key":"closedLoopControlName",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"nfName",
+ "value":{
+ "key":"nfName",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"policyName",
+ "value":{
+ "key":"policyName",
+ "fieldSchemaKey":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ },
+ {
+ "key":"subscription",
+ "value":{
+ "key":"subscription",
+ "fieldSchemaKey":{
+ "name":"SubscriptionType",
+ "version":"0.0.1"
+ },
+ "optional":false
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ },
+ "albums":{
+ "key":{
+ "name":"PMControlPolicy_Albums",
+ "version":"0.0.1"
+ },
+ "albums":{
+ "entry":[
+ {
+ "key":{
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMSubscriptionAlbum",
+ "version":"0.0.1"
+ },
+ "scope":"policy",
+ "isWritable":true,
+ "itemSchema":{
+ "name":"PMSubscriptionType",
+ "version":"0.0.1"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "schemas":{
+ "key":{
+ "name":"PMControlPolicy_Schemas",
+ "version":"0.0.1"
+ },
+ "schemas":{
+ "entry":[
+ {
+ "key":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSActionIdentifiersType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ActionIdentifiers_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"actionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"mode\",\n \"type\": \"string\"\n }\n ]\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"CDSCreateResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n \"name\": \"CreateResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"CDSCreateSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSCreateSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteResponsePayloadType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n \"name\": \"DeleteResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"com.acme.avro\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"CDSDeleteSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSDeleteSubscriptionPayloadType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"CDSRequestCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSRequestCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"RequestCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n }\n ]\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"CDSResponseCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSResponseCommonHeaderType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ResponseCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"flags\",\n \"type\": [\"null\", \"string\"]\n }\n ]\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"CDSResponseStatusType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"CDSResponseStatusType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ResponseStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"code\",\n \"type\": \"int\"\n },\n {\n \"name\": \"eventType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"PMSubscriptionType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"PMSubscriptionType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\",\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t]\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"SimpleIntType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"SimpleIntType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Java",
+ "schemaDefinition":"java.lang.Integer"
+ }
+ },
+ {
+ "key":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"SimpleStringType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Java",
+ "schemaDefinition":"java.lang.String"
+ }
+ },
+ {
+ "key":{
+ "name":"SubscriptionStatusType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"SubscriptionStatusType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ActivateSubscriptionStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"changeType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"SubscriptionType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"SubscriptionType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Avro",
+ "schemaDefinition":"{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}"
+ }
+ },
+ {
+ "key":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "value":{
+ "key":{
+ "name":"UUIDType",
+ "version":"0.0.1"
+ },
+ "schemaFlavour":"Java",
+ "schemaDefinition":"java.util.UUID"
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "engineParameters":{
+ "executorParameters":{
+ "JAVASCRIPT":{
+ "parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ },
+ "contextParameters":{
+ "parameterClassName":"org.onap.policy.apex.context.parameters.ContextParameters",
+ "schemaParameters":{
+ "Avro":{
+ "parameterClassName":"org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
+ },
+ "Java":{
+ "parameterClassName":"org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters",
+ "jsonAdapters":{
+ "Instant":{
+ "adaptedClass":"java.time.Instant",
+ "adaptorClass":"org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "eventInputParameters":{
+ "DCAEConsumer":{
+ "carrierTechnologyParameters":{
+ "carrierTechnology":"RESTCLIENT",
+ "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters":{
+ "consumerPollTime":"50",
+ "url":"https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1"
+ }
+ },
+ "eventProtocolParameters":{
+ "eventProtocol":"JSON",
+ "parameters":{
+ "nameAlias":"policyName"
+ }
+ },
+ "eventName":"pmsh-operational-policy",
+ "eventNameFilter":"pmsh-operational-policy"
+ },
+ "CDSRequestConsumer":{
+ "carrierTechnologyParameters":{
+ "carrierTechnology":"RESTREQUESTOR",
+ "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
+ "parameters":{
+ "url":"http://10.10.10.184:30254/api/v1/execution-service/process",
+ "httpMethod":"POST",
+ "restRequestTimeout":2000,
+ "httpHeaders":[
+ [
+ "Authorization",
+ "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw=="
+ ]
+ ]
+ }
+ },
+ "eventProtocolParameters":{
+ "eventProtocol":"JSON"
+ },
+ "eventName":"CDSCreateResponseEvent",
+ "eventNameFilter":"CDSCreateResponseEvent",
+ "requestorMode":true,
+ "requestorPeer":"CDSRequestProducer",
+ "requestorTimeout":500
+ },
+ "CDSDeleteRequestConsumer":{
+ "carrierTechnologyParameters":{
+ "carrierTechnology":"RESTREQUESTOR",
+ "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
+ "parameters":{
+ "url":"http://10.10.10.184:30254/api/v1/execution-service/process",
+ "httpMethod":"POST",
+ "restRequestTimeout":2000,
+ "httpHeaders":[
+ [
+ "Authorization",
+ "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw=="
+ ]
+ ]
+ }
+ },
+ "eventProtocolParameters":{
+ "eventProtocol":"JSON"
+ },
+ "eventName":"CDSDeleteResponseEvent",
+ "eventNameFilter":"CDSDeleteResponseEvent",
+ "requestorMode":true,
+ "requestorPeer":"CDSDeleteRequestProducer",
+ "requestorTimeout":500
+ },
+ "CDSReplyConsumer":{
+ "carrierTechnologyParameters":{
+ "carrierTechnology":"RESTREQUESTOR",
+ "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
+ "parameters":{
+ "url":"https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT",
+ "httpMethod":"POST",
+ "restRequestTimeout":2000
+ }
+ },
+ "eventProtocolParameters":{
+ "eventProtocol":"JSON"
+ },
+ "eventName":"MRResponseEvent",
+ "eventNameFilter":"MRResponseEvent",
+ "requestorMode":true,
+ "requestorPeer":"CDSReplyProducer",
+ "requestorTimeout":500
+ }
+ },
+ "eventOutputParameters":{
+ "logOutputter":{
+ "carrierTechnologyParameters":{
+ "carrierTechnology":"FILE",
+ "parameters":{
+ "fileName":"/tmp/outputevents.log"
+ }
+ },
+ "eventProtocolParameters":{
+ "eventProtocol":"JSON"
+ }
+ },
+ "StdOutOutputter":{
+ "carrierTechnologyParameters":{
+ "carrierTechnology":"FILE",
+ "parameters":{
+ "standardIo":true
+ }
+ },
+ "eventProtocolParameters":{
+ "eventProtocol":"JSON"
+ }
+ },
+ "CDSRequestProducer":{
+ "carrierTechnologyParameters":{
+ "carrierTechnology":"RESTREQUESTOR",
+ "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters":{
+ "eventProtocol":"JSON"
+ },
+ "eventNameFilter":"CDSCreateSubscriptionRequestEvent",
+ "requestorMode":true,
+ "requestorPeer":"CDSRequestConsumer",
+ "requestorTimeout":500
+ },
+ "CDSDeleteRequestProducer":{
+ "carrierTechnologyParameters":{
+ "carrierTechnology":"RESTREQUESTOR",
+ "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters":{
+ "eventProtocol":"JSON"
+ },
+ "eventNameFilter":"CDSDeleteSubscriptionRequestEvent",
+ "requestorMode":true,
+ "requestorPeer":"CDSDeleteRequestConsumer",
+ "requestorTimeout":500
+ },
+ "CDSReplyProducer":{
+ "carrierTechnologyParameters":{
+ "carrierTechnology":"RESTREQUESTOR",
+ "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters":{
+ "eventProtocol":"JSON"
+ },
+ "eventNameFilter":"CDSResponseStatusEvent",
+ "requestorMode":true,
+ "requestorPeer":"CDSReplyConsumer",
+ "requestorTimeout":500
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml b/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml
new file mode 100644
index 000000000..faf579012
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml
@@ -0,0 +1,2619 @@
+---
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+topology_template:
+ policies:
+ - operational.apex.pmcontrol:
+ type: onap.policies.controlloop.operational.Apex
+ type_version: 1.0.0
+ version: 1.0.0
+ metadata:
+ policy-id: operational.apex.pmcontrol
+ policy-version: 1
+ properties:
+ engineServiceParameters:
+ name: MyApexEngine
+ version: 0.0.1
+ id: 45
+ instanceCount: 2
+ deploymentPort: 12561
+ policy_type_impl:
+ apexPolicyModel:
+ key:
+ name: PMControlPolicy
+ version: 0.0.1
+ keyInformation:
+ key:
+ name: PMControlPolicy_KeyInfo
+ version: 0.0.1
+ keyInfoMap:
+ entry:
+ - key:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82
+ description: Generated description for concept referred to by
+ key "CDSActionIdentifiersType:0.0.1"
+ - key:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad
+ description: Generated description for concept referred to by
+ key "CDSCreateResponseEvent:0.0.1"
+ - key:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13
+ description: Generated description for concept referred to by
+ key "CDSCreateResponsePayloadType:0.0.1"
+ - key:
+ name: CDSCreateResponsePolicy
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponsePolicy
+ version: 0.0.1
+ UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c
+ description: Generated description for concept referred to by
+ key "CDSCreateResponsePolicy:0.0.1"
+ - key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2
+ description: Generated description for concept referred to by
+ key "CDSCreateResponseTask:0.0.1"
+ - key:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60
+ description: Generated description for concept referred to by
+ key "CDSCreateSubscriptionPayloadType:0.0.1"
+ - key:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2
+ description: Generated description for concept referred to by
+ key "CDSCreateSubscriptionRequestEvent:0.0.1"
+ - key:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8
+ description: Generated description for concept referred to by
+ key "CDSDeleteResponseEvent:0.0.1"
+ - key:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0
+ description: Generated description for concept referred to by
+ key "CDSDeleteResponsePayloadType:0.0.1"
+ - key:
+ name: CDSDeleteResponsePolicy
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponsePolicy
+ version: 0.0.1
+ UUID: a780251c-edd5-3132-b865-04313246b43c
+ description: Generated description for concept referred to by
+ key "CDSDeleteResponsePolicy:0.0.1"
+ - key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc
+ description: Generated description for concept referred to by
+ key "CDSDeleteResponseTask:0.0.1"
+ - key:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b
+ description: Generated description for concept referred to by
+ key "CDSDeleteSubscriptionPayloadType:0.0.1"
+ - key:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9
+ description: Generated description for concept referred to by
+ key "CDSDeleteSubscriptionRequestEvent:0.0.1"
+ - key:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1
+ description: Generated description for concept referred to by
+ key "CDSRequestCommonHeaderType:0.0.1"
+ - key:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c
+ description: Generated description for concept referred to by
+ key "CDSResponseCommonHeaderType:0.0.1"
+ - key:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ UUID: 7986e21b-32f7-302e-9554-31f21b673493
+ description: Generated description for concept referred to by
+ key "CDSResponseStatusEvent:0.0.1"
+ - key:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa
+ description: Generated description for concept referred to by
+ key "CDSResponseStatusType:0.0.1"
+ - key:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a
+ description: Generated description for concept referred to by
+ key "CreateSubscriptionPayloadEvent:0.0.1"
+ - key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d
+ description: Generated description for concept referred to by
+ key "CreateSubscriptionPayloadTask:0.0.1"
+ - key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869
+ description: Generated description for concept referred to by
+ key "CreateSubscriptionRequestTask:0.0.1"
+ - key:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074
+ description: Generated description for concept referred to by
+ key "DeleteSubscriptionPayloadEvent:0.0.1"
+ - key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ UUID: 0f519117-5fea-3e4b-941f-8f778100465f
+ description: Generated description for concept referred to by
+ key "DeleteSubscriptionPayloadTask:0.0.1"
+ - key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ UUID: acb772fe-d442-39e3-98f9-b1080caf4150
+ description: Generated description for concept referred to by
+ key "DeleteSubscriptionRequestTask:0.0.1"
+ - key:
+ name: MRResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: MRResponseEvent
+ version: 0.0.1
+ UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194
+ description: Generated description for concept referred to by
+ key "MRResponseEvent:0.0.1"
+ - key:
+ name: PMControlPolicy
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy
+ version: 0.0.1
+ UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4
+ description: Generated description for concept referred to by
+ key "PMControlPolicy:0.0.1"
+ - key:
+ name: PMControlPolicy_Albums
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Albums
+ version: 0.0.1
+ UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b
+ description: Generated description for concept referred to by
+ key "PMControlPolicy_Albums:0.0.1"
+ - key:
+ name: PMControlPolicy_Events
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Events
+ version: 0.0.1
+ UUID: be3871a0-c42a-3113-a066-82d192840eca
+ description: Generated description for concept referred to by
+ key "PMControlPolicy_Events:0.0.1"
+ - key:
+ name: PMControlPolicy_KeyInfo
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_KeyInfo
+ version: 0.0.1
+ UUID: ced37634-28a4-3178-b7f6-2980794927b0
+ description: Generated description for concept referred to by
+ key "PMControlPolicy_KeyInfo:0.0.1"
+ - key:
+ name: PMControlPolicy_Policies
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Policies
+ version: 0.0.1
+ UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed
+ description: Generated description for concept referred to by
+ key "PMControlPolicy_Policies:0.0.1"
+ - key:
+ name: PMControlPolicy_Schemas
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Schemas
+ version: 0.0.1
+ UUID: e61973f1-189c-39e5-82f6-0d3afe298a20
+ description: Generated description for concept referred to by
+ key "PMControlPolicy_Schemas:0.0.1"
+ - key:
+ name: PMControlPolicy_Tasks
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Tasks
+ version: 0.0.1
+ UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a
+ description: Generated description for concept referred to by
+ key "PMControlPolicy_Tasks:0.0.1"
+ - key:
+ name: PMSubscriptionAlbum
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionAlbum
+ version: 0.0.1
+ UUID: c2bd6f0d-6854-317a-9be2-97c08338428c
+ description: Generated description for concept referred to by
+ key "PMSubscriptionAlbum:0.0.1"
+ - key:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05
+ description: Generated description for concept referred to by
+ key "PMSubscriptionOutputEvent:0.0.1"
+ - key:
+ name: PMSubscriptionType
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionType
+ version: 0.0.1
+ UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae
+ description: Generated description for concept referred to by
+ key "PMSubscriptionType:0.0.1"
+ - key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ value:
+ key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1
+ description: Generated description for concept referred to by
+ key "ReceiveEventPolicy:0.0.1"
+ - key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ value:
+ key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ UUID: f596afc8-100c-35eb-92c8-352355ea457d
+ description: Generated description for concept referred to by
+ key "ReceiveSubscriptionTask:0.0.1"
+ - key:
+ name: SimpleIntType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleIntType
+ version: 0.0.1
+ UUID: 153791fd-ae0a-36a7-88a5-309a7936415d
+ description: Generated description for concept referred to by
+ key "SimpleIntType:0.0.1"
+ - key:
+ name: SimpleStringType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleStringType
+ version: 0.0.1
+ UUID: 8a4957cf-9493-3a76-8c22-a208e23259af
+ description: Generated description for concept referred to by
+ key "SimpleStringType:0.0.1"
+ - key:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ value:
+ key:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b
+ description: Generated description for concept referred to by
+ key "SubscriptionStatusType:0.0.1"
+ - key:
+ name: SubscriptionType
+ version: 0.0.1
+ value:
+ key:
+ name: SubscriptionType
+ version: 0.0.1
+ UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce
+ description: Generated description for concept referred to by
+ key "SubscriptionType:0.0.1"
+ - key:
+ name: UUIDType
+ version: 0.0.1
+ value:
+ key:
+ name: UUIDType
+ version: 0.0.1
+ UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c
+ description: Generated description for concept referred to by
+ key "UUIDType:0.0.1"
+ - key:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ value:
+ key:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d
+ description: Generated description for concept referred to by
+ key "pmsh-operational-policy:0.0.1"
+ policies:
+ key:
+ name: PMControlPolicy_Policies
+ version: 0.0.1
+ policyMap:
+ entry:
+ - key:
+ name: CDSCreateResponsePolicy
+ version: 0.0.1
+ value:
+ policyKey:
+ name: CDSCreateResponsePolicy
+ version: 0.0.1
+ template: Freestyle
+ state:
+ entry:
+ - key: CDSCreateResponseState
+ value:
+ stateKey:
+ parentKeyName: CDSCreateResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CDSCreateResponseState
+ trigger:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: ResponseOutput
+ value:
+ key:
+ parentKeyName: CDSCreateResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSCreateResponseState
+ localName: ResponseOutput
+ outgoingEvent:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference: []
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: CDSCreateResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSCreateResponseState
+ localName: CDSCreateResponsePolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: CDSCreateResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSCreateResponseState
+ localName: ResponseOutput
+ firstState: CDSCreateResponseState
+ - key:
+ name: CDSDeleteResponsePolicy
+ version: 0.0.1
+ value:
+ policyKey:
+ name: CDSDeleteResponsePolicy
+ version: 0.0.1
+ template: Freestyle
+ state:
+ entry:
+ - key: CDSDeleteResponseState
+ value:
+ stateKey:
+ parentKeyName: CDSDeleteResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CDSDeleteResponseState
+ trigger:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: ResponseOutput
+ value:
+ key:
+ parentKeyName: CDSDeleteResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSDeleteResponseState
+ localName: ResponseOutput
+ outgoingEvent:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference: []
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: CDSDeleteResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSDeleteResponseState
+ localName: CDSDeleteResponsePolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: CDSDeleteResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSDeleteResponseState
+ localName: ResponseOutput
+ firstState: CDSDeleteResponseState
+ - key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ value:
+ policyKey:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ template: Freestyle
+ state:
+ entry:
+ - key: CreateOrDeleteState
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CreateOrDeleteState
+ trigger:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: CreateSubscriptionPayload
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: CreateSubscriptionPayload
+ outgoingEvent:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CreateSubscription
+ - key: DeleteSubscriptionPayload
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: DeleteSubscriptionPayload
+ outgoingEvent:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DeleteSubscription
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskSelectionLogic:
+ key: TaskSelectionLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+ var changeType = pmSubscriptionInfo.get("changeType").toString()
+
+ executor.logger.info("Change Type is " + changeType)
+
+ if ("CREATE".equals(changeType)) {
+ executor.logger.info("Choosing to create a subscription")
+ executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask);
+ }
+ else if ("DELETE".equals(changeType)) {
+ executor.logger.info("Choosing to delete a subscription")
+ executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask);
+ }
+
+ //var returnValue = executor.isTrue;
+ true;
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: CreateSubscriptionPayload
+ - key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: DeleteSubscriptionPayload
+ - key: CreateSubscription
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CreateSubscription
+ trigger:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: IssueCreateSubscriptionRequestOutput
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateSubscription
+ localName: IssueCreateSubscriptionRequestOutput
+ outgoingEvent:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateSubscription
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateSubscription
+ localName: IssueCreateSubscriptionRequestOutput
+ - key: DeleteSubscription
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DeleteSubscription
+ trigger:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: IssueDeleteSubscriptionRequestOutput
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DeleteSubscription
+ localName: IssueDeleteSubscriptionRequestOutput
+ outgoingEvent:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DeleteSubscription
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DeleteSubscription
+ localName: IssueDeleteSubscriptionRequestOutput
+ - key: ReceiveSubscriptionState
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: ReceiveSubscriptionState
+ trigger:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: ReceivePMSubscriptionOutput
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: ReceiveSubscriptionState
+ localName: ReceivePMSubscriptionOutput
+ outgoingEvent:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CreateOrDeleteState
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: ReceiveSubscriptionState
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: ReceiveSubscriptionState
+ localName: ReceivePMSubscriptionOutput
+ firstState: ReceiveSubscriptionState
+ tasks:
+ key:
+ name: PMControlPolicy_Tasks
+ version: 0.0.1
+ taskMap:
+ entry:
+ - key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ optional: false
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var commonHeader = executor.inFields.get("commonHeader")
+ var response = executor.inFields.get("payload")
+ var albumID = commonHeader.get("requestId")
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString());
+ var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance();
+
+ responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+ responseStatus.put("nfName", pmSubscriptionInfo.get("nfName"))
+ responseStatus.put("changeType", pmSubscriptionInfo.get("changeType"))
+
+ var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status")
+
+ executor.logger.info("RESPONSE STATUS = " + status)
+
+ if(status == "success") {
+ responseStatus.put("message", "success")
+ } else {
+ responseStatus.put("message", "failed")
+ }
+
+ executor.outFields.put("status", responseStatus)
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ optional: false
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var commonHeader = executor.inFields.get("commonHeader")
+ var response = executor.inFields.get("payload")
+ var albumID = commonHeader.get("requestId")
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString());
+ var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance();
+
+ responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+ responseStatus.put("nfName", pmSubscriptionInfo.get("nfName"))
+ responseStatus.put("changeType", pmSubscriptionInfo.get("changeType"))
+
+ var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status")
+
+ executor.logger.info("RESPONSE STATUS = " + status)
+
+ if(status == "success") {
+ responseStatus.put("message", "success")
+ } else {
+ responseStatus.put("message", "failed")
+ }
+
+ executor.outFields.put("status", responseStatus)
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+ var changeType = pmSubscriptionInfo.get("changeType").toLowerCase()
+
+ var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record");
+
+ payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName"))
+ payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+ payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState"))
+ payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString())
+ payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation"))
+ payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups"))
+
+ var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry");
+ payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties)
+
+ var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance();
+ payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry);
+
+ executor.outFields.put("albumID", executor.inFields.get("albumID"))
+ executor.outFields.put("payload", payload);
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+ var changeType = pmSubscriptionInfo.get("changeType").toLowerCase()
+ var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase()
+ var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase()
+ var payload = executor.inFields.get("payload")
+ var actionName = changeType + "-subscription"
+
+ var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance();
+ commonHeader.put("originatorId", "sdnc");
+ commonHeader.put("requestId", executor.inFields.get("albumID").toString());
+ commonHeader.put("subRequestId", "sub-123456-1000");
+
+ var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance();
+ actionIdentifiers.put("actionName", actionName);
+ actionIdentifiers.put("blueprintName", blueprintName);
+ actionIdentifiers.put("blueprintVersion", blueprintVersion);
+ actionIdentifiers.put("mode", "sync");
+
+ executor.outFields.put("commonHeader", commonHeader);
+ executor.outFields.put("actionIdentifiers", actionIdentifiers);
+ executor.outFields.put("payload", payload);
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+ var changeType = pmSubscriptionInfo.get("changeType").toLowerCase()
+
+ var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record");
+
+ payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName"))
+ payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+ payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState"))
+ payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString())
+ payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation"))
+ payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups"))
+
+ var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry");
+ payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties)
+
+ var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance();
+ payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry);
+
+ executor.outFields.put("albumID", executor.inFields.get("albumID"))
+ executor.outFields.put("payload", payload);
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+ var changeType = pmSubscriptionInfo.get("changeType").toLowerCase()
+ var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase()
+ var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase()
+ var payload = executor.inFields.get("payload")
+ var actionName = changeType + "-subscription"
+
+ var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance();
+ commonHeader.put("originatorId", "sdnc");
+ commonHeader.put("requestId", executor.inFields.get("albumID").toString());
+ commonHeader.put("subRequestId", "sub-123456-1000");
+
+ var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance();
+ actionIdentifiers.put("actionName", actionName);
+ actionIdentifiers.put("blueprintName", blueprintName);
+ actionIdentifiers.put("blueprintVersion", blueprintVersion);
+ actionIdentifiers.put("mode", "sync");
+
+ executor.outFields.put("commonHeader", commonHeader);
+ executor.outFields.put("actionIdentifiers", actionIdentifiers);
+ executor.outFields.put("payload", payload);
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ value:
+ key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: blueprintName
+ value:
+ key: blueprintName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: blueprintVersion
+ value:
+ key: blueprintVersion
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: changeType
+ value:
+ key: changeType
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: closedLoopControlName
+ value:
+ key: closedLoopControlName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: nfName
+ value:
+ key: nfName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: policyName
+ value:
+ key: policyName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: subscription
+ value:
+ key: subscription
+ fieldSchemaKey:
+ name: SubscriptionType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+ var uuidType = java.util.UUID;
+
+ executor.logger.info(executor.subject.id);
+
+ //albumID will be used to fetch info from our album later
+ var albumID = uuidType.randomUUID();
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance();
+ var returnValue = true;
+
+ if(executor.inFields.get("policyName") != null) {
+ executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName"));
+
+ var changeType = executor.inFields.get("changeType")
+ var nfName = executor.inFields.get("nfName")
+ var policyName = executor.inFields.get("policyName")
+ var closedLoopControlName = executor.inFields.get("closedLoopControlName")
+ var subscription = executor.inFields.get("subscription")
+ var blueprintName = executor.inFields.get("blueprintName")
+ var blueprintVersion = executor.inFields.get("blueprintVersion")
+
+ pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName"));
+ pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType"))
+ pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName"))
+ pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName"))
+ pmSubscriptionInfo.put("subscription", subscription)
+ pmSubscriptionInfo.put("blueprintName", blueprintName)
+ pmSubscriptionInfo.put("blueprintVersion", blueprintVersion)
+
+
+ executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo);
+
+ executor.outFields.put("albumID", albumID)
+ } else {
+ executor.message = "Received invalid event"
+ returnValue = false;
+ }
+
+ returnValue;
+ events:
+ key:
+ name: PMControlPolicy_Events
+ version: 0.0.1
+ eventMap:
+ entry:
+ - key:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: CDS
+ target: APEX
+ parameter:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ optional: false
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: CDS
+ target: APEX
+ parameter:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ optional: false
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: DCAE
+ parameter:
+ entry:
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: MRResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: MRResponseEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: DCAE
+ target: APEX
+ parameter:
+ entry:
+ - key: count
+ value:
+ key: count
+ fieldSchemaKey:
+ name: SimpleIntType
+ version: 0.0.1
+ optional: false
+ - key: serverTimeMs
+ value:
+ key: serverTimeMs
+ fieldSchemaKey:
+ name: SimpleIntType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ value:
+ key:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: DCAE
+ target: APEX
+ parameter:
+ entry:
+ - key: blueprintName
+ value:
+ key: blueprintName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: blueprintVersion
+ value:
+ key: blueprintVersion
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: changeType
+ value:
+ key: changeType
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: closedLoopControlName
+ value:
+ key: closedLoopControlName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: nfName
+ value:
+ key: nfName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: policyName
+ value:
+ key: policyName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: subscription
+ value:
+ key: subscription
+ fieldSchemaKey:
+ name: SubscriptionType
+ version: 0.0.1
+ optional: false
+ albums:
+ key:
+ name: PMControlPolicy_Albums
+ version: 0.0.1
+ albums:
+ entry:
+ - key:
+ name: PMSubscriptionAlbum
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionAlbum
+ version: 0.0.1
+ scope: policy
+ isWritable: true
+ itemSchema:
+ name: PMSubscriptionType
+ version: 0.0.1
+ schemas:
+ key:
+ name: PMControlPolicy_Schemas
+ version: 0.0.1
+ schemas:
+ entry:
+ - key:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "ActionIdentifiers_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "actionName",
+ "type": "string"
+ },
+ {
+ "name": "blueprintName",
+ "type": "string"
+ },
+ {
+ "name": "blueprintVersion",
+ "type": "string"
+ },
+ {
+ "name": "mode",
+ "type": "string"
+ }
+ ]
+ }
+ - key:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "name": "CreateResponsePayloadEntry",
+ "type": "record",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "create_DasH_subscription_DasH_response",
+ "type": {
+ "name": "create_DasH_subscription_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "odl_DasH_response",
+ "type": {
+ "name": "odl_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "status",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ - key:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "map",
+ "values": {
+ "type": "record",
+ "name": "CDSRequestPayloadEntry",
+ "fields": [
+ {
+ "name": "create_DasH_subscription_DasH_properties",
+ "type": {
+ "name": "create_DasH_subscription_DasH_properties_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "administrativeState",
+ "type": "string"
+ },
+ {
+ "name": "fileBasedGP",
+ "type": "string"
+ },
+ {
+ "name": "fileLocation",
+ "type": "string"
+ },
+ {
+ "name": "measurementGroups",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementGroups_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementGroup",
+ "type": {
+ "name": "measurementGroup",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementTypes",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementTypes_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementType",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "managedObjectDNsBasic",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "managedObjectDNsBasic_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "DN",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ - key:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "name": "DeleteResponsePayloadEntry",
+ "type": "record",
+ "namespace": "com.acme.avro",
+ "fields": [
+ {
+ "name": "delete_DasH_subscription_DasH_response",
+ "type": {
+ "name": "delete_DasH_subscription_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "odl_DasH_response",
+ "type": {
+ "name": "odl_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "status",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ - key:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "map",
+ "values": {
+ "type": "record",
+ "name": "CDSRequestPayloadEntry",
+ "fields": [
+ {
+ "name": "delete_DasH_subscription_DasH_properties",
+ "type": {
+ "name": "delete_DasH_subscription_DasH_properties_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "administrativeState",
+ "type": "string"
+ },
+ {
+ "name": "fileBasedGP",
+ "type": "string"
+ },
+ {
+ "name": "fileLocation",
+ "type": "string"
+ },
+ {
+ "name": "measurementGroups",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementGroups_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementGroup",
+ "type": {
+ "name": "measurementGroup",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementTypes",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementTypes_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementType",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "managedObjectDNsBasic",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "managedObjectDNsBasic_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "DN",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ - key:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "RequestCommonHeader_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "originatorId",
+ "type": "string"
+ },
+ {
+ "name": "requestId",
+ "type": "string"
+ },
+ {
+ "name": "subRequestId",
+ "type": "string"
+ }
+ ]
+ }
+ - key:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "ResponseCommonHeader_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "originatorId",
+ "type": "string"
+ },
+ {
+ "name": "requestId",
+ "type": "string"
+ },
+ {
+ "name": "subRequestId",
+ "type": "string"
+ },
+ {
+ "name": "timestamp",
+ "type": "string"
+ },
+ {
+ "name": "flags",
+ "type": ["null", "string"]
+ }
+ ]
+ }
+ - key:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "ResponseStatus_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "code",
+ "type": "int"
+ },
+ {
+ "name": "eventType",
+ "type": "string"
+ },
+ {
+ "name": "timestamp",
+ "type": "string"
+ },
+ {
+ "name": "message",
+ "type": "string"
+ }
+ ]
+ }
+ - key:
+ name: PMSubscriptionType
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\":
+ \"record\",\n\t\"namespace\": \"org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\":
+ [\n {\n \"name\": \"nfName\",\n \"type\":
+ \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"type\":
+ \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\":
+ \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\":
+ \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": \"blueprintName\",\n\t\t
+ \ \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\":
+ \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\":
+ \"subscription\",\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\":
+ \"record\",\n\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\":
+ \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\":
+ \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\":
+ \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\":
+ \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\":
+ \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\"type\":
+ \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\":
+ \"Measurement_Groups_Type\",\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\":
+ [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\":
+ {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\t\t\t\"type\":
+ \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\":
+ \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\":
+ \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\":
+ \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\":
+ \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\":
+ \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\":
+ \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\":
+ \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\":
+ {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\":
+ {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\":
+ \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\":
+ \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t]\n}"
+ - key:
+ name: SimpleIntType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleIntType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.lang.Integer
+ - key:
+ name: SimpleStringType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleStringType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.lang.String
+ - key:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ value:
+ key:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "ActivateSubscriptionStatus_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "changeType",
+ "type": "string"
+ },
+ {
+ "name": "message",
+ "type": "string"
+ }
+ ]
+ }
+ - key:
+ name: SubscriptionType
+ version: 0.0.1
+ value:
+ key:
+ name: SubscriptionType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\":
+ \"record\",\n\t\"fields\": [{\n\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\"type\":
+ \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\",\n\t\t\t\"type\":
+ \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\":
+ \"int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\":
+ \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\":
+ {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": {\n\t\t\t\t\t\"name\":
+ \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\"fields\":
+ [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\":
+ {\n\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\":
+ \"record\",\n\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\":
+ \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\":
+ \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\":
+ \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\":
+ \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\":
+ \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\":
+ \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\":
+ \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\":
+ \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\":
+ \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\":
+ \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}"
+ - key:
+ name: UUIDType
+ version: 0.0.1
+ value:
+ key:
+ name: UUIDType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.util.UUID
+ engineParameters:
+ executorParameters:
+ JAVASCRIPT:
+ parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters
+ contextParameters:
+ parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters
+ schemaParameters:
+ Avro:
+ parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters
+ Java:
+ parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters
+ jsonAdapters:
+ Instant:
+ adaptedClass: java.time.Instant
+ adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter
+ eventInputParameters:
+ DCAEConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTCLIENT
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters
+ parameters:
+ consumerPollTime: '50'
+ url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1
+ eventProtocolParameters:
+ eventProtocol: JSON
+ parameters:
+ nameAlias: policyName
+ eventName: pmsh-operational-policy
+ eventNameFilter: pmsh-operational-policy
+ CDSRequestConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ parameters:
+ url: http://10.10.10.184:30254/api/v1/execution-service/process
+ httpMethod: POST
+ restRequestTimeout: 2000
+ httpHeaders:
+ - - Authorization
+ - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventName: CDSCreateResponseEvent
+ eventNameFilter: CDSCreateResponseEvent
+ requestorMode: true
+ requestorPeer: CDSRequestProducer
+ requestorTimeout: 500
+ CDSDeleteRequestConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ parameters:
+ url: http://10.10.10.184:30254/api/v1/execution-service/process
+ httpMethod: POST
+ restRequestTimeout: 2000
+ httpHeaders:
+ - - Authorization
+ - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventName: CDSDeleteResponseEvent
+ eventNameFilter: CDSDeleteResponseEvent
+ requestorMode: true
+ requestorPeer: CDSDeleteRequestProducer
+ requestorTimeout: 500
+ CDSReplyConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ parameters:
+ url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT
+ httpMethod: POST
+ restRequestTimeout: 2000
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventName: MRResponseEvent
+ eventNameFilter: MRResponseEvent
+ requestorMode: true
+ requestorPeer: CDSReplyProducer
+ requestorTimeout: 500
+ eventOutputParameters:
+ logOutputter:
+ carrierTechnologyParameters:
+ carrierTechnology: FILE
+ parameters:
+ fileName: "/tmp/outputevents.log"
+ eventProtocolParameters:
+ eventProtocol: JSON
+ StdOutOutputter:
+ carrierTechnologyParameters:
+ carrierTechnology: FILE
+ parameters:
+ standardIo: true
+ eventProtocolParameters:
+ eventProtocol: JSON
+ CDSRequestProducer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventNameFilter: CDSCreateSubscriptionRequestEvent
+ requestorMode: true
+ requestorPeer: CDSRequestConsumer
+ requestorTimeout: 500
+ CDSDeleteRequestProducer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventNameFilter: CDSDeleteSubscriptionRequestEvent
+ requestorMode: true
+ requestorPeer: CDSDeleteRequestConsumer
+ requestorTimeout: 500
+ CDSReplyProducer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventNameFilter: CDSResponseStatusEvent
+ requestorMode: true
+ requestorPeer: CDSReplyConsumer
+ requestorTimeout: 500
diff --git a/common/src/main/resources/examples/controlloop/PMSubscriptionHandling.yaml b/common/src/main/resources/examples/controlloop/PMSubscriptionHandling.yaml
new file mode 100644
index 000000000..f9f97420a
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSubscriptionHandling.yaml
@@ -0,0 +1,3314 @@
+# ============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=========================================================
+tosca_definitions_version: tosca_simple_yaml_1_3
+data_types:
+ onap.datatypes.ToscaConceptIdentifier:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ required: true
+ version:
+ type: string
+ required: true
+ org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo:
+ name: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ properties:
+ consulUrl:
+ name: consulUrl
+ type: string
+ typeVersion: 0.0.0
+ description: Consul url for this entry
+ required: true
+ consul_body:
+ name: consulBody
+ type: string
+ typeVersion: 0.0.0
+ description: Body of Consul entry
+ required: true
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ constraints: []
+ properties:
+ DN:
+ name: DN
+ type: string
+ typeVersion: 0.0.0
+ description: Managed object distinguished name
+ required: true
+ constraints: []
+ metadata: {}
+ name: onap.datatypes.monitoring.managedObjectDNsBasic
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ onap.datatypes.monitoring.managedObjectDNsBasics:
+ constraints: []
+ properties:
+ managedObjectDNsBasic:
+ name: managedObjectDNsBasic
+ type: map
+ typeVersion: 0.0.0
+ description: Managed object distinguished name object
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.managedObjectDNsBasic
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ name: onap.datatypes.monitoring.managedObjectDNsBasics
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ onap.datatypes.monitoring.measurementGroup:
+ constraints: []
+ properties:
+ measurementTypes:
+ name: measurementTypes
+ type: list
+ typeVersion: 0.0.0
+ description: List of measurement types
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementTypes
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ managedObjectDNsBasic:
+ name: managedObjectDNsBasic
+ type: list
+ typeVersion: 0.0.0
+ description: List of managed object distinguished names
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.managedObjectDNsBasics
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ name: onap.datatypes.monitoring.measurementGroup
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ onap.datatypes.monitoring.measurementGroups:
+ constraints: []
+ properties:
+ measurementGroup:
+ name: measurementGroup
+ type: map
+ typeVersion: 0.0.0
+ description: Measurement Group
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementGroup
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ name: onap.datatypes.monitoring.measurementGroups
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ onap.datatypes.monitoring.measurementType:
+ constraints: []
+ properties:
+ measurementType:
+ name: measurementType
+ type: string
+ typeVersion: 0.0.0
+ description: Measurement type
+ required: true
+ constraints: []
+ metadata: {}
+ name: onap.datatypes.monitoring.measurementType
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ onap.datatypes.monitoring.measurementTypes:
+ constraints: []
+ properties:
+ measurementType:
+ name: measurementType
+ type: map
+ typeVersion: 0.0.0
+ description: Measurement type object
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementType
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ name: onap.datatypes.monitoring.measurementTypes
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ onap.datatypes.monitoring.nfFilter:
+ constraints: []
+ properties:
+ modelNames:
+ name: modelNames
+ type: list
+ typeVersion: 0.0.0
+ description: List of model names
+ required: true
+ constraints: []
+ entry_schema:
+ type: string
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ modelInvariantIDs:
+ name: modelInvariantIDs
+ type: list
+ typeVersion: 0.0.0
+ description: List of model invariant IDs
+ required: true
+ constraints: []
+ entry_schema:
+ type: string
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ modelVersionIDs:
+ name: modelVersionIDs
+ type: list
+ typeVersion: 0.0.0
+ description: List of model version IDs
+ required: true
+ constraints: []
+ entry_schema:
+ type: string
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ nfNames:
+ name: nfNames
+ type: list
+ typeVersion: 0.0.0
+ description: List of network functions
+ required: true
+ constraints: []
+ entry_schema:
+ type: string
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ name: onap.datatypes.monitoring.nfFilter
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+ onap.datatypes.monitoring.subscription:
+ constraints: []
+ properties:
+ measurementGroups:
+ name: measurementGroups
+ type: list
+ typeVersion: 0.0.0
+ description: Measurement Groups
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementGroups
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ fileBasedGP:
+ name: fileBasedGP
+ type: integer
+ typeVersion: 0.0.0
+ description: File based granularity period
+ required: true
+ constraints: []
+ metadata: {}
+ fileLocation:
+ name: fileLocation
+ type: string
+ typeVersion: 0.0.0
+ description: ROP file location
+ required: true
+ constraints: []
+ metadata: {}
+ subscriptionName:
+ name: subscriptionName
+ type: string
+ typeVersion: 0.0.0
+ description: Name of the subscription
+ required: true
+ constraints: []
+ metadata: {}
+ administrativeState:
+ name: administrativeState
+ type: string
+ typeVersion: 0.0.0
+ description: State of the subscription
+ required: true
+ constraints:
+ - valid_values:
+ - LOCKED
+ - UNLOCKED
+ metadata: {}
+ nfFilter:
+ name: nfFilter
+ type: map
+ typeVersion: 0.0.0
+ description: Network function filter
+ required: true
+ constraints: []
+ entry_schema:
+ type: onap.datatypes.monitoring.nfFilter
+ typeVersion: 0.0.0
+ constraints: []
+ metadata: {}
+ name: onap.datatypes.monitoring.subscription
+ version: 0.0.0
+ derived_from: tosca.datatypes.Root
+ metadata: {}
+policy_types:
+ onap.policies.Monitoring:
+ derived_from: tosca.policies.Root
+ description: a base policy type for all policies that govern monitoring provisioning
+ version: 1.0.0
+ name: onap.policies.Monitoring
+ onap.policies.monitoring.dcae-pm-subscription-handler:
+ properties:
+ pmsh_policy:
+ name: pmsh_policy
+ type: onap.datatypes.monitoring.subscription
+ typeVersion: 0.0.0
+ description: PMSH Policy JSON
+ required: false
+ constraints: []
+ metadata: {}
+ name: onap.policies.monitoring.dcae-pm-subscription-handler
+ version: 1.0.0
+ derived_from: onap.policies.Monitoring
+ metadata: {}
+node_types:
+ org.onap.policy.clamp.controlloop.Participant:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ org.onap.policy.clamp.controlloop.ControlLoopElement:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ participant_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.ControlLoop:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ elements:
+ type: list
+ required: true
+ entry_schema:
+ type: onap.datatypes.ToscaConceptIdentifier
+ org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ dcae_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: false
+ dcae_blueprint:
+ type: onap.dcae.cloudify_blueprint
+ requred: false
+ consul_info:
+ type: list
+ required: false
+ entry_schema:
+ type: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo
+ org.onap.policy.clamp.controlloop.PolicyControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ policy_type_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ policy_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: false
+ org.onap.policy.clamp.controlloop.CDSControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ cds_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+topology_template:
+ inputs:
+ pmsh_monitoring_policy:
+ type: onap.datatypes.ToscaConceptIdentifier
+ description: The ID of the PMSH monitoring policy to use
+ default:
+ name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test
+ version: 1.0.0
+ pmsh_operational_policy:
+ type: onap.datatypes.ToscaConceptIdentifier
+ description: The ID of the PMSH operational policy to use
+ default:
+ name: operational.apex.pmcontrol
+ version: 1.0.0
+ node_templates:
+ org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant:
+ version: 2.3.4
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.policy.controlloop.PolicyControlLoopParticipant:
+ version: 2.3.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant:
+ version: 2.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.domain.pmsh.PMSH_DCAEMicroservice:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ dcae_blueprint:
+ tosca_definitions_version: cloudify_dsl_1_3
+ imports:
+ - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml
+ - plugin:k8splugin?version=3.7.0
+ - plugin:pgaas?version=1.3.0
+ - plugin:clamppolicyplugin?version=1.1.0
+ inputs:
+ tag_version:
+ type: string
+ description: Docker image to be used
+ default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2
+ replicas:
+ type: integer
+ description: Number of instances
+ default: 1
+ operational_policy_name:
+ type: string
+ default: operational.apex.pmcontrol
+ control_loop_name:
+ type: string
+ default: pmsh-control-loop
+ pmsh_publish_topic_name:
+ type: string
+ default: unauthenticated.DCAE_CL_OUTPUT
+ policy_feedback_topic_name:
+ type: string
+ default: unauthenticated.PMSH_CL_INPUT
+ aai_notification_topic_name:
+ type: string
+ default: AAI-EVENT
+ publisher_client_role:
+ type: string
+ description: Client role to request secure access to topic
+ default: org.onap.dcae.pmPublisher
+ subscriber_client_role:
+ type: string
+ description: Client role to request secure access to topic
+ default: org.onap.dcae.pmSubscriber
+ dcae_location:
+ type: string
+ description: DCAE location for the subscriber, used to set up routing
+ default: san-francisco
+ cpu_limit:
+ type: string
+ default: 1000m
+ cpu_request:
+ type: string
+ default: 1000m
+ memory_limit:
+ type: string
+ default: 1024Mi
+ memory_request:
+ type: string
+ default: 1024Mi
+ pgaas_cluster_name:
+ type: string
+ default: dcae-pg-primary.onap
+ enable_tls:
+ type: boolean
+ default: true
+ protocol:
+ type: string
+ description: PMSH protocol. If enable_tls is false, set to http
+ default: https
+ policy_model_id:
+ type: string
+ default: onap.policies.monitoring.dcae-pm-subscription-handler
+ policy_id:
+ type: string
+ default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test
+ node_templates:
+ pgaasvm:
+ type: dcae.nodes.pgaas.database
+ properties:
+ writerfqdn:
+ get_input: pgaas_cluster_name
+ name: pmsh
+ pmsh:
+ type: dcae.nodes.ContainerizedServiceComponentUsingDmaap
+ interfaces:
+ cloudify.interfaces.lifecycle:
+ create:
+ inputs:
+ ports:
+ - '8443:0'
+ envs:
+ PMSH_PG_URL:
+ get_attribute:
+ - pgaasvm
+ - admin
+ - host
+ PMSH_PG_PASSWORD:
+ get_attribute:
+ - pgaasvm
+ - admin
+ - password
+ PMSH_PG_USERNAME:
+ get_attribute:
+ - pgaasvm
+ - admin
+ - user
+ PMSH_DB_NAME:
+ get_attribute:
+ - pgaasvm
+ - admin
+ - database
+ relationships:
+ - target: pmsh-policy
+ type: cloudify.relationships.depends_on
+ properties:
+ service_component_type: dcae-pmsh
+ service_component_name_override: dcae-pmsh
+ application_config:
+ enable_tls:
+ get_input: enable_tls
+ aaf_identity: dcae@dcae.onap.org
+ aaf_password: demo123456!
+ operational_policy_name:
+ get_input: operational_policy_name
+ control_loop_name:
+ get_input: control_loop_name
+ cert_path: /opt/app/pmsh/etc/certs/cert.pem
+ key_path: /opt/app/pmsh/etc/certs/key.pem
+ ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem
+ streams_publishes:
+ policy_pm_publisher:
+ type: message_router
+ dmaap_info:
+ topic_url:
+ concat:
+ - http://message-router:3904/events/
+ - get_input: pmsh_publish_topic_name
+ streams_subscribes:
+ policy_pm_subscriber:
+ type: message_router
+ dmaap_info:
+ topic_url:
+ concat:
+ - http://message-router:3904/events/
+ - get_input: policy_feedback_topic_name
+ aai_subscriber:
+ type: message_router
+ dmaap_info:
+ topic_url:
+ concat:
+ - http://message-router:3904/events/
+ - get_input: aai_notification_topic_name
+ resource_config:
+ limits:
+ cpu:
+ get_input: cpu_limit
+ memory:
+ get_input: memory_limit
+ requests:
+ cpu:
+ get_input: cpu_request
+ memory:
+ get_input: memory_request
+ docker_config:
+ healthcheck:
+ endpoint: /healthcheck
+ interval: 15s
+ timeout: 1s
+ type:
+ get_input: protocol
+ image:
+ get_input: tag_version
+ replicas:
+ get_input: replicas
+ log_info:
+ log_directory: /var/log/ONAP/dcaegen2/services/pmsh
+ tls_info:
+ cert_directory: /opt/app/pmsh/etc/certs
+ use_tls:
+ get_input: enable_tls
+ pmsh-policy:
+ type: clamp.nodes.policy
+ properties:
+ policy_model_id:
+ get_input: policy_model_id
+ policy_id:
+ get_input: policy_id
+ consul_info:
+ - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy
+ consulBody:
+ subscription:
+ subscriptionName: subscriptiona
+ administrativeState: UNLOCKED
+ fileBasedGP: 15
+ fileLocation: /pm/pm.xml
+ nfFilter:
+ nfNames:
+ - ^pnf1.*
+ modelInvariantIDs:
+ - 5845y423-g654-6fju-po78-8n53154532k6
+ - 7129e420-d396-4efb-af02-6b83499b12f8
+ modelVersionIDs:
+ - e80a6ae3-cafd-4d24-850d-e14c084a5ca9
+ measurementGroups:
+ - measurementGroup:
+ measurementTypes:
+ - measurementType: countera
+ - measurementType: counterb
+ managedObjectDNsBasic:
+ - DN: dna
+ - DN: dnb
+ - measurementGroup:
+ measurementTypes:
+ - measurementType: counterc
+ - measurementType: counterd
+ managedObjectDNsBasic:
+ - DN: dnc
+ - DN: dnd
+ org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.3.1
+ policy_type_id:
+ name: onap.policies.monitoring.pm-subscription-handler
+ version: 1.0.0
+ policy_id:
+ get_input: pmsh_monitoring_policy
+ org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ policy_id:
+ get_input: pmsh_operational_policy
+ org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.CDSControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for CDS for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_Id:
+ name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
+ version: 3.2.1
+ cds_blueprint_id:
+ name: org.onap.ccsdk.cds.PMSHCdsBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSHControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ elements:
+ - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement
+ version: 1.2.3
+ policies:
+ - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test:
+ type: onap.policies.monitoring.dcae-pm-subscription-handler
+ type_version: 1.0.0
+ name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test
+ version: 1.0.0
+ metadata:
+ policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test
+ policy-version: 1.0.0
+ properties:
+ pmsh_policy:
+ fileBasedGP: 15
+ fileLocation: /pm/pm.xml
+ subscriptionName: subscriptiona
+ administrativeState: UNLOCKED
+ nfFilter:
+ onap.datatypes.monitoring.nfFilter:
+ modelVersionIDs:
+ - e80a6ae3-cafd-4d24-850d-e14c084a5ca9
+ modelInvariantIDs:
+ - 5845y423-g654-6fju-po78-8n53154532k6
+ - 7129e420-d396-4efb-af02-6b83499b12f8
+ modelNames: []
+ nfNames:
+ - '"^pnf1.*"'
+ measurementGroups:
+ - measurementGroup:
+ onap.datatypes.monitoring.measurementGroup:
+ measurementTypes:
+ - measurementType:
+ onap.datatypes.monitoring.measurementType:
+ measurementType: countera
+ - measurementType:
+ onap.datatypes.monitoring.measurementType:
+ measurementType: counterb
+ managedObjectDNsBasic:
+ - managedObjectDNsBasic:
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ DN: dna
+ - managedObjectDNsBasic:
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ DN: dnb
+ - measurementGroup:
+ onap.datatypes.monitoring.measurementGroup:
+ measurementTypes:
+ - measurementType:
+ onap.datatypes.monitoring.measurementType:
+ measurementType: counterc
+ - measurementType:
+ onap.datatypes.monitoring.measurementType:
+ measurementType: counterd
+ managedObjectDNsBasic:
+ - managedObjectDNsBasic:
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ DN: dnc
+ - managedObjectDNsBasic:
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ DN: dnd
+ - operational.apex.pmcontrol:
+ type: onap.policies.controlloop.operational.common.Apex
+ type_version: 1.0.0
+ version: 1.0.0
+ metadata:
+ policy-id: operational.apex.pmcontrol
+ policy-version: 1
+ properties:
+ engineServiceParameters:
+ name: MyApexEngine
+ version: 0.0.1
+ id: 45
+ instanceCount: 2
+ deploymentPort: 12561
+ policy_type_impl:
+ apexPolicyModel:
+ key:
+ name: PMControlPolicy
+ version: 0.0.1
+ keyInformation:
+ key:
+ name: PMControlPolicy_KeyInfo
+ version: 0.0.1
+ keyInfoMap:
+ entry:
+ - key:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82
+ description: Generated description for concept referred to by key "CDSActionIdentifiersType:0.0.1"
+ - key:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad
+ description: Generated description for concept referred to by key "CDSCreateResponseEvent:0.0.1"
+ - key:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13
+ description: Generated description for concept referred to by key "CDSCreateResponsePayloadType:0.0.1"
+ - key:
+ name: CDSCreateResponsePolicy
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponsePolicy
+ version: 0.0.1
+ UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c
+ description: Generated description for concept referred to by key "CDSCreateResponsePolicy:0.0.1"
+ - key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2
+ description: Generated description for concept referred to by key "CDSCreateResponseTask:0.0.1"
+ - key:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60
+ description: Generated description for concept referred to by key "CDSCreateSubscriptionPayloadType:0.0.1"
+ - key:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2
+ description: Generated description for concept referred to by key "CDSCreateSubscriptionRequestEvent:0.0.1"
+ - key:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8
+ description: Generated description for concept referred to by key "CDSDeleteResponseEvent:0.0.1"
+ - key:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0
+ description: Generated description for concept referred to by key "CDSDeleteResponsePayloadType:0.0.1"
+ - key:
+ name: CDSDeleteResponsePolicy
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponsePolicy
+ version: 0.0.1
+ UUID: a780251c-edd5-3132-b865-04313246b43c
+ description: Generated description for concept referred to by key "CDSDeleteResponsePolicy:0.0.1"
+ - key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc
+ description: Generated description for concept referred to by key "CDSDeleteResponseTask:0.0.1"
+ - key:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b
+ description: Generated description for concept referred to by key "CDSDeleteSubscriptionPayloadType:0.0.1"
+ - key:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9
+ description: Generated description for concept referred to by key "CDSDeleteSubscriptionRequestEvent:0.0.1"
+ - key:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1
+ description: Generated description for concept referred to by key "CDSRequestCommonHeaderType:0.0.1"
+ - key:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c
+ description: Generated description for concept referred to by key "CDSResponseCommonHeaderType:0.0.1"
+ - key:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ UUID: 7986e21b-32f7-302e-9554-31f21b673493
+ description: Generated description for concept referred to by key "CDSResponseStatusEvent:0.0.1"
+ - key:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa
+ description: Generated description for concept referred to by key "CDSResponseStatusType:0.0.1"
+ - key:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a
+ description: Generated description for concept referred to by key "CreateSubscriptionPayloadEvent:0.0.1"
+ - key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d
+ description: Generated description for concept referred to by key "CreateSubscriptionPayloadTask:0.0.1"
+ - key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869
+ description: Generated description for concept referred to by key "CreateSubscriptionRequestTask:0.0.1"
+ - key:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074
+ description: Generated description for concept referred to by key "DeleteSubscriptionPayloadEvent:0.0.1"
+ - key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ UUID: 0f519117-5fea-3e4b-941f-8f778100465f
+ description: Generated description for concept referred to by key "DeleteSubscriptionPayloadTask:0.0.1"
+ - key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ UUID: acb772fe-d442-39e3-98f9-b1080caf4150
+ description: Generated description for concept referred to by key "DeleteSubscriptionRequestTask:0.0.1"
+ - key:
+ name: MRResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: MRResponseEvent
+ version: 0.0.1
+ UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194
+ description: Generated description for concept referred to by key "MRResponseEvent:0.0.1"
+ - key:
+ name: PMControlPolicy
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy
+ version: 0.0.1
+ UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4
+ description: Generated description for concept referred to by key "PMControlPolicy:0.0.1"
+ - key:
+ name: PMControlPolicy_Albums
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Albums
+ version: 0.0.1
+ UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b
+ description: Generated description for concept referred to by key "PMControlPolicy_Albums:0.0.1"
+ - key:
+ name: PMControlPolicy_Events
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Events
+ version: 0.0.1
+ UUID: be3871a0-c42a-3113-a066-82d192840eca
+ description: Generated description for concept referred to by key "PMControlPolicy_Events:0.0.1"
+ - key:
+ name: PMControlPolicy_KeyInfo
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_KeyInfo
+ version: 0.0.1
+ UUID: ced37634-28a4-3178-b7f6-2980794927b0
+ description: Generated description for concept referred to by key "PMControlPolicy_KeyInfo:0.0.1"
+ - key:
+ name: PMControlPolicy_Policies
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Policies
+ version: 0.0.1
+ UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed
+ description: Generated description for concept referred to by key "PMControlPolicy_Policies:0.0.1"
+ - key:
+ name: PMControlPolicy_Schemas
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Schemas
+ version: 0.0.1
+ UUID: e61973f1-189c-39e5-82f6-0d3afe298a20
+ description: Generated description for concept referred to by key "PMControlPolicy_Schemas:0.0.1"
+ - key:
+ name: PMControlPolicy_Tasks
+ version: 0.0.1
+ value:
+ key:
+ name: PMControlPolicy_Tasks
+ version: 0.0.1
+ UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a
+ description: Generated description for concept referred to by key "PMControlPolicy_Tasks:0.0.1"
+ - key:
+ name: PMSubscriptionAlbum
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionAlbum
+ version: 0.0.1
+ UUID: c2bd6f0d-6854-317a-9be2-97c08338428c
+ description: Generated description for concept referred to by key "PMSubscriptionAlbum:0.0.1"
+ - key:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05
+ description: Generated description for concept referred to by key "PMSubscriptionOutputEvent:0.0.1"
+ - key:
+ name: PMSubscriptionType
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionType
+ version: 0.0.1
+ UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae
+ description: Generated description for concept referred to by key "PMSubscriptionType:0.0.1"
+ - key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ value:
+ key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1
+ description: Generated description for concept referred to by key "ReceiveEventPolicy:0.0.1"
+ - key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ value:
+ key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ UUID: f596afc8-100c-35eb-92c8-352355ea457d
+ description: Generated description for concept referred to by key "ReceiveSubscriptionTask:0.0.1"
+ - key:
+ name: SimpleIntType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleIntType
+ version: 0.0.1
+ UUID: 153791fd-ae0a-36a7-88a5-309a7936415d
+ description: Generated description for concept referred to by key "SimpleIntType:0.0.1"
+ - key:
+ name: SimpleStringType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleStringType
+ version: 0.0.1
+ UUID: 8a4957cf-9493-3a76-8c22-a208e23259af
+ description: Generated description for concept referred to by key "SimpleStringType:0.0.1"
+ - key:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ value:
+ key:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b
+ description: Generated description for concept referred to by key "SubscriptionStatusType:0.0.1"
+ - key:
+ name: SubscriptionType
+ version: 0.0.1
+ value:
+ key:
+ name: SubscriptionType
+ version: 0.0.1
+ UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce
+ description: Generated description for concept referred to by key "SubscriptionType:0.0.1"
+ - key:
+ name: UUIDType
+ version: 0.0.1
+ value:
+ key:
+ name: UUIDType
+ version: 0.0.1
+ UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c
+ description: Generated description for concept referred to by key "UUIDType:0.0.1"
+ - key:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ value:
+ key:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d
+ description: Generated description for concept referred to by key "pmsh-operational-policy:0.0.1"
+ policies:
+ key:
+ name: PMControlPolicy_Policies
+ version: 0.0.1
+ policyMap:
+ entry:
+ - key:
+ name: CDSCreateResponsePolicy
+ version: 0.0.1
+ value:
+ policyKey:
+ name: CDSCreateResponsePolicy
+ version: 0.0.1
+ template: Freestyle
+ state:
+ entry:
+ - key: CDSCreateResponseState
+ value:
+ stateKey:
+ parentKeyName: CDSCreateResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CDSCreateResponseState
+ trigger:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: ResponseOutput
+ value:
+ key:
+ parentKeyName: CDSCreateResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSCreateResponseState
+ localName: ResponseOutput
+ outgoingEvent:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference: []
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: CDSCreateResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSCreateResponseState
+ localName: CDSCreateResponsePolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: CDSCreateResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSCreateResponseState
+ localName: ResponseOutput
+ firstState: CDSCreateResponseState
+ - key:
+ name: CDSDeleteResponsePolicy
+ version: 0.0.1
+ value:
+ policyKey:
+ name: CDSDeleteResponsePolicy
+ version: 0.0.1
+ template: Freestyle
+ state:
+ entry:
+ - key: CDSDeleteResponseState
+ value:
+ stateKey:
+ parentKeyName: CDSDeleteResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CDSDeleteResponseState
+ trigger:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: ResponseOutput
+ value:
+ key:
+ parentKeyName: CDSDeleteResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSDeleteResponseState
+ localName: ResponseOutput
+ outgoingEvent:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference: []
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: CDSDeleteResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSDeleteResponseState
+ localName: CDSDeleteResponsePolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: CDSDeleteResponsePolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CDSDeleteResponseState
+ localName: ResponseOutput
+ firstState: CDSDeleteResponseState
+ - key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ value:
+ policyKey:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ template: Freestyle
+ state:
+ entry:
+ - key: CreateOrDeleteState
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CreateOrDeleteState
+ trigger:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: CreateSubscriptionPayload
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: CreateSubscriptionPayload
+ outgoingEvent:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CreateSubscription
+ - key: DeleteSubscriptionPayload
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: DeleteSubscriptionPayload
+ outgoingEvent:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DeleteSubscription
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskSelectionLogic:
+ key: TaskSelectionLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+ var changeType = pmSubscriptionInfo.get("changeType").toString()
+
+ executor.logger.info("Change Type is " + changeType)
+
+ if ("CREATE".equals(changeType)) {
+ executor.logger.info("Choosing to create a subscription")
+ executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask);
+ }
+ else if ("DELETE".equals(changeType)) {
+ executor.logger.info("Choosing to delete a subscription")
+ executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask);
+ }
+
+ //var returnValue = executor.isTrue;
+ true;
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: CreateSubscriptionPayload
+ - key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateOrDeleteState
+ localName: DeleteSubscriptionPayload
+ - key: CreateSubscription
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CreateSubscription
+ trigger:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: IssueCreateSubscriptionRequestOutput
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateSubscription
+ localName: IssueCreateSubscriptionRequestOutput
+ outgoingEvent:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateSubscription
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: CreateSubscription
+ localName: IssueCreateSubscriptionRequestOutput
+ - key: DeleteSubscription
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DeleteSubscription
+ trigger:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: IssueDeleteSubscriptionRequestOutput
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DeleteSubscription
+ localName: IssueDeleteSubscriptionRequestOutput
+ outgoingEvent:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DeleteSubscription
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DeleteSubscription
+ localName: IssueDeleteSubscriptionRequestOutput
+ - key: ReceiveSubscriptionState
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: ReceiveSubscriptionState
+ trigger:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: ReceivePMSubscriptionOutput
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: ReceiveSubscriptionState
+ localName: ReceivePMSubscriptionOutput
+ outgoingEvent:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: CreateOrDeleteState
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskSelectionLogic:
+ key: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: ReceiveSubscriptionState
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: ReceiveSubscriptionState
+ localName: ReceivePMSubscriptionOutput
+ firstState: ReceiveSubscriptionState
+ tasks:
+ key:
+ name: PMControlPolicy_Tasks
+ version: 0.0.1
+ taskMap:
+ entry:
+ - key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponseTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ optional: false
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var commonHeader = executor.inFields.get("commonHeader")
+ var response = executor.inFields.get("payload")
+ var albumID = commonHeader.get("requestId")
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString());
+ var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance();
+
+ responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+ responseStatus.put("nfName", pmSubscriptionInfo.get("nfName"))
+ responseStatus.put("changeType", pmSubscriptionInfo.get("changeType"))
+
+ var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status")
+
+ executor.logger.info("RESPONSE STATUS = " + status)
+
+ if(status == "success") {
+ responseStatus.put("message", "success")
+ } else {
+ responseStatus.put("message", "failed")
+ }
+
+ executor.outFields.put("status", responseStatus)
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponseTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ optional: false
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var commonHeader = executor.inFields.get("commonHeader")
+ var response = executor.inFields.get("payload")
+ var albumID = commonHeader.get("requestId")
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString());
+ var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance();
+
+ responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+ responseStatus.put("nfName", pmSubscriptionInfo.get("nfName"))
+ responseStatus.put("changeType", pmSubscriptionInfo.get("changeType"))
+
+ var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status")
+
+ executor.logger.info("RESPONSE STATUS = " + status)
+
+ if(status == "success") {
+ responseStatus.put("message", "success")
+ } else {
+ responseStatus.put("message", "failed")
+ }
+
+ executor.outFields.put("status", responseStatus)
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionPayloadTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+ var changeType = pmSubscriptionInfo.get("changeType").toLowerCase()
+
+ var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record");
+
+ payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName"))
+ payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+ payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState"))
+ payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString())
+ payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation"))
+ payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups"))
+
+ var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry");
+ payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties)
+
+ var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance();
+ payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry);
+
+ executor.outFields.put("albumID", executor.inFields.get("albumID"))
+ executor.outFields.put("payload", payload);
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionRequestTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+ var changeType = pmSubscriptionInfo.get("changeType").toLowerCase()
+ var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase()
+ var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase()
+ var payload = executor.inFields.get("payload")
+ var actionName = changeType + "-subscription"
+
+ var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance();
+ commonHeader.put("originatorId", "sdnc");
+ commonHeader.put("requestId", executor.inFields.get("albumID").toString());
+ commonHeader.put("subRequestId", "sub-123456-1000");
+
+ var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance();
+ actionIdentifiers.put("actionName", actionName);
+ actionIdentifiers.put("blueprintName", blueprintName);
+ actionIdentifiers.put("blueprintVersion", blueprintVersion);
+ actionIdentifiers.put("mode", "sync");
+
+ executor.outFields.put("commonHeader", commonHeader);
+ executor.outFields.put("actionIdentifiers", actionIdentifiers);
+ executor.outFields.put("payload", payload);
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionPayloadTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+ var changeType = pmSubscriptionInfo.get("changeType").toLowerCase()
+
+ var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record");
+
+ payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName"))
+ payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+ payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState"))
+ payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString())
+ payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation"))
+ payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups"))
+
+ var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry");
+ payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties)
+
+ var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance();
+ payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry);
+
+ executor.outFields.put("albumID", executor.inFields.get("albumID"))
+ executor.outFields.put("payload", payload);
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionRequestTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+ executor.logger.info(executor.subject.id);
+
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+ var changeType = pmSubscriptionInfo.get("changeType").toLowerCase()
+ var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase()
+ var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase()
+ var payload = executor.inFields.get("payload")
+ var actionName = changeType + "-subscription"
+
+ var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance();
+ commonHeader.put("originatorId", "sdnc");
+ commonHeader.put("requestId", executor.inFields.get("albumID").toString());
+ commonHeader.put("subRequestId", "sub-123456-1000");
+
+ var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance();
+ actionIdentifiers.put("actionName", actionName);
+ actionIdentifiers.put("blueprintName", blueprintName);
+ actionIdentifiers.put("blueprintVersion", blueprintVersion);
+ actionIdentifiers.put("mode", "sync");
+
+ executor.outFields.put("commonHeader", commonHeader);
+ executor.outFields.put("actionIdentifiers", actionIdentifiers);
+ executor.outFields.put("payload", payload);
+
+ //var returnValue = executor.isTrue;
+ true;
+ - key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ value:
+ key:
+ name: ReceiveSubscriptionTask
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: blueprintName
+ value:
+ key: blueprintName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: blueprintVersion
+ value:
+ key: blueprintVersion
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: changeType
+ value:
+ key: changeType
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: closedLoopControlName
+ value:
+ key: closedLoopControlName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: nfName
+ value:
+ key: nfName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: policyName
+ value:
+ key: policyName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: subscription
+ value:
+ key: subscription
+ fieldSchemaKey:
+ name: SubscriptionType
+ version: 0.0.1
+ optional: false
+ outputFields:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: PMSubscriptionAlbum
+ version: 0.0.1
+ taskLogic:
+ key: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: |-
+ /*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+ var uuidType = java.util.UUID;
+
+ executor.logger.info(executor.subject.id);
+
+ //albumID will be used to fetch info from our album later
+ var albumID = uuidType.randomUUID();
+ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance();
+ var returnValue = true;
+
+ if(executor.inFields.get("policyName") != null) {
+ executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName"));
+
+ var changeType = executor.inFields.get("changeType")
+ var nfName = executor.inFields.get("nfName")
+ var policyName = executor.inFields.get("policyName")
+ var closedLoopControlName = executor.inFields.get("closedLoopControlName")
+ var subscription = executor.inFields.get("subscription")
+ var blueprintName = executor.inFields.get("blueprintName")
+ var blueprintVersion = executor.inFields.get("blueprintVersion")
+
+ pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName"));
+ pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType"))
+ pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName"))
+ pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName"))
+ pmSubscriptionInfo.put("subscription", subscription)
+ pmSubscriptionInfo.put("blueprintName", blueprintName)
+ pmSubscriptionInfo.put("blueprintVersion", blueprintVersion)
+
+
+ executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo);
+
+ executor.outFields.put("albumID", albumID)
+ } else {
+ executor.message = "Received invalid event"
+ returnValue = false;
+ }
+
+ returnValue;
+ events:
+ key:
+ name: PMControlPolicy_Events
+ version: 0.0.1
+ eventMap:
+ entry:
+ - key:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponseEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: CDS
+ target: APEX
+ parameter:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ optional: false
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateSubscriptionRequestEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponseEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: CDS
+ target: APEX
+ parameter:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ optional: false
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteSubscriptionRequestEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: actionIdentifiers
+ value:
+ key: actionIdentifiers
+ fieldSchemaKey:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ optional: false
+ - key: commonHeader
+ value:
+ key: commonHeader
+ fieldSchemaKey:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseStatusEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: DCAE
+ parameter:
+ entry:
+ - key: status
+ value:
+ key: status
+ fieldSchemaKey:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ value:
+ key:
+ name: CreateSubscriptionPayloadEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ value:
+ key:
+ name: DeleteSubscriptionPayloadEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key: payload
+ value:
+ key: payload
+ fieldSchemaKey:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: MRResponseEvent
+ version: 0.0.1
+ value:
+ key:
+ name: MRResponseEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: DCAE
+ target: APEX
+ parameter:
+ entry:
+ - key: count
+ value:
+ key: count
+ fieldSchemaKey:
+ name: SimpleIntType
+ version: 0.0.1
+ optional: false
+ - key: serverTimeMs
+ value:
+ key: serverTimeMs
+ fieldSchemaKey:
+ name: SimpleIntType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionOutputEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: APEX
+ target: APEX
+ parameter:
+ entry:
+ - key: albumID
+ value:
+ key: albumID
+ fieldSchemaKey:
+ name: UUIDType
+ version: 0.0.1
+ optional: false
+ - key:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ value:
+ key:
+ name: pmsh-operational-policy
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.onap.pmcontrol
+ source: DCAE
+ target: APEX
+ parameter:
+ entry:
+ - key: blueprintName
+ value:
+ key: blueprintName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: blueprintVersion
+ value:
+ key: blueprintVersion
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: changeType
+ value:
+ key: changeType
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: closedLoopControlName
+ value:
+ key: closedLoopControlName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: nfName
+ value:
+ key: nfName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: policyName
+ value:
+ key: policyName
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: subscription
+ value:
+ key: subscription
+ fieldSchemaKey:
+ name: SubscriptionType
+ version: 0.0.1
+ optional: false
+ albums:
+ key:
+ name: PMControlPolicy_Albums
+ version: 0.0.1
+ albums:
+ entry:
+ - key:
+ name: PMSubscriptionAlbum
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionAlbum
+ version: 0.0.1
+ scope: policy
+ isWritable: true
+ itemSchema:
+ name: PMSubscriptionType
+ version: 0.0.1
+ schemas:
+ key:
+ name: PMControlPolicy_Schemas
+ version: 0.0.1
+ schemas:
+ entry:
+ - key:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSActionIdentifiersType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "ActionIdentifiers_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "actionName",
+ "type": "string"
+ },
+ {
+ "name": "blueprintName",
+ "type": "string"
+ },
+ {
+ "name": "blueprintVersion",
+ "type": "string"
+ },
+ {
+ "name": "mode",
+ "type": "string"
+ }
+ ]
+ }
+ - key:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateResponsePayloadType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "name": "CreateResponsePayloadEntry",
+ "type": "record",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "create_DasH_subscription_DasH_response",
+ "type": {
+ "name": "create_DasH_subscription_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "odl_DasH_response",
+ "type": {
+ "name": "odl_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "status",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ - key:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSCreateSubscriptionPayloadType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "map",
+ "values": {
+ "type": "record",
+ "name": "CDSRequestPayloadEntry",
+ "fields": [
+ {
+ "name": "create_DasH_subscription_DasH_properties",
+ "type": {
+ "name": "create_DasH_subscription_DasH_properties_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "administrativeState",
+ "type": "string"
+ },
+ {
+ "name": "fileBasedGP",
+ "type": "string"
+ },
+ {
+ "name": "fileLocation",
+ "type": "string"
+ },
+ {
+ "name": "measurementGroups",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementGroups_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementGroup",
+ "type": {
+ "name": "measurementGroup",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementTypes",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementTypes_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementType",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "managedObjectDNsBasic",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "managedObjectDNsBasic_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "DN",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ - key:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteResponsePayloadType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "name": "DeleteResponsePayloadEntry",
+ "type": "record",
+ "namespace": "com.acme.avro",
+ "fields": [
+ {
+ "name": "delete_DasH_subscription_DasH_response",
+ "type": {
+ "name": "delete_DasH_subscription_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "odl_DasH_response",
+ "type": {
+ "name": "odl_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "status",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ - key:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSDeleteSubscriptionPayloadType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "map",
+ "values": {
+ "type": "record",
+ "name": "CDSRequestPayloadEntry",
+ "fields": [
+ {
+ "name": "delete_DasH_subscription_DasH_properties",
+ "type": {
+ "name": "delete_DasH_subscription_DasH_properties_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "administrativeState",
+ "type": "string"
+ },
+ {
+ "name": "fileBasedGP",
+ "type": "string"
+ },
+ {
+ "name": "fileLocation",
+ "type": "string"
+ },
+ {
+ "name": "measurementGroups",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementGroups_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementGroup",
+ "type": {
+ "name": "measurementGroup",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementTypes",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementTypes_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementType",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "managedObjectDNsBasic",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "managedObjectDNsBasic_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "DN",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ - key:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSRequestCommonHeaderType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "RequestCommonHeader_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "originatorId",
+ "type": "string"
+ },
+ {
+ "name": "requestId",
+ "type": "string"
+ },
+ {
+ "name": "subRequestId",
+ "type": "string"
+ }
+ ]
+ }
+ - key:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseCommonHeaderType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "ResponseCommonHeader_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "originatorId",
+ "type": "string"
+ },
+ {
+ "name": "requestId",
+ "type": "string"
+ },
+ {
+ "name": "subRequestId",
+ "type": "string"
+ },
+ {
+ "name": "timestamp",
+ "type": "string"
+ },
+ {
+ "name": "flags",
+ "type": ["null", "string"]
+ }
+ ]
+ }
+ - key:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ value:
+ key:
+ name: CDSResponseStatusType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "ResponseStatus_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "code",
+ "type": "int"
+ },
+ {
+ "name": "eventType",
+ "type": "string"
+ },
+ {
+ "name": "timestamp",
+ "type": "string"
+ },
+ {
+ "name": "message",
+ "type": "string"
+ }
+ ]
+ }
+ - key:
+ name: PMSubscriptionType
+ version: 0.0.1
+ value:
+ key:
+ name: PMSubscriptionType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"\
+ org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\"\
+ ,\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"\
+ type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"\
+ string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\
+ {\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\"\
+ : \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\"\
+ ,\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\
+ \"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\
+ \t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\
+ \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\
+ \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\
+ \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\
+ \t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\"\
+ ,\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\"\
+ : \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\"\
+ ,\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\
+ \t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\
+ \t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\
+ name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\
+ \t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\
+ \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\
+ \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\
+ \t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\
+ \t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\
+ \t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\"\
+ ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\
+ \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\
+ \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\
+ \t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\
+ \t}\n\t]\n}"
+ - key:
+ name: SimpleIntType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleIntType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.lang.Integer
+ - key:
+ name: SimpleStringType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleStringType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.lang.String
+ - key:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ value:
+ key:
+ name: SubscriptionStatusType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: |-
+ {
+ "type": "record",
+ "name": "ActivateSubscriptionStatus_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "changeType",
+ "type": "string"
+ },
+ {
+ "name": "message",
+ "type": "string"
+ }
+ ]
+ }
+ - key:
+ name: SubscriptionType
+ version: 0.0.1
+ value:
+ key:
+ name: SubscriptionType
+ version: 0.0.1
+ schemaFlavour: Avro
+ schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\
+ \t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\"\
+ ,\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"\
+ int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\
+ {\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\
+ \t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\
+ \t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\
+ \t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\
+ \t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\"\
+ : {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\
+ \t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\
+ \t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\
+ \t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\
+ }\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\
+ \t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\"\
+ : {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"\
+ type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\"\
+ ,\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\
+ \t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\
+ \t\t}\n\t\t}\n\t]\n}"
+ - key:
+ name: UUIDType
+ version: 0.0.1
+ value:
+ key:
+ name: UUIDType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.util.UUID
+ engineParameters:
+ executorParameters:
+ JAVASCRIPT:
+ parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters
+ contextParameters:
+ parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters
+ schemaParameters:
+ Avro:
+ parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters
+ Java:
+ parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters
+ jsonAdapters:
+ Instant:
+ adaptedClass: java.time.Instant
+ adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter
+ eventInputParameters:
+ DCAEConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTCLIENT
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters
+ parameters:
+ consumerPollTime: '50'
+ url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1
+ eventProtocolParameters:
+ eventProtocol: JSON
+ parameters:
+ nameAlias: policyName
+ eventName: pmsh-operational-policy
+ eventNameFilter: pmsh-operational-policy
+ CDSRequestConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ parameters:
+ url: http://10.10.10.184:30254/api/v1/execution-service/process
+ httpMethod: POST
+ restRequestTimeout: 2000
+ httpHeaders:
+ - - Authorization
+ - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventName: CDSCreateResponseEvent
+ eventNameFilter: CDSCreateResponseEvent
+ requestorMode: true
+ requestorPeer: CDSRequestProducer
+ requestorTimeout: 500
+ CDSDeleteRequestConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ parameters:
+ url: http://10.10.10.184:30254/api/v1/execution-service/process
+ httpMethod: POST
+ restRequestTimeout: 2000
+ httpHeaders:
+ - - Authorization
+ - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventName: CDSDeleteResponseEvent
+ eventNameFilter: CDSDeleteResponseEvent
+ requestorMode: true
+ requestorPeer: CDSDeleteRequestProducer
+ requestorTimeout: 500
+ CDSReplyConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ parameters:
+ url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT
+ httpMethod: POST
+ restRequestTimeout: 2000
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventName: MRResponseEvent
+ eventNameFilter: MRResponseEvent
+ requestorMode: true
+ requestorPeer: CDSReplyProducer
+ requestorTimeout: 500
+ eventOutputParameters:
+ logOutputter:
+ carrierTechnologyParameters:
+ carrierTechnology: FILE
+ parameters:
+ fileName: /tmp/outputevents.log
+ eventProtocolParameters:
+ eventProtocol: JSON
+ StdOutOutputter:
+ carrierTechnologyParameters:
+ carrierTechnology: FILE
+ parameters:
+ standardIo: true
+ eventProtocolParameters:
+ eventProtocol: JSON
+ CDSRequestProducer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventNameFilter: CDSCreateSubscriptionRequestEvent
+ requestorMode: true
+ requestorPeer: CDSRequestConsumer
+ requestorTimeout: 500
+ CDSDeleteRequestProducer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventNameFilter: CDSDeleteSubscriptionRequestEvent
+ requestorMode: true
+ requestorPeer: CDSDeleteRequestConsumer
+ requestorTimeout: 500
+ CDSReplyProducer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTREQUESTOR
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters
+ eventProtocolParameters:
+ eventProtocol: JSON
+ eventNameFilter: CDSResponseStatusEvent
+ requestorMode: true
+ requestorPeer: CDSReplyConsumer
+ requestorTimeout: 500
diff --git a/common/src/main/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml b/common/src/main/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml
new file mode 100644
index 000000000..51e369696
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml
@@ -0,0 +1,455 @@
+# ============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=========================================================
+
+tosca_definitions_version: tosca_simple_yaml_1_3
+capability_types:
+ org.onap.EventProducer:
+ properties:
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ event_format:
+ type: string
+ required: true
+ event_format_version:
+ type: string
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+ org.onap.EventConsumer:
+ properties:
+ responding_capability:
+ type: string
+ required: false
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ - all valid values should be added here
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured,
+ etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+node_types:
+ org.onap.DynamicConfig:
+ properties:
+ application_name:
+ type: string
+ description: Value used to tie the config to an application ? should we be
+ using a relationship here instead?
+ required: true
+ application_version:
+ type: string
+ required: true
+ application_provider:
+ type: string
+ required: false
+ data_types:
+ type: object
+ required: false
+ schema:
+ type: object
+ required: false
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.APP:
+ properties:
+ application_name:
+ type: string
+ description: Human readable name for the application Product
+ required: false
+ provider:
+ type: string
+ description: Provider of the application and of the descriptor
+ required: true
+ application_version:
+ type: string
+ description: Software version of the application
+ required: true
+ blueprint_id:
+ type: string
+ description: A reference to the app blueprint
+ required: false
+ monitoring_policy:
+ type: string
+ description: A reference to the monitoring policy
+ required: false
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0
+ - UNBOUNDED
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0
+ - UNBOUNDED
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.EventRelay:
+ properties:
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: true
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key is relayed
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ supported_carrier_protocols:
+ type: map
+ description: 'A map describing supported carrier protocols and translations.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ supported_data_formats:
+ type: map
+ description: 'Is a map describing supported data formats and translation.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0
+ - UNBOUNDED
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0
+ - UNBOUNDED
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+relationship_types:
+ org.onap.PropagateEvent:
+ properties:
+ config_keys:
+ type: list
+ description: The relationship type used on requirements to org.onap.EventProducer
+ and org.onap.EventConsumer capabilities. Filters events by specific config_keys
+ to be transferred by this relationship. That is, any event with a specific
+ config_key found in the list is transferred. If list is not defined or is
+ empty, events with all config_keys are transferred.
+ required: false
+ entry_schema:
+ type: string
+ version: 0.0.1
+ derived_from: tosca.relationships.Root
+topology_template:
+ inputs:
+ pm_subscription_topic:
+ type: string
+ pm_subscription_response_topic:
+ type: string
+ pm_subscription_handler_blueprint_id:
+ type: string
+ pm_subscription_operational_policy_id:
+ type: string
+ pm_subscription_cds_blueprint_id:
+ type: string
+ enable_tls:
+ type: string
+ node_templates:
+ org.onap.PM_Subscription_Handler:
+ type: org.onap.polcy.clamp.ControlLoopElement
+ properties:
+ application_name: PM Subscription Handler
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_handler_blueprint_id
+ description: Is this a reference to the DCAE Cloudify Blueprint that is
+ already stored(or will be stored before CL configuration & instatiation)
+ in DCAE Inventory?
+ artifact_config:
+ enable_tls:
+ get_input: enable_tls
+ pmsh_publish_topic_name:
+ get_input: pm_subscription_topic
+ capabilities:
+ pm-subscription-event-publisher:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-format
+ event_format_version: 1.0.0
+ attributes:
+ type: org.onap.EventProducer
+ occurrences:
+ - 0
+ - UNBOUNDED
+ pm-subscription-event-receiver:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ relationships:
+ - type: tosca.relationships.DependsOn
+ - description: any ideas on a better realtionship ? or is it better to
+ just use the root realtionship ?
+ - target: org.onap.PM_Monitoring_Policy
+ attributes:
+ type: org.onap.EventConsumer
+ occurrences:
+ - 0
+ - UNBOUNDED
+ org.onap.PM_Monitoring_Policy:
+ type: org.onap.DynamicConfig
+ properties:
+ application_name: PM Subscription Handler
+ application_version: 1.0.0
+ provider: Ericsson
+ data_types:
+ measurementType:
+ type: string
+ DN:
+ type: string
+ nfFilter:
+ properties:
+ nfNames:
+ type: list
+ entry_schema: string
+ modelInvariantIDs:
+ type: list
+ entry_schema:
+ type: string
+ modelVersionIDs:
+ type: list
+ entry_schema:
+ type: string
+ measurementGroup:
+ properties:
+ masurementTypes:
+ type: list
+ entry_schema:
+ type: measurementType
+ managedObjectDNsBasic:
+ type: list
+ entry_schema:
+ type: DN
+ schema:
+ subscription:
+ subscriptionName:
+ type: string
+ required: true
+ administrativeState:
+ type: string
+ required: true
+ filebasedGP:
+ type: integer
+ required: true
+ fileLocation:
+ type: string
+ required: true
+ nfFilter:
+ type: nfFilter
+ measurementGroups:
+ type: list
+ entry_schema:
+ type: measurementGroup
+ description: Should I be showing a dependency between PM Subscription Handler
+ and the PM Monitoring Policy
+ org.onap.PM_Policy:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription Operational Policy
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_operational_policy_id
+ artifact_config: NOT_DEFINED
+ requirements:
+ - receive_0:
+ capability: pm-subscription-event-publisher
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_topic
+ - send_0:
+ capability: cds-rest-receive
+ node: org.onap.CDS
+ - receive_1:
+ capability: cds-rest-response
+ node: org.onap.CDS
+ - send_1:
+ capability: pm-subscription-event-receiver
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_response_topic
+ capabilities:
+ pm-subscription-response-event-publisher:
+ properties:
+ type: org.onap.EventProducer
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0
+ - UNBOUNDED
+ org.onap.PM_CDS_Blueprint:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription CDS Blueprint
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_cds_blueprint_id
+ capabilities:
+ cds-rest-receive:
+ properties:
+ type: org.onap.EventConsumer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_format
+ event_format_version: 1.0.0
+ responding_capability: cds-rest-response
+ occurrences:
+ - 0
+ - UNBOUNDED
+ cds-rest-response:
+ properties:
+ type: org.onap.EventProducer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_response_format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0
+ org.onap.controlloop0:
+ version: 1.2.3
+ type: org.onap.policy.clamp.ControlLoop
+ properties:
+ application_name: Test Control Loop
+ provider: Ericsson
+ application_version: 1.0.0
+ status: NOT_DEPLOYED
+ elements:
+ element1: org.onap.PM_Monitoring_Policy
+
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml b/common/src/main/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml
new file mode 100644
index 000000000..96ea133c2
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml
@@ -0,0 +1,83 @@
+# ============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=========================================================
+
+tosca_definitions_version: tosca_simple_yaml_1_3
+
+imports:
+ - cloop_base_types.yaml
+ - cloop_dcae_types.yaml
+
+topology_template:
+ inputs:
+ some_property_input:
+ type: string
+
+ substitution_mappings:
+ node_type: org.onap.DCAE_VES_TCA
+ properties:
+ some_property: { get_input: some_property_input }
+ capabilities:
+ VES-5.28.4-publisher: [ node1_VES_Collector, VES-5.28.4-publisher ]
+ VES-7.30.1-publisher: [ node1_VES_Collector, VES-7.30.1-publisher ]
+ TCA-handle-out-publisher: [ node2_TCA_GEN_2, TCA-handle-out-publisher ]
+ VES_specification-subscriber: [ node2_TCA_GEN_2, VES_specification-subscriber ]
+
+ node_templates:
+ ################################################################################
+ #alt1: without relay
+
+ node1_VES_Collector:
+ type: org.onap.VESCollector
+
+ node2_TCA_GEN_2:
+ type: org.onap.TCA_GEN_2
+ requirements:
+ - receive:
+ capability: VES-5.28.4-publisher
+ node: node1_VES_Collector
+ relationship:
+ type: org.onap.PropagateEvent
+ properties:
+ config-keys: [ ves-measurement ]
+
+
+ ################################################################################
+ #alt2: with relay
+
+ node1_VES_Collector:
+ type: org.onap.VESCollector
+
+ node2_TCA_GEN_2:
+ type: org.onap.TCA_GEN_2
+
+ node3_Relay:
+ type: org.onap.EventRelay
+ properties:
+ event_format: "VES_specification"
+ event_format_version: "5.28.4"
+ supported_carrier_protocols: [{ DMAAP_message_router: DMAAP_message_router }]
+ supported_data_formats: [{ JSON: JSON }]
+ requirements:
+ - receive:
+ node: node1_VES_Collector
+ properties:
+ config_keys: [ ves-measurement ]
+ - send:
+ node: node2_TCA_GEN_2
+ properties:
+ config_keys: [ ves-measurement ]
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_base_types.yaml b/common/src/main/resources/examples/controlloop/original/cloop_base_types.yaml
new file mode 100644
index 000000000..4f29e5635
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/original/cloop_base_types.yaml
@@ -0,0 +1,210 @@
+# ============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=========================================================
+
+tosca_definitions_version: tosca_simple_yaml_1_2
+
+capability_types:
+ #producer capability type
+ org.onap.EventProducer:
+ derived_from: tosca.capabilities.Root
+ properties:
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ valid_values: [ DMAAP_message_router, REST ]
+ #all valid values should be added here
+ data_format:
+ type: string
+ required: true
+ constraints:
+ valid_values: [ JSON, YAML, JMS ]
+ #all valid values should be added here
+ event_format:
+ type: string
+ required: true
+ #examples for event_format: Ves_specification, etc.
+ event_format_version:
+ type: string
+ #examples for event_format_version: 5.28.4, 7.30.1, etc.
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ #valid_values: [ ]
+ #all valid values should be added here
+ #if not specified, events of any config key may be generated
+ #examples for config_key: ves-measurement, ves-syslog, tca_handle_out, etc.
+
+
+ #consumer capability type
+ org.onap.EventConsumer:
+ derived_from: tosca.capabilities.Root
+ properties:
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ valid_values: [ DMAAP_message_router, REST ]
+ #all valid values should be added here
+ data_format:
+ type: string
+ required: true
+ constraints:
+ valid_values: [ JSON, YAML, JMS ]
+ #all valid values should be added here
+ event_format:
+ type: string
+ required: true
+ #examples for event_format: Ves_specification, LinkUp, VnfConfigured, etc.
+ event_format_version:
+ type: string
+ #examples for event_format_version: 5.28.4, 7.30.1, etc.
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ #valid_values: [ ]
+ #all valid values should be added here
+ #if not specified, events of any config key may be generated
+ #examples for config_key: ves-measurement, ves-syslog, tca_handle_out, etc.
+
+
+relationship_types:
+ #the relationship type used on requirements to org.onap.EventProducer and org.onap.EventConsumer capabilities
+ org.onap.PropagateEvent:
+ derived_from: tosca.relationships.Root
+ properties:
+ config_keys:
+ type: list
+ required: false
+ description: >
+ Filters events by specific config_keys to be transferred by this relationship.
+ That is, any event with a specific config_key found in the list is transferred.
+ If list is not defined or is empty, events with all config_keys are transferred.
+ entry_schema: string
+
+
+
+node_types:
+ #base app node type
+ org.onap.APP:
+ derived_from: tosca.nodes.Root
+ properties:
+ application_name:
+ type: string
+ description: Human readable name for the application Product
+ required: false
+ provider:
+ type: string
+ description: Provider of the application and of the descriptor
+ required: true
+ application_version:
+ type: string
+ description: Software version of the application
+ required: true
+ blueprint_id:
+ type: string
+ description: A reference to the app blueprint
+ monitoring_policy:
+ type: string
+ required: false
+ description: A reference to the monitoring policy
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences: [0, UNBOUNDED]
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences: [0, UNBOUNDED]
+
+ #the event relay node type
+ org.onap.EventRelay:
+ derived_from: tosca.nodes.Root
+ properties:
+ event_format:
+ type: string
+ required: true
+ #examples for event_format: Ves_specification, etc.
+ event_format_version:
+ type: string
+ required: true
+ #examples for event_format_version: 5.28.4, 7.30.1, etc.
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ #valid_values: [ ]
+ #all valid values should be added here
+ #if not specified, events of any config key is relayed
+ #examples for config_key: ves-measurement, ves-syslog, tca_handle_out, etc.
+ supported_carrier_protocols:
+ type: map
+ required: true
+ description: >
+ A map describing supported carrier protocols and translations. The
+ tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}
+ key_schema:
+ type: string
+ constraints:
+ valid_values: [ DMAAP_message_router, REST ]
+ #all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ valid_values: [ DMAAP_message_router, REST ]
+ #all valid values should be added here
+ supported_data_formats:
+ type: map
+ required: true
+ description: >
+ Is a map describing supported data formats and translation. The tuples
+ define what protocol combinations are supported on the producer and
+ consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }
+ key_schema:
+ type: string
+ constraints:
+ valid_values: [ JSON, JMS, YAML, etc ]
+ #all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ valid_values: [ JSON, JMS, YAML, etc ]
+ #all valid values should be added here
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences: [1, UNBOUNDED]
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences: [1, UNBOUNDED]
+
+
+
+
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_dcae_example.yaml b/common/src/main/resources/examples/controlloop/original/cloop_dcae_example.yaml
new file mode 100644
index 000000000..4629f6f75
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/original/cloop_dcae_example.yaml
@@ -0,0 +1,50 @@
+# ============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=========================================================
+
+tosca_definitions_version: tosca_simple_yaml_1_3
+
+imports:
+ - cloop_base_types.yaml
+ - cloop_dcae_types.yaml
+ - cloop_other_types.yaml
+
+topology_template:
+ node_templates:
+
+ node1_DCAE_VES_TCA:
+ type: org.onap.DCAE_VES_TCA
+ directives:
+ - substitute
+
+ node2_PolicyFramework:
+ type: org.onap.ApexPolicyFramework
+ requirements:
+ - receive:
+ capability: TCA-handle-out-publisher
+ node: node1_DCAE_VES_TCA
+ relationship:
+ properties:
+ config_keys: [ ves-measurement ]
+ - send:
+ capability: SelfService
+ node: org.onap.CDS
+ relationship:
+ properties:
+ config_keys: [ ves-measurement ]
+
+ #if this closed loop to subscribe to other events via the VesCollector, should we not add that?
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_dcae_types.yaml b/common/src/main/resources/examples/controlloop/original/cloop_dcae_types.yaml
new file mode 100644
index 000000000..5f96cd5df
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/original/cloop_dcae_types.yaml
@@ -0,0 +1,140 @@
+# ============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=========================================================
+
+tosca_definitions_version: tosca_simple_yaml_1_3
+
+imports:
+ - cloop_types.yaml
+
+node_types:
+
+ #node type for VES_Collector
+ org.onap.VES_Collector:
+ derived_from: org.onap.APP
+ capabilities:
+ VES-5.28.4-publisher:
+ type: org.onap.EventProducer
+ occurrences: [ 0, UNBOUNDED ]
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "VES_specification"
+ event_format_version: "5.28.4"
+ config_keys:
+ - "ves-fault"
+ - "ves-measurement"
+ - "ves-syslog"
+ - "ves-heartbeat"
+ - "ves-other"
+ - "ves-mobileflow"
+ - "ves-statechange"
+ - "ves-thresholdCrossingAlert"
+ - "ves-voicequality"
+ - "ves-sipsignaling"
+ VES-7.30.1-publisher:
+ type: org.onap.EventProducer
+ occurrences: [ 0, UNBOUNDED ]
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "VES_specification"
+ event_format_version: "7.30.1"
+ config_keys:
+ - "ves-fault"
+ - "ves-pnfRegistration"
+ - "ves-notification"
+ - "ves-perf3gpp"
+
+ #node type for TCA_GEN_2
+ org.onap.TCA_GEN_2:
+ derived_from: org.onap.APP
+ capabilities:
+ TCA-handle-out-publisher:
+ type: org.onap.EventProducer
+ occurrences: [ 0, UNBOUNDED ]
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "DCAE_CL_Output"
+ event_format_version: "1.0.1"
+ config_keys: [ "tca_handle_out" ]
+ VES_specification-subscriber:
+ type: org.onap.EventConsumer
+ occurrences: [ 0, UNBOUNDED ]
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "VES_specification"
+ event_format_version: "5.28.4"
+ config_keys: [ "tca_handle_in" ]
+
+
+
+ #node type for the composed VES_Collector and TCA_GEN_2
+ org.onap.DCAE_VES_TCA:
+ derived_from: org.onap.APP
+ capabilities:
+ VES-5.28.4-publisher:
+ type: org.onap.EventProducer
+ occurrences: [ 0, UNBOUNDED ]
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "VES_specification"
+ event_format_version: "5.28.4"
+ config_keys:
+ - "ves-fault"
+ - "ves-measurement"
+ - "ves-syslog"
+ - "ves-heartbeat"
+ - "ves-other"
+ - "ves-mobileflow"
+ - "ves-statechange"
+ - "ves-thresholdCrossingAlert"
+ - "ves-voicequality"
+ - "ves-sipsignaling"
+ VES-7.30.1-publisher:
+ type: org.onap.EventProducer
+ occurrences: [ 0, UNBOUNDED ]
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "VES_specification"
+ event_format_version: "7.30.1"
+ config_keys:
+ - "ves-pnfRegistration"
+ - "ves-notification"
+ - "ves-perf3gpp"
+ TCA-handle-out-publisher:
+ type: org.onap.EventProducer
+ occurrences: [ 0, UNBOUNDED ]
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "DCAE_CL_Output"
+ event_format_version: "1.0.1"
+ config_keys: [ "tca_handle_out" ]
+ VES_specification-subscriber:
+ type: org.onap.EventConsumer
+ occurrences: [ 0, UNBOUNDED ]
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "VES_specification"
+ event_format_version: "5.28.4"
+ config_keys: [ "tca_handle_in" ]
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_other_types.yaml b/common/src/main/resources/examples/controlloop/original/cloop_other_types.yaml
new file mode 100644
index 000000000..d743f499f
--- /dev/null
+++ b/common/src/main/resources/examples/controlloop/original/cloop_other_types.yaml
@@ -0,0 +1,63 @@
+# ============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=========================================================
+
+tosca_definitions_version: tosca_simple_yaml_1_2
+
+imports:
+ - cloop_base_types.yaml
+
+node_types:
+ #node type for Policy
+ org.onap.PolicyFramework:
+ derived_from: org.onap.APP
+
+ #node type for Apex Policy
+ org.onap.ApexPolicyFramework:
+ derived_from: org.onap.PolicyFramework
+
+ #node type for CDS
+ org.onap.CDS:
+ derived_from: org.onap.APP
+ capabilities:
+ #consumer capability for CDS for events of type ResourceAndTemplate management API
+ ResourceAndTemplateManagement:
+ type: org.onap.EventConsumer
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "ResourceAndTemplate"
+ event_format_version: "x.xx.x"
+ occurrences: [ 0, UNBOUNDED ]
+ #consumer capability for CDS for events of type SelfService API
+ SelfService:
+ type: org.onap.EventConsumer
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "SelfService"
+ event_format_version: "x.xx.x"
+ occurrences: [ 0, UNBOUNDED ]
+ #producer capability for CDS for events of type PNFControl
+ PNFcontrolEventsProducer:
+ type: org.onap.EventProducer
+ properties:
+ carrier_protocol_type: "DMAAP_message_router"
+ data_format: "JSON"
+ event_format: "PNFcontrol"
+ event_format_version: "x.xx.x"
+ occurrences: [ 0, UNBOUNDED ]
diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java
new file mode 100644
index 000000000..3c1688582
--- /dev/null
+++ b/common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.common.exception;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.junit.Test;
+import org.onap.policy.models.errors.concepts.ErrorResponse;
+
+public class ExceptionsTest {
+
+ private static final String STRING_TEXT = "String";
+ private static final String MESSAGE = "Message";
+
+ @Test
+ public void testExceptions() {
+ assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE));
+ assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE, STRING_TEXT));
+ assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE, new IOException()));
+ assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT));
+
+ String key = "A String";
+ ControlLoopException ae =
+ new ControlLoopException(Response.Status.OK, MESSAGE, new IOException("IO exception message"), key);
+ ErrorResponse errorResponse = ae.getErrorResponse();
+ assertEquals("Message\nIO exception message", String.join("\n", errorResponse.getErrorDetails()));
+ assertEquals(key, ae.getObject());
+
+ assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE));
+ assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE, STRING_TEXT));
+ assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE, new IOException()));
+ assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT));
+
+ String rkey = "A String";
+ ControlLoopRuntimeException re = new ControlLoopRuntimeException(Response.Status.OK, "Runtime Message",
+ new IOException("IO runtime exception message"), rkey);
+ errorResponse = re.getErrorResponse();
+ assertEquals("Runtime Message\nIO runtime exception message",
+ String.join("\n", errorResponse.getErrorDetails()));
+ assertEquals(key, re.getObject());
+
+ ControlLoopRuntimeException clre = new ControlLoopRuntimeException(ae);
+ assertEquals(ae.getErrorResponse().getResponseCode(), clre.getErrorResponse().getResponseCode());
+ assertEquals(ae.getMessage(), clre.getMessage());
+
+ try {
+ try {
+ throw new ControlLoopException(Status.BAD_GATEWAY, "An Exception");
+ } catch (ControlLoopException cle) {
+ throw new ControlLoopRuntimeException(cle);
+ }
+ } catch (ControlLoopRuntimeException clred) {
+ assertEquals(Status.BAD_GATEWAY, clred.getErrorResponse().getResponseCode());
+ assertEquals("An Exception", clred.getMessage());
+ assertEquals(ControlLoopException.class.getName(), clred.getCause().getClass().getName());
+ }
+
+ assertThat(ae.toString()).contains("A String");
+ assertThat(re.toString()).contains("A String");
+ }
+}
diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/handler/ControlLoopHandlerTest.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/handler/ControlLoopHandlerTest.java
new file mode 100644
index 000000000..845bc8df0
--- /dev/null
+++ b/common/src/test/java/org/onap/policy/clamp/controlloop/common/handler/ControlLoopHandlerTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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.common.handler;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+
+public class ControlLoopHandlerTest {
+
+ @Test
+ public void testControlLoopHandler() {
+ assertThatThrownBy(() -> new DummyControlLoopHandler(null)).isInstanceOf(NullPointerException.class);
+
+ assertNotNull(new DummyControlLoopHandler(new PolicyModelsProviderParameters()));
+ Registry.unregister(DummyControlLoopHandler.class.getName());
+
+ String dummyClassName = DummyControlLoopHandler.class.getName();
+ assertThatThrownBy(() -> Registry.get(dummyClassName)).isInstanceOf(IllegalArgumentException.class);
+
+ PolicyModelsProviderParameters pars = new PolicyModelsProviderParameters();
+
+ DummyControlLoopHandler dclh = new DummyControlLoopHandler(pars);
+ assertNotNull(dclh);
+
+ assertEquals(pars, dclh.getDatabaseProviderParameters());
+ assertEquals(0, dclh.getProviderClasses().size());
+
+ dclh.close();
+ assertThatThrownBy(() -> Registry.get(dummyClassName)).isInstanceOf(IllegalArgumentException.class);
+ }
+}
diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/handler/DummyControlLoopHandler.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/handler/DummyControlLoopHandler.java
new file mode 100644
index 000000000..1602fb6eb
--- /dev/null
+++ b/common/src/test/java/org/onap/policy/clamp/controlloop/common/handler/DummyControlLoopHandler.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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.common.handler;
+
+import java.util.List;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+
+public class DummyControlLoopHandler extends ControlLoopHandler {
+
+ public DummyControlLoopHandler(PolicyModelsProviderParameters databaseProviderParameters) {
+ super(databaseProviderParameters);
+ }
+
+ @Override
+ public void startAndRegisterListeners(MessageTypeDispatcher msgDispatcher) {
+ // Do nothing on this dummy class
+ }
+
+ @Override
+ public void startAndRegisterPublishers(List<TopicSink> topicSinks) {
+ // Do nothing on this dummy class
+ }
+
+ @Override
+ public void stopAndUnregisterPublishers() {
+ // Do nothing on this dummy class
+ }
+
+ @Override
+ public void stopAndUnregisterListeners(MessageTypeDispatcher msgDispatcher) {
+ // Do nothing on this dummy class
+ }
+
+ @Override
+ public void startProviders() {
+ // Do nothing on this dummy class
+ }
+
+ @Override
+ public void stopProviders() {
+ // Do nothing on this dummy class
+ }
+}
diff --git a/common/src/test/resources/demo/Notes.txt b/common/src/test/resources/demo/Notes.txt
new file mode 100644
index 000000000..21be91449
--- /dev/null
+++ b/common/src/test/resources/demo/Notes.txt
@@ -0,0 +1,39 @@
+Run DMaaP simulator using Docker
+c/Users/${USER}/Github/simulator/distribution
+${USER}@S031PC03 MINGW64 ~/Github/simulator/distribution (master)
+$ docker run -p 3904:3904 --volume //c/Users/${USER}/Github/simulator/distribution:/opt/app/policy/simulators/etc/mounted:ro --name=dmaap-simulator nexus3.onap.org:10001/onap/policy-models-simulator:latest
+
+
+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"
+
+
+Run CL from command line
+Go to clamp/tosca-controlloop/runtime
+mvn exec:java -Dexec.mainClass=org.onap.policy.clamp.controlloop.runtime.main.startstop.Main -Dexec.args="-c src/test/resources/parameters/TestParametersMariaDB.json"
+
+Run Participant from command line
+mvn exec:java -Dexec.mainClass=org.onap.policy.clamp.controlloop.participants.ParticipantMain -Dexec.args=" -c src/main/resources/config/CDSParticipantConfig.json"
+mvn exec:java -Dexec.mainClass=org.onap.policy.clamp.controlloop.participant.dcae.main.startstop.Main -Dexec.args=" -c src/main/resources/config/DCAEParticipantConfig.json"
+mvn exec:java -Dexec.mainClass=org.onap.policy.clamp.controlloop.participants.ParticipantMain -Dexec.args=" -c src/main/resources/config/PolicyParticipantConfig.json"
+
+Config of DB
+
+Prompt > mysql
+MariaDB [(none)]> create database controlloop;
+MariaDB [(none)]> CREATE USER 'policy'@localhost IDENTIFIED BY 'P01icY';
+MariaDB [(none)]> GRANT ALL PRIVILEGES ON controlloop.* TO 'policy'@'localhost';\
+MariaDB [(none)]> SHOW GRANTS for 'policy'@localhost;
++---------------------------------------------------------------------------------------------------------------+
+| Grants for policy@localhost |
++---------------------------------------------------------------------------------------------------------------+
+| GRANT USAGE ON *.* TO `policy`@`localhost` IDENTIFIED BY PASSWORD '*D0574A541C5DEDF11838FB41CA04E256FD5A04CC' |
+| GRANT ALL PRIVILEGES ON `controlloop`.* TO `policy`@`localhost` |
++---------------------------------------------------------------------------------------------------------------+
+2 rows in set (0.000 sec)
+
+
+Run Policy API:
+mvn exec:java -Dexec.mainClass=org.onap.policy.api.main.startstop.Main -Dexec.args="-c ../../clamp-tpn/tosca-controlloop/common/src/test/resources/demo/policy-api/PolicyAPIConfig.json"
diff --git a/common/src/test/resources/demo/config/DEMO.postman_collection.json b/common/src/test/resources/demo/config/DEMO.postman_collection.json
new file mode 100644
index 000000000..0b4c1f2ce
--- /dev/null
+++ b/common/src/test/resources/demo/config/DEMO.postman_collection.json
@@ -0,0 +1,302 @@
+{
+ "info": {
+ "_postman_id": "44176e3a-cd0d-457f-9ea9-b414bc368f33",
+ "name": "DEMO",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+ },
+ "item": [
+ {
+ "name": "Demo: Comission control loop definition Multiple Copy",
+ "protocolProfileBehavior": {
+ "disabledSystemHeaders": {
+ "content-type": true
+ }
+ },
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "zb!XztG34",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "healthcheck",
+ "type": "string"
+ }
+ ]
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "X-ONAP-RequestID",
+ "type": "text",
+ "value": "709c62b3-8918-41b9-a747-d21eb79c6c20"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/yaml"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "tosca_definitions_version: tosca_simple_yaml_1_1_0\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\n org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo:\n name: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n properties:\n consulUrl:\n name: consulUrl\n type: string\n typeVersion: 0.0.0\n description: Consul url for this entry\n required: true\n consul_body:\n name: consulBody\n type: string\n typeVersion: 0.0.0\n description: Body of Consul entry\n required: true\n onap.datatype.controlloop.Target:\n derived_from: tosca.datatypes.Root\n description: Definition for a entity in A&AI to perform a control loop operation on\n properties:\n targetType:\n type: string\n description: Category for the target type\n required: true\n constraints:\n - valid_values:\n - VNF\n - VM\n - VFMODULE\n - PNF\n entityIds:\n type: map\n description: |\n Map of values that identify the resource. If none are provided, it is assumed that the\n entity that generated the ONSET event will be the target.\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CSAR_RESOURCES\n entry_schema:\n type: string\n onap.datatype.controlloop.Actor:\n derived_from: tosca.datatypes.Root\n description: An actor/operation/target definition\n properties:\n actor:\n type: string\n description: The actor performing the operation.\n required: true\n metadata:\n clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor\n operation:\n type: string\n description: The operation the actor is performing.\n metadata:\n clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation\n required: true\n target:\n type: onap.datatype.controlloop.Target\n description: The resource the operation should be performed on.\n required: true\n payload:\n type: map\n description: Name/value pairs of payload information passed by Policy to the actor\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CDS/payload\n entry_schema:\n type: string\n onap.datatype.controlloop.Operation:\n derived_from: tosca.datatypes.Root\n description: An operation supported by an actor\n properties:\n id:\n type: string\n description: Unique identifier for the operation\n required: true\n description:\n type: string\n description: A user-friendly description of the intent for the operation\n required: false\n operation:\n type: onap.datatype.controlloop.Actor\n description: The definition of the operation to be performed.\n required: true\n timeout:\n type: integer\n description: The amount of time for the actor to perform the operation.\n required: true\n retries:\n type: integer\n description: The number of retries the actor should attempt to perform the operation.\n required: true\n default: 0\n success:\n type: string\n description: Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.\n required: false\n default: final_success\n failure:\n type: string\n description: Points to the operation to invoke on Actor operation failure.\n required: false\n default: final_failure\n failure_timeout:\n type: string\n description: Points to the operation to invoke when the time out for the operation occurs.\n required: false\n default: final_failure_timeout\n failure_retries:\n type: string\n description: Points to the operation to invoke when the current operation has exceeded its max retries.\n required: false\n default: final_failure_retries\n failure_exception:\n type: string\n description: Points to the operation to invoke when the current operation causes an exception.\n required: false\n default: final_failure_exception\n failure_guard:\n type: string\n description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.\n required: false\n default: final_failure_guard\n onap.datatypes.monitoring.managedObjectDNsBasic:\n constraints: []\n properties:\n DN:\n name: DN\n type: string\n typeVersion: 0.0.0\n description: Managed object distinguished name\n required: true\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.managedObjectDNsBasic\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.managedObjectDNsBasics:\n constraints: []\n properties:\n managedObjectDNsBasic:\n name: managedObjectDNsBasic\n type: map\n typeVersion: 0.0.0\n description: Managed object distinguished name object\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.managedObjectDNsBasic\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.managedObjectDNsBasics\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementGroup:\n constraints: []\n properties:\n measurementTypes:\n name: measurementTypes\n type: list\n typeVersion: 0.0.0\n description: List of measurement types\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementTypes\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n managedObjectDNsBasic:\n name: managedObjectDNsBasic\n type: list\n typeVersion: 0.0.0\n description: List of managed object distinguished names\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.managedObjectDNsBasics\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementGroup\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementGroups:\n constraints: []\n properties:\n measurementGroup:\n name: measurementGroup\n type: map\n typeVersion: 0.0.0\n description: Measurement Group\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementGroup\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementGroups\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementType:\n constraints: []\n properties:\n measurementType:\n name: measurementType\n type: string\n typeVersion: 0.0.0\n description: Measurement type\n required: true\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementType\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementTypes:\n constraints: []\n properties:\n measurementType:\n name: measurementType\n type: map\n typeVersion: 0.0.0\n description: Measurement type object\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementType\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementTypes\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.nfFilter:\n constraints: []\n properties:\n modelNames:\n name: modelNames\n type: list\n typeVersion: 0.0.0\n description: List of model names\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n modelInvariantIDs:\n name: modelInvariantIDs\n type: list\n typeVersion: 0.0.0\n description: List of model invariant IDs\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n modelVersionIDs:\n name: modelVersionIDs\n type: list\n typeVersion: 0.0.0\n description: List of model version IDs\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n nfNames:\n name: nfNames\n type: list\n typeVersion: 0.0.0\n description: List of network functions\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.nfFilter\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.subscription:\n constraints: []\n properties:\n measurementGroups:\n name: measurementGroups\n type: list\n typeVersion: 0.0.0\n description: Measurement Groups\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementGroups\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n fileBasedGP:\n name: fileBasedGP\n type: integer\n typeVersion: 0.0.0\n description: File based granularity period\n required: true\n constraints: []\n metadata: {}\n fileLocation:\n name: fileLocation\n type: string\n typeVersion: 0.0.0\n description: ROP file location\n required: true\n constraints: []\n metadata: {}\n subscriptionName:\n name: subscriptionName\n type: string\n typeVersion: 0.0.0\n description: Name of the subscription\n required: true\n constraints: []\n metadata: {}\n administrativeState:\n name: administrativeState\n type: string\n typeVersion: 0.0.0\n description: State of the subscription\n required: true\n constraints:\n - valid_values:\n - LOCKED\n - UNLOCKED\n metadata: {}\n nfFilter:\n name: nfFilter\n type: map\n typeVersion: 0.0.0\n description: Network function filter\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.nfFilter\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.subscription\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\npolicy_types:\n onap.policies.Monitoring:\n derived_from: tosca.policies.Root\n description: a base policy type for all policies that govern monitoring provisioning\n version: 1.0.0\n name: onap.policies.Monitoring\n onap.policies.Sirisha:\n derived_from: tosca.policies.Root\n description: a base policy type for all policies that govern monitoring provisioning\n version: 1.0.0\n name: onap.policies.Sirisha\n onap.policies.monitoring.dcae-pm-subscription-handler:\n properties:\n pmsh_policy:\n name: pmsh_policy\n type: onap.datatypes.monitoring.subscription\n typeVersion: 0.0.0\n description: PMSH Policy JSON\n required: false\n constraints: []\n metadata: {}\n name: onap.policies.monitoring.dcae-pm-subscription-handler\n version: 1.0.0\n derived_from: onap.policies.Monitoring\n metadata: {}\n onap.policies.controlloop.operational.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n name: onap.policies.controlloop.operational.Common\n description: |\n Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\n Policy Types. This does NOT support the legacy Policy YAML policy type.\n properties:\n id:\n type: string\n description: The unique control loop id.\n required: true\n timeout:\n type: integer\n description: |\n Overall timeout for executing all the operations. This timeout should equal or exceed the total\n timeout for each operation listed.\n required: true\n abatement:\n type: boolean\n description: Whether an abatement event message will be expected for the control loop from DCAE.\n required: true\n default: false\n trigger:\n type: string\n description: Initial operation to execute upon receiving an Onset event message for the Control Loop.\n required: true\n operations:\n type: list\n description: List of operations to be performed when Control Loop is triggered.\n required: true\n entry_schema:\n type: onap.datatype.controlloop.Operation\n onap.policies.controlloop.operational.common.Apex:\n derived_from: onap.policies.controlloop.operational.Common\n type_version: 1.0.0\n version: 1.0.0\n name: onap.policies.controlloop.operational.common.Apex\n description: Operational policies for Apex PDP\n properties:\n engineServiceParameters:\n type: string\n description: The engine parameters like name, instanceCount, policy implementation, parameters etc.\n required: true\n eventInputParameters:\n type: string\n description: The event input parameters.\n required: true\n eventOutputParameters:\n type: string\n description: The event output parameters.\n required: true\n javaProperties:\n type: string\n description: Name/value pairs of properties to be set for APEX if needed.\n required: false\nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n dcae_blueprint_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: false\n dcae_blueprint:\n type: onap.dcae.cloudify_blueprint\n requred: false\n consul_info:\n type: list\n required: false\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo\n org.onap.policy.clamp.controlloop.PolicyControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n policy_type_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n policy_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: false\n org.onap.policy.clamp.controlloop.CDSControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n cds_blueprint_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\ntopology_template:\n inputs:\n pmsh_monitoring_policy:\n type: onap.datatypes.ToscaConceptIdentifier\n description: The ID of the PMSH monitoring policy to use\n default:\n name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n version: 1.0.0\n pmsh_operational_policy:\n type: onap.datatypes.ToscaConceptIdentifier\n description: The ID of the PMSH operational policy to use\n default:\n name: operational.apex.pmcontrol\n version: 1.0.0\n node_templates:\n org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for DCAE microservices\n properties:\n provider: ONAP\n org.onap.policy.controlloop.PolicyControlLoopParticipant:\n version: 2.3.1\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for DCAE microservices\n properties:\n provider: ONAP\n org.onap.domain.pmsh.PMSH_DCAEMicroservice:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the DCAE microservice for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n participant_id:\n name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant\n version: 2.3.4\n dcae_blueprint:\n tosca_definitions_version: cloudify_dsl_1_3\n imports:\n - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml\n - plugin:k8splugin?version=3.7.0\n - plugin:pgaas?version=1.3.0\n - plugin:clamppolicyplugin?version=1.1.0\n inputs:\n tag_version:\n type: string\n description: Docker image to be used\n default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2\n replicas:\n type: integer\n description: Number of instances\n default: 1\n operational_policy_name:\n type: string\n default: operational.apex.pmcontrol\n control_loop_name:\n type: string\n default: pmsh-control-loop\n pmsh_publish_topic_name:\n type: string\n default: unauthenticated.DCAE_CL_OUTPUT\n policy_feedback_topic_name:\n type: string\n default: unauthenticated.PMSH_CL_INPUT\n aai_notification_topic_name:\n type: string\n default: AAI-EVENT\n publisher_client_role:\n type: string\n description: Client role to request secure access to topic\n default: org.onap.dcae.pmPublisher\n subscriber_client_role:\n type: string\n description: Client role to request secure access to topic\n default: org.onap.dcae.pmSubscriber\n dcae_location:\n type: string\n description: DCAE location for the subscriber, used to set up routing\n default: san-francisco\n cpu_limit:\n type: string\n default: 1000m\n cpu_request:\n type: string\n default: 1000m\n memory_limit:\n type: string\n default: 1024Mi\n memory_request:\n type: string\n default: 1024Mi\n pgaas_cluster_name:\n type: string\n default: dcae-pg-primary.onap\n enable_tls:\n type: boolean\n default: true\n protocol:\n type: string\n description: PMSH protocol. If enable_tls is false, set to http\n default: https\n policy_model_id:\n type: string\n default: onap.policies.monitoring.dcae-pm-subscription-handler\n policy_id:\n type: string\n default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n node_templates:\n pgaasvm:\n type: dcae.nodes.pgaas.database\n properties:\n writerfqdn:\n get_input: pgaas_cluster_name\n name: pmsh\n pmsh:\n type: dcae.nodes.ContainerizedServiceComponentUsingDmaap\n interfaces:\n cloudify.interfaces.lifecycle:\n create:\n inputs:\n ports:\n - '8443:0'\n envs:\n PMSH_PG_URL:\n get_attribute:\n - pgaasvm\n - admin\n - host\n PMSH_PG_PASSWORD:\n get_attribute:\n - pgaasvm\n - admin\n - password\n PMSH_PG_USERNAME:\n get_attribute:\n - pgaasvm\n - admin\n - user\n PMSH_DB_NAME:\n get_attribute:\n - pgaasvm\n - admin\n - database\n relationships:\n - target: pmsh-policy\n type: cloudify.relationships.depends_on\n properties:\n service_component_type: dcae-pmsh\n service_component_name_override: dcae-pmsh\n application_config:\n enable_tls:\n get_input: enable_tls\n aaf_identity: dcae@dcae.onap.org\n aaf_password: demo123456!\n operational_policy_name:\n get_input: operational_policy_name\n control_loop_name:\n get_input: control_loop_name\n cert_path: /opt/app/pmsh/etc/certs/cert.pem\n key_path: /opt/app/pmsh/etc/certs/key.pem\n ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem\n streams_publishes:\n policy_pm_publisher:\n type: message_router\n dmaap_info:\n topic_url:\n concat:\n - http://message-router:3904/events/\n - get_input: pmsh_publish_topic_name\n streams_subscribes:\n policy_pm_subscriber:\n type: message_router\n dmaap_info:\n topic_url:\n concat:\n - http://message-router:3904/events/\n - get_input: policy_feedback_topic_name\n aai_subscriber:\n type: message_router\n dmaap_info:\n topic_url:\n concat:\n - http://message-router:3904/events/\n - get_input: aai_notification_topic_name\n resource_config:\n limits:\n cpu:\n get_input: cpu_limit\n memory:\n get_input: memory_limit\n requests:\n cpu:\n get_input: cpu_request\n memory:\n get_input: memory_request\n docker_config:\n healthcheck:\n endpoint: /healthcheck\n interval: 15s\n timeout: 1s\n type:\n get_input: protocol\n image:\n get_input: tag_version\n replicas:\n get_input: replicas\n log_info:\n log_directory: /var/log/ONAP/dcaegen2/services/pmsh\n tls_info:\n cert_directory: /opt/app/pmsh/etc/certs\n use_tls:\n get_input: enable_tls\n pmsh-policy:\n type: clamp.nodes.policy\n properties:\n policy_model_id:\n get_input: policy_model_id\n policy_id:\n get_input: policy_id\n consul_info:\n - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy\n consulBody:\n subscription:\n subscriptionName: subscriptiona\n administrativeState: UNLOCKED\n fileBasedGP: 15\n fileLocation: /pm/pm.xml\n nfFilter:\n nfNames:\n - ^pnf1.*\n modelInvariantIDs:\n - 5845y423-g654-6fju-po78-8n53154532k6\n - 7129e420-d396-4efb-af02-6b83499b12f8\n modelVersionIDs:\n - e80a6ae3-cafd-4d24-850d-e14c084a5ca9\n measurementGroups:\n - measurementGroup:\n measurementTypes:\n - measurementType: countera\n - measurementType: counterb\n managedObjectDNsBasic:\n - DN: dna\n - DN: dnb\n - measurementGroup:\n measurementTypes:\n - measurementType: counterc\n - measurementType: counterd\n managedObjectDNsBasic:\n - DN: dnc\n - DN: dnd\n org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the monitoring policy for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n participant_id:\n name: org.onap.policy.controlloop.PolicyControlLoopParticipant\n version: 2.3.1\n policy_type_id:\n name: onap.policies.monitoring.pm-subscription-handler\n version: 1.0.0\n policy_id:\n get_input: pmsh_monitoring_policy\n org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the operational policy for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n participant_id:\n name: org.onap.policy.controlloop.PolicyControlLoopParticipant\n version: 2.3.1\n policy_type_id:\n name: onap.policies.operational.pm-subscription-handler\n version: 1.0.0\n policy_id:\n get_input: pmsh_operational_policy\n org.onap.domain.pmsh.PMSHControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n elements:\n - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice\n version: 1.2.3\n - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement\n version: 1.2.3\n - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement\n version: 1.2.3\n policies:\n - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test:\n type: onap.policies.monitoring.dcae-pm-subscription-handler\n type_version: 1.0.0\n name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n version: 1.0.0\n metadata:\n policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n policy-version: 1.0.0\n properties:\n pmsh_policy:\n fileBasedGP: 15\n fileLocation: /pm/pm.xml\n subscriptionName: subscriptiona\n administrativeState: UNLOCKED\n nfFilter:\n onap.datatypes.monitoring.nfFilter:\n modelVersionIDs:\n - e80a6ae3-cafd-4d24-850d-e14c084a5ca9\n modelInvariantIDs:\n - 5845y423-g654-6fju-po78-8n53154532k6\n - 7129e420-d396-4efb-af02-6b83499b12f8\n modelNames: []\n nfNames:\n - '\"^pnf1.*\"'\n measurementGroups:\n - measurementGroup:\n onap.datatypes.monitoring.measurementGroup:\n measurementTypes:\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: countera\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: counterb\n managedObjectDNsBasic:\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dna\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dnb\n - measurementGroup:\n onap.datatypes.monitoring.measurementGroup:\n measurementTypes:\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: counterc\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: counterd\n managedObjectDNsBasic:\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dnc\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dnd\n - operational.apex.pmcontrol:\n type: onap.policies.controlloop.operational.common.Apex\n type_version: 1.0.0\n version: 1.0.0\n metadata:\n policy-id: operational.apex.pmcontrol\n policy-version: 1\n properties:\n engineServiceParameters:\n name: MyApexEngine\n version: 0.0.1\n id: 45\n instanceCount: 2\n deploymentPort: 12561\n policy_type_impl:\n apexPolicyModel:\n key:\n name: PMControlPolicy\n version: 0.0.1\n keyInformation:\n key:\n name: PMControlPolicy_KeyInfo\n version: 0.0.1\n keyInfoMap:\n entry:\n - key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n value:\n key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82\n description: Generated description for concept referred to by key \"CDSActionIdentifiersType:0.0.1\"\n - key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad\n description: Generated description for concept referred to by key \"CDSCreateResponseEvent:0.0.1\"\n - key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13\n description: Generated description for concept referred to by key \"CDSCreateResponsePayloadType:0.0.1\"\n - key:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c\n description: Generated description for concept referred to by key \"CDSCreateResponsePolicy:0.0.1\"\n - key:\n name: CDSCreateResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseTask\n version: 0.0.1\n UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2\n description: Generated description for concept referred to by key \"CDSCreateResponseTask:0.0.1\"\n - key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60\n description: Generated description for concept referred to by key \"CDSCreateSubscriptionPayloadType:0.0.1\"\n - key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2\n description: Generated description for concept referred to by key \"CDSCreateSubscriptionRequestEvent:0.0.1\"\n - key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8\n description: Generated description for concept referred to by key \"CDSDeleteResponseEvent:0.0.1\"\n - key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0\n description: Generated description for concept referred to by key \"CDSDeleteResponsePayloadType:0.0.1\"\n - key:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n UUID: a780251c-edd5-3132-b865-04313246b43c\n description: Generated description for concept referred to by key \"CDSDeleteResponsePolicy:0.0.1\"\n - key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc\n description: Generated description for concept referred to by key \"CDSDeleteResponseTask:0.0.1\"\n - key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b\n description: Generated description for concept referred to by key \"CDSDeleteSubscriptionPayloadType:0.0.1\"\n - key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9\n description: Generated description for concept referred to by key \"CDSDeleteSubscriptionRequestEvent:0.0.1\"\n - key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1\n description: Generated description for concept referred to by key \"CDSRequestCommonHeaderType:0.0.1\"\n - key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c\n description: Generated description for concept referred to by key \"CDSResponseCommonHeaderType:0.0.1\"\n - key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n UUID: 7986e21b-32f7-302e-9554-31f21b673493\n description: Generated description for concept referred to by key \"CDSResponseStatusEvent:0.0.1\"\n - key:\n name: CDSResponseStatusType\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusType\n version: 0.0.1\n UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa\n description: Generated description for concept referred to by key \"CDSResponseStatusType:0.0.1\"\n - key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a\n description: Generated description for concept referred to by key \"CreateSubscriptionPayloadEvent:0.0.1\"\n - key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d\n description: Generated description for concept referred to by key \"CreateSubscriptionPayloadTask:0.0.1\"\n - key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869\n description: Generated description for concept referred to by key \"CreateSubscriptionRequestTask:0.0.1\"\n - key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074\n description: Generated description for concept referred to by key \"DeleteSubscriptionPayloadEvent:0.0.1\"\n - key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n UUID: 0f519117-5fea-3e4b-941f-8f778100465f\n description: Generated description for concept referred to by key \"DeleteSubscriptionPayloadTask:0.0.1\"\n - key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n UUID: acb772fe-d442-39e3-98f9-b1080caf4150\n description: Generated description for concept referred to by key \"DeleteSubscriptionRequestTask:0.0.1\"\n - key:\n name: MRResponseEvent\n version: 0.0.1\n value:\n key:\n name: MRResponseEvent\n version: 0.0.1\n UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194\n description: Generated description for concept referred to by key \"MRResponseEvent:0.0.1\"\n - key:\n name: PMControlPolicy\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy\n version: 0.0.1\n UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4\n description: Generated description for concept referred to by key \"PMControlPolicy:0.0.1\"\n - key:\n name: PMControlPolicy_Albums\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Albums\n version: 0.0.1\n UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b\n description: Generated description for concept referred to by key \"PMControlPolicy_Albums:0.0.1\"\n - key:\n name: PMControlPolicy_Events\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Events\n version: 0.0.1\n UUID: be3871a0-c42a-3113-a066-82d192840eca\n description: Generated description for concept referred to by key \"PMControlPolicy_Events:0.0.1\"\n - key:\n name: PMControlPolicy_KeyInfo\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_KeyInfo\n version: 0.0.1\n UUID: ced37634-28a4-3178-b7f6-2980794927b0\n description: Generated description for concept referred to by key \"PMControlPolicy_KeyInfo:0.0.1\"\n - key:\n name: PMControlPolicy_Policies\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Policies\n version: 0.0.1\n UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed\n description: Generated description for concept referred to by key \"PMControlPolicy_Policies:0.0.1\"\n - key:\n name: PMControlPolicy_Schemas\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Schemas\n version: 0.0.1\n UUID: e61973f1-189c-39e5-82f6-0d3afe298a20\n description: Generated description for concept referred to by key \"PMControlPolicy_Schemas:0.0.1\"\n - key:\n name: PMControlPolicy_Tasks\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Tasks\n version: 0.0.1\n UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a\n description: Generated description for concept referred to by key \"PMControlPolicy_Tasks:0.0.1\"\n - key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n UUID: c2bd6f0d-6854-317a-9be2-97c08338428c\n description: Generated description for concept referred to by key \"PMSubscriptionAlbum:0.0.1\"\n - key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05\n description: Generated description for concept referred to by key \"PMSubscriptionOutputEvent:0.0.1\"\n - key:\n name: PMSubscriptionType\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionType\n version: 0.0.1\n UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae\n description: Generated description for concept referred to by key \"PMSubscriptionType:0.0.1\"\n - key:\n name: ReceiveEventPolicy\n version: 0.0.1\n value:\n key:\n name: ReceiveEventPolicy\n version: 0.0.1\n UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1\n description: Generated description for concept referred to by key \"ReceiveEventPolicy:0.0.1\"\n - key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n value:\n key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n UUID: f596afc8-100c-35eb-92c8-352355ea457d\n description: Generated description for concept referred to by key \"ReceiveSubscriptionTask:0.0.1\"\n - key:\n name: SimpleIntType\n version: 0.0.1\n value:\n key:\n name: SimpleIntType\n version: 0.0.1\n UUID: 153791fd-ae0a-36a7-88a5-309a7936415d\n description: Generated description for concept referred to by key \"SimpleIntType:0.0.1\"\n - key:\n name: SimpleStringType\n version: 0.0.1\n value:\n key:\n name: SimpleStringType\n version: 0.0.1\n UUID: 8a4957cf-9493-3a76-8c22-a208e23259af\n description: Generated description for concept referred to by key \"SimpleStringType:0.0.1\"\n - key:\n name: SubscriptionStatusType\n version: 0.0.1\n value:\n key:\n name: SubscriptionStatusType\n version: 0.0.1\n UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b\n description: Generated description for concept referred to by key \"SubscriptionStatusType:0.0.1\"\n - key:\n name: SubscriptionType\n version: 0.0.1\n value:\n key:\n name: SubscriptionType\n version: 0.0.1\n UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce\n description: Generated description for concept referred to by key \"SubscriptionType:0.0.1\"\n - key:\n name: UUIDType\n version: 0.0.1\n value:\n key:\n name: UUIDType\n version: 0.0.1\n UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c\n description: Generated description for concept referred to by key \"UUIDType:0.0.1\"\n - key:\n name: pmsh-operational-policy\n version: 0.0.1\n value:\n key:\n name: pmsh-operational-policy\n version: 0.0.1\n UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d\n description: Generated description for concept referred to by key \"pmsh-operational-policy:0.0.1\"\n policies:\n key:\n name: PMControlPolicy_Policies\n version: 0.0.1\n policyMap:\n entry:\n - key:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n value:\n policyKey:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n template: Freestyle\n state:\n entry:\n - key: CDSCreateResponseState\n value:\n stateKey:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CDSCreateResponseState\n trigger:\n name: CDSCreateResponseEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: ResponseOutput\n value:\n key:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSCreateResponseState\n localName: ResponseOutput\n outgoingEvent:\n name: CDSResponseStatusEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference: []\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CDSCreateResponseTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CDSCreateResponseTask\n version: 0.0.1\n value:\n key:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSCreateResponseState\n localName: CDSCreateResponsePolicy\n outputType: DIRECT\n output:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSCreateResponseState\n localName: ResponseOutput\n firstState: CDSCreateResponseState\n - key:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n value:\n policyKey:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n template: Freestyle\n state:\n entry:\n - key: CDSDeleteResponseState\n value:\n stateKey:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CDSDeleteResponseState\n trigger:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: ResponseOutput\n value:\n key:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSDeleteResponseState\n localName: ResponseOutput\n outgoingEvent:\n name: CDSResponseStatusEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference: []\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CDSDeleteResponseTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n value:\n key:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSDeleteResponseState\n localName: CDSDeleteResponsePolicy\n outputType: DIRECT\n output:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSDeleteResponseState\n localName: ResponseOutput\n firstState: CDSDeleteResponseState\n - key:\n name: ReceiveEventPolicy\n version: 0.0.1\n value:\n policyKey:\n name: ReceiveEventPolicy\n version: 0.0.1\n template: Freestyle\n state:\n entry:\n - key: CreateOrDeleteState\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateOrDeleteState\n trigger:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: CreateSubscriptionPayload\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: CreateSubscriptionPayload\n outgoingEvent:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n nextState:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateSubscription\n - key: DeleteSubscriptionPayload\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: DeleteSubscriptionPayload\n outgoingEvent:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n nextState:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: DeleteSubscription\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: TaskSelectionLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n var changeType = pmSubscriptionInfo.get(\"changeType\").toString()\n\n executor.logger.info(\"Change Type is \" + changeType)\n\n if (\"CREATE\".equals(changeType)) {\n executor.logger.info(\"Choosing to create a subscription\")\n executor.subject.getTaskKey(\"CreateSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n }\n else if (\"DELETE\".equals(changeType)) {\n executor.logger.info(\"Choosing to delete a subscription\")\n executor.subject.getTaskKey(\"DeleteSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n }\n\n //var returnValue = executor.isTrue;\n true;\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: CreateSubscriptionPayload\n - key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: DeleteSubscriptionPayload\n - key: CreateSubscription\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateSubscription\n trigger:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: IssueCreateSubscriptionRequestOutput\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateSubscription\n localName: IssueCreateSubscriptionRequestOutput\n outgoingEvent:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateSubscription\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateSubscription\n localName: IssueCreateSubscriptionRequestOutput\n - key: DeleteSubscription\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: DeleteSubscription\n trigger:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: IssueDeleteSubscriptionRequestOutput\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: DeleteSubscription\n localName: IssueDeleteSubscriptionRequestOutput\n outgoingEvent:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: DeleteSubscription\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: DeleteSubscription\n localName: IssueDeleteSubscriptionRequestOutput\n - key: ReceiveSubscriptionState\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: ReceiveSubscriptionState\n trigger:\n name: pmsh-operational-policy\n version: 0.0.1\n stateOutputs:\n entry:\n - key: ReceivePMSubscriptionOutput\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: ReceiveSubscriptionState\n localName: ReceivePMSubscriptionOutput\n outgoingEvent:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n nextState:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateOrDeleteState\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: ReceiveSubscriptionState\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: ReceiveSubscriptionState\n localName: ReceivePMSubscriptionOutput\n firstState: ReceiveSubscriptionState\n tasks:\n key:\n name: PMControlPolicy_Tasks\n version: 0.0.1\n taskMap:\n entry:\n - key:\n name: CDSCreateResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseTask\n version: 0.0.1\n inputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: SubscriptionStatusType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var commonHeader = executor.inFields.get(\"commonHeader\")\n var response = executor.inFields.get(\"payload\")\n var albumID = commonHeader.get(\"requestId\")\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\n var responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\n responseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n responseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n responseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\n var status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\n executor.logger.info(\"RESPONSE STATUS = \" + status)\n\n if(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n } else {\n responseStatus.put(\"message\", \"failed\")\n }\n\n executor.outFields.put(\"status\", responseStatus)\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n inputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: SubscriptionStatusType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var commonHeader = executor.inFields.get(\"commonHeader\")\n var response = executor.inFields.get(\"payload\")\n var albumID = commonHeader.get(\"requestId\")\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\n var responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\n responseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n responseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n responseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\n var status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\n executor.logger.info(\"RESPONSE STATUS = \" + status)\n\n if(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n } else {\n responseStatus.put(\"message\", \"failed\")\n }\n\n executor.outFields.put(\"status\", responseStatus)\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\n var payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\n payloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n payloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n payloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\n payloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\n payloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\n payloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\n var payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\n payloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\n var payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\n payload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\n executor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n var blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\n var blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\n var payload = executor.inFields.get(\"payload\")\n var actionName = changeType + \"-subscription\"\n\n var commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\n commonHeader.put(\"originatorId\", \"sdnc\");\n commonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\n commonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\n var actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\n actionIdentifiers.put(\"actionName\", actionName);\n actionIdentifiers.put(\"blueprintName\", blueprintName);\n actionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\n actionIdentifiers.put(\"mode\", \"sync\");\n\n executor.outFields.put(\"commonHeader\", commonHeader);\n executor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\n var payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\n payloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n payloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n payloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\n payloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\n payloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\n payloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\n var payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\n payloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\n var payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\n payload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\n executor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n var blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\n var blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\n var payload = executor.inFields.get(\"payload\")\n var actionName = changeType + \"-subscription\"\n\n var commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\n commonHeader.put(\"originatorId\", \"sdnc\");\n commonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\n commonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\n var actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\n actionIdentifiers.put(\"actionName\", actionName);\n actionIdentifiers.put(\"blueprintName\", blueprintName);\n actionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\n actionIdentifiers.put(\"mode\", \"sync\");\n\n executor.outFields.put(\"commonHeader\", commonHeader);\n executor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n value:\n key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n inputFields:\n entry:\n - key: blueprintName\n value:\n key: blueprintName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: blueprintVersion\n value:\n key: blueprintVersion\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: changeType\n value:\n key: changeType\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: closedLoopControlName\n value:\n key: closedLoopControlName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: nfName\n value:\n key: nfName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: policyName\n value:\n key: policyName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: subscription\n value:\n key: subscription\n fieldSchemaKey:\n name: SubscriptionType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n var uuidType = java.util.UUID;\n\n executor.logger.info(executor.subject.id);\n\n //albumID will be used to fetch info from our album later\n var albumID = uuidType.randomUUID();\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").getSchemaHelper().createNewInstance();\n var returnValue = true;\n\n if(executor.inFields.get(\"policyName\") != null) {\n executor.logger.info(\"nfName in receive sub event \" + executor.inFields.get(\"nfName\"));\n\n var changeType = executor.inFields.get(\"changeType\")\n var nfName = executor.inFields.get(\"nfName\")\n var policyName = executor.inFields.get(\"policyName\")\n var closedLoopControlName = executor.inFields.get(\"closedLoopControlName\")\n var subscription = executor.inFields.get(\"subscription\")\n var blueprintName = executor.inFields.get(\"blueprintName\")\n var blueprintVersion = executor.inFields.get(\"blueprintVersion\")\n\n pmSubscriptionInfo.put(\"nfName\", executor.inFields.get(\"nfName\"));\n pmSubscriptionInfo.put(\"changeType\", executor.inFields.get(\"changeType\"))\n pmSubscriptionInfo.put(\"policyName\", executor.inFields.get(\"policyName\"))\n pmSubscriptionInfo.put(\"closedLoopControlName\", executor.inFields.get(\"closedLoopControlName\"))\n pmSubscriptionInfo.put(\"subscription\", subscription)\n pmSubscriptionInfo.put(\"blueprintName\", blueprintName)\n pmSubscriptionInfo.put(\"blueprintVersion\", blueprintVersion)\n\n\n executor.getContextAlbum(\"PMSubscriptionAlbum\").put(albumID.toString(), pmSubscriptionInfo);\n\n executor.outFields.put(\"albumID\", albumID)\n } else {\n executor.message = \"Received invalid event\"\n returnValue = false;\n }\n\n returnValue;\n events:\n key:\n name: PMControlPolicy_Events\n version: 0.0.1\n eventMap:\n entry:\n - key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: CDS\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n - key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: CDS\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n - key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: DCAE\n parameter:\n entry:\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: SubscriptionStatusType\n version: 0.0.1\n optional: false\n - key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: MRResponseEvent\n version: 0.0.1\n value:\n key:\n name: MRResponseEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: DCAE\n target: APEX\n parameter:\n entry:\n - key: count\n value:\n key: count\n fieldSchemaKey:\n name: SimpleIntType\n version: 0.0.1\n optional: false\n - key: serverTimeMs\n value:\n key: serverTimeMs\n fieldSchemaKey:\n name: SimpleIntType\n version: 0.0.1\n optional: false\n - key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key:\n name: pmsh-operational-policy\n version: 0.0.1\n value:\n key:\n name: pmsh-operational-policy\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: DCAE\n target: APEX\n parameter:\n entry:\n - key: blueprintName\n value:\n key: blueprintName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: blueprintVersion\n value:\n key: blueprintVersion\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: changeType\n value:\n key: changeType\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: closedLoopControlName\n value:\n key: closedLoopControlName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: nfName\n value:\n key: nfName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: policyName\n value:\n key: policyName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: subscription\n value:\n key: subscription\n fieldSchemaKey:\n name: SubscriptionType\n version: 0.0.1\n optional: false\n albums:\n key:\n name: PMControlPolicy_Albums\n version: 0.0.1\n albums:\n entry:\n - key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n scope: policy\n isWritable: true\n itemSchema:\n name: PMSubscriptionType\n version: 0.0.1\n schemas:\n key:\n name: PMControlPolicy_Schemas\n version: 0.0.1\n schemas:\n entry:\n - key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n value:\n key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ActionIdentifiers_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"actionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"mode\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"name\": \"CreateResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n }\n - key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n - key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"name\": \"DeleteResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"com.acme.avro\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n }\n - key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n - key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"RequestCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ResponseCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"flags\",\n \"type\": [\"null\", \"string\"]\n }\n ]\n }\n - key:\n name: CDSResponseStatusType\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ResponseStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"code\",\n \"type\": \"int\"\n },\n {\n \"name\": \"eventType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: PMSubscriptionType\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: \"{\\n\\t\\\"name\\\": \\\"PMSubscription\\\",\\n\\t\\\"type\\\": \\\"record\\\",\\n\\t\\\"namespace\\\": \\\"\\\n org.onap.policy.apex.onap.pmcontrol\\\",\\n\\t\\\"fields\\\": [\\n {\\n \\\"name\\\": \\\"nfName\\\"\\\n ,\\n \\\"type\\\": \\\"string\\\"\\n },\\n\\t {\\n\\t\\t\\t\\\"name\\\": \\\"changeType\\\",\\n\\t\\t\\t\\\"\\\n type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"closedLoopControlName\\\",\\n\\t\\t\\t\\\"type\\\": \\\"\\\n string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"policyName\\\",\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t\\\n {\\n\\t\\t \\\"name\\\": \\\"blueprintName\\\",\\n\\t\\t \\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t \\\"name\\\"\\\n : \\\"blueprintVersion\\\",\\n\\t\\t \\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"subscription\\\"\\\n ,\\n\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\\"name\\\": \\\"subscription\\\",\\n\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\\n \\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"subscriptionName\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\\n \\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"administrativeState\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\\n \\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"fileBasedGP\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"int\\\"\\\n \\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"fileLocation\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\\n \\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementGroups\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\\n \\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Groups_Type\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\"\\\n : \\\"measurementGroup\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Group_Type\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\\"name\\\": \\\"measurementTypes\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"\\\n name\\\": \\\"Measurement_Types_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementType\\\",\\n\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"managedObjectDNsBasic\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\\"name\\\": \\\"Managed_Object_Dns_Basic_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"DN\\\",\\n\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t]\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t]\\n\\t\\t\\t}\\n\\t\\\n \\t}\\n\\t]\\n}\"\n - key:\n name: SimpleIntType\n version: 0.0.1\n value:\n key:\n name: SimpleIntType\n version: 0.0.1\n schemaFlavour: Java\n schemaDefinition: java.lang.Integer\n - key:\n name: SimpleStringType\n version: 0.0.1\n value:\n key:\n name: SimpleStringType\n version: 0.0.1\n schemaFlavour: Java\n schemaDefinition: java.lang.String\n - key:\n name: SubscriptionStatusType\n version: 0.0.1\n value:\n key:\n name: SubscriptionStatusType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ActivateSubscriptionStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"changeType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: SubscriptionType\n version: 0.0.1\n value:\n key:\n name: SubscriptionType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: \"{\\n\\t\\\"name\\\": \\\"subscription\\\",\\n\\t\\\"type\\\": \\\"record\\\",\\n\\t\\\"fields\\\": [{\\n\\t\\t\\\n \\t\\\"name\\\": \\\"subscriptionName\\\",\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"administrativeState\\\"\\\n ,\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"fileBasedGP\\\",\\n\\t\\t\\t\\\"type\\\": \\\"\\\n int\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"fileLocation\\\",\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t\\\n {\\n\\t\\t\\t\\\"name\\\": \\\"measurementGroups\\\",\\n\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\\n \\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Groups_Type\\\",\\n\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\\n \\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementGroup\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\\n \\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Group_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementTypes\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\"\\\n : {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\\"name\\\": \\\"Measurement_Types_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementType\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n }\\n\\t\\t\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"managedObjectDNsBasic\\\",\\n\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\"\\\n : {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Managed_Object_Dns_Basic_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"\\\n type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"DN\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t]\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t}\\n\\t\\\n \\t\\t}\\n\\t\\t}\\n\\t]\\n}\"\n - key:\n name: UUIDType\n version: 0.0.1\n value:\n key:\n name: UUIDType\n version: 0.0.1\n schemaFlavour: Java\n schemaDefinition: java.util.UUID\n engineParameters:\n executorParameters:\n JAVASCRIPT:\n parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters\n contextParameters:\n parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters\n schemaParameters:\n Avro:\n parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters\n Java:\n parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters\n jsonAdapters:\n Instant:\n adaptedClass: java.time.Instant\n adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter\n eventInputParameters:\n DCAEConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTCLIENT\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters\n parameters:\n consumerPollTime: '50'\n url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1\n eventProtocolParameters:\n eventProtocol: JSON\n parameters:\n nameAlias: policyName\n eventName: pmsh-operational-policy\n eventNameFilter: pmsh-operational-policy\n CDSRequestConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n parameters:\n url: http://10.10.10.184:30254/api/v1/execution-service/process\n httpMethod: POST\n restRequestTimeout: 2000\n httpHeaders:\n - - Authorization\n - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==\n eventProtocolParameters:\n eventProtocol: JSON\n eventName: CDSCreateResponseEvent\n eventNameFilter: CDSCreateResponseEvent\n requestorMode: true\n requestorPeer: CDSRequestProducer\n requestorTimeout: 500\n CDSDeleteRequestConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n parameters:\n url: http://10.10.10.184:30254/api/v1/execution-service/process\n httpMethod: POST\n restRequestTimeout: 2000\n httpHeaders:\n - - Authorization\n - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==\n eventProtocolParameters:\n eventProtocol: JSON\n eventName: CDSDeleteResponseEvent\n eventNameFilter: CDSDeleteResponseEvent\n requestorMode: true\n requestorPeer: CDSDeleteRequestProducer\n requestorTimeout: 500\n CDSReplyConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n parameters:\n url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT\n httpMethod: POST\n restRequestTimeout: 2000\n eventProtocolParameters:\n eventProtocol: JSON\n eventName: MRResponseEvent\n eventNameFilter: MRResponseEvent\n requestorMode: true\n requestorPeer: CDSReplyProducer\n requestorTimeout: 500\n eventOutputParameters:\n logOutputter:\n carrierTechnologyParameters:\n carrierTechnology: FILE\n parameters:\n fileName: /tmp/outputevents.log\n eventProtocolParameters:\n eventProtocol: JSON\n StdOutOutputter:\n carrierTechnologyParameters:\n carrierTechnology: FILE\n parameters:\n standardIo: true\n eventProtocolParameters:\n eventProtocol: JSON\n CDSRequestProducer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n eventProtocolParameters:\n eventProtocol: JSON\n eventNameFilter: CDSCreateSubscriptionRequestEvent\n requestorMode: true\n requestorPeer: CDSRequestConsumer\n requestorTimeout: 500\n CDSDeleteRequestProducer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n eventProtocolParameters:\n eventProtocol: JSON\n eventNameFilter: CDSDeleteSubscriptionRequestEvent\n requestorMode: true\n requestorPeer: CDSDeleteRequestConsumer\n requestorTimeout: 500\n CDSReplyProducer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n eventProtocolParameters:\n eventProtocol: JSON\n eventNameFilter: CDSResponseStatusEvent\n requestorMode: true\n requestorPeer: CDSReplyConsumer\n requestorTimeout: 500",
+ "options": {
+ "raw": {
+ "language": "text"
+ }
+ }
+ },
+ "url": {
+ "raw": "localhost:6969/onap/controlloop/v2/commission",
+ "host": [
+ "localhost"
+ ],
+ "port": "6969",
+ "path": [
+ "onap",
+ "controlloop",
+ "v2",
+ "commission"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Demo: Instantiation control loop definition (Full tosca try)",
+ "protocolProfileBehavior": {
+ "disabledSystemHeaders": {
+ "content-type": true
+ }
+ },
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "zb!XztG34",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "healthcheck",
+ "type": "string"
+ }
+ ]
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "X-ONAP-RequestID",
+ "value": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "type": "text"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "type": "text"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"controlLoopList\": [\n {\n \"name\": \"PMSHInstance0\",\n \"version\": \"1.0.1\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSHControlLoopDefinition\",\n \"version\": \"1.2.3\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"PMSH control loop instance 0\",\n \"elements\": {\n \"709c62b3-8918-41b9-a747-d21eb79c6c20\": {\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c20\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSH_DCAEMicroservice\",\n \"version\": \"1.2.3\"\n },\n \"participantType\": {\n \"name\": \"org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant\",\n \"version\": \"2.3.4\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"DCAE Control Loop Element for the PMSH instance 0 control loop\"\n },\n \"709c62b3-8918-41b9-a747-d21eb79c6c21\": {\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c21\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement\",\n \"version\": \"1.2.3\"\n },\n \"participantType\": {\n \"name\": \"org.onap.policy.controlloop.PolicyControlLoopParticipant\",\n \"version\": \"2.3.1\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"Monitoring Policy Control Loop Element for the PMSH instance 0 control loop\"\n },\n \"709c62b3-8918-41b9-a747-d21eb79c6c22\": {\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c22\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement\",\n \"version\": \"1.2.3\"\n },\n \"participantType\": {\n \"name\": \"org.onap.policy.controlloop.PolicyControlLoopParticipant\",\n \"version\": \"2.3.1\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"Operational Policy Control Loop Element for the PMSH instance 0 control loop\"\n }\n }\n }\n ]\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "localhost:6969/onap/controlloop/v2/instantiation",
+ "host": [
+ "localhost"
+ ],
+ "port": "6969",
+ "path": [
+ "onap",
+ "controlloop",
+ "v2",
+ "instantiation"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Demo: Instantiation control loop definition Command",
+ "protocolProfileBehavior": {
+ "disabledSystemHeaders": {
+ "content-type": true
+ }
+ },
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "zb!XztG34",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "healthcheck",
+ "type": "string"
+ }
+ ]
+ },
+ "method": "PUT",
+ "header": [
+ {
+ "key": "X-ONAP-RequestID",
+ "type": "text",
+ "value": "709c62b3-8918-41b9-a747-d21eb79c6c20"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"orderedState\": \"PASSIVE\",\n \"controlLoopIdentifierList\": [\n {\n \"name\": \"PMSHInstance0\",\n \"version\": \"1.0.1\"\n }\n ]\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "localhost:6969/onap/controlloop/v2/instantiation/command",
+ "host": [
+ "localhost"
+ ],
+ "port": "6969",
+ "path": [
+ "onap",
+ "controlloop",
+ "v2",
+ "instantiation",
+ "command"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Demo: Get PolicyTypes Policy API",
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "zb!XztG34",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "healthcheck",
+ "type": "string"
+ }
+ ]
+ },
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "localhost:6968/policy/api/v1/policytypes/onap.policies.Sirisha",
+ "host": [
+ "localhost"
+ ],
+ "port": "6968",
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.Sirisha"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Demo: Get Policies Policy API",
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "zb!XztG34",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "healthcheck",
+ "type": "string"
+ }
+ ]
+ },
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "localhost:6968/policy/api/v1/policies",
+ "host": [
+ "localhost"
+ ],
+ "port": "6968",
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policies"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Demo: Get instantiated control loops",
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "zb!XztG34",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "healthcheck",
+ "type": "string"
+ }
+ ]
+ },
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "localhost:6969/onap/controlloop/v2/instantiation",
+ "host": [
+ "localhost"
+ ],
+ "port": "6969",
+ "path": [
+ "onap",
+ "controlloop",
+ "v2",
+ "instantiation"
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+} \ No newline at end of file
diff --git a/common/src/test/resources/demo/config/PolicyAPIConfig.json b/common/src/test/resources/demo/config/PolicyAPIConfig.json
new file mode 100644
index 000000000..48e89c5dc
--- /dev/null
+++ b/common/src/test/resources/demo/config/PolicyAPIConfig.json
@@ -0,0 +1,53 @@
+{
+ "name": "ApiGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6968,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://localhost:3306/policyadmin",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "PolicyMariaDb"
+ },
+ "preloadPolicyTypes": [
+ "policytypes/onap.policies.monitoring.tcagen2.yaml",
+ "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml",
+ "policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml",
+ "policytypes/onap.policies.Optimization.yaml",
+ "policytypes/onap.policies.optimization.Resource.yaml",
+ "policytypes/onap.policies.optimization.Service.yaml",
+ "policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.DistancePolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.HpaPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.PciPolicy.yaml",
+ "policytypes/onap.policies.optimization.service.QueryPolicy.yaml",
+ "policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.Vim_fit.yaml",
+ "policytypes/onap.policies.optimization.resource.VnfPolicy.yaml",
+ "policytypes/onap.policies.controlloop.guard.Common.yaml",
+ "policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml",
+ "policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml",
+ "policytypes/onap.policies.controlloop.guard.common.MinMax.yaml",
+ "policytypes/onap.policies.controlloop.guard.common.Filter.yaml",
+ "policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml",
+ "policytypes/onap.policies.Naming.yaml",
+ "policytypes/onap.policies.Match.yaml",
+ "policytypes/onap.policies.native.Drools.yaml",
+ "policytypes/onap.policies.native.Xacml.yaml",
+ "policytypes/onap.policies.native.Apex.yaml",
+ "policytypes/onap.policies.controlloop.operational.Common.yaml",
+ "policytypes/onap.policies.controlloop.operational.common.Drools.yaml"
+ ],
+ "preloadPolicies" : [
+ "policies/sdnc.policy.naming.input.tosca.yaml"
+ ]
+}
diff --git a/common/src/test/resources/demo/config/PolicyParticipantConfig.json b/common/src/test/resources/demo/config/PolicyParticipantConfig.json
new file mode 100644
index 000000000..f02fbdd23
--- /dev/null
+++ b/common/src/test/resources/demo/config/PolicyParticipantConfig.json
@@ -0,0 +1,53 @@
+{
+ "name": "ControlLoopParticipantGroup",
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantType":{
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version":"2.3.1"
+ },
+ "participantId": {
+ "name": "org.onap.PM_Policy",
+ "version": "1.0.0"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://localhost:3306/policyadmin",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/common/src/test/resources/demo/config/RuntimeConfig.json b/common/src/test/resources/demo/config/RuntimeConfig.json
new file mode 100644
index 000000000..2c0127b16
--- /dev/null
+++ b/common/src/test/resources/demo/config/RuntimeConfig.json
@@ -0,0 +1,79 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://localhost:3306/controlloop",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "CommissioningMariaDb"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ },
+ "healthCheckRestClientParameters": [
+ {
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }
+ ]
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java
new file mode 100644
index 000000000..4ef9bdcd9
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import java.io.Serializable;
+import java.time.Instant;
+import java.util.UUID;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import lombok.ToString;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+@NoArgsConstructor
+@Data
+@ToString
+public class ClElementStatistics implements Serializable {
+
+ private static final long serialVersionUID = 3284285693112271055L;
+
+ @NonNull
+ private UUID id = UUID.randomUUID();
+
+ @NonNull
+ private ToscaConceptIdentifier participantId;
+
+ @NonNull
+ private Instant timeStamp;
+
+ @NonNull
+ private ControlLoopState controlLoopState;
+
+ private long clElementUptime;
+
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java
new file mode 100644
index 000000000..166f1e48f
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class ClElementStatisticsList {
+ private List<ClElementStatistics> clElementStatistics;
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java
new file mode 100644
index 000000000..d0d79274c
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java
@@ -0,0 +1,113 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
+
+/**
+ * Class to represent a control loop instance.
+ */
+@NoArgsConstructor
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop> {
+ @NonNull
+ private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
+
+ @NonNull
+ private ControlLoopState state = ControlLoopState.UNINITIALISED;
+
+ @NonNull
+ private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED;
+
+ private Map<UUID, ControlLoopElement> elements;
+
+ @Override
+ public String getType() {
+ return definition.getName();
+ }
+
+ @Override
+ public String getTypeVersion() {
+ return definition.getVersion();
+ }
+
+ /**
+ * Copy contructor, does a deep copy.
+ *
+ * @param otherControlLoop the other element to copy from
+ */
+ public ControlLoop(final ControlLoop otherControlLoop) {
+ super(otherControlLoop);
+ this.definition = new ToscaConceptIdentifier(otherControlLoop.definition);
+ this.state = otherControlLoop.state;
+ this.orderedState = otherControlLoop.orderedState;
+ this.elements = PfUtils.mapMap(otherControlLoop.elements, ControlLoopElement::new);
+ }
+
+ @Override
+ public int compareTo(final ControlLoop other) {
+ return compareNameVersion(this, other);
+ }
+
+ /**
+ * Set the ordered state on the control loop and on all its control loop elements.
+ *
+ * @param orderedState the state we want the control loop to transition to
+ */
+ public void setCascadedOrderedState(final ControlLoopOrderedState orderedState) {
+ this.orderedState = orderedState;
+
+ if (MapUtils.isEmpty(elements)) {
+ return;
+ }
+
+ elements.values().forEach(element -> element.setOrderedState(orderedState));
+ }
+
+ /**
+ * Get a list of control loop element statistics.
+ *
+ * @param controlLoop the control loop
+ * @return List of ClElementStatistics
+ */
+ public List<ClElementStatistics> getControlLoopElementStatisticsList(final ControlLoop controlLoop) {
+ if (MapUtils.isEmpty(controlLoop.elements)) {
+ return null;
+ }
+
+ return controlLoop.elements.values().stream().map(ControlLoopElement::getClElementStatistics)
+ .collect(Collectors.toList());
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
new file mode 100644
index 000000000..83f062c74
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import java.util.UUID;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import lombok.ToString;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to represent a control loop instance.
+ */
+@NoArgsConstructor
+@Data
+@ToString
+public class ControlLoopElement {
+ @NonNull
+ private UUID id = UUID.randomUUID();
+
+ @NonNull
+ private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
+
+ @NonNull
+ private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
+
+ @NonNull
+ private ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
+
+ @NonNull
+ private ControlLoopState state = ControlLoopState.UNINITIALISED;
+
+ @NonNull
+ private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED;
+
+ private String description;
+
+ private ClElementStatistics clElementStatistics;
+
+ /**
+ * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
+ *
+ * @param otherElement the other element to copy from
+ */
+ public ControlLoopElement(final ControlLoopElement otherElement) {
+ this.id = otherElement.id;
+ this.definition = new ToscaConceptIdentifier(otherElement.definition);
+ this.participantType = new ToscaConceptIdentifier(otherElement.participantType);
+ this.participantId = new ToscaConceptIdentifier(otherElement.participantId);
+ this.state = otherElement.state;
+ this.orderedState = otherElement.orderedState;
+ this.description = otherElement.description;
+ this.clElementStatistics = otherElement.clElementStatistics;
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java
new file mode 100644
index 000000000..91f90275e
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+public enum ControlLoopOrderedState {
+ /**
+ * The control loop or control loop element should become uninitialised on participants, it should not exist on
+ * participants.
+ */
+ UNINITIALISED,
+ /**
+ * The control loop or control loop element should initialised on the participants and be passive, that is, it is
+ * not handling control loop messages yet.
+ */
+ PASSIVE,
+ /** The control loop or control loop element should running and is executing control loops. */
+ RUNNING;
+
+ public boolean equalsControlLoopState(final ControlLoopState controlLoopState) {
+ return this.name().equals(controlLoopState.name());
+ }
+
+ public ControlLoopState asState() {
+ return ControlLoopState.valueOf(this.name());
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java
new file mode 100644
index 000000000..ff0d553af
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+public enum ControlLoopState {
+ /**
+ * The control loop or control loop element is not initialised on participants, it does not exist on participants.
+ */
+ UNINITIALISED,
+ /**
+ * The control loop or control loop element is changing from unitialised to passive, it is being initialised onto
+ * participants.
+ */
+ UNINITIALISED2PASSIVE,
+ /**
+ * The control loop or control loop element is initialised on the participants but is passive, that is, it is not
+ * handling control loop messages yet.
+ */
+ PASSIVE,
+ /**
+ * The control loop or control loop element is changing from passive to running, the participants are preparing to
+ * execute control loops.
+ */
+ PASSIVE2RUNNING,
+ /** The control loop or control loop element is running and is executing control loops. */
+ RUNNING,
+ /**
+ * The control loop or control loop element is completing execution of current control loops but will not start
+ * running any more control loops and will become passive.
+ */
+ RUNNING2PASSIVE,
+ /**
+ * The control loop or control loop element is changing from passive to unitialised, the control loop is being
+ * removed from participants.
+ */
+ PASSIVE2UNINITIALISED;
+
+ public boolean equalsControlLoopOrderedState(final ControlLoopOrderedState controlLoopOrderedState) {
+ return this.name().equals(controlLoopOrderedState.name());
+ }
+
+ public ControlLoopOrderedState asOrderedState() {
+ return ControlLoopOrderedState.valueOf(this.name());
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java
new file mode 100644
index 000000000..8edcc3c11
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java
@@ -0,0 +1,47 @@
+/*-
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
+
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.models.base.PfUtils;
+
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode
+public class ControlLoops {
+ private List<ControlLoop> controlLoopList;
+
+ /**
+ * Copy contructor, does a deep copy.
+ *
+ * @param otherControlLoops the other element to copy from
+ */
+ public ControlLoops(final ControlLoops otherControlLoops) {
+ this.controlLoopList = PfUtils.mapList(controlLoopList, ControlLoop::new);
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java
new file mode 100644
index 000000000..3130b6c2f
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java
@@ -0,0 +1,73 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
+
+/**
+ * Class to represent details of a running participant instance.
+ */
+@NoArgsConstructor
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class Participant extends ToscaEntity implements Comparable<Participant> {
+ @NonNull
+ private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
+
+ @NonNull
+ private ParticipantState participantState = ParticipantState.UNKNOWN;
+
+ @NonNull
+ private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN;
+
+ @Override
+ public String getType() {
+ return definition.getName();
+ }
+
+ @Override
+ public String getTypeVersion() {
+ return definition.getVersion();
+ }
+
+ @Override
+ public int compareTo(final Participant other) {
+ return compareNameVersion(this, other);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param otherParticipant the participant to copy from
+ */
+ public Participant(Participant otherParticipant) {
+ super(otherParticipant);
+ this.definition = new ToscaConceptIdentifier(otherParticipant.definition);
+ this.participantState = otherParticipant.participantState;
+ this.healthStatus = otherParticipant.healthStatus;
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java
new file mode 100644
index 000000000..0cf41c9cd
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java
@@ -0,0 +1,47 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+/**
+ * Class to hold the possible values for health status of Participant.
+ */
+public enum ParticipantHealthStatus {
+
+ /**
+ * Participant is healthy and working fine.
+ */
+ HEALTHY,
+
+ /**
+ * Participant is not healthy.
+ */
+ NOT_HEALTHY,
+
+ /**
+ * Participant is currently under test state and performing tests.
+ */
+ TEST_IN_PROGRESS,
+
+ /**
+ * The health status of the Participant is unknown.
+ */
+ UNKNOWN
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java
new file mode 100644
index 000000000..1af32660d
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+/**
+ * Class to hold the possible values for mode of participant.
+ */
+public enum ParticipantState {
+
+ /**
+ * Control Loop execution is unknown.
+ */
+ UNKNOWN,
+
+ /**
+ * Control Loop execution is always rejected.
+ */
+ PASSIVE,
+
+ /**
+ * Control Loop execution execution proceeds, but changes to domain state or context are not carried out. The
+ * participant returns an indication that it is running in SAFE mode together with the action it would have
+ * performed if it was operating in ACTIVE mode.
+ */
+ SAFE,
+
+ /**
+ * Control Loop execution execution proceeds and changes to domain and state are carried out in a test environment.
+ * The participant returns an indication that it is running in TEST mode together with the action it has performed
+ * on the test environment.
+ */
+ TEST,
+
+ /**
+ * Control Loop execution execution is executed in the live environment by the participant.
+ */
+ ACTIVE,
+
+ /**
+ * Control Loop execution execution is terminated and not available.
+ */
+ TERMINATED
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java
new file mode 100644
index 000000000..3a7b21fa1
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import java.io.Serializable;
+import java.time.Instant;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import lombok.ToString;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+@NoArgsConstructor
+@Data
+@ToString
+public class ParticipantStatistics implements Serializable {
+ private static final long serialVersionUID = 744036598792333124L;
+
+
+ @NonNull
+ private ToscaConceptIdentifier participantId;
+
+ @NonNull
+ private Instant timeStamp;
+
+ private ParticipantState state;
+ private ParticipantHealthStatus healthStatus;
+ private long eventCount;
+ private long lastExecutionTime;
+ private double averageExecutionTime;
+ private long upTime;
+ private long lastEnterTime;
+ private long lastStart;
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java
new file mode 100644
index 000000000..a69f96f85
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class ParticipantStatisticsList {
+ private List<ParticipantStatistics> statisticsList;
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java
new file mode 100644
index 000000000..c5ce99677
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java
@@ -0,0 +1,194 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.UUID;
+import javax.persistence.AttributeOverride;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import org.apache.commons.lang3.builder.CompareToBuilder;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.base.PfAuthorative;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceTimestampKey;
+import org.onap.policy.models.base.validation.annotations.VerifyKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to represent a controlloop element statistics in the database.
+ *
+ * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech)
+ */
+@Entity
+@Table(name = "ClElementStatistics")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@AllArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+public class JpaClElementStatistics extends PfConcept implements PfAuthorative<ClElementStatistics>, Serializable {
+
+ private static final long serialVersionUID = 621426717868738629L;
+
+ @EmbeddedId
+ @VerifyKey
+ @NotNull
+ private PfReferenceTimestampKey key = new PfReferenceTimestampKey();
+
+
+ @VerifyKey
+ @NotNull
+ // @formatter:off
+ @AttributeOverride(name = "name", column = @Column(name = "participant_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "participant_version"))
+ private PfConceptKey participantId;
+ // @formatter: on
+
+ @Column
+ @NotNull
+ private ControlLoopState state;
+
+ @Column
+ private long clElementUptime;
+
+
+ /**
+ * The Default Constructor creates a {@link JpaClElementStatistics} object with a null key.
+ */
+ public JpaClElementStatistics() {
+ this(new PfReferenceTimestampKey());
+ }
+
+
+ /**
+ * The Key Constructor creates a {@link JpaClElementStatistics} object with the given Reference Timestamp key.
+ *
+ * @param key the key
+ */
+ public JpaClElementStatistics(@NonNull final PfReferenceTimestampKey key) {
+ this(key, new PfConceptKey(), ControlLoopState.PASSIVE, 0L);
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaClElementStatistics} object with all mandatory fields.
+ *
+ * @param key the key
+ * @param participantId the TOSCA definition of the control loop element
+ */
+ public JpaClElementStatistics(@NonNull final PfReferenceTimestampKey key,
+ @NonNull final PfConceptKey participantId) {
+ this.key = key;
+ this.participantId = participantId;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public JpaClElementStatistics(@NonNull final JpaClElementStatistics copyConcept) {
+ super(copyConcept);
+ this.key = new PfReferenceTimestampKey(copyConcept.key);
+ this.participantId = new PfConceptKey(copyConcept.participantId);
+ this.state = copyConcept.state;
+ this.clElementUptime = copyConcept.clElementUptime;
+ }
+
+
+ /**
+ * Authorative constructor.
+ *
+ * @param authorativeConcept the authorative concept to copy from
+ */
+ public JpaClElementStatistics(@NonNull final ClElementStatistics authorativeConcept) {
+ this.fromAuthorative(authorativeConcept);
+ }
+
+
+
+ @Override
+ public ClElementStatistics toAuthorative() {
+ ClElementStatistics clElementStatistics = new ClElementStatistics();
+ clElementStatistics.setId(UUID.fromString(getKey().getReferenceKey().getLocalName()));
+ clElementStatistics.setTimeStamp(key.getInstant());
+ clElementStatistics.setParticipantId(new ToscaConceptIdentifier(participantId));
+ clElementStatistics.setControlLoopState(state);
+ clElementStatistics.setClElementUptime(clElementUptime);
+
+ return clElementStatistics;
+ }
+
+ @Override
+ public void fromAuthorative(@NonNull ClElementStatistics clElementStatistics) {
+ // @formatter:off
+ if (this.key == null || this.getKey().isNullKey()) {
+ this.setKey(new PfReferenceTimestampKey(clElementStatistics.getParticipantId().getName(),
+ clElementStatistics.getParticipantId().getVersion(), clElementStatistics.getId().toString(),
+ clElementStatistics.getTimeStamp()));
+ }
+ // @formatter:on
+ this.setParticipantId(clElementStatistics.getParticipantId().asConceptKey());
+ this.setState(clElementStatistics.getControlLoopState());
+ this.setClElementUptime(clElementStatistics.getClElementUptime());
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ return getKey().getKeys();
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+ participantId.clean();
+ }
+
+
+ @Override
+ public int compareTo(PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return getClass().getName().compareTo(otherConcept.getClass().getName());
+ }
+
+ final JpaClElementStatistics other = (JpaClElementStatistics) otherConcept;
+ return new CompareToBuilder().append(this.key, other.key).append(this.state, other.state)
+ .append(this.clElementUptime, other.clElementUptime).toComparison();
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
new file mode 100644
index 000000000..cac405abd
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
@@ -0,0 +1,258 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.UUID;
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import org.apache.commons.lang3.ObjectUtils;
+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.ControlLoopOrderedState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
+import org.onap.policy.models.base.PfAuthorative;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.base.validation.annotations.VerifyKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to represent a control loop in the database.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ControlLoop")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLoop> {
+ private static final long serialVersionUID = -4725410933242154805L;
+
+ @EmbeddedId
+ @VerifyKey
+ @NotNull
+ private PfConceptKey key;
+
+ // @formatter:off
+ @VerifyKey
+ @NotNull
+ @AttributeOverrides({
+ @AttributeOverride(name = "name", column = @Column(name = "definition_name")),
+ @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
+ }
+ )
+ private PfConceptKey definition;
+ // @formatter:on
+
+ @Column
+ @NotNull
+ private ControlLoopState state;
+
+ @Column
+ @NotNull
+ private ControlLoopOrderedState orderedState;
+
+ @Column
+ private String description;
+
+ // @formatter:off
+ @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
+ @NotNull
+ private Map<@NotNull UUID, @NotNull @Valid JpaControlLoopElement> elements;
+
+ /**
+ * The Default Constructor creates a {@link JpaControlLoop} object with a null key.
+ */
+ public JpaControlLoop() {
+ this(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaControlLoop} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public JpaControlLoop(@NonNull final PfConceptKey key) {
+ this(key, new PfConceptKey(), ControlLoopState.UNINITIALISED, new LinkedHashMap<>());
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaControlLoop} object with all mandatory fields.
+ *
+ * @param key the key
+ * @param definition the TOSCA definition of the control loop
+ * @param state the state of the control loop
+ * @param elements the elements of the control looop in participants
+ */
+ public JpaControlLoop(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition,
+ @NonNull final ControlLoopState state, @NonNull final Map<UUID, JpaControlLoopElement> elements) {
+ this.key = key;
+ this.definition = definition;
+ this.state = state;
+ this.elements = elements;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public JpaControlLoop(@NonNull final JpaControlLoop copyConcept) {
+ super(copyConcept);
+ this.key = new PfConceptKey(copyConcept.key);
+ this.definition = new PfConceptKey(copyConcept.definition);
+ this.state = copyConcept.state;
+ this.orderedState = copyConcept.orderedState;
+ this.description = copyConcept.description;
+ this.elements = PfUtils.mapMap(copyConcept.elements, JpaControlLoopElement::new, new LinkedHashMap<>(0));
+ }
+
+ /**
+ * Authorative constructor.
+ *
+ * @param authorativeConcept the authorative concept to copy from
+ */
+ public JpaControlLoop(@NonNull final ControlLoop authorativeConcept) {
+ this.fromAuthorative(authorativeConcept);
+ }
+
+ @Override
+ public ControlLoop toAuthorative() {
+ ControlLoop controlLoop = new ControlLoop();
+
+ controlLoop.setName(getKey().getName());
+ controlLoop.setVersion(getKey().getVersion());
+ controlLoop.setDefinition(new ToscaConceptIdentifier(definition));
+ controlLoop.setState(state);
+ controlLoop.setOrderedState(orderedState != null ? orderedState : state.asOrderedState());
+ controlLoop.setDescription(description);
+ controlLoop.setElements(PfUtils.mapMap(elements, JpaControlLoopElement::toAuthorative, new LinkedHashMap<>(0)));
+
+ return controlLoop;
+ }
+
+ @Override
+ public void fromAuthorative(@NonNull final ControlLoop controlLoop) {
+ if (this.key == null || this.getKey().isNullKey()) {
+ this.setKey(new PfConceptKey(controlLoop.getName(), controlLoop.getVersion()));
+ }
+
+ this.definition = controlLoop.getDefinition().asConceptKey();
+ this.state = controlLoop.getState();
+ this.orderedState = controlLoop.getOrderedState();
+ this.description = controlLoop.getDescription();
+
+ this.elements = new LinkedHashMap<>(controlLoop.getElements().size());
+ for (Entry<UUID, ControlLoopElement> elementEntry : controlLoop.getElements().entrySet()) {
+ JpaControlLoopElement jpaControlLoopElement = new JpaControlLoopElement();
+ jpaControlLoopElement.setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString()));
+ jpaControlLoopElement.fromAuthorative(elementEntry.getValue());
+ this.elements.put(elementEntry.getKey(), jpaControlLoopElement);
+ }
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ List<PfKey> keyList = getKey().getKeys();
+
+ keyList.add(definition);
+
+ for (JpaControlLoopElement element : elements.values()) {
+ keyList.addAll(element.getKeys());
+ }
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+ definition.clean();
+ description = (description == null ? null : description.trim());
+
+ for (JpaControlLoopElement element : elements.values()) {
+ element.clean();
+ }
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.getClass().getName().compareTo(otherConcept.getClass().getName());
+ }
+
+ final JpaControlLoop other = (JpaControlLoop) otherConcept;
+ int result = key.compareTo(other.key);
+ if (result != 0) {
+ return result;
+ }
+
+ result = definition.compareTo(other.definition);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(state, other.state);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(orderedState, other.orderedState);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(description, other.description);
+ if (result != 0) {
+ return result;
+ }
+
+ return PfUtils.compareObjects(elements, other.elements);
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java
new file mode 100644
index 000000000..911a52089
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java
@@ -0,0 +1,251 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import java.util.List;
+import java.util.UUID;
+import javax.persistence.AttributeOverride;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.base.PfAuthorative;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.validation.annotations.VerifyKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to represent a participant control loop element in the database.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ControlLoopElement")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class JpaControlLoopElement extends PfConcept implements PfAuthorative<ControlLoopElement> {
+ private static final long serialVersionUID = -1791732273187890213L;
+
+ @EmbeddedId
+ @VerifyKey
+ @NotNull
+ private PfReferenceKey key;
+
+ // @formatter:off
+ @VerifyKey
+ @NotNull
+ @AttributeOverride(name = "name", column = @Column(name = "definition_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
+ private PfConceptKey definition;
+
+ @VerifyKey
+ @NotNull
+ @AttributeOverride(name = "name", column = @Column(name = "participant_type_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "participant_type_version"))
+ private PfConceptKey participantType;
+
+ @NotNull
+ @AttributeOverride(name = "name", column = @Column(name = "participant_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "participant_version"))
+ private PfConceptKey participantId;
+ // @formatter:on
+
+ @Column
+ @NotNull
+ private ControlLoopState state;
+
+ @Column
+ @NotNull
+ private ControlLoopOrderedState orderedState;
+
+ @Column
+ private String description;
+
+ /**
+ * The Default Constructor creates a {@link JpaControlLoopElement} object with a null key.
+ */
+ public JpaControlLoopElement() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaControlLoopElement} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public JpaControlLoopElement(@NonNull final PfReferenceKey key) {
+ this(key, new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED);
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaControlLoopElement} object with all mandatory fields.
+ *
+ * @param key the key
+ * @param definition the TOSCA definition of the control loop element
+ * @param participantType the TOSCA definition of the participant running the control loop element
+ * @param state the state of the control loop
+ */
+ public JpaControlLoopElement(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey definition,
+ @NonNull final PfConceptKey participantType, @NonNull final ControlLoopState state) {
+ this.key = key;
+ this.definition = definition;
+ this.participantType = participantType;
+ this.state = state;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public JpaControlLoopElement(@NonNull final JpaControlLoopElement copyConcept) {
+ super(copyConcept);
+ this.key = new PfReferenceKey(copyConcept.key);
+ this.definition = new PfConceptKey(copyConcept.definition);
+ this.participantType = new PfConceptKey(copyConcept.participantType);
+ this.participantId = new PfConceptKey(copyConcept.participantId);
+ this.state = copyConcept.state;
+ this.orderedState = copyConcept.orderedState;
+ this.description = copyConcept.description;
+ }
+
+ /**
+ * Authorative constructor.
+ *
+ * @param authorativeConcept the authorative concept to copy from
+ */
+ public JpaControlLoopElement(@NonNull final ControlLoopElement authorativeConcept) {
+ this.fromAuthorative(authorativeConcept);
+ }
+
+ @Override
+ public ControlLoopElement toAuthorative() {
+ ControlLoopElement element = new ControlLoopElement();
+
+ element.setId(UUID.fromString(getKey().getLocalName()));
+ element.setDefinition(new ToscaConceptIdentifier(definition));
+ element.setParticipantType(new ToscaConceptIdentifier(participantType));
+ element.setParticipantId(new ToscaConceptIdentifier(participantId));
+ element.setState(state);
+ element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState());
+ element.setDescription(description);
+
+ return element;
+ }
+
+ @Override
+ public void fromAuthorative(@NonNull final ControlLoopElement element) {
+ if (this.key == null || this.getKey().isNullKey()) {
+ this.setKey(new PfReferenceKey());
+ getKey().setLocalName(element.getId().toString());
+ }
+
+ this.definition = element.getDefinition().asConceptKey();
+ this.participantType = element.getParticipantType().asConceptKey();
+ this.participantId = element.getParticipantId().asConceptKey();
+ this.state = element.getState();
+ this.orderedState = element.getOrderedState();
+ this.description = element.getDescription();
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ List<PfKey> keyList = getKey().getKeys();
+
+ keyList.add(definition);
+ keyList.add(participantType);
+ keyList.add(participantId);
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+ definition.clean();
+ participantType.clean();
+ participantId.clean();
+
+ if (description != null) {
+ description = description.trim();
+ }
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.getClass().getName().compareTo(otherConcept.getClass().getName());
+ }
+
+ final JpaControlLoopElement other = (JpaControlLoopElement) otherConcept;
+ int result = key.compareTo(other.key);
+ if (result != 0) {
+ return result;
+ }
+
+ result = definition.compareTo(other.definition);
+ if (result != 0) {
+ return result;
+ }
+
+ result = participantType.compareTo(other.participantType);
+ if (result != 0) {
+ return result;
+ }
+
+ result = participantId.compareTo(other.participantId);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(state, other.state);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(orderedState, other.orderedState);
+ if (result != 0) {
+ return result;
+ }
+
+ return ObjectUtils.compare(description, other.description);
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
new file mode 100644
index 000000000..69b565266
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
@@ -0,0 +1,220 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import org.apache.commons.lang3.ObjectUtils;
+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.common.parameters.annotations.NotNull;
+import org.onap.policy.models.base.PfAuthorative;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.validation.annotations.VerifyKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to represent a participant in the database.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "Participant")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class JpaParticipant extends PfConcept implements PfAuthorative<Participant>, Serializable {
+ private static final long serialVersionUID = -4697758484642403483L;
+
+ @EmbeddedId
+ @VerifyKey
+ @NotNull
+ private PfConceptKey key;
+
+ // @formatter:off
+ @VerifyKey
+ @NotNull
+ @AttributeOverrides({
+ @AttributeOverride(name = "name", column = @Column(name = "definition_name")),
+ @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
+ }
+ )
+ private PfConceptKey definition;
+ // @formatter:on
+
+ @Column
+ @NotNull
+ private ParticipantState participantState;
+
+ @Column
+ @NotNull
+ private ParticipantHealthStatus healthStatus;
+
+ @Column
+ private String description;
+
+ /**
+ * The Default Constructor creates a {@link JpaParticipant} object with a null key.
+ */
+ public JpaParticipant() {
+ this(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaParticipant} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public JpaParticipant(@NonNull final PfConceptKey key) {
+ this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.UNKNOWN);
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaParticipant} object with all mandatory fields.
+ *
+ * @param key the key
+ * @param definition the TOSCA definition of the participant
+ * @param participantState the state of the participant
+ * @param healthStatus the health state of the participant
+ */
+ public JpaParticipant(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition,
+ @NonNull final ParticipantState participantState, @NonNull ParticipantHealthStatus healthStatus) {
+ this.key = key;
+ this.definition = definition;
+ this.participantState = participantState;
+ this.healthStatus = healthStatus;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public JpaParticipant(@NonNull final JpaParticipant copyConcept) {
+ super(copyConcept);
+ this.key = new PfConceptKey(copyConcept.key);
+ this.definition = new PfConceptKey(copyConcept.definition);
+ this.participantState = copyConcept.participantState;
+ this.healthStatus = copyConcept.healthStatus;
+ this.description = copyConcept.description;
+ }
+
+ /**
+ * Authorative constructor.
+ *
+ * @param authorativeConcept the authorative concept to copy from
+ */
+ public JpaParticipant(@NonNull final Participant authorativeConcept) {
+ this.fromAuthorative(authorativeConcept);
+ }
+
+ @Override
+ public Participant toAuthorative() {
+ Participant participant = new Participant();
+
+ participant.setName(key.getName());
+ participant.setVersion(key.getVersion());
+ participant.setDefinition(new ToscaConceptIdentifier(definition));
+ participant.setParticipantState(participantState);
+ participant.setHealthStatus(healthStatus);
+ participant.setDescription(description);
+
+ return participant;
+ }
+
+ @Override
+ public void fromAuthorative(@NonNull final Participant participant) {
+ if (this.key == null || this.getKey().isNullKey()) {
+ this.setKey(new PfConceptKey(participant.getName(), participant.getVersion()));
+ }
+
+ this.definition = participant.getDefinition().asConceptKey();
+ this.setParticipantState(participant.getParticipantState());
+ this.setHealthStatus(participant.getHealthStatus());
+ this.setDescription(participant.getDescription());
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ List<PfKey> keyList = getKey().getKeys();
+
+ keyList.add(definition);
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+ definition.clean();
+ description = (description == null ? null : description.trim());
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return getClass().getName().compareTo(otherConcept.getClass().getName());
+ }
+
+ final JpaParticipant other = (JpaParticipant) otherConcept;
+ int result = key.compareTo(other.key);
+ if (result != 0) {
+ return result;
+ }
+
+ result = definition.compareTo(other.definition);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(participantState, other.participantState);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(healthStatus, other.healthStatus);
+ if (result != 0) {
+ return result;
+ }
+
+ return ObjectUtils.compare(description, other.description);
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java
new file mode 100644
index 000000000..b97f9ed69
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java
@@ -0,0 +1,237 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.persistence.AttributeOverride;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import org.apache.commons.lang3.builder.CompareToBuilder;
+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.common.parameters.annotations.NotNull;
+import org.onap.policy.models.base.PfAuthorative;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfTimestampKey;
+import org.onap.policy.models.base.validation.annotations.VerifyKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to represent a control loop statistics in the database.
+ *
+ * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech)
+ */
+@Entity
+@Table(name = "ParticipantStatistics")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@AllArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+public class JpaParticipantStatistics extends PfConcept implements PfAuthorative<ParticipantStatistics>, Serializable {
+
+ private static final long serialVersionUID = -5992214428190133190L;
+
+ @EmbeddedId
+ @VerifyKey
+ @NotNull
+ private PfTimestampKey key;
+
+ @VerifyKey
+ @NotNull
+ @AttributeOverride(name = "name", column = @Column(name = "participant_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "participant_version"))
+ private PfConceptKey participantId;
+
+ @Column
+ @NotNull
+ private ParticipantState state;
+
+ @Column
+ @NotNull
+ private ParticipantHealthStatus healthStatus;
+
+ @Column
+ private long eventCount;
+
+ @Column
+ private long lastExecutionTime;
+
+ @Column
+ private double averageExecutionTime;
+
+ @Column
+ private long upTime;
+
+ @Column
+ private long lastEnterTime;
+
+ @Column
+ private long lastStart;
+
+
+ /**
+ * The Default Constructor creates a {@link JpaParticipantStatistics} object with a null key.
+ */
+ public JpaParticipantStatistics() {
+ this(new PfTimestampKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaParticipantStatistics} object with the given Timestamp key.
+ *
+ * @param key the key
+ */
+ public JpaParticipantStatistics(@NonNull final PfTimestampKey key) {
+ this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.HEALTHY, 0L, 0L, 0.0d, 0L, 0L,
+ 0L);
+ }
+
+
+ /**
+ * The Key Constructor creates a {@link JpaParticipantStatistics} object with all mandatory fields.
+ *
+ * @param key the key
+ * @param participantId the TOSCA definition of the control loop participant
+ */
+ public JpaParticipantStatistics(@NonNull final PfTimestampKey key, @NonNull final PfConceptKey participantId) {
+ this.key = key;
+ this.participantId = participantId;
+ }
+
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public JpaParticipantStatistics(@NonNull final JpaParticipantStatistics copyConcept) {
+ super(copyConcept);
+ this.key = new PfTimestampKey(copyConcept.key);
+ this.participantId = new PfConceptKey(copyConcept.participantId);
+ this.state = copyConcept.state;
+ this.healthStatus = copyConcept.healthStatus;
+ this.eventCount = copyConcept.eventCount;
+ this.lastExecutionTime = copyConcept.lastExecutionTime;
+ this.averageExecutionTime = copyConcept.averageExecutionTime;
+ this.upTime = copyConcept.upTime;
+ this.lastEnterTime = copyConcept.lastEnterTime;
+ this.lastStart = copyConcept.lastStart;
+ }
+
+ /**
+ * Authorative constructor.
+ *
+ * @param authorativeConcept the authorative concept to copy from
+ */
+ public JpaParticipantStatistics(@NonNull final ParticipantStatistics authorativeConcept) {
+ this.fromAuthorative(authorativeConcept);
+ }
+
+
+ @Override
+ public int compareTo(PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return getClass().getName().compareTo(otherConcept.getClass().getName());
+ }
+
+ final JpaParticipantStatistics other = (JpaParticipantStatistics) otherConcept;
+ // @formatter:off
+ return new CompareToBuilder()
+ .append(this.key, other.key)
+ .append(this.participantId, other.participantId)
+ .append(this.state, other.state)
+ .append(this.healthStatus, other.healthStatus)
+ .append(this.eventCount, other.eventCount)
+ .append(this.lastExecutionTime, other.lastExecutionTime)
+ .append(this.averageExecutionTime, other.averageExecutionTime)
+ .append(this.upTime, other.upTime)
+ .append(this.lastEnterTime, other.lastEnterTime)
+ .append(this.lastStart, other.lastStart).toComparison();
+ // @formatter:on
+ }
+
+ @Override
+ public ParticipantStatistics toAuthorative() {
+ ParticipantStatistics participantStatistics = new ParticipantStatistics();
+ participantStatistics.setTimeStamp(key.getTimeStamp().toInstant());
+ participantStatistics.setParticipantId(new ToscaConceptIdentifier(participantId));
+ participantStatistics.setState(state);
+ participantStatistics.setHealthStatus(healthStatus);
+ participantStatistics.setAverageExecutionTime(averageExecutionTime);
+ participantStatistics.setEventCount(eventCount);
+ participantStatistics.setLastExecutionTime(lastExecutionTime);
+ participantStatistics.setUpTime(upTime);
+ participantStatistics.setLastEnterTime(lastEnterTime);
+ participantStatistics.setLastStart(lastStart);
+
+ return participantStatistics;
+ }
+
+ @Override
+ public void fromAuthorative(@NonNull final ParticipantStatistics participantStatistics) {
+ if (this.key == null || this.getKey().isNullKey()) {
+ this.setKey(new PfTimestampKey(participantStatistics.getParticipantId().getName(),
+ participantStatistics.getParticipantId().getVersion(), participantStatistics.getTimeStamp()));
+ }
+ this.setParticipantId(participantStatistics.getParticipantId().asConceptKey());
+ this.setState(participantStatistics.getState());
+ this.setHealthStatus(participantStatistics.getHealthStatus());
+ this.setAverageExecutionTime(participantStatistics.getAverageExecutionTime());
+ this.setEventCount(participantStatistics.getEventCount());
+ this.setLastExecutionTime(participantStatistics.getLastExecutionTime());
+ this.setUpTime(participantStatistics.getUpTime());
+ this.setLastEnterTime(participantStatistics.getLastEnterTime());
+ this.setLastStart(participantStatistics.getLastStart());
+
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ List<PfKey> keyList = getKey().getKeys();
+ keyList.addAll(participantId.getKeys());
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+ participantId.clean();
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
new file mode 100644
index 000000000..8a06cbf1e
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
@@ -0,0 +1,154 @@
+/*-
+ * ============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.models.controlloop.persistence.provider;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import javax.ws.rs.core.Response;
+import lombok.NonNull;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.base.PfReferenceTimestampKey;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.provider.impl.AbstractModelsProvider;
+
+/**
+ * This class provides the provision of information on control loop element statistics in the database to callers.
+ *
+ * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech)
+ */
+public class ClElementStatisticsProvider extends AbstractModelsProvider {
+
+ /**
+ * Create a provider for control loop element statistics.
+ *
+ * @param parameters the parameters for database access
+ * @throws PfModelException on initiation errors
+ */
+ public ClElementStatisticsProvider(@NonNull PolicyModelsProviderParameters parameters) throws PfModelException {
+ super(parameters);
+ this.init();
+ }
+
+ /**
+ * Creates control loop element statistics.
+ *
+ * @param clElementStatisticsList a specification of the CL element statistics to create
+ * @return the clElement statistics created
+ * @throws PfModelException on errors creating clElement statistics
+ */
+ public List<ClElementStatistics> createClElementStatistics(
+ @NonNull final List<ClElementStatistics> clElementStatisticsList) throws PfModelException {
+
+ BeanValidationResult validationResult =
+ new BeanValidationResult("control loop element statistics list", clElementStatisticsList);
+ for (ClElementStatistics clElementStatistics : clElementStatisticsList) {
+ JpaClElementStatistics jpaClElementStatistics = new JpaClElementStatistics();
+ jpaClElementStatistics.fromAuthorative(clElementStatistics);
+
+ validationResult.addResult(jpaClElementStatistics.validate("control loop element statistics"));
+ }
+
+ if (!validationResult.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
+
+ for (ClElementStatistics clElementStatistics : clElementStatisticsList) {
+ JpaClElementStatistics jpaClElementStatistics = new JpaClElementStatistics();
+ jpaClElementStatistics.fromAuthorative(clElementStatistics);
+ getPfDao().create(jpaClElementStatistics);
+ }
+
+ // Return the created control loop element statistics
+ List<ClElementStatistics> elementStatistics = new ArrayList<>(clElementStatisticsList.size());
+
+ for (ClElementStatistics clElementStat : clElementStatisticsList) {
+ JpaClElementStatistics jpaClElementStatistics = getPfDao().get(JpaClElementStatistics.class,
+ new PfReferenceTimestampKey(clElementStat.getParticipantId().getName(),
+ clElementStat.getParticipantId().getVersion(), clElementStat.getId().toString(),
+ clElementStat.getTimeStamp()));
+ elementStatistics.add(jpaClElementStatistics.toAuthorative());
+ }
+
+ return elementStatistics;
+ }
+
+ /**
+ * Convert JPA clElement statistics list to clElement statistics list.
+ *
+ * @param jpaClElementStatistics the list to convert
+ * @return the clElement statistics list
+ */
+ private List<ClElementStatistics> asClElementStatisticsList(List<JpaClElementStatistics> jpaClElementStatistics) {
+ return jpaClElementStatistics.stream().map(JpaClElementStatistics::toAuthorative).collect(Collectors.toList());
+ }
+
+ /**
+ * Get clElement statistics.
+ *
+ * @param name the name of the participant
+ * @param version version of the participant
+ * @param id of the control loop element
+ * @param timestamp timestamp of the statistics
+ * @return the clElement statistics found
+ * @throws PfModelException on errors getting clElement statistics
+ */
+ public List<ClElementStatistics> getClElementStatistics(final String name, final String version, final String id,
+ final Instant timestamp) throws PfModelException {
+ List<ClElementStatistics> clElementStatistics = new ArrayList<>(1);
+ if (name != null && version != null && timestamp != null && id != null) {
+ clElementStatistics.add(getPfDao()
+ .get(JpaClElementStatistics.class, new PfReferenceTimestampKey(name, version, id, timestamp))
+ .toAuthorative());
+ return clElementStatistics;
+ } else if (name != null) {
+ clElementStatistics.addAll(getFilteredClElementStatistics(name, version, null, null, null,
+ "DESC", 0));
+ } else {
+ clElementStatistics.addAll(asClElementStatisticsList(getPfDao().getAll(JpaClElementStatistics.class)));
+ }
+ return clElementStatistics;
+ }
+
+ /**
+ * Get filtered clElement statistics.
+ *
+ * @param name the clElement name for the statistics to get
+ * @param startTimeStamp startTimeStamp to filter statistics
+ * @param endTimeStamp endTimeStamp to filter statistics
+ * @param sortOrder sortOrder to query database
+ * @param getRecordNum Total query count from database
+ * @return the clElement statistics found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ClElementStatistics> getFilteredClElementStatistics(final String name, final String version,
+ final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap,
+ final String sortOrder, final int getRecordNum) {
+ return asClElementStatisticsList(getPfDao().getFiltered(JpaClElementStatistics.class, name, version,
+ startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum));
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
new file mode 100644
index 000000000..520e9b864
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
@@ -0,0 +1,248 @@
+/*-
+ * ============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.models.controlloop.persistence.provider;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.ws.rs.core.Response;
+import lombok.NonNull;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.models.base.PfAuthorative;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.provider.impl.AbstractModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
+
+/**
+ * This class provides information on control loop concepts in the database to callers.
+ */
+public class ControlLoopProvider extends AbstractModelsProvider {
+
+ /**
+ * Create a provider for control loops.
+ *
+ * @param parameters the parameters for database access
+ * @throws PfModelException on initiation errors
+ */
+ public ControlLoopProvider(@NonNull PolicyModelsProviderParameters parameters) throws PfModelException {
+ super(parameters);
+ this.init();
+ }
+
+ /**
+ * Get Control Loop.
+ *
+ * @param controlLoopId the ID of the control loop to get
+ * @return the control loop found
+ * @throws PfModelException on errors getting the control loop
+ */
+ public ControlLoop getControlLoop(final ToscaConceptIdentifier controlLoopId) throws PfModelException {
+ JpaControlLoop jpaControlLoop = getPfDao().get(JpaControlLoop.class, controlLoopId.asConceptKey());
+
+ return jpaControlLoop == null ? null : jpaControlLoop.toAuthorative();
+ }
+
+ /**
+ * Update Control Loop.
+ *
+ * @param controlLoop the control loop to update
+ * @return the updated control loop
+ * @throws PfModelException on errors updating the control loop
+ */
+ public ControlLoop updateControlLoop(final ControlLoop controlLoop) throws PfModelException {
+ return updateControlLoops(Collections.singletonList(controlLoop)).get(0);
+ }
+
+ /**
+ * Get Control Loops.
+ *
+ * @param name the name of the control loop to get, null to get all control loops
+ * @param version the version of the control loop to get, null to get all control loops
+ * @return the control loops found
+ * @throws PfModelException on errors getting control loops
+ */
+ public List<ControlLoop> getControlLoops(final String name, final String version) throws PfModelException {
+
+ return asEntityList(getPfDao().getFiltered(JpaControlLoop.class, name, version));
+ }
+
+ /**
+ * Get filtered control loops.
+ *
+ * @param filter the filter for the control loops to get
+ * @return the control loops found
+ * @throws PfModelException on errors getting control loops
+ */
+ public List<ControlLoop> getFilteredControlLoops(@NonNull final ToscaTypedEntityFilter<ControlLoop> filter) {
+
+ return filter.filter(
+ asEntityList(getPfDao().getFiltered(JpaControlLoop.class, filter.getName(), PfKey.NULL_KEY_VERSION)));
+ }
+
+ /**
+ * Creates control loops.
+ *
+ * @param controlLoops a specification of the control loops to create
+ * @return the control loops created
+ * @throws PfModelException on errors creating control loops
+ */
+ public List<ControlLoop> createControlLoops(@NonNull final List<ControlLoop> controlLoops) throws PfModelException {
+
+ BeanValidationResult validationResult = new BeanValidationResult("control loops", controlLoops);
+
+ for (ControlLoop controlLoop : controlLoops) {
+ JpaControlLoop jpaControlLoop = new JpaControlLoop();
+ jpaControlLoop.fromAuthorative(controlLoop);
+
+ validationResult.addResult(jpaControlLoop.validate("control loop"));
+ }
+
+ if (!validationResult.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
+
+ for (ControlLoop controlLoop : controlLoops) {
+ JpaControlLoop jpaControlLoop = new JpaControlLoop();
+ jpaControlLoop.fromAuthorative(controlLoop);
+
+ getPfDao().create(jpaControlLoop);
+ }
+
+ // Return the created control loops
+ List<ControlLoop> returnControlLoops = new ArrayList<>(controlLoops.size());
+
+ for (ControlLoop controlLoop : controlLoops) {
+ JpaControlLoop jpaControlLoop = getPfDao().get(JpaControlLoop.class,
+ new PfConceptKey(controlLoop.getName(), controlLoop.getVersion()));
+ returnControlLoops.add(jpaControlLoop.toAuthorative());
+ }
+
+ return returnControlLoops;
+ }
+
+ /**
+ * Updates control loops.
+ *
+ * @param controlLoops a specification of the control loops to update
+ * @return the control loops updated
+ * @throws PfModelException on errors updating control loops
+ */
+ public List<ControlLoop> updateControlLoops(@NonNull final List<ControlLoop> controlLoops) throws PfModelException {
+
+ BeanValidationResult validationResult = new BeanValidationResult("control loops", controlLoops);
+
+ for (ControlLoop controlLoop : controlLoops) {
+ JpaControlLoop jpaControlLoop = new JpaControlLoop();
+ jpaControlLoop.fromAuthorative(controlLoop);
+
+ validationResult.addResult(jpaControlLoop.validate("control loop"));
+ }
+
+ if (!validationResult.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
+
+ // Return the created control loops
+ List<ControlLoop> returnControlLoops = new ArrayList<>(controlLoops.size());
+
+ for (ControlLoop controlLoop : controlLoops) {
+ JpaControlLoop jpaControlLoop = new JpaControlLoop();
+ jpaControlLoop.fromAuthorative(controlLoop);
+
+ JpaControlLoop returnJpaControlLoop = getPfDao().update(jpaControlLoop);
+ returnControlLoops.add(returnJpaControlLoop.toAuthorative());
+ }
+
+ return returnControlLoops;
+ }
+
+ /**
+ * Delete a control loop.
+ *
+ * @param name the name of the control loop to delete
+ * @param version the version of the control loop to delete
+ * @return the control loop deleted
+ * @throws PfModelException on errors deleting the control loop
+ */
+ public ControlLoop deleteControlLoop(@NonNull final String name, @NonNull final String version) {
+
+ PfConceptKey controlLoopKey = new PfConceptKey(name, version);
+
+ JpaControlLoop jpaDeleteControlLoop = getPfDao().get(JpaControlLoop.class, controlLoopKey);
+
+ if (jpaDeleteControlLoop == null) {
+ String errorMessage =
+ "delete of control loop \"" + controlLoopKey.getId() + "\" failed, control loop does not exist";
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
+ }
+
+ getPfDao().delete(jpaDeleteControlLoop);
+
+ return jpaDeleteControlLoop.toAuthorative();
+ }
+
+ /**
+ * Get Node Templates.
+ *
+ * @param name the name of the node template to get, null to get all node templates
+ * @param version the version of the node template to get, null to get all node templates
+ * @return the node templates found
+ * @throws PfModelException on errors getting node templates
+ */
+ public List<ToscaNodeTemplate> getNodeTemplates(final String name, final String version) {
+ return asEntityList(getPfDao().getFiltered(JpaToscaNodeTemplate.class, name, version));
+ }
+
+ /**
+ * Get filtered node templates.
+ *
+ * @param filter the filter for the node templates to get
+ * @return the node templates found
+ * @throws PfModelException on errors getting node templates
+ */
+ public List<ToscaNodeTemplate> getFilteredNodeTemplates(
+ @NonNull final ToscaTypedEntityFilter<ToscaNodeTemplate> filter) {
+
+ return filter.filter(asEntityList(
+ getPfDao().getFiltered(JpaToscaNodeTemplate.class, filter.getName(), filter.getVersion())));
+ }
+
+ /**
+ * Convert JPA control loop list to an authorative control loop list.
+ *
+ * @param jpaEntityList the list to convert
+ * @return the authorative list
+ */
+ private <T extends ToscaEntity, J extends PfAuthorative<T>> List<T> asEntityList(List<J> jpaEntityList) {
+ return jpaEntityList.stream().map(J::toAuthorative).collect(Collectors.toList());
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
new file mode 100644
index 000000000..e82956f93
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
@@ -0,0 +1,195 @@
+/*-
+ * ============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.models.controlloop.persistence.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.ws.rs.core.Response;
+import lombok.NonNull;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.provider.impl.AbstractModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+
+/**
+ * This class provides information on participant concepts in the database to callers.
+ */
+public class ParticipantProvider extends AbstractModelsProvider {
+ /**
+ * Create a provider for participants.
+ *
+ * @param parameters the parameters for database access
+ * @throws PfModelException on initiation errors
+ */
+ public ParticipantProvider(@NonNull PolicyModelsProviderParameters parameters) throws PfModelException {
+ super(parameters);
+ this.init();
+ }
+
+ /**
+ * Get participants.
+ *
+ * @param name the name of the participant to get, null to get all participants
+ * @param version the version of the participant to get, null to get all participants
+ * @return the participants found
+ * @throws PfModelException on errors getting participants
+ */
+ public List<Participant> getParticipants(final String name, final String version) throws PfModelException {
+
+ return asParticipantList(getPfDao().getFiltered(JpaParticipant.class, name, version));
+ }
+
+ /**
+ * Get filtered participants.
+ *
+ * @param filter the filter for the participants to get
+ * @return the participants found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<Participant> getFilteredParticipants(@NonNull final ToscaTypedEntityFilter<Participant> filter) {
+
+ return filter.filter(asParticipantList(
+ getPfDao().getFiltered(JpaParticipant.class, filter.getName(), filter.getVersion())));
+ }
+
+ /**
+ * Creates participants.
+ *
+ * @param participants a specification of the participants to create
+ * @return the participants created
+ * @throws PfModelException on errors creating participants
+ */
+ public List<Participant> createParticipants(@NonNull final List<Participant> participants) throws PfModelException {
+
+ BeanValidationResult validationResult = new BeanValidationResult("participants", participants);
+
+ for (Participant participant : participants) {
+ JpaParticipant jpaParticipant = new JpaParticipant();
+ jpaParticipant.fromAuthorative(participant);
+
+ validationResult.addResult(jpaParticipant.validate("participant"));
+ }
+
+ if (!validationResult.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
+
+ for (Participant participant : participants) {
+ JpaParticipant jpaParticipant = new JpaParticipant();
+ jpaParticipant.fromAuthorative(participant);
+
+ getPfDao().create(jpaParticipant);
+ }
+
+ // Return the created participants
+ List<Participant> returnParticipants = new ArrayList<>(participants.size());
+
+ for (Participant participant : participants) {
+ JpaParticipant jpaParticipant = getPfDao().get(JpaParticipant.class,
+ new PfConceptKey(participant.getName(), participant.getVersion()));
+ returnParticipants.add(jpaParticipant.toAuthorative());
+ }
+
+ return returnParticipants;
+ }
+
+ /**
+ * Updates participants.
+ *
+ * @param participants a specification of the participants to update
+ * @return the participants updated
+ * @throws PfModelException on errors updating participants
+ */
+ public List<Participant> updateParticipants(@NonNull final List<Participant> participants) throws PfModelException {
+
+ BeanValidationResult validationResult = new BeanValidationResult("participants", participants);
+
+ for (Participant participant : participants) {
+ JpaParticipant jpaParticipant = new JpaParticipant();
+ jpaParticipant.fromAuthorative(participant);
+
+ validationResult.addResult(jpaParticipant.validate("participant"));
+ }
+
+ if (!validationResult.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
+
+ for (Participant participant : participants) {
+ JpaParticipant jpaParticipant = new JpaParticipant();
+ jpaParticipant.fromAuthorative(participant);
+
+ getPfDao().update(jpaParticipant);
+ }
+
+ // Return the created participants
+ List<Participant> returnParticipants = new ArrayList<>(participants.size());
+
+ for (Participant participant : participants) {
+ JpaParticipant jpaParticipant = getPfDao().get(JpaParticipant.class,
+ new PfConceptKey(participant.getName(), participant.getVersion()));
+ returnParticipants.add(jpaParticipant.toAuthorative());
+ }
+
+ return returnParticipants;
+ }
+
+ /**
+ * Delete a participant.
+ *
+ * @param name the name of the participant to delete
+ * @param version the version of the participant to get
+ * @return the participant deleted
+ * @throws PfModelException on errors deleting participants
+ */
+ public Participant deleteParticipant(@NonNull final String name, @NonNull final String version) {
+
+ PfConceptKey participantKey = new PfConceptKey(name, version);
+
+ JpaParticipant jpaDeleteParticipant = getPfDao().get(JpaParticipant.class, participantKey);
+
+ if (jpaDeleteParticipant == null) {
+ String errorMessage =
+ "delete of participant \"" + participantKey.getId() + "\" failed, participant does not exist";
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
+ }
+
+ getPfDao().delete(jpaDeleteParticipant);
+
+ return jpaDeleteParticipant.toAuthorative();
+ }
+
+ /**
+ * Convert JPA participant list to an authorative participant list.
+ *
+ * @param foundParticipants the list to convert
+ * @return the authorative list
+ */
+ private List<Participant> asParticipantList(List<JpaParticipant> jpaParticipantList) {
+ return jpaParticipantList.stream().map(JpaParticipant::toAuthorative).collect(Collectors.toList());
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
new file mode 100644
index 000000000..6b075278c
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
@@ -0,0 +1,159 @@
+/*-
+ * ============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.models.controlloop.persistence.provider;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import javax.ws.rs.core.Response;
+import lombok.NonNull;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.base.PfTimestampKey;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.provider.impl.AbstractModelsProvider;
+
+/**
+ * This class provides the provision of information on participant statistics in the database to callers.
+ *
+ * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech)
+ */
+public class ParticipantStatisticsProvider extends AbstractModelsProvider {
+
+ /**
+ * Create a provider for control loops statistics.
+ *
+ * @param parameters the parameters for database access
+ * @throws PfModelException on initiation errors
+ */
+ public ParticipantStatisticsProvider(@NonNull PolicyModelsProviderParameters parameters) throws PfModelException {
+ super(parameters);
+ this.init();
+ }
+
+ /**
+ * Get Participant statistics.
+ *
+ * @param name the name of the participant statistics to get, null to get all stats
+ * @return the participant statistics found
+ * @throws PfModelException on errors getting participant statistics
+ */
+ public List<ParticipantStatistics> getParticipantStatistics(final String name, final String version,
+ final Instant timestamp) throws PfModelException {
+
+ if (name != null && version != null && timestamp != null) {
+ List<ParticipantStatistics> participantStatistics = new ArrayList<>(1);
+ participantStatistics.add(getPfDao()
+ .get(JpaParticipantStatistics.class, new PfTimestampKey(name, version, timestamp)).toAuthorative());
+ return participantStatistics;
+ } else if (name != null) {
+ return getFilteredParticipantStatistics(name, version, timestamp, null, null,
+ "DESC", 0);
+ } else {
+ return asParticipantStatisticsList(getPfDao().getAll(JpaParticipantStatistics.class));
+ }
+ }
+
+
+ /**
+ * Get filtered participant statistics.
+ *
+ * @param name the participant name for the statistics to get
+ * @param startTimeStamp startTimeStamp to filter statistics
+ * @param endTimeStamp endTimeStamp to filter statistics
+ * @param sortOrder sortOrder to query database
+ * @param getRecordNum Total query count from database
+ * @return the participant statistics found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ParticipantStatistics> getFilteredParticipantStatistics(final String name, final String version,
+ final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap,
+ final String sortOrder, final int getRecordNum) {
+
+ return asParticipantStatisticsList(getPfDao().getFiltered(JpaParticipantStatistics.class, name, version,
+ startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum));
+ }
+
+
+ /**
+ * Creates Participant statistics.
+ *
+ * @param participantStatisticsList a specification of the CL statistics to create
+ * @return the participant statistics created
+ * @throws PfModelException on errors creating participant statistics
+ */
+ public List<ParticipantStatistics> createParticipantStatistics(
+ @NonNull final List<ParticipantStatistics> participantStatisticsList) throws PfModelException {
+
+ BeanValidationResult validationResult =
+ new BeanValidationResult("participant statistics List", participantStatisticsList);
+
+ for (ParticipantStatistics participantStatistics : participantStatisticsList) {
+ JpaParticipantStatistics jpaParticipantStatistics = new JpaParticipantStatistics();
+ jpaParticipantStatistics.fromAuthorative(participantStatistics);
+
+ validationResult.addResult(jpaParticipantStatistics.validate("participant statistics"));
+ }
+
+ if (!validationResult.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
+
+ for (ParticipantStatistics participantStatistics : participantStatisticsList) {
+ JpaParticipantStatistics jpaParticipantStatistics = new JpaParticipantStatistics();
+ jpaParticipantStatistics.fromAuthorative(participantStatistics);
+
+ getPfDao().create(jpaParticipantStatistics);
+ }
+
+ // Return the created participant statistics
+ List<ParticipantStatistics> participantStatistics = new ArrayList<>(participantStatisticsList.size());
+
+ for (ParticipantStatistics participantStatisticsItem : participantStatisticsList) {
+ JpaParticipantStatistics jpaParticipantStatistics = getPfDao().get(JpaParticipantStatistics.class,
+ new PfTimestampKey(participantStatisticsItem.getParticipantId().getName(),
+ participantStatisticsItem.getParticipantId().getVersion(),
+ participantStatisticsItem.getTimeStamp()));
+ participantStatistics.add(jpaParticipantStatistics.toAuthorative());
+ }
+
+ return participantStatistics;
+ }
+
+
+ /**
+ * Convert JPA participant statistics list to participant statistics list.
+ *
+ * @param jpaParticipantStatisticsList the list to convert
+ * @return the participant statistics list
+ */
+ private List<ParticipantStatistics> asParticipantStatisticsList(
+ List<JpaParticipantStatistics> jpaParticipantStatisticsList) {
+
+ return jpaParticipantStatisticsList.stream().map(JpaParticipantStatistics::toAuthorative)
+ .collect(Collectors.toList());
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java
new file mode 100644
index 000000000..c6bbd81d6
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification;
+
+import com.google.gson.annotations.SerializedName;
+import java.util.ArrayList;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.collections4.CollectionUtils;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ControlLoopNotification {
+
+ /**
+ * Status of control loops that are being added to participants.
+ */
+ @SerializedName("deployed-control-loops")
+ private List<ControlLoopStatus> added = new ArrayList<>();
+
+ /**
+ * Status of policies that are being deleted from PDPs.
+ */
+ @SerializedName("undeployed-control-loops")
+ private List<ControlLoopStatus> deleted = new ArrayList<>();
+
+
+ /**
+ * Determines if the notification is empty (i.e., has no added or delete control loop
+ * notifications).
+ *
+ * @return {@code true} if the notification is empty, {@code false} otherwise
+ */
+ public boolean isEmpty() {
+ return (CollectionUtils.isEmpty(added) && CollectionUtils.isEmpty(deleted));
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java
new file mode 100644
index 000000000..033843e75
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java
@@ -0,0 +1,36 @@
+/*-
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification;
+
+import com.google.gson.annotations.SerializedName;
+import java.util.UUID;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ControlLoopStatus {
+ @SerializedName("control-loop-id")
+ private UUID id;
+
+ private ToscaConceptIdentifier definition;
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChange.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChange.java
new file mode 100644
index 000000000..1a9a891f6
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChange.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+
+/**
+ * Class to represent the PARTICIPANT_CONTROL_LOOP_STATE_CHANGE message that the control loop runtime will send to
+ * participants to change the state of a control loop they are running.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class ParticipantControlLoopStateChange extends ParticipantMessage {
+ private ControlLoopOrderedState orderedState;
+
+ /**
+ * Constructor for instantiating ParticipantControlLoopStateChange class with message name.
+ *
+ */
+ public ParticipantControlLoopStateChange() {
+ super(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_STATE_CHANGE);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantControlLoopStateChange(ParticipantControlLoopStateChange source) {
+ super(source);
+
+ this.orderedState = source.orderedState;
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdate.java
new file mode 100644
index 000000000..ed729a64b
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdate.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+/**
+ * Class to represent the PARTICIPANT_CONTROL_LOOP_UPDATE message that the control loop runtime sends to a participant.
+ * When a participant receives this message, it creates the control loop elements contained in the message and sets them
+ * to state PASSIVE. subsequent PARTICIPANT_CONTROL_LOOP_STATE_CHANGE messages are used to activate the control loops.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class ParticipantControlLoopUpdate extends ParticipantMessage {
+ // The control loop
+ private ControlLoop controlLoop;
+
+ // A service template containing a complete definition of the control loop
+ private ToscaServiceTemplate controlLoopDefinition;
+
+ /**
+ * Constructor for instantiating ParticipantControlLoopUpdate class with message name.
+ *
+ */
+ public ParticipantControlLoopUpdate() {
+ super(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_UPDATE);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantControlLoopUpdate(ParticipantControlLoopUpdate source) {
+ super(source);
+
+ this.controlLoop = new ControlLoop(source.controlLoop);
+ this.controlLoopDefinition = new ToscaServiceTemplate(source.controlLoopDefinition);
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheck.java
new file mode 100644
index 000000000..e472e15fe
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheck.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+
+/**
+ * Class to represent the PARTICIPANT_HEALTHCHECK message that the control loop runtime will send to
+ * participants to change the state of a control loop they are running.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class ParticipantHealthCheck extends ParticipantMessage {
+ private ParticipantState state;
+
+ /**
+ * Constructor for instantiating ParticipantHealthCheck class with message name.
+ *
+ */
+ public ParticipantHealthCheck() {
+ super(ParticipantMessageType.PARTICIPANT_HEALTH_CHECK);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantHealthCheck(ParticipantHealthCheck source) {
+ super(source);
+
+ this.state = source.state;
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java
new file mode 100644
index 000000000..3ca4d3d34
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java
@@ -0,0 +1,113 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import java.time.Instant;
+import java.util.UUID;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to represent the base class for various messages that will be exchanged between the control loop runtime and
+ * participants.
+ */
+@Getter
+@Setter
+@ToString
+public class ParticipantMessage {
+ @Setter(AccessLevel.NONE)
+ private ParticipantMessageType messageType;
+
+ private UUID messageId = UUID.randomUUID();
+
+ /**
+ * Time-stamp, in milliseconds, when the message was created. Defaults to the current time.
+ */
+ private Instant timestamp = Instant.now();
+
+ /**
+ * Participant Type, or {@code null} for messages from participants.
+ */
+ private ToscaConceptIdentifier participantType;
+
+ /**
+ * Participant ID, or {@code null} for messages from participants.
+ */
+ private ToscaConceptIdentifier participantId;
+
+ /**
+ * Control loop ID, or {@code null} for messages to participants.
+ */
+ private ToscaConceptIdentifier controlLoopId;
+
+ /**
+ * Constructor for instantiating a participant message class.
+ *
+ * @param messageType the message type
+ */
+ public ParticipantMessage(final ParticipantMessageType messageType) {
+ this.messageType = messageType;
+ }
+
+ /**
+ * Constructs the object, making a deep copy. Does <i>not</i> copy the request id or the time stamp.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantMessage(final ParticipantMessage source) {
+ this.messageType = source.messageType;
+ this.participantType = source.participantType;
+ this.participantId = source.participantId;
+ this.controlLoopId = source.controlLoopId;
+ }
+
+ /**
+ * Determines if this message applies to this participant type.
+ *
+ * @param participantType type of the participant to match against
+ * @param participantId id of the participant to match against
+ * @return {@code true} if this message applies to this participant, {@code false} otherwise
+ */
+ public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType,
+ @NonNull final ToscaConceptIdentifier participantId) {
+ // Broadcast message to all participants
+ if (this.participantType == null) {
+ return true;
+ }
+
+ // Broadcast message to all control loop elements on this participant
+ if (participantType.equals(this.participantType) && this.participantId == null) {
+ return true;
+ }
+
+ // Targeted message at this specific participant
+ if (participantType.equals(this.participantType) && participantId.equals(this.participantId)) {
+ return true;
+ }
+
+ // Message is not for this participant
+ return false;
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java
new file mode 100644
index 000000000..77a50bd36
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+/**
+ * Class to hold the possible values for the type of participant messages.
+ */
+public enum ParticipantMessageType {
+
+ /**
+ * Used by participants to report status to the control loop runtime.
+ */
+ PARTICIPANT_STATUS,
+
+ /**
+ * Used by the control loop runtime to change the state of participants, triggers a PARTICIPANT_STATUS message with
+ * the result of the PARTICIPANT_STATE_CHANGE operation.
+ */
+ PARTICIPANT_STATE_CHANGE,
+
+ /**
+ * Used by the control loop runtime to update the control loops running on participants, triggers a
+ * PARTICIPANT_STATUS message with the result of the PARTICIPANT_CONTROL_LOOP_UPDATE operation.
+ */
+ PARTICIPANT_CONTROL_LOOP_UPDATE,
+
+ /**
+ * Used by the control loop runtime to change the state of control loops in participants, triggers a
+ * PARTICIPANT_STATUS message with the result of the PARTICIPANT_CONTROL_LOOP_STATE_CHANGE operation.
+ */
+ PARTICIPANT_CONTROL_LOOP_STATE_CHANGE,
+
+ /**
+ * Used by the control loop runtime to order a health check on participants, triggers a PARTICIPANT_STATUS message
+ * with the result of the PARTICIPANT_HEALTH_CHECK operation.
+ */
+ PARTICIPANT_HEALTH_CHECK
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java
new file mode 100644
index 000000000..4c771b405
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java
@@ -0,0 +1,64 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import java.util.UUID;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * Class to represent participant response details.
+ */
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+public class ParticipantResponseDetails {
+
+ // The responseTo field should match the original request id in the request.
+ private UUID responseTo;
+ private ParticipantResponseStatus responseStatus;
+ private String responseMessage;
+
+ /**
+ * Constructs the object as a response to.
+ *
+ * @param triggerMessage the message to which this is a response
+ */
+ public ParticipantResponseDetails(ParticipantMessage triggerMessage) {
+ this.responseMessage = null;
+ this.responseStatus = ParticipantResponseStatus.FAIL;
+ this.responseTo = triggerMessage.getMessageId();
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantResponseDetails(ParticipantResponseDetails source) {
+ this.responseMessage = source.responseMessage;
+ this.responseStatus = source.responseStatus;
+ this.responseTo = source.responseTo;
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java
new file mode 100644
index 000000000..f014529b3
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+/**
+ * Class to hold the possible values for participant response status.
+ */
+public enum ParticipantResponseStatus {
+
+ /**
+ * participant operation was successful.
+ */
+ SUCCESS,
+
+ /**
+ * participant operation failed.
+ */
+ FAIL,
+
+ /**
+ * periodic response.
+ */
+ PERIODIC
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChange.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChange.java
new file mode 100644
index 000000000..5f5150077
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChange.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+
+/**
+ * Class to represent the PARTICIPANT_STATE_CHANGE message that the control loop runtime will send to participants
+ * to change their state.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class ParticipantStateChange extends ParticipantMessage {
+ private ParticipantState state;
+
+ /**
+ * Constructor for instantiating ParticipantStateChange class with message name.
+ *
+ */
+ public ParticipantStateChange() {
+ super(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantStateChange(ParticipantStateChange source) {
+ super(source);
+
+ this.state = source.state;
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java
new file mode 100644
index 000000000..5b9284243
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java
@@ -0,0 +1,76 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
+
+/**
+ * Class to represent the PARTICIPANT_STATUS message that all the participants send to the control loop runtime.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class ParticipantStatus extends ParticipantMessage {
+ // The response should be completed if this message is a response to a request from the Control Loop Runtime
+ private ParticipantResponseDetails response;
+
+ // State and health status of the participant
+ private ParticipantState state;
+ private ParticipantHealthStatus healthStatus;
+
+ // Control Loops on the participant
+ private ControlLoops controlLoops;
+
+ // Participant statistics
+ private ParticipantStatistics participantStatistics;
+
+ // Description. May be left {@code null}.
+ private String message;
+
+ /**
+ * Constructor for instantiating ParticipantStatus class with message name.
+ *
+ */
+ public ParticipantStatus() {
+ super(ParticipantMessageType.PARTICIPANT_STATUS);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantStatus(final ParticipantStatus source) {
+ super(source);
+
+ this.state = source.state;
+ this.healthStatus = source.healthStatus;
+ this.message = source.message;
+ this.controlLoops = (source.controlLoops == null ? null : new ControlLoops(source.controlLoops));
+ this.response = (source.response == null ? null : new ParticipantResponseDetails(source.response));
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java
new file mode 100644
index 000000000..2bd09c632
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java
@@ -0,0 +1,37 @@
+/*
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.models.messages.rest;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * Response returned when no extra output fields are needed.
+ */
+@Getter
+@Setter
+@ToString
+public class SimpleResponse {
+
+ /**
+ * Optional detailed message in error cases.
+ */
+ private String errorDetails;
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java
new file mode 100644
index 000000000..199ac8ee1
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.models.messages.rest;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * Response returned when no extra output fields are needed.
+ */
+@Getter
+@Setter
+@ToString
+public class TypedSimpleResponse<T> extends SimpleResponse {
+ private T response;
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java
new file mode 100644
index 000000000..6363db8d2
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.models.messages.rest.commissioning;
+
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Response to Commissioning requests that affect a change.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class CommissioningResponse extends SimpleResponse {
+ private List<ToscaConceptIdentifier> affectedControlLoopDefinitions;
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java
new file mode 100644
index 000000000..71b7ab92c
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.models.messages.rest.instantiation;
+
+import java.util.List;
+import lombok.Data;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+@Data
+public class InstantiationCommand {
+ // The state to which the control loops are to be set
+ private ControlLoopOrderedState orderedState;
+
+ // The list of control loops on which the command is to be issued
+ private List<ToscaConceptIdentifier> controlLoopIdentifierList;
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java
new file mode 100644
index 000000000..d932f29ac
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.models.messages.rest.instantiation;
+
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Response to Commissioning requests that affect a change.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class InstantiationResponse extends SimpleResponse {
+ private List<ToscaConceptIdentifier> affectedControlLoops;
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java
new file mode 100644
index 000000000..0addc25ad
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ClElementStatisticsTest {
+ @Test
+ public void testClElementStatisticsLombok() {
+ assertNotNull(new ClElementStatistics());
+ ClElementStatistics cles0 = new ClElementStatistics();
+
+ assertThat(cles0.toString()).contains("ClElementStatistics(");
+ assertThat(cles0.hashCode()).isNotZero();
+ assertEquals(true, cles0.equals(cles0));
+ assertEquals(false, cles0.equals(null));
+
+
+ ClElementStatistics cles1 = new ClElementStatistics();
+ cles1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
+ cles1.setTimeStamp(Instant.now());
+
+ assertThat(cles1.toString()).contains("ClElementStatistics(");
+ assertEquals(false, cles1.hashCode() == 0);
+ assertEquals(false, cles1.equals(cles0));
+ assertEquals(false, cles1.equals(null));
+
+ assertNotEquals(cles1, cles0);
+
+ ClElementStatistics cles2 = new ClElementStatistics();
+ cles2.setId(UUID.randomUUID());
+
+ // @formatter:off
+ assertThatThrownBy(() -> cles2.setParticipantId(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cles2.setTimeStamp(null)).isInstanceOf(NullPointerException.class);
+ // @formatter:on
+
+ assertNotEquals(cles2, cles0);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java
new file mode 100644
index 000000000..908c91417
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.EqualsAndHashCodeMatchRule;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+import java.util.List;
+import org.junit.Test;
+import org.onap.policy.common.utils.test.ToStringTester;
+
+/**
+ * Class to perform unit tests of all pojos.
+ */
+public class ControlLoopConceptPojosTest {
+
+ @Test
+ public void testPojos() {
+ List<PojoClass> pojoClasses =
+ PojoClassFactory.getPojoClasses(ControlLoopConceptPojosTest.class.getPackageName());
+
+ // @formatter:off
+ final Validator validator = ValidatorBuilder
+ .create()
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .with(new EqualsAndHashCodeMatchRule())
+ .with(new NoPublicFieldsExceptStaticFinalRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .with(new ToStringTester())
+ .build();
+
+ validator.validate(pojoClasses);
+ // @formatter:on
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java
new file mode 100644
index 000000000..2264f6dc2
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ControlLoopElementTest {
+ @Test
+ public void testControlLoopElement() {
+
+ ControlLoopElement cle0 = new ControlLoopElement();
+
+ ControlLoopElement cle1 = new ControlLoopElement(cle0);
+ assertEquals(cle0, cle1);
+ }
+
+ @Test
+ public void testControlLoopElementLombok() {
+ assertNotNull(new ControlLoopElement());
+ ControlLoopElement cle0 = new ControlLoopElement();
+
+ assertThat(cle0.toString()).contains("ControlLoopElement(");
+ assertThat(cle0.hashCode()).isNotZero();
+ assertEquals(true, cle0.equals(cle0));
+ assertEquals(false, cle0.equals(null));
+
+ ControlLoopElement cle1 = new ControlLoopElement();
+
+ cle1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
+ cle1.setDescription("Description");
+ cle1.setId(UUID.randomUUID());
+ cle1.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ cle1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3"));
+ cle1.setState(ControlLoopState.UNINITIALISED);
+
+ assertThat(cle1.toString()).contains("ControlLoopElement(");
+ assertEquals(false, cle1.hashCode() == 0);
+ assertEquals(false, cle1.equals(cle0));
+ assertEquals(false, cle1.equals(null));
+
+ assertNotEquals(cle1, cle0);
+
+ ControlLoopElement cle2 = new ControlLoopElement();
+
+ // @formatter:off
+ assertThatThrownBy(() -> cle2.setDefinition(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cle2.setId(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cle2.setOrderedState(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cle2.setParticipantId(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cle2.setState(null)). isInstanceOf(NullPointerException.class);
+ // @formatter:on
+
+ assertNotEquals(cle2, cle0);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java
new file mode 100644
index 000000000..c865b76ab
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java
@@ -0,0 +1,102 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.LinkedHashMap;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ControlLoopTest {
+ @Test
+ public void testControlLoop() {
+ ControlLoop cl0 = new ControlLoop();
+ cl0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3"));
+ assertEquals("dfName", cl0.getType());
+ assertEquals("1.2.3", cl0.getTypeVersion());
+
+ ControlLoop cl1 = new ControlLoop(cl0);
+ assertEquals(cl0, cl1);
+
+ assertEquals(0, cl0.compareTo(cl1));
+ }
+
+ @Test
+ public void testControlLoopLombok() {
+ assertNotNull(new ControlLoop());
+ ControlLoop cl0 = new ControlLoop();
+ cl0.setElements(new LinkedHashMap<>());
+
+ assertThat(cl0.toString()).contains("ControlLoop(");
+ assertThat(cl0.hashCode()).isNotZero();
+ assertEquals(true, cl0.equals(cl0));
+ assertEquals(false, cl0.equals(null));
+
+ ControlLoop cl1 = new ControlLoop();
+
+ cl1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
+ cl1.setDescription("Description");
+ cl1.setElements(new LinkedHashMap<>());
+ cl1.setName("Name");
+ cl1.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ cl1.setState(ControlLoopState.UNINITIALISED);
+ cl1.setVersion("0.0.1");
+
+ assertThat(cl1.toString()).contains("ControlLoop(");
+ assertEquals(false, cl1.hashCode() == 0);
+ assertEquals(false, cl1.equals(cl0));
+ assertEquals(false, cl1.equals(null));
+
+ assertNotEquals(cl1, cl0);
+
+ ControlLoop cl2 = new ControlLoop();
+ cl2.setElements(new LinkedHashMap<>());
+
+ // @formatter:off
+ assertThatThrownBy(() -> cl2.setDefinition(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cl2.setOrderedState(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cl2.setState(null)). isInstanceOf(NullPointerException.class);
+ // @formatter:on
+
+ assertEquals(cl2, cl0);
+
+ cl1.setCascadedOrderedState(ControlLoopOrderedState.PASSIVE);
+ assertEquals(ControlLoopOrderedState.PASSIVE, cl1.getOrderedState());
+
+ cl1.getElements().put(UUID.randomUUID(), new ControlLoopElement());
+ cl1.setCascadedOrderedState(ControlLoopOrderedState.RUNNING);
+ assertEquals(ControlLoopOrderedState.RUNNING, cl1.getOrderedState());
+ assertEquals(ControlLoopOrderedState.RUNNING, cl1.getElements().values().iterator().next().getOrderedState());
+
+ assertNull(cl0.getElements().get(UUID.randomUUID()));
+ assertNull(cl1.getElements().get(UUID.randomUUID()));
+
+ assertEquals(PfKey.NULL_KEY_NAME, cl0.getDefinition().getName());
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java
new file mode 100644
index 000000000..54eaca00e
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.time.Instant;
+import org.junit.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ParticipantStatisticsTest {
+ @Test
+ public void testParticipantStatisticsLombok() {
+ assertNotNull(new ParticipantStatistics());
+ ParticipantStatistics ps0 = new ParticipantStatistics();
+
+ assertThat(ps0.toString()).contains("ParticipantStatistics(");
+ assertThat(ps0.hashCode()).isNotZero();
+ assertEquals(true, ps0.equals(ps0));
+ assertEquals(false, ps0.equals(null));
+
+
+ ParticipantStatistics ps1 = new ParticipantStatistics();
+ ps1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
+ ps1.setTimeStamp(Instant.now());
+
+ assertThat(ps1.toString()).contains("ParticipantStatistics(");
+ assertEquals(false, ps1.hashCode() == 0);
+ assertEquals(false, ps1.equals(ps0));
+ assertEquals(false, ps1.equals(null));
+
+ assertNotEquals(ps1, ps0);
+
+ ParticipantStatistics ps2 = new ParticipantStatistics();
+
+ // @formatter:off
+ assertThatThrownBy(() -> ps2.setParticipantId(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> ps2.setTimeStamp(null)). isInstanceOf(NullPointerException.class);
+ // @formatter:on
+
+ assertEquals(ps2, ps0);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java
new file mode 100644
index 000000000..1eb80db09
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.models.controlloop.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ParticipantTest {
+ @Test
+ public void testParticipant() {
+
+ Participant p0 = new Participant();
+ p0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3"));
+ assertEquals("dfName", p0.getType());
+ assertEquals("1.2.3", p0.getTypeVersion());
+
+ Participant p1 = new Participant(p0);
+ assertEquals(p0, p1);
+
+ assertEquals(0, p0.compareTo(p1));
+ }
+
+ @Test
+ public void testParticipantLombok() {
+ assertNotNull(new Participant());
+ Participant p0 = new Participant();
+
+ assertThat(p0.toString()).contains("Participant(");
+ assertThat(p0.hashCode()).isNotZero();
+ assertEquals(true, p0.equals(p0));
+ assertEquals(false, p0.equals(null));
+
+
+ Participant p1 = new Participant();
+
+ p1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
+ p1.setDescription("Description");
+ p1.setHealthStatus(ParticipantHealthStatus.HEALTHY);
+ p1.setName("Name");
+ p1.setParticipantState(ParticipantState.ACTIVE);
+ p1.setVersion("0.0.1");
+
+ assertThat(p1.toString()).contains("Participant(");
+ assertEquals(false, p1.hashCode() == 0);
+ assertEquals(false, p1.equals(p0));
+ assertEquals(false, p1.equals(null));
+
+ assertNotEquals(p1, p0);
+
+ Participant p2 = new Participant();
+
+ // @formatter:off
+ assertThatThrownBy(() -> p2.setDefinition(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> p2.setHealthStatus(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> p2.setParticipantState(null)).isInstanceOf(NullPointerException.class);
+ // @formatter:on
+
+ assertEquals(p2, p0);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java
new file mode 100644
index 000000000..b90ccba5b
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+/**
+ * Test class for {@link JpaClElementStatistics} comparisons.
+ */
+public class DummyJpaClElementStatisticsChild extends JpaClElementStatistics {
+ private static final long serialVersionUID = -5101743610779424064L;
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java
new file mode 100644
index 000000000..c4eb364d3
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+/**
+ * Test class for {@link JpaControlLoop} comparisons.
+ */
+public class DummyJpaControlLoopChild extends JpaControlLoop {
+ private static final long serialVersionUID = -5101743610779424064L;
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java
new file mode 100644
index 000000000..2082ff41c
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+/**
+ * Test class for {@link JpaControlLoopElement} comparisons.
+ */
+public class DummyJpaControlLoopElementChild extends JpaControlLoopElement {
+ private static final long serialVersionUID = -5101743610779424064L;
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java
new file mode 100644
index 000000000..e6bc92efb
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+/**
+ * Test class for {@link JpaParticipant} comparisons.
+ */
+public class DummyJpaParticipantChild extends JpaParticipant {
+ private static final long serialVersionUID = -5101743610779424064L;
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java
new file mode 100644
index 000000000..74dd40034
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+/**
+ * Test class for {@link JpaParticipantStatistics} comparisons.
+ */
+public class DummyJpaParticipantStatisticsChild extends JpaParticipantStatistics {
+ private static final long serialVersionUID = -5101743610779424064L;
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java
new file mode 100644
index 000000000..16c302f94
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java
@@ -0,0 +1,189 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceTimestampKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the {@link JpaClElementStatistics} class.
+ */
+public class JpaClElementStatisticsTest {
+
+ private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+
+ @Test
+ public void testJpaClElementStatisticsConstructor() {
+ assertThatThrownBy(() -> {
+ new JpaClElementStatistics((JpaClElementStatistics) null);
+ }).hasMessageMatching("copyConcept is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaClElementStatistics((PfReferenceTimestampKey) null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaClElementStatistics(null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaClElementStatistics(null, new PfConceptKey());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaClElementStatistics(new PfReferenceTimestampKey(), null);
+ }).hasMessageMatching("participantId is marked .*ull but is null");
+
+ assertNotNull(new JpaClElementStatistics());
+ assertNotNull(new JpaClElementStatistics((new PfReferenceTimestampKey())));
+ assertNotNull(new JpaClElementStatistics(new PfReferenceTimestampKey(), new PfConceptKey()));
+ }
+
+ @Test
+ public void testJpaClElementStatistics() {
+ JpaClElementStatistics testJpaClElementStatistics = createJpaClElementStatisticsInstance();
+
+ ClElementStatistics cles = createClElementStatisticsInstance();
+ assertEquals(cles, testJpaClElementStatistics.toAuthorative());
+
+ assertThatThrownBy(() -> {
+ testJpaClElementStatistics.fromAuthorative(null);
+ }).hasMessageMatching("clElementStatistics is marked .*ull but is null");
+
+ assertThatThrownBy(() -> new JpaClElementStatistics((JpaClElementStatistics) null))
+ .isInstanceOf(NullPointerException.class);
+
+ JpaClElementStatistics testJpaClElementStatisticsFa = new JpaClElementStatistics();
+ testJpaClElementStatisticsFa.setKey(null);
+ testJpaClElementStatisticsFa.fromAuthorative(cles);
+ assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
+ testJpaClElementStatisticsFa.setKey(PfReferenceTimestampKey.getNullKey());
+ testJpaClElementStatisticsFa.fromAuthorative(cles);
+ assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
+ testJpaClElementStatisticsFa.setKey(new PfReferenceTimestampKey("elementName", "0.0.1",
+ "a95757ba-b34a-4049-a2a8-46773abcbe5e", Instant.ofEpochSecond(123456L)));
+ testJpaClElementStatisticsFa.fromAuthorative(cles);
+ assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
+
+ testJpaClElementStatisticsFa = new JpaClElementStatistics(cles);
+ assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
+
+ assertEquals(1, testJpaClElementStatistics.getKeys().size());
+
+ assertEquals("elementName", testJpaClElementStatistics.getKey().getReferenceKey().getParentKeyName());
+
+ testJpaClElementStatistics.clean();
+ assertEquals("elementName", testJpaClElementStatistics.getKey().getReferenceKey().getParentKeyName());
+
+ JpaClElementStatistics testJpaClElementStatistics2 = new JpaClElementStatistics(testJpaClElementStatistics);
+ assertEquals(testJpaClElementStatistics, testJpaClElementStatistics2);
+ }
+
+ @Test
+ public void testJpaClElementStatisticsValidation() {
+ JpaClElementStatistics testJpaClElementStatistics = createJpaClElementStatisticsInstance();
+
+ assertThatThrownBy(() -> {
+ testJpaClElementStatistics.validate(null);
+ }).hasMessageMatching("fieldName is marked .*ull but is null");
+
+ assertTrue(testJpaClElementStatistics.validate("").isValid());
+ }
+
+ @Test
+ public void testJpaClElementStatisticsCompareTo() {
+ JpaClElementStatistics testJpaClElementStatistics = createJpaClElementStatisticsInstance();
+
+ JpaClElementStatistics otherJpaClElementStatistics = new JpaClElementStatistics(testJpaClElementStatistics);
+ assertEquals(0, testJpaClElementStatistics.compareTo(otherJpaClElementStatistics));
+ assertEquals(-1, testJpaClElementStatistics.compareTo(null));
+ assertEquals(0, testJpaClElementStatistics.compareTo(testJpaClElementStatistics));
+ assertNotEquals(0, testJpaClElementStatistics.compareTo(new DummyJpaClElementStatisticsChild()));
+
+ testJpaClElementStatistics.setState(ControlLoopState.PASSIVE);
+ assertNotEquals(0, testJpaClElementStatistics.compareTo(otherJpaClElementStatistics));
+ testJpaClElementStatistics.setState(ControlLoopState.UNINITIALISED);
+ assertEquals(0, testJpaClElementStatistics.compareTo(otherJpaClElementStatistics));
+
+ assertEquals(testJpaClElementStatistics, new JpaClElementStatistics(testJpaClElementStatistics));
+ }
+
+ @Test
+ public void testJpaClElementStatisticsLombok() {
+ assertNotNull(new Participant());
+ JpaClElementStatistics cles0 = new JpaClElementStatistics();
+
+ assertThat(cles0.toString()).contains("JpaClElementStatistics(");
+ assertThat(cles0.hashCode()).isNotZero();
+ assertEquals(true, cles0.equals(cles0));
+ assertEquals(false, cles0.equals(null));
+
+
+ JpaClElementStatistics cles11 = new JpaClElementStatistics();
+
+ cles11.setState(ControlLoopState.UNINITIALISED);
+
+ assertThat(cles11.toString()).contains("JpaClElementStatistics(");
+ assertEquals(false, cles11.hashCode() == 0);
+ assertEquals(false, cles11.equals(cles0));
+ assertEquals(false, cles11.equals(null));
+
+ assertNotEquals(cles11, cles0);
+
+ JpaClElementStatistics cles2 = new JpaClElementStatistics();
+ assertEquals(cles2, cles0);
+ }
+
+ private JpaClElementStatistics createJpaClElementStatisticsInstance() {
+ ClElementStatistics testCles = createClElementStatisticsInstance();
+ JpaClElementStatistics testJpaClElementStatistics = new JpaClElementStatistics();
+ testJpaClElementStatistics.setKey(null);
+ testJpaClElementStatistics.fromAuthorative(testCles);
+ testJpaClElementStatistics.setKey(PfReferenceTimestampKey.getNullKey());
+ testJpaClElementStatistics.fromAuthorative(testCles);
+
+ return testJpaClElementStatistics;
+ }
+
+ private ClElementStatistics createClElementStatisticsInstance() {
+ ClElementStatistics clElementStatistics = new ClElementStatistics();
+ clElementStatistics.setParticipantId(new ToscaConceptIdentifier("elementName", "0.0.1"));
+ clElementStatistics.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ clElementStatistics.setTimeStamp(Instant.ofEpochSecond(123456L));
+ clElementStatistics.setControlLoopState(ControlLoopState.UNINITIALISED);
+
+ return clElementStatistics;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java
new file mode 100644
index 000000000..032d655e3
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java
@@ -0,0 +1,300 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+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.Participant;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the {@link JpaControlLoopElement} class.
+ */
+public class JpaControlLoopElementTest {
+
+ private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+
+ @Test
+ public void testJpaControlLoopElementConstructor() {
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement((JpaControlLoopElement) null);
+ }).hasMessageMatching("copyConcept is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement((PfReferenceKey) null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(null, null, null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(null, null, null, ControlLoopState.UNINITIALISED);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(null, null, new PfConceptKey("participant", "0.0.1"), null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(null, null, new PfConceptKey("participant", "0.0.1"),
+ ControlLoopState.UNINITIALISED);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(null, new PfConceptKey(), null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(null, new PfConceptKey(), null, ControlLoopState.UNINITIALISED);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"), null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"),
+ ControlLoopState.UNINITIALISED);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(new PfReferenceKey(), null, null, null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(new PfReferenceKey(), null, null, ControlLoopState.UNINITIALISED);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"), null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"),
+ ControlLoopState.UNINITIALISED);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(), null, null);
+ }).hasMessageMatching("participantType is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(), null, ControlLoopState.UNINITIALISED);
+ }).hasMessageMatching("participantType is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(),
+ new PfConceptKey("participant", "0.0.1"), null);
+ }).hasMessageMatching("state is marked .*ull but is null");
+
+ assertNotNull(new JpaControlLoopElement());
+ assertNotNull(new JpaControlLoopElement((new PfReferenceKey())));
+ assertNotNull(new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(),
+ new PfConceptKey("participant", "0.0.1"), ControlLoopState.UNINITIALISED));
+ }
+
+ @Test
+ public void testJpaControlLoopElement() {
+ JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance();
+
+ ControlLoopElement cle = createControlLoopElementInstance();
+ assertEquals(cle, testJpaControlLoopElement.toAuthorative());
+
+ assertThatThrownBy(() -> {
+ testJpaControlLoopElement.fromAuthorative(null);
+ }).hasMessageMatching("element is marked .*ull but is null");
+
+ assertThatThrownBy(() -> new JpaControlLoopElement((JpaControlLoopElement) null))
+ .isInstanceOf(NullPointerException.class);
+
+ JpaControlLoopElement testJpaControlLoopElementFa = new JpaControlLoopElement();
+ testJpaControlLoopElementFa.setKey(null);
+ testJpaControlLoopElementFa.fromAuthorative(cle);
+ assertEquals(testJpaControlLoopElement, testJpaControlLoopElementFa);
+ testJpaControlLoopElementFa.setKey(PfReferenceKey.getNullKey());
+ testJpaControlLoopElementFa.fromAuthorative(cle);
+ assertEquals(testJpaControlLoopElement, testJpaControlLoopElementFa);
+ testJpaControlLoopElementFa.setKey(new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION,
+ "a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ testJpaControlLoopElementFa.fromAuthorative(cle);
+ assertEquals(testJpaControlLoopElement, testJpaControlLoopElementFa);
+
+ assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", testJpaControlLoopElement.getKey().getLocalName());
+ assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e",
+ new JpaControlLoopElement(createControlLoopElementInstance()).getKey().getLocalName());
+ assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e",
+ ((PfReferenceKey) new JpaControlLoopElement(createControlLoopElementInstance()).getKeys().get(0))
+ .getLocalName());
+
+ testJpaControlLoopElement.clean();
+ assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", testJpaControlLoopElement.getKey().getLocalName());
+
+ testJpaControlLoopElement.setDescription(" A Message ");
+ testJpaControlLoopElement.clean();
+ assertEquals("A Message", testJpaControlLoopElement.getDescription());
+
+ JpaControlLoopElement testJpaControlLoopElement2 = new JpaControlLoopElement(testJpaControlLoopElement);
+ assertEquals(testJpaControlLoopElement, testJpaControlLoopElement2);
+ }
+
+ @Test
+ public void testJpaControlLoopElementOrderedState() throws CoderException {
+ ControlLoopElement testControlLoopElement = createControlLoopElementInstance();
+ JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance();
+
+ testJpaControlLoopElement.setOrderedState(null);
+ assertEquals(testControlLoopElement, testJpaControlLoopElement.toAuthorative());
+ testJpaControlLoopElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+
+ ControlLoopElement noOrderedStateCle = new StandardCoder().decode(
+ new File("src/test/resources/json/ControlLoopElementNoOrderedState.json"), ControlLoopElement.class);
+
+ JpaControlLoopElement noOrderedStateJpaCle = new JpaControlLoopElement(noOrderedStateCle);
+ assertNull(noOrderedStateJpaCle.getOrderedState());
+ noOrderedStateCle.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ noOrderedStateJpaCle = new JpaControlLoopElement(noOrderedStateCle);
+ assertEquals(testJpaControlLoopElement, noOrderedStateJpaCle);
+ }
+
+ @Test
+ public void testJpaControlLoopElementValidation() {
+ JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance();
+
+ assertThatThrownBy(() -> {
+ testJpaControlLoopElement.validate(null);
+ }).hasMessageMatching("fieldName is marked .*ull but is null");
+
+ assertTrue(testJpaControlLoopElement.validate("").isValid());
+ }
+
+ @Test
+ public void testJpaControlLoopElementCompareTo() {
+ JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance();
+
+ JpaControlLoopElement otherJpaControlLoopElement = new JpaControlLoopElement(testJpaControlLoopElement);
+ assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+ assertEquals(-1, testJpaControlLoopElement.compareTo(null));
+ assertEquals(0, testJpaControlLoopElement.compareTo(testJpaControlLoopElement));
+ assertNotEquals(0, testJpaControlLoopElement.compareTo(new DummyJpaControlLoopElementChild()));
+
+ testJpaControlLoopElement
+ .setKey(new PfReferenceKey("BadValue", "0.0.1", "a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+ testJpaControlLoopElement.setKey(new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION,
+ "a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+
+ testJpaControlLoopElement.setDefinition(new PfConceptKey("BadValue", "0.0.1"));
+ assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+ testJpaControlLoopElement.setDefinition(new PfConceptKey("cleDef", "0.0.1"));
+ assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+
+ testJpaControlLoopElement.setDescription("Description");
+ assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+ testJpaControlLoopElement.setDescription(null);
+ assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+
+ testJpaControlLoopElement.setOrderedState(ControlLoopOrderedState.PASSIVE);
+ assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+ testJpaControlLoopElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+
+ testJpaControlLoopElement.setState(ControlLoopState.PASSIVE);
+ assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+ testJpaControlLoopElement.setState(ControlLoopState.UNINITIALISED);
+ assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+
+ testJpaControlLoopElement.setParticipantType(new PfConceptKey("dummy", "0.0.1"));
+ assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+ testJpaControlLoopElement.setParticipantType(new PfConceptKey("participantType", "0.0.1"));
+ assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
+
+ assertEquals(testJpaControlLoopElement, new JpaControlLoopElement(testJpaControlLoopElement));
+ }
+
+ @Test
+ public void testJpaControlLoopElementLombok() {
+ assertNotNull(new Participant());
+ JpaControlLoopElement cle0 = new JpaControlLoopElement();
+
+ assertThat(cle0.toString()).contains("JpaControlLoopElement(");
+ assertThat(cle0.hashCode()).isNotZero();
+ assertEquals(true, cle0.equals(cle0));
+ assertEquals(false, cle0.equals(null));
+
+
+ JpaControlLoopElement cle1 = new JpaControlLoopElement();
+
+ cle1.setDefinition(new PfConceptKey("defName", "0.0.1"));
+ cle1.setDescription("Description");
+ cle1.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ cle1.setState(ControlLoopState.UNINITIALISED);
+ cle1.setParticipantId(new PfConceptKey("participant", "0.0.1"));
+
+ assertThat(cle1.toString()).contains("ControlLoopElement(");
+ assertEquals(false, cle1.hashCode() == 0);
+ assertEquals(false, cle1.equals(cle0));
+ assertEquals(false, cle1.equals(null));
+
+ assertNotEquals(cle1, cle0);
+
+ JpaControlLoopElement cle2 = new JpaControlLoopElement();
+ assertEquals(cle2, cle0);
+ }
+
+ private JpaControlLoopElement createJpaControlLoopElementInstance() {
+ ControlLoopElement testCle = createControlLoopElementInstance();
+ JpaControlLoopElement testJpaControlLoopElement = new JpaControlLoopElement();
+ testJpaControlLoopElement.setKey(null);
+ testJpaControlLoopElement.fromAuthorative(testCle);
+ testJpaControlLoopElement.setKey(PfReferenceKey.getNullKey());
+ testJpaControlLoopElement.fromAuthorative(testCle);
+
+ return testJpaControlLoopElement;
+ }
+
+ private ControlLoopElement createControlLoopElementInstance() {
+ ControlLoopElement controlLoopElement = new ControlLoopElement();
+ controlLoopElement.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ controlLoopElement.setDefinition(new ToscaConceptIdentifier("cleDef", "0.0.1"));
+ controlLoopElement.setParticipantType(new ToscaConceptIdentifier("participantType", "0.0.1"));
+
+ return controlLoopElement;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java
new file mode 100644
index 000000000..01062b046
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java
@@ -0,0 +1,296 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.LinkedHashMap;
+import org.junit.Test;
+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.ControlLoops;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the {@link JpaControlLoopTest} class.
+ */
+public class JpaControlLoopTest {
+
+ private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+
+ @Test
+ public void testJpaControlLoopConstructor() {
+ assertThatThrownBy(() -> {
+ new JpaControlLoop((JpaControlLoop) null);
+ }).hasMessageMatching("copyConcept is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop((PfConceptKey) null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(null, null, null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(null, null, null, new LinkedHashMap<>());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(null, null, ControlLoopState.UNINITIALISED, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(null, null, ControlLoopState.UNINITIALISED, new LinkedHashMap<>());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(null, new PfConceptKey(), null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(null, new PfConceptKey(), null, new LinkedHashMap<>());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(null, new PfConceptKey(), ControlLoopState.UNINITIALISED, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(null, new PfConceptKey(), ControlLoopState.UNINITIALISED, new LinkedHashMap<>());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(new PfConceptKey(), null, null, null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(new PfConceptKey(), null, null, new LinkedHashMap<>());
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(new PfConceptKey(), null, ControlLoopState.UNINITIALISED, null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(new PfConceptKey(), null, ControlLoopState.UNINITIALISED, new LinkedHashMap<>());
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), null, null);
+ }).hasMessageMatching("state is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), null, new LinkedHashMap<>());
+ }).hasMessageMatching("state is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED, null);
+ }).hasMessageMatching("elements is marked .*ull but is null");
+
+ assertNotNull(new JpaControlLoop());
+ assertNotNull(new JpaControlLoop((new PfConceptKey())));
+ assertNotNull(new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED,
+ new LinkedHashMap<>()));
+ }
+
+ @Test
+ public void testJpaControlLoop() {
+ JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance();
+
+ ControlLoop participant = createControlLoopInstance();
+ assertEquals(participant, testJpaControlLoop.toAuthorative());
+
+ assertThatThrownBy(() -> {
+ testJpaControlLoop.fromAuthorative(null);
+ }).hasMessageMatching("controlLoop is marked .*ull but is null");
+
+ assertThatThrownBy(() -> new JpaControlLoop((JpaControlLoop) null)).isInstanceOf(NullPointerException.class);
+
+ JpaControlLoop testJpaControlLoopFa = new JpaControlLoop();
+ testJpaControlLoopFa.setKey(null);
+ testJpaControlLoopFa.fromAuthorative(participant);
+ assertEquals(testJpaControlLoop, testJpaControlLoopFa);
+ testJpaControlLoopFa.setKey(PfConceptKey.getNullKey());
+ testJpaControlLoopFa.fromAuthorative(participant);
+ assertEquals(testJpaControlLoop, testJpaControlLoopFa);
+ testJpaControlLoopFa.setKey(new PfConceptKey("control-loop", "0.0.1"));
+ testJpaControlLoopFa.fromAuthorative(participant);
+ assertEquals(testJpaControlLoop, testJpaControlLoopFa);
+
+ assertEquals("control-loop", testJpaControlLoop.getKey().getName());
+ assertEquals("control-loop", new JpaControlLoop(createControlLoopInstance()).getKey().getName());
+ assertEquals("control-loop",
+ ((PfConceptKey) new JpaControlLoop(createControlLoopInstance()).getKeys().get(0)).getName());
+
+ testJpaControlLoop.clean();
+ assertEquals("control-loop", testJpaControlLoop.getKey().getName());
+
+ testJpaControlLoop.setDescription(" A Message ");
+ testJpaControlLoop.clean();
+ assertEquals("A Message", testJpaControlLoop.getDescription());
+
+ JpaControlLoop testJpaControlLoop2 = new JpaControlLoop(testJpaControlLoop);
+ assertEquals(testJpaControlLoop, testJpaControlLoop2);
+ }
+
+ @Test
+ public void testJpaControlLoopElementOrderedState() throws CoderException {
+ ControlLoop testControlLoop = createControlLoopInstance();
+ JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance();
+
+ testJpaControlLoop.setOrderedState(null);
+ assertEquals(testControlLoop, testJpaControlLoop.toAuthorative());
+ testJpaControlLoop.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+
+ ControlLoop noOrderedStateCl = new StandardCoder()
+ .decode(new File("src/test/resources/json/ControlLoopNoOrderedState.json"), ControlLoop.class);
+
+ JpaControlLoop noOrderedStateJpaCl = new JpaControlLoop(noOrderedStateCl);
+ assertNull(noOrderedStateJpaCl.getOrderedState());
+ noOrderedStateCl.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ noOrderedStateJpaCl = new JpaControlLoop(noOrderedStateCl);
+ assertEquals(testJpaControlLoop, noOrderedStateJpaCl);
+
+ ControlLoops controlLoopsWithElements = new StandardCoder()
+ .decode(new File("src/test/resources/providers/TestControlLoops.json"), ControlLoops.class);
+
+ JpaControlLoop jpaControlLoopWithElements =
+ new JpaControlLoop(controlLoopsWithElements.getControlLoopList().get(0));
+ assertEquals(4, jpaControlLoopWithElements.getElements().size());
+ assertEquals(18, jpaControlLoopWithElements.getKeys().size());
+ assertThatCode(() -> jpaControlLoopWithElements.clean()).doesNotThrowAnyException();
+
+ assertEquals(controlLoopsWithElements.getControlLoopList().get(0), jpaControlLoopWithElements.toAuthorative());
+ }
+
+ @Test
+ public void testJpaControlLoopValidation() {
+ JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance();
+
+ assertThatThrownBy(() -> {
+ testJpaControlLoop.validate(null);
+ }).hasMessageMatching("fieldName is marked .*ull but is null");
+
+ assertTrue(testJpaControlLoop.validate("").isValid());
+ }
+
+ @Test
+ public void testJpaControlLoopCompareTo() {
+ JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance();
+
+ JpaControlLoop otherJpaControlLoop = new JpaControlLoop(testJpaControlLoop);
+ assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+ assertEquals(-1, testJpaControlLoop.compareTo(null));
+ assertEquals(0, testJpaControlLoop.compareTo(testJpaControlLoop));
+ assertNotEquals(0, testJpaControlLoop.compareTo(new DummyJpaControlLoopChild()));
+
+ testJpaControlLoop.setKey(new PfConceptKey("BadValue", "0.0.1"));
+ assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+ testJpaControlLoop.setKey(new PfConceptKey("control-loop", "0.0.1"));
+ assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+
+ testJpaControlLoop.setDefinition(new PfConceptKey("BadValue", "0.0.1"));
+ assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+ testJpaControlLoop.setDefinition(new PfConceptKey("controlLoopDefinitionName", "0.0.1"));
+ assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+
+ testJpaControlLoop.setState(ControlLoopState.PASSIVE);
+ assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+ testJpaControlLoop.setState(ControlLoopState.UNINITIALISED);
+ assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+
+ testJpaControlLoop.setOrderedState(ControlLoopOrderedState.PASSIVE);
+ assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+ testJpaControlLoop.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+
+ testJpaControlLoop.setDescription("A description");
+ assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+ testJpaControlLoop.setDescription(null);
+ assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
+
+ assertEquals(testJpaControlLoop, new JpaControlLoop(testJpaControlLoop));
+ }
+
+ @Test
+ public void testJpaControlLoopLombok() {
+ assertNotNull(new ControlLoop());
+ JpaControlLoop cl0 = new JpaControlLoop();
+
+ assertThat(cl0.toString()).contains("JpaControlLoop(");
+ assertThat(cl0.hashCode()).isNotZero();
+ assertEquals(true, cl0.equals(cl0));
+ assertEquals(false, cl0.equals(null));
+
+
+ JpaControlLoop cl1 = new JpaControlLoop();
+
+ cl1.setDefinition(new PfConceptKey("defName", "0.0.1"));
+ cl1.setDescription("Description");
+ cl1.setElements(new LinkedHashMap<>());
+ cl1.setKey(new PfConceptKey("participant", "0.0.1"));
+ cl1.setState(ControlLoopState.UNINITIALISED);
+
+ assertThat(cl1.toString()).contains("ControlLoop(");
+ assertEquals(false, cl1.hashCode() == 0);
+ assertEquals(false, cl1.equals(cl0));
+ assertEquals(false, cl1.equals(null));
+
+ assertNotEquals(cl1, cl0);
+
+ JpaControlLoop cl2 = new JpaControlLoop();
+ assertEquals(cl2, cl0);
+ }
+
+ private JpaControlLoop createJpaControlLoopInstance() {
+ ControlLoop testControlLoop = createControlLoopInstance();
+ JpaControlLoop testJpaControlLoop = new JpaControlLoop();
+ testJpaControlLoop.setKey(null);
+ testJpaControlLoop.fromAuthorative(testControlLoop);
+ testJpaControlLoop.setKey(PfConceptKey.getNullKey());
+ testJpaControlLoop.fromAuthorative(testControlLoop);
+
+ return testJpaControlLoop;
+ }
+
+ private ControlLoop createControlLoopInstance() {
+ ControlLoop testControlLoop = new ControlLoop();
+ testControlLoop.setName("control-loop");
+ testControlLoop.setVersion("0.0.1");
+ testControlLoop.setDefinition(new ToscaConceptIdentifier("controlLoopDefinitionName", "0.0.1"));
+ testControlLoop.setElements(new LinkedHashMap<>());
+
+ return testControlLoop;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java
new file mode 100644
index 000000000..7eedd245b
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java
@@ -0,0 +1,193 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Instant;
+import org.junit.Test;
+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.common.parameters.BeanValidationResult;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfTimestampKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the {@link JpaParticipantStatistics} class.
+ */
+public class JpaParticipantStatisticsTest {
+
+ private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+
+ @Test
+ public void testJpaParticipantStatisticsConstructor() {
+ assertThatThrownBy(() -> {
+ new JpaParticipantStatistics((JpaParticipantStatistics) null);
+ }).hasMessageMatching("copyConcept is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaParticipantStatistics((PfTimestampKey) null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipantStatistics(null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipantStatistics(null, new PfConceptKey());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipantStatistics(new PfTimestampKey(), null);
+ }).hasMessageMatching("participantId is marked .*ull but is null");
+
+ assertNotNull(new JpaParticipantStatistics());
+ assertNotNull(new JpaParticipantStatistics((new PfTimestampKey())));
+ assertNotNull(new JpaParticipantStatistics(new PfTimestampKey(), new PfConceptKey()));
+ }
+
+ @Test
+ public void testJpaParticipantStatistics() {
+ JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance();
+
+ ParticipantStatistics cles = createParticipantStatisticsInstance();
+ assertEquals(cles, testJpaParticipantStatistics.toAuthorative());
+
+ assertThatThrownBy(() -> {
+ testJpaParticipantStatistics.fromAuthorative(null);
+ }).hasMessageMatching("participantStatistics is marked .*ull but is null");
+
+ assertThatThrownBy(() -> new JpaParticipantStatistics((JpaParticipantStatistics) null))
+ .isInstanceOf(NullPointerException.class);
+
+ JpaParticipantStatistics testJpaParticipantStatisticsFa = new JpaParticipantStatistics();
+ testJpaParticipantStatisticsFa.setKey(null);
+ testJpaParticipantStatisticsFa.fromAuthorative(cles);
+ assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
+ testJpaParticipantStatisticsFa.setKey(PfTimestampKey.getNullKey());
+ testJpaParticipantStatisticsFa.fromAuthorative(cles);
+ assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
+ testJpaParticipantStatisticsFa
+ .setKey(new PfTimestampKey("participantName", "0.0.1", Instant.ofEpochMilli(123456L)));
+ testJpaParticipantStatisticsFa.fromAuthorative(cles);
+ assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
+
+ testJpaParticipantStatisticsFa = new JpaParticipantStatistics(cles);
+ assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
+
+ assertEquals(2, testJpaParticipantStatistics.getKeys().size());
+
+ assertEquals("participantName", testJpaParticipantStatistics.getKey().getName());
+
+ testJpaParticipantStatistics.clean();
+ assertEquals("participantName", testJpaParticipantStatistics.getKey().getName());
+
+ JpaParticipantStatistics testJpaParticipantStatistics2 =
+ new JpaParticipantStatistics(testJpaParticipantStatistics);
+ assertEquals(testJpaParticipantStatistics, testJpaParticipantStatistics2);
+ }
+
+ @Test
+ public void testJpaParticipantStatisticsValidation() {
+ JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance();
+
+ assertThatThrownBy(() -> {
+ testJpaParticipantStatistics.validate(null);
+ }).hasMessageMatching("fieldName is marked .*ull but is null");
+
+ BeanValidationResult validationResult = testJpaParticipantStatistics.validate("");
+ assertTrue(validationResult.isValid());
+ }
+
+ @Test
+ public void testJpaParticipantStatisticsConmpareTo() {
+ JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance();
+
+ JpaParticipantStatistics otherJpaParticipantStatistics =
+ new JpaParticipantStatistics(testJpaParticipantStatistics);
+ assertEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics));
+ assertEquals(-1, testJpaParticipantStatistics.compareTo(null));
+ assertEquals(0, testJpaParticipantStatistics.compareTo(testJpaParticipantStatistics));
+ assertNotEquals(0, testJpaParticipantStatistics.compareTo(new DummyJpaParticipantStatisticsChild()));
+
+ testJpaParticipantStatistics.setState(ParticipantState.UNKNOWN);
+ assertNotEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics));
+ testJpaParticipantStatistics.setState(ParticipantState.PASSIVE);
+ assertEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics));
+
+ assertEquals(testJpaParticipantStatistics, new JpaParticipantStatistics(testJpaParticipantStatistics));
+ }
+
+ @Test
+ public void testJpaParticipantStatisticsLombok() {
+ assertNotNull(new Participant());
+ JpaParticipantStatistics ps0 = new JpaParticipantStatistics();
+
+ assertThat(ps0.toString()).contains("JpaParticipantStatistics(");
+ assertThat(ps0.hashCode()).isNotZero();
+ assertEquals(true, ps0.equals(ps0));
+ assertEquals(false, ps0.equals(null));
+
+
+ JpaParticipantStatistics ps1 = new JpaParticipantStatistics();
+
+ ps1.setState(ParticipantState.UNKNOWN);
+
+ assertThat(ps1.toString()).contains("JpaParticipantStatistics(");
+ assertEquals(false, ps1.hashCode() == 0);
+ assertEquals(false, ps1.equals(ps0));
+ assertEquals(false, ps1.equals(null));
+
+ assertNotEquals(ps1, ps0);
+
+ JpaParticipantStatistics ps2 = new JpaParticipantStatistics();
+ assertEquals(ps2, ps0);
+ }
+
+ private JpaParticipantStatistics createJpaParticipantStatisticsInstance() {
+ ParticipantStatistics testCles = createParticipantStatisticsInstance();
+ JpaParticipantStatistics testJpaParticipantStatistics = new JpaParticipantStatistics();
+ testJpaParticipantStatistics.setKey(null);
+ testJpaParticipantStatistics.fromAuthorative(testCles);
+ testJpaParticipantStatistics.setKey(PfTimestampKey.getNullKey());
+ testJpaParticipantStatistics.fromAuthorative(testCles);
+
+ return testJpaParticipantStatistics;
+ }
+
+ private ParticipantStatistics createParticipantStatisticsInstance() {
+ ParticipantStatistics participantStatistics = new ParticipantStatistics();
+ participantStatistics.setParticipantId(new ToscaConceptIdentifier("participantName", "0.0.1"));
+ participantStatistics.setTimeStamp(Instant.ofEpochMilli(123456L));
+ participantStatistics.setState(ParticipantState.PASSIVE);
+ participantStatistics.setHealthStatus(ParticipantHealthStatus.HEALTHY);
+
+ return participantStatistics;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java
new file mode 100644
index 000000000..5c96df6f1
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java
@@ -0,0 +1,253 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+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.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the {@link JpaParticiant} class.
+ */
+public class JpaParticipantTest {
+
+ private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+
+ @Test
+ public void testJpaParticipantConstructor() {
+ assertThatThrownBy(() -> {
+ new JpaParticipant((JpaParticipant) null);
+ }).hasMessageMatching("copyConcept is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant((PfConceptKey) null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(null, null, null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(null, null, null, ParticipantHealthStatus.HEALTHY);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(null, null, ParticipantState.ACTIVE, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(null, null, ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(null, new PfConceptKey(), null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(null, new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(new PfConceptKey(), null, null, null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(new PfConceptKey(), null, null, ParticipantHealthStatus.HEALTHY);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(new PfConceptKey(), null, ParticipantState.ACTIVE, null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(new PfConceptKey(), null, ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, null);
+ }).hasMessageMatching("participantState is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY);
+ }).hasMessageMatching("participantState is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ACTIVE, null);
+ }).hasMessageMatching("healthStatus is marked .*ull but is null");
+
+ assertNotNull(new JpaParticipant());
+ assertNotNull(new JpaParticipant((new PfConceptKey())));
+ assertNotNull(new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ACTIVE,
+ ParticipantHealthStatus.HEALTHY));
+ }
+
+ @Test
+ public void testJpaParticipant() {
+ JpaParticipant testJpaParticipant = createJpaParticipantInstance();
+
+ Participant participant = createParticipantInstance();
+ assertEquals(participant, testJpaParticipant.toAuthorative());
+
+ assertThatThrownBy(() -> {
+ testJpaParticipant.fromAuthorative(null);
+ }).hasMessageMatching("participant is marked .*ull but is null");
+
+ assertThatThrownBy(() -> new JpaParticipant((JpaParticipant) null)).isInstanceOf(NullPointerException.class);
+
+ JpaParticipant testJpaParticipantFa = new JpaParticipant();
+ testJpaParticipantFa.setKey(null);
+ testJpaParticipantFa.fromAuthorative(participant);
+ assertEquals(testJpaParticipant, testJpaParticipantFa);
+ testJpaParticipantFa.setKey(PfConceptKey.getNullKey());
+ testJpaParticipantFa.fromAuthorative(participant);
+ assertEquals(testJpaParticipant, testJpaParticipantFa);
+ testJpaParticipantFa.setKey(new PfConceptKey("participant", "0.0.1"));
+ testJpaParticipantFa.fromAuthorative(participant);
+ assertEquals(testJpaParticipant, testJpaParticipantFa);
+
+ assertEquals("participant", testJpaParticipant.getKey().getName());
+ assertEquals("participant", new JpaParticipant(createParticipantInstance()).getKey().getName());
+ assertEquals("participant",
+ ((PfConceptKey) new JpaParticipant(createParticipantInstance()).getKeys().get(0)).getName());
+
+ testJpaParticipant.clean();
+ assertEquals("participant", testJpaParticipant.getKey().getName());
+
+ testJpaParticipant.setDescription(" A Message ");
+ testJpaParticipant.clean();
+ assertEquals("A Message", testJpaParticipant.getDescription());
+
+ JpaParticipant testJpaParticipant2 = new JpaParticipant(testJpaParticipant);
+ assertEquals(testJpaParticipant, testJpaParticipant2);
+ }
+
+ @Test
+ public void testJpaParticipantValidation() {
+ JpaParticipant testJpaParticipant = createJpaParticipantInstance();
+
+ assertThatThrownBy(() -> {
+ testJpaParticipant.validate(null);
+ }).hasMessageMatching("fieldName is marked .*ull but is null");
+
+ assertTrue(testJpaParticipant.validate("").isValid());
+ }
+
+ @Test
+ public void testJpaParticipantCompareTo() {
+ JpaParticipant testJpaParticipant = createJpaParticipantInstance();
+
+ JpaParticipant otherJpaParticipant = new JpaParticipant(testJpaParticipant);
+ assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
+ assertEquals(-1, testJpaParticipant.compareTo(null));
+ assertEquals(0, testJpaParticipant.compareTo(testJpaParticipant));
+ assertNotEquals(0, testJpaParticipant.compareTo(new DummyJpaParticipantChild()));
+
+ testJpaParticipant.setKey(new PfConceptKey("BadValue", "0.0.1"));
+ assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
+ testJpaParticipant.setKey(new PfConceptKey("participant", "0.0.1"));
+ assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
+
+ testJpaParticipant.setDefinition(new PfConceptKey("BadValue", "0.0.1"));
+ assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
+ testJpaParticipant.setDefinition(new PfConceptKey("participantDefinitionName", "0.0.1"));
+ assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
+
+ testJpaParticipant.setParticipantState(ParticipantState.PASSIVE);
+ assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
+ testJpaParticipant.setParticipantState(ParticipantState.UNKNOWN);
+ assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
+
+ testJpaParticipant.setHealthStatus(ParticipantHealthStatus.NOT_HEALTHY);
+ assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
+ testJpaParticipant.setHealthStatus(ParticipantHealthStatus.UNKNOWN);
+ assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
+
+ assertEquals(testJpaParticipant, new JpaParticipant(testJpaParticipant));
+ }
+
+ @Test
+ public void testJpaParticipantLombok() {
+ assertNotNull(new Participant());
+ JpaParticipant p0 = new JpaParticipant();
+
+ assertThat(p0.toString()).contains("JpaParticipant(");
+ assertThat(p0.hashCode()).isNotZero();
+ assertEquals(true, p0.equals(p0));
+ assertEquals(false, p0.equals(null));
+
+
+ JpaParticipant p1 = new JpaParticipant();
+
+ p1.setDefinition(new PfConceptKey("defName", "0.0.1"));
+ p1.setDescription("Description");
+ p1.setHealthStatus(ParticipantHealthStatus.HEALTHY);
+ p1.setKey(new PfConceptKey("participant", "0.0.1"));
+ p1.setParticipantState(ParticipantState.ACTIVE);
+
+ assertThat(p1.toString()).contains("Participant(");
+ assertEquals(false, p1.hashCode() == 0);
+ assertEquals(false, p1.equals(p0));
+ assertEquals(false, p1.equals(null));
+
+ assertNotEquals(p1, p0);
+
+ JpaParticipant p2 = new JpaParticipant();
+ assertEquals(p2, p0);
+ }
+
+ private JpaParticipant createJpaParticipantInstance() {
+ Participant testParticipant = createParticipantInstance();
+ JpaParticipant testJpaParticipant = new JpaParticipant();
+ testJpaParticipant.setKey(null);
+ testJpaParticipant.fromAuthorative(testParticipant);
+ testJpaParticipant.setKey(PfConceptKey.getNullKey());
+ testJpaParticipant.fromAuthorative(testParticipant);
+
+ return testJpaParticipant;
+ }
+
+ private Participant createParticipantInstance() {
+ Participant testParticipant = new Participant();
+ testParticipant.setName("participant");
+ testParticipant.setVersion("0.0.1");
+ testParticipant.setDefinition(new ToscaConceptIdentifier("participantDefinitionName", "0.0.1"));
+
+ return testParticipant;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java
new file mode 100644
index 000000000..9e21b216b
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.models.controlloop.persistence.concepts;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.EqualsAndHashCodeMatchRule;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+import java.util.List;
+import org.junit.Test;
+import org.onap.policy.common.utils.test.ToStringTester;
+
+/**
+ * Class to perform unit tests of all pojos.
+ */
+public class PojosTest {
+
+ @Test
+ public void testPojos() {
+ List<PojoClass> pojoClasses =
+ PojoClassFactory.getPojoClasses(PojosTest.class.getPackageName());
+
+ // @formatter:off
+ final Validator validator = ValidatorBuilder
+ .create()
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .with(new EqualsAndHashCodeMatchRule())
+ .with(new NoPublicFieldsExceptStaticFinalRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .with(new ToStringTester())
+ .build();
+
+ validator.validate(pojoClasses);
+ // @formatter:on
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
new file mode 100644
index 000000000..f5d094f9e
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
@@ -0,0 +1,115 @@
+/*-
+ * ============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.models.controlloop.persistence.provider;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+
+import java.time.Instant;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ClElementStatisticsProviderTest {
+ private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
+ private static final Coder CODER = new StandardCoder();
+ private static final String CL_ELEMENT_STATS_JSON =
+ "src/test/resources/providers/TestClElementStatistics.json";
+
+ private static AtomicInteger dbNameCounter = new AtomicInteger();
+
+ private PolicyModelsProviderParameters parameters;
+ private ClElementStatisticsProvider clElementStatisticsProvider;
+ private ClElementStatisticsList inputClElementStats;
+ private String originalJson = ResourceUtils.getResourceAsString(CL_ELEMENT_STATS_JSON);
+
+ /**
+ * Set up test ClElement statistics provider.
+ */
+ @Before
+ public void setupDao() throws Exception {
+
+ parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
+ parameters.setName("PolicyProviderParameterGroup");
+ parameters.setImplementation("org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
+ parameters.setDatabaseUrl("jdbc:h2:mem:clElementTestDb" + dbNameCounter.getAndIncrement());
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword("P01icY");
+ parameters.setPersistenceUnit("ToscaConceptTest");
+
+ clElementStatisticsProvider = new ClElementStatisticsProvider(parameters);
+ inputClElementStats = CODER.decode(originalJson, ClElementStatisticsList.class);
+ }
+
+ @After
+ public void teardown() {
+ clElementStatisticsProvider.close();
+ }
+
+ @Test
+ public void testClElementStatisticsCreate() throws Exception {
+ assertThatThrownBy(() -> {
+ clElementStatisticsProvider.createClElementStatistics(null);
+ }).hasMessageMatching(LIST_IS_NULL);
+
+ ClElementStatisticsList createdClElementStats = new ClElementStatisticsList();
+ createdClElementStats.setClElementStatistics(clElementStatisticsProvider
+ .createClElementStatistics(inputClElementStats.getClElementStatistics()));
+
+ assertEquals(inputClElementStats.toString().replaceAll("\\s+", ""),
+ createdClElementStats.toString().replaceAll("\\s+", ""));
+ }
+
+ @Test
+ public void testGetClElementStatistics() throws Exception {
+
+ List<ClElementStatistics> getResponse;
+
+ //Return empty list when no data present in db
+ getResponse = clElementStatisticsProvider.getClElementStatistics(null, null, null,
+ null);
+ assertThat(getResponse).isEmpty();
+
+ clElementStatisticsProvider.createClElementStatistics(inputClElementStats
+ .getClElementStatistics());
+ ToscaConceptIdentifier identifier = inputClElementStats.getClElementStatistics().get(0)
+ .getParticipantId();
+ Instant instant = inputClElementStats.getClElementStatistics().get(0).getTimeStamp();
+ String id = inputClElementStats.getClElementStatistics().get(0).getId().toString();
+ assertEquals(1, clElementStatisticsProvider.getClElementStatistics(identifier.getName(),
+ identifier.getVersion(), id, instant).size());
+
+ assertEquals(1, clElementStatisticsProvider.getFilteredClElementStatistics("name2",
+ "1.0.1", null, null, null,
+ "DESC", 1).size());
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
new file mode 100644
index 000000000..96b63a23d
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
@@ -0,0 +1,160 @@
+/*-
+ * ============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.models.controlloop.persistence.provider;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+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.ControlLoops;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+
+public class ControlLoopProviderTest {
+
+ private static final String LIST_IS_NULL = "controlLoops is marked .*ull but is null";
+ private static final Coder CODER = new StandardCoder();
+ private static final String CONTROL_LOOP_JSON = "src/test/resources/providers/TestControlLoops.json";
+ private static final String UPDATE_CL_JSON = "src/test/resources/providers/UpdateControlLoops.json";
+
+ private static AtomicInteger dbNameCounter = new AtomicInteger();
+
+ private PolicyModelsProviderParameters parameters;
+ private ControlLoopProvider controlLoopProvider;
+ private ControlLoops inputControlLoops;
+ private ControlLoops updateControlLoops;
+ private String originalJson = ResourceUtils.getResourceAsString(CONTROL_LOOP_JSON);
+ private String updateClJson = ResourceUtils.getResourceAsString(UPDATE_CL_JSON);
+
+ /**
+ * Set up test control loop provider.
+ */
+ @Before
+ public void setupDao() throws Exception {
+
+ parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
+ parameters.setName("PolicyProviderParameterGroup");
+ parameters.setImplementation("org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
+ parameters.setDatabaseUrl("jdbc:h2:mem:controlLoopProviderTestDb" + dbNameCounter.getAndDecrement());
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword("P01icY");
+ parameters.setPersistenceUnit("ToscaConceptTest");
+
+ controlLoopProvider = new ControlLoopProvider(parameters);
+
+ inputControlLoops = CODER.decode(originalJson, ControlLoops.class);
+ updateControlLoops = CODER.decode(updateClJson, ControlLoops.class);
+ }
+
+ @After
+ public void teardown() {
+ controlLoopProvider.close();
+ }
+
+ @Test
+ public void testControlLoopCreate() throws Exception {
+ assertThatThrownBy(() -> {
+ controlLoopProvider.createControlLoops(null);
+ }).hasMessageMatching(LIST_IS_NULL);
+
+ ControlLoops createdControlLoops = new ControlLoops();
+ createdControlLoops
+ .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
+
+ assertEquals(inputControlLoops, createdControlLoops);
+ }
+
+ @Test
+ public void testGetControlLoops() throws Exception {
+
+ List<ControlLoop> getResponse;
+
+ // Return empty list when no data present in db
+ getResponse = controlLoopProvider.getControlLoops(null, null);
+ assertThat(getResponse).isEmpty();
+
+ controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList());
+ String name = inputControlLoops.getControlLoopList().get(0).getName();
+ String version = inputControlLoops.getControlLoopList().get(0).getVersion();
+ assertEquals(1, controlLoopProvider.getControlLoops(name, version).size());
+
+ ControlLoop cl = new ControlLoop();
+ cl = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier("PMSHInstance1", "1.0.1"));
+ assertEquals(inputControlLoops.getControlLoopList().get(1), cl);
+
+ assertNull(controlLoopProvider.getControlLoop(new ToscaConceptIdentifier("invalid_name", "1.0.1")));
+
+ assertThatThrownBy(() -> {
+ controlLoopProvider.getFilteredControlLoops(null);
+ }).hasMessageMatching("filter is marked .*ull but is null");
+
+ final ToscaTypedEntityFilter<ControlLoop> filter = ToscaTypedEntityFilter.<ControlLoop>builder()
+ .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
+ assertEquals(2, controlLoopProvider.getFilteredControlLoops(filter).size());
+ }
+
+
+ @Test
+ public void testUpdateControlLoops() throws Exception {
+ assertThatThrownBy(() -> {
+ controlLoopProvider.updateControlLoops(null);
+ }).hasMessageMatching("controlLoops is marked .*ull but is null");
+
+ ControlLoops existingControlLoops = new ControlLoops();
+ existingControlLoops
+ .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
+ ControlLoop updateResponse = new ControlLoop();
+ updateResponse = controlLoopProvider.updateControlLoop(updateControlLoops.getControlLoopList().get(0));
+
+ assertEquals(ControlLoopOrderedState.RUNNING, updateResponse.getOrderedState());
+ }
+
+ @Test
+ public void testDeleteControlLoop() throws Exception {
+ assertThatThrownBy(() -> {
+ controlLoopProvider.deleteControlLoop("Invalid_name", "1.0.1");
+ }).hasMessageMatching(".*.failed, control loop does not exist");
+
+ ControlLoop deletedCl;
+ List<ControlLoop> clList = controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList());
+ String name = inputControlLoops.getControlLoopList().get(0).getName();
+ String version = inputControlLoops.getControlLoopList().get(0).getVersion();
+
+ deletedCl = controlLoopProvider.deleteControlLoop(name, version);
+ assertEquals(clList.get(0), deletedCl);
+
+ }
+}
+
+
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java
new file mode 100644
index 000000000..7a86a49dc
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java
@@ -0,0 +1,154 @@
+/*-
+ * ============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.models.controlloop.persistence.provider;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+
+public class ParticipantProviderTest {
+
+ private static final Coder CODER = new StandardCoder();
+ private static final String PARTICIPANT_JSON =
+ "src/test/resources/providers/TestParticipant.json";
+ private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
+
+ private static AtomicInteger dbNameCounter = new AtomicInteger();
+
+ private PolicyModelsProviderParameters parameters;
+ private ParticipantProvider participantProvider;
+ private List<Participant> inputParticipants = new ArrayList<>();
+ private Participant updateParticipants;
+ private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_JSON);
+
+ /**
+ * Set up test Participant provider.
+ */
+ @Before
+ public void setupDao() throws Exception {
+
+ parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
+ parameters.setName("PolicyProviderParameterGroup");
+ parameters.setImplementation("org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
+ parameters.setDatabaseUrl("jdbc:h2:mem:participantProviderTestDb" + dbNameCounter.getAndIncrement());
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword("P01icY");
+ parameters.setPersistenceUnit("ToscaConceptTest");
+
+ participantProvider = new ParticipantProvider(parameters);
+ inputParticipants.add(CODER.decode(originalJson, Participant.class));
+
+ }
+
+ @After
+ public void teardown() {
+ participantProvider.close();
+ }
+
+ @Test
+ public void testParticipantCreate() throws Exception {
+ assertThatThrownBy(() -> {
+ participantProvider.createParticipants(null);
+ }).hasMessageMatching(LIST_IS_NULL);
+
+ List<Participant> createdParticipants = new ArrayList<>();
+ createdParticipants.addAll(participantProvider
+ .createParticipants(inputParticipants));
+
+ assertEquals(createdParticipants.get(0),
+ inputParticipants.get(0));
+ }
+
+
+ @Test
+ public void testGetControlLoops() throws Exception {
+
+ List<Participant> getResponse;
+
+ //Return empty list when no data present in db
+ getResponse = participantProvider.getParticipants(null, null);
+ assertThat(getResponse).isEmpty();
+
+ participantProvider.createParticipants(inputParticipants);
+ String name = inputParticipants.get(0).getName();
+ String version = inputParticipants.get(0).getVersion();
+ assertEquals(1, participantProvider.getParticipants(name, version).size());
+
+ assertThat(participantProvider.getParticipants("invalid_name",
+ "1.0.1")).isEmpty();
+
+ assertThatThrownBy(() -> {
+ participantProvider.getFilteredParticipants(null);
+ }).hasMessageMatching("filter is marked .*ull but is null");
+
+ final ToscaTypedEntityFilter<Participant> filter = ToscaTypedEntityFilter.<Participant>builder()
+ .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
+ assertEquals(1, participantProvider.getFilteredParticipants(filter).size());
+ }
+
+ @Test
+ public void testUpdateParticipant() throws Exception {
+ assertThatThrownBy(() -> {
+ participantProvider.updateParticipants(null);
+ }).hasMessageMatching("participants is marked .*ull but is null");
+
+ participantProvider.createParticipants(inputParticipants);
+ updateParticipants = inputParticipants.get(0);
+ updateParticipants.setParticipantState(ParticipantState.ACTIVE);
+ List<Participant> participantList = new ArrayList<>();
+ participantList.add(updateParticipants);
+ List<Participant> updateResponse = new ArrayList<>();
+ updateResponse = participantProvider.updateParticipants(participantList);
+
+ assertEquals(ParticipantState.ACTIVE, updateResponse.get(0).getParticipantState());
+ }
+
+ @Test
+ public void testDeleteParticipant() throws Exception {
+ assertThatThrownBy(() -> {
+ participantProvider.deleteParticipant("Invalid_name", "1.0.1");
+ }).hasMessageMatching(".*.failed, participant does not exist");
+
+ Participant deletedParticipant;
+ List<Participant> participantList = participantProvider.createParticipants(inputParticipants);
+ String name = inputParticipants.get(0).getName();
+ String version = inputParticipants.get(0).getVersion();
+
+ deletedParticipant = participantProvider.deleteParticipant(name, version);
+ assertEquals(participantList.get(0), deletedParticipant);
+
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java
new file mode 100644
index 000000000..d4bc9777a
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java
@@ -0,0 +1,109 @@
+/*-
+ * ============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.models.controlloop.persistence.provider;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+
+import java.time.Instant;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ParticipantStatisticsProviderTest {
+
+ private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
+ private static final Coder CODER = new StandardCoder();
+ private static final String PARTICIPANT_STATS_JSON = "src/test/resources/providers/TestParticipantStatistics.json";
+
+ private static AtomicInteger dbNameCounter = new AtomicInteger();
+
+ private PolicyModelsProviderParameters parameters;
+ private ParticipantStatisticsProvider participantStatisticsProvider;
+ private ParticipantStatisticsList inputParticipantStatistics;
+ private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_STATS_JSON);
+
+ /**
+ * Set up test Participant statistics provider.
+ */
+ @Before
+ public void setupDao() throws Exception {
+
+ parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
+ parameters.setName("PolicyProviderParameterGroup");
+ parameters.setImplementation("org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
+ parameters.setDatabaseUrl("jdbc:h2:mem:participantStatisticsProviderTestDb" + dbNameCounter.getAndIncrement());
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword("P01icY");
+ parameters.setPersistenceUnit("ToscaConceptTest");
+
+ participantStatisticsProvider = new ParticipantStatisticsProvider(parameters);
+ inputParticipantStatistics = CODER.decode(originalJson, ParticipantStatisticsList.class);
+ }
+
+ @After
+ public void teardown() {
+ participantStatisticsProvider.close();
+ }
+
+ @Test
+ public void testParticipantStatisticsCreate() throws Exception {
+ assertThatThrownBy(() -> {
+ participantStatisticsProvider.createParticipantStatistics(null);
+ }).hasMessageMatching(LIST_IS_NULL);
+
+ ParticipantStatisticsList createdStatsList = new ParticipantStatisticsList();
+ createdStatsList.setStatisticsList(participantStatisticsProvider
+ .createParticipantStatistics(inputParticipantStatistics.getStatisticsList()));
+
+ assertEquals(inputParticipantStatistics.toString().replaceAll("\\s+", ""),
+ createdStatsList.toString().replaceAll("\\s+", ""));
+ }
+
+ @Test
+ public void testGetControlLoops() throws Exception {
+ List<ParticipantStatistics> getResponse;
+
+ // Return empty list when no data present in db
+ getResponse = participantStatisticsProvider.getParticipantStatistics(null, null, null);
+ assertThat(getResponse).isEmpty();
+
+ participantStatisticsProvider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
+ ToscaConceptIdentifier identifier = inputParticipantStatistics.getStatisticsList().get(0).getParticipantId();
+ Instant instant = inputParticipantStatistics.getStatisticsList().get(0).getTimeStamp();
+ assertEquals(1, participantStatisticsProvider
+ .getParticipantStatistics(identifier.getName(), identifier.getVersion(), instant).size());
+
+ assertEquals(1, participantStatisticsProvider
+ .getFilteredParticipantStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size());
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java
new file mode 100644
index 000000000..d1e3dcfcc
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java
@@ -0,0 +1,83 @@
+/*-
+ * ============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.models.messages.dmaap.notification;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+
+public class ControlLoopNotificationTest {
+
+ @Test
+ public void testControlLoopNotification() {
+ ControlLoopNotification cln0 = new ControlLoopNotification();
+
+ List<ControlLoopStatus> addedList = new ArrayList<>();
+ addedList.add(new ControlLoopStatus());
+
+ List<ControlLoopStatus> deletedList = new ArrayList<>();
+ deletedList.add(new ControlLoopStatus());
+
+ assertEquals(true, cln0.isEmpty());
+
+ cln0.setAdded(addedList);
+ assertEquals(false, cln0.isEmpty());
+ cln0.setAdded(null);
+ assertEquals(true, cln0.isEmpty());
+
+ cln0.setDeleted(deletedList);
+ assertEquals(false, cln0.isEmpty());
+ cln0.setDeleted(null);
+ assertEquals(true, cln0.isEmpty());
+
+ cln0.setAdded(addedList);
+ cln0.setDeleted(deletedList);
+ assertEquals(false, cln0.isEmpty());
+ cln0.setAdded(null);
+ cln0.setDeleted(null);
+ assertEquals(true, cln0.isEmpty());
+ }
+
+ @Test
+ public void testControlLoopNotificationLombok() {
+ assertNotNull(new ControlLoopNotification());
+ assertNotNull(new ControlLoopNotification(new ArrayList<>(), new ArrayList<>()));
+
+ ControlLoopNotification cln0 = new ControlLoopNotification();
+
+ assertThat(cln0.toString()).contains("ControlLoopNotification(");
+ assertEquals(false, cln0.hashCode() == 0);
+ assertEquals(true, cln0.equals(cln0));
+ assertEquals(false, cln0.equals(null));
+
+
+ ControlLoopNotification cln1 = new ControlLoopNotification();
+
+ assertThat(cln1.toString()).contains("ControlLoopNotification(");
+ assertEquals(false, cln1.hashCode() == 0);
+ assertEquals(true, cln1.equals(cln0));
+ assertEquals(false, cln1.equals(null));
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java
new file mode 100644
index 000000000..d1ddbf4e6
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java
@@ -0,0 +1,48 @@
+/*-
+ * ============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.models.messages.dmaap.notification;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ControlLoopStatusTest {
+
+ @Test
+ public void testControlLoopStatusLombok() {
+ assertNotNull(new ControlLoopStatus());
+ assertNotNull(new ControlLoopStatus(UUID.randomUUID(), new ToscaConceptIdentifier()));
+
+ ControlLoopStatus cln0 = new ControlLoopStatus();
+
+ assertThat(cln0.toString()).contains("ControlLoopStatus(");
+ assertEquals(false, cln0.hashCode() == 0);
+ assertEquals(true, cln0.equals(cln0));
+ assertEquals(false, cln0.equals(null));
+
+ ControlLoopStatus cln1 = new ControlLoopStatus();
+ assertEquals(true, cln1.equals(cln0));
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java
new file mode 100644
index 000000000..6ea07be76
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.models.messages.dmaap.notification;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+import java.util.List;
+import org.junit.Test;
+import org.onap.policy.common.utils.test.ToStringTester;
+
+/**
+ * Class to perform unit tests of all pojos.
+ */
+public class NotificationPojosTest {
+
+ @Test
+ public void testPojos() {
+ List<PojoClass> pojoClasses =
+ PojoClassFactory.getPojoClasses(NotificationPojosTest.class.getPackageName());
+
+ // @formatter:off
+ final Validator validator = ValidatorBuilder
+ .create()
+ .with(new ToStringTester())
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+
+ validator.validate(pojoClasses);
+ // @formatter:on
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChangeTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChangeTest.java
new file mode 100644
index 000000000..06d6ecf77
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChangeTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the copy constructor and other methods.
+ */
+public class ParticipantControlLoopStateChangeTest {
+
+ @Test
+ public void testCopyConstructor() {
+ assertThatThrownBy(() -> new ParticipantStateChange(null)).isInstanceOf(NullPointerException.class);
+
+ ParticipantControlLoopStateChange orig = new ParticipantControlLoopStateChange();
+
+ // verify with null values
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantControlLoopStateChange(orig).toString()));
+
+ // verify with all values
+ ToscaConceptIdentifier id = new ToscaConceptIdentifier();
+ id.setName("id");
+ id.setVersion("1.2.3");
+ orig.setControlLoopId(id);
+ orig.setParticipantId(id);
+ orig.setMessageId(UUID.randomUUID());
+ orig.setOrderedState(ControlLoopOrderedState.RUNNING);
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
+
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantControlLoopStateChange(orig).toString()));
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdateTest.java
new file mode 100644
index 000000000..4397bf158
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdateTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+/**
+ * Test the copy constructor.
+ */
+public class ParticipantControlLoopUpdateTest {
+ @Test
+ public void testCopyConstructor() {
+ assertThatThrownBy(() -> new ParticipantControlLoopUpdate(null)).isInstanceOf(NullPointerException.class);
+
+ ParticipantControlLoopUpdate orig = new ParticipantControlLoopUpdate();
+ // verify with all values
+ ToscaConceptIdentifier id = new ToscaConceptIdentifier();
+ id.setName("id");
+ id.setVersion("1.2.3");
+ orig.setControlLoopId(id);
+ orig.setParticipantId(id);
+ orig.setMessageId(UUID.randomUUID());
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
+
+ ControlLoop controlLoop = new ControlLoop();
+ controlLoop.setName("controlLoop");
+ ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate();
+ toscaServiceTemplate.setName("serviceTemplate");
+ toscaServiceTemplate.setDerivedFrom("parentServiceTemplate");
+ toscaServiceTemplate.setDescription("Description of serviceTemplate");
+ toscaServiceTemplate.setVersion("1.2.3");
+ orig.setControlLoopDefinition(toscaServiceTemplate);
+ orig.setControlLoop(controlLoop);
+
+ ParticipantControlLoopUpdate other = new ParticipantControlLoopUpdate(orig);
+
+ assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
+
+ // ensure list and items are not the same object
+ assertNotSame(other.getControlLoop(), controlLoop);
+ assertNotSame(other.getControlLoopDefinition(), toscaServiceTemplate);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheckTest.java
new file mode 100644
index 000000000..1cc356627
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheckTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the copy constructor and other methods.
+ */
+public class ParticipantHealthCheckTest {
+
+ @Test
+ public void testCopyConstructor() {
+ assertThatThrownBy(() -> new ParticipantStateChange(null)).isInstanceOf(NullPointerException.class);
+
+ ParticipantHealthCheck orig = new ParticipantHealthCheck();
+
+ // verify with null values
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantHealthCheck(orig).toString()));
+
+ // verify with all values
+ ToscaConceptIdentifier id = new ToscaConceptIdentifier();
+ id.setName("id");
+ id.setVersion("1.2.3");
+ orig.setControlLoopId(id);
+ orig.setParticipantId(id);
+ orig.setMessageId(UUID.randomUUID());
+ orig.setState(ParticipantState.ACTIVE);
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
+
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantHealthCheck(orig).toString()));
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java
new file mode 100644
index 000000000..d27d3a22c
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ParticipantMessageTest {
+ private ParticipantMessage message;
+
+ @Test
+ public void testCopyConstructor() {
+ assertThatThrownBy(() -> new ParticipantMessage((ParticipantMessage) null))
+ .isInstanceOf(NullPointerException.class);
+
+ // verify with null values
+ message = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
+ ParticipantMessage newmsg = new ParticipantMessage(message);
+ newmsg.setMessageId(message.getMessageId());
+ newmsg.setTimestamp(message.getTimestamp());
+ assertEquals(message.toString(), newmsg.toString());
+
+ // verify with all values
+ message = makeMessage();
+ newmsg = new ParticipantMessage(message);
+ newmsg.setMessageId(message.getMessageId());
+ newmsg.setTimestamp(message.getTimestamp());
+ assertEquals(message.toString(), newmsg.toString());
+ }
+
+ @Test
+ public void testAppliesTo_NullParticipantId() {
+ message = makeMessage();
+
+ assertThatThrownBy(() -> message.appliesTo(null, null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> message.appliesTo(new ToscaConceptIdentifier("PType", "4.5.6"), null))
+ .isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> message.appliesTo(null, new ToscaConceptIdentifier("id", "1.2.3")))
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ public void testAppliesTo_ParticipantIdMatches() {
+ message = makeMessage();
+
+ // ParticipantId matches
+ assertTrue(message.appliesTo(new ToscaConceptIdentifier("PType", "4.5.6"),
+ new ToscaConceptIdentifier("id", "1.2.3")));
+ assertFalse(message.appliesTo(new ToscaConceptIdentifier("PType", "4.5.6"),
+ new ToscaConceptIdentifier("id", "1.2.4")));
+ assertFalse(message.appliesTo(new ToscaConceptIdentifier("PType", "4.5.7"),
+ new ToscaConceptIdentifier("id", "1.2.3")));
+ }
+
+ @Test
+ public void testAppliesTo_ParticipantIdNoMatch() {
+ message = makeMessage();
+
+ // ParticipantId does not match
+ ToscaConceptIdentifier id = new ToscaConceptIdentifier();
+ id.setName("id1111");
+ id.setVersion("3.2.1");
+ assertFalse(message.appliesTo(id, id));
+ message.setParticipantType(null);
+ assertTrue(message.appliesTo(id, id));
+ }
+
+ private ParticipantMessage makeMessage() {
+ ParticipantMessage msg = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
+
+ msg.setParticipantType(new ToscaConceptIdentifier("PType", "4.5.6"));
+ msg.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3"));
+ msg.setMessageId(UUID.randomUUID());
+ msg.setTimestamp(Instant.ofEpochMilli(3000));
+
+ return msg;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java
new file mode 100644
index 000000000..dfbc25d1b
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+/**
+ * Utility class for tests of ParticipantMessage subclasses.
+ */
+public class ParticipantMessageUtils {
+
+ private ParticipantMessageUtils() {
+
+ }
+
+ public static String removeVariableFields(String text) {
+ return text.replaceAll("messageId=[^,]*", "messageId=xxx").replaceAll("timestamp=[^,]*", "timestamp=nnn");
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java
new file mode 100644
index 000000000..301f9acc0
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+import java.util.List;
+import org.junit.Test;
+import org.onap.policy.common.utils.test.ToStringTester;
+
+/**
+ * Class to perform unit tests of all pojos.
+ */
+public class ParticipantPojosTest {
+
+ @Test
+ public void testPojos() {
+ List<PojoClass> pojoClasses =
+ PojoClassFactory.getPojoClasses(ParticipantPojosTest.class.getPackageName());
+
+ pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessage.class));
+ pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class));
+
+ // @formatter:off
+ final Validator validator = ValidatorBuilder
+ .create()
+ .with(new ToStringTester())
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+
+ validator.validate(pojoClasses);
+ // @formatter:on
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChangeTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChangeTest.java
new file mode 100644
index 000000000..235532681
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChangeTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the copy constructor and the other methods.
+ */
+public class ParticipantStateChangeTest {
+
+ @Test
+ public void testCopyConstructor() {
+ assertThatThrownBy(() -> new ParticipantStateChange(null)).isInstanceOf(NullPointerException.class);
+
+ ParticipantStateChange orig = new ParticipantStateChange();
+
+ // verify with null values
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantStateChange(orig).toString()));
+
+ // verify with all values
+ ToscaConceptIdentifier id = new ToscaConceptIdentifier();
+ id.setName("id");
+ id.setVersion("1.2.3");
+ orig.setControlLoopId(id);
+ orig.setParticipantId(id);
+ orig.setMessageId(UUID.randomUUID());
+ orig.setState(ParticipantState.ACTIVE);
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
+
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantStateChange(orig).toString()));
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
new file mode 100644
index 000000000..9b5722bce
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.models.messages.dmaap.participant;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+public class ParticipantStatusTest {
+
+ @Test
+ public void testCopyConstructor() {
+ assertThatThrownBy(() -> new ParticipantStatus(null)).isInstanceOf(NullPointerException.class);
+
+ final ParticipantStatus orig = new ParticipantStatus();
+
+ // verify with null values
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantStatus(orig).toString()));
+
+ // verify with all values
+ ToscaConceptIdentifier id = new ToscaConceptIdentifier();
+ id.setName("id");
+ id.setVersion("1.2.3");
+ orig.setControlLoopId(id);
+ orig.setParticipantId(id);
+ orig.setMessageId(UUID.randomUUID());
+ orig.setState(ParticipantState.ACTIVE);
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
+
+ final ParticipantResponseDetails resp = new ParticipantResponseDetails();
+ resp.setResponseMessage("my-response");
+ orig.setResponse(resp);
+
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantStatus(orig).toString()));
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java
new file mode 100644
index 000000000..299a580d3
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.models.messages.rest;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+import java.util.List;
+import org.junit.Test;
+import org.onap.policy.common.utils.test.ToStringTester;
+
+/**
+ * Class to perform unit tests of all pojos.
+ */
+public class MessagesRestPojosTest {
+
+ @Test
+ public void testPojos() {
+ List<PojoClass> pojoClasses =
+ PojoClassFactory.getPojoClassesRecursively(MessagesRestPojosTest.class.getPackageName(), null);
+
+
+ // @formatter:off
+ final Validator validator = ValidatorBuilder
+ .create()
+ .with(new ToStringTester())
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+
+ validator.validate(pojoClasses);
+ // @formatter:on
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java
new file mode 100644
index 000000000..6bda3b736
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.models.messages.rest.instantiation;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+
+public class InstantiationCommandTest {
+ @Test
+ public void testInstantiationCommandLombok() {
+ assertNotNull(new InstantiationCommand());
+ InstantiationCommand ic0 = new InstantiationCommand();
+
+ assertThat(ic0.toString()).contains("InstantiationCommand(");
+ assertEquals(false, ic0.hashCode() == 0);
+ assertEquals(true, ic0.equals(ic0));
+ assertEquals(false, ic0.equals(null));
+
+
+ InstantiationCommand ic1 = new InstantiationCommand();
+
+ ic1.setControlLoopIdentifierList(new ArrayList<>());
+ ic1.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+
+ assertThat(ic1.toString()).contains("InstantiationCommand(");
+ assertEquals(false, ic1.hashCode() == 0);
+ assertEquals(false, ic1.equals(ic0));
+ assertEquals(false, ic1.equals(null));
+
+ assertNotEquals(ic1, ic0);
+
+ InstantiationCommand ic2 = new InstantiationCommand();
+
+ assertEquals(ic2, ic0);
+ }
+}
diff --git a/models/src/test/resources/META-INF/persistence.xml b/models/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 000000000..078d534be
--- /dev/null
+++ b/models/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="CommissioningMariaDb" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.base.PfConceptKey</class>
+ <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
+ <class>org.onap.policy.models.dao.converters.Uuid2String</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpStatistics</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+
+ <properties>
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+
+ <!-- property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL" /-->
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+
+ <persistence-unit name="ToscaConceptTest" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.base.PfConceptKey</class>
+ <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
+ <class>org.onap.policy.models.dao.converters.Uuid2String</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpStatistics</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+
+ <!-- <property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL"/> -->
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+</persistence>
+
diff --git a/models/src/test/resources/json/ControlLoopElementNoOrderedState.json b/models/src/test/resources/json/ControlLoopElementNoOrderedState.json
new file mode 100644
index 000000000..33a63e604
--- /dev/null
+++ b/models/src/test/resources/json/ControlLoopElementNoOrderedState.json
@@ -0,0 +1,13 @@
+{
+ "id": "a95757ba-b34a-4049-a2a8-46773abcbe5e",
+ "definition": {
+ "name": "cleDef",
+ "version": "0.0.1"
+ },
+ "participantType": {
+ "name": "participantType",
+ "version": "0.0.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": null
+}
diff --git a/models/src/test/resources/json/ControlLoopNoOrderedState.json b/models/src/test/resources/json/ControlLoopNoOrderedState.json
new file mode 100644
index 000000000..6bff97580
--- /dev/null
+++ b/models/src/test/resources/json/ControlLoopNoOrderedState.json
@@ -0,0 +1,12 @@
+{
+ "definition": {
+ "name": "controlLoopDefinitionName",
+ "version": "0.0.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": null,
+ "elements": [
+ ],
+ "name": "control-loop",
+ "version": "0.0.1"
+}
diff --git a/models/src/test/resources/providers/TestClElementStatistics.json b/models/src/test/resources/providers/TestClElementStatistics.json
new file mode 100644
index 000000000..ae19e560d
--- /dev/null
+++ b/models/src/test/resources/providers/TestClElementStatistics.json
@@ -0,0 +1,24 @@
+{
+ "clElementStatistics":[
+ {
+ "participantId":{
+ "name":"name1",
+ "version":"1.001"
+ },
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "timeStamp": "2021-01-10T13:45:00.000Z",
+ "controlLoopState": "UNINITIALISED",
+ "clElementUptime":250
+ },
+ {
+ "participantId":{
+ "name":"name2",
+ "version":"1.001"
+ },
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "timeStamp": "2021-01-10T14:25:00.000Z",
+ "controlLoopState": "UNINITIALISED",
+ "clElementUptime":330
+ }
+ ]
+}
diff --git a/models/src/test/resources/providers/TestControlLoops.json b/models/src/test/resources/providers/TestControlLoops.json
new file mode 100644
index 000000000..fedda9600
--- /dev/null
+++ b/models/src/test/resources/providers/TestControlLoops.json
@@ -0,0 +1,142 @@
+{
+ "controlLoopList": [
+ {
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.0.0"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "elements": {
+ "709c62b3-8918-41b9-a747-e21eb79c6c20": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-e21eb79c6c21": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-e21eb79c6c22": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-e21eb79c6c23": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 0 control loop"
+ }
+ },
+ "name": "PMSHInstance0",
+ "version": "1.0.1",
+ "description": "PMSH control loop instance 0"
+ },
+ {
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.0.0"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "elements": {
+ "709c62b3-8918-41b9-a747-e21eb79c6c24": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-e21eb79c6c25": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-e21eb79c6c26": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-e21eb79c6c27": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 1 control loop"
+ }
+ },
+ "name": "PMSHInstance1",
+ "version": "1.0.1",
+ "description": "PMSH control loop instance 1"
+ }
+ ]
+}
diff --git a/models/src/test/resources/providers/TestParticipant.json b/models/src/test/resources/providers/TestParticipant.json
new file mode 100644
index 000000000..c6965ce62
--- /dev/null
+++ b/models/src/test/resources/providers/TestParticipant.json
@@ -0,0 +1,11 @@
+{
+ "name": "dummy_participant1",
+ "version": "1.0.1",
+ "definition":{
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.0.0"
+ },
+ "participantState": "PASSIVE",
+ "healthStatus": "HEALTHY",
+ "description": "A dummy PMSH participant1"
+}
diff --git a/models/src/test/resources/providers/TestParticipantStatistics.json b/models/src/test/resources/providers/TestParticipantStatistics.json
new file mode 100644
index 000000000..5cf626816
--- /dev/null
+++ b/models/src/test/resources/providers/TestParticipantStatistics.json
@@ -0,0 +1,32 @@
+{
+ "statisticsList":[
+ {
+ "participantId":{
+ "name":"name1",
+ "version":"1.001"
+ },
+ "timeStamp": "2021-01-10T13:45:00.000Z",
+ "state": "PASSIVE",
+ "healthStatus": "HEALTHY",
+ "eventCount":250,
+ "lastExecutionTime":100,
+ "averageExecutionTime":90,
+ "upTime":1000,
+ "lastStart":3000
+ },
+ {
+ "participantId":{
+ "name":"name2",
+ "version":"1.001"
+ },
+ "timeStamp": "2021-01-27T14:25:00.000Z",
+ "state": "PASSIVE",
+ "healthStatus": "HEALTHY",
+ "eventCount":245,
+ "lastExecutionTime":1020,
+ "averageExecutionTime":85,
+ "upTime":1050,
+ "lastStart":3100
+ }
+ ]
+}
diff --git a/models/src/test/resources/providers/UpdateControlLoops.json b/models/src/test/resources/providers/UpdateControlLoops.json
new file mode 100644
index 000000000..2d6bd0753
--- /dev/null
+++ b/models/src/test/resources/providers/UpdateControlLoops.json
@@ -0,0 +1,73 @@
+{
+ "controlLoopList": [
+ {
+ "name": "PMSHInstance0",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.0.0"
+ },
+ "state": "RUNNING",
+ "orderedState": "RUNNING",
+ "description": "PMSH control loop instance 0",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c20": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "RUNNING",
+ "orderedState": "RUNNING",
+ "description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "RUNNING",
+ "orderedState": "RUNNING",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "2.3.1"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "1.0.0"
+ },
+ "state": "RUNNING",
+ "orderedState": "RUNNING",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "RUNNING",
+ "orderedState": "RUNNING",
+ "description": "CDS Control Loop Element for the PMSH instance 0 control loop"
+ }
+ }
+ }
+ ]
+}
diff --git a/participant/participant-impl/participant-impl-dcae/pom.xml b/participant/participant-impl/participant-impl-dcae/pom.xml
index 6186ced61..308084255 100644
--- a/participant/participant-impl/participant-impl-dcae/pom.xml
+++ b/participant/participant-impl/participant-impl-dcae/pom.xml
@@ -31,4 +31,23 @@
<artifactId>policy-clamp-participant-impl-dcae</artifactId>
<name>${project.artifactId}</name>
<description>DCAE participant, that allows DCAE to partake in control loops</description>
+
+ <properties>
+ <mockserver.version>5.11.2</mockserver.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.mock-server</groupId>
+ <artifactId>mockserver-netty</artifactId>
+ <version>${mockserver.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mock-server</groupId>
+ <artifactId>mockserver-client-java</artifactId>
+ <version>${mockserver.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java
new file mode 100644
index 000000000..b2d0b61d0
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java
@@ -0,0 +1,154 @@
+/*-
+ * ============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.dcae.httpclient;
+
+import java.io.Closeable;
+import java.io.IOException;
+import javax.ws.rs.core.Response.Status;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.ParseException;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.AuthCache;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.util.EntityUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.participant.dcae.model.Loop;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractHttpClient implements Closeable {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AbstractHttpClient.class);
+ private final HttpClientContext localContext;
+ private final CloseableHttpClient httpclient;
+ private final HttpHost target;
+ public static final Coder CODER = new StandardCoder();
+
+ /**
+ * Constructor.
+ */
+ protected AbstractHttpClient(RestServerParameters restServerParameters) {
+ try {
+ final String scheme = restServerParameters.isHttps() ? "https" : "http";
+ target = new HttpHost(restServerParameters.getHost(), restServerParameters.getPort(), scheme);
+
+ CredentialsProvider credsProvider = new BasicCredentialsProvider();
+ credsProvider.setCredentials(new AuthScope(target.getHostName(), target.getPort()),
+ new UsernamePasswordCredentials(restServerParameters.getUserName(),
+ restServerParameters.getPassword()));
+
+ AuthCache authCache = new BasicAuthCache();
+ BasicScheme basicAuth = new BasicScheme();
+ authCache.put(target, basicAuth);
+ localContext = HttpClientContext.create();
+ localContext.setAuthCache(authCache);
+
+ HttpClientBuilder builder = HttpClients.custom().setDefaultCredentialsProvider(credsProvider);
+ if (restServerParameters.isHttps()) {
+ final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(new SSLContextBuilder()
+ .loadTrustMaterial(null, new TrustSelfSignedStrategy()).setProtocol("TLSv1.2").build(),
+ new NoopHostnameVerifier());
+ builder.setSSLSocketFactory(sslsf);
+ }
+ httpclient = builder.build();
+
+ } catch (final Exception e) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ restServerParameters.getName() + " Client failed to start", e);
+ }
+ }
+
+ CloseableHttpResponse execute(HttpRequest request) throws IOException {
+ return httpclient.execute(target, request, localContext);
+ }
+
+ protected boolean executePut(String path, int statusCode) {
+ try (CloseableHttpResponse response = execute(new HttpPut(path))) {
+ return response.getStatusLine().getStatusCode() == statusCode;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ protected Loop executePost(String path, int statusCode) {
+ try (CloseableHttpResponse response = execute(new HttpPost(path))) {
+ if (response.getStatusLine().getStatusCode() != statusCode) {
+ return null;
+ }
+ return entityToMap(response.getEntity());
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ protected Loop executeGet(String path, int statusCode) {
+ try (CloseableHttpResponse response = execute(new HttpGet(path))) {
+ if (response.getStatusLine().getStatusCode() != statusCode) {
+ return null;
+ }
+ return entityToMap(response.getEntity());
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private Loop entityToMap(HttpEntity httpEntity) {
+ if (httpEntity == null) {
+ return new Loop();
+ }
+ try {
+ return CODER.convert(EntityUtils.toString(httpEntity), Loop.class);
+ } catch (ParseException | IOException e) {
+ LOGGER.error("error reading Entity", e);
+ return new Loop();
+ } catch (CoderException e) {
+ LOGGER.error("cannot convert to Loop Object", e);
+ return new Loop();
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ httpclient.close();
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java
new file mode 100644
index 000000000..eb805054d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java
@@ -0,0 +1,140 @@
+/*-
+ * ============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.dcae.httpclient;
+
+import org.apache.http.HttpStatus;
+import org.onap.policy.clamp.controlloop.participant.dcae.model.ExternalComponent;
+import org.onap.policy.clamp.controlloop.participant.dcae.model.Loop;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ClampHttpClient extends AbstractHttpClient {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ClampHttpClient.class);
+
+ private static final String STATUS = "/restservices/clds/v2/loop/getstatus/";
+ private static final String CREATE = "/restservices/clds/v2/loop/create/%s?templateName=%s";
+ private static final String UPDATE = "/restservices/clds/v2/loop/updateMicroservicePolicy/";
+ private static final String DEPLOY = "/restservices/clds/v2/loop/deploy/";
+ private static final String STOP = "/restservices/clds/v2/loop/stop/";
+ private static final String DELETE = "/restservices/clds/v2/loop/delete/";
+ private static final String UNDEPLOY = "/restservices/clds/v2/loop/undeploy/";
+ public static final String STATUS_NOT_FOUND = "STATUS_NOT_FOUND";
+ public static final String POLICY_NOT_FOUND = "POLICY_NOT_FOUND";
+
+ /**
+ * Constructor.
+ */
+ public ClampHttpClient(RestServerParameters restServerParameters) {
+ super(restServerParameters);
+ }
+
+ /**
+ * Create.
+ *
+ * @param loopName the loopName
+ * @param templateName the templateName
+ * @return the Loop object or null if error occurred
+ */
+ public Loop create(String loopName, String templateName) {
+ return executePost(String.format(CREATE, loopName, templateName), HttpStatus.SC_OK);
+ }
+
+ /**
+ * Update.
+ *
+ * @param loopName the loopName
+ * @param jsonEntity the Json entity
+ * @return true
+ */
+ public boolean update(String loopName, String jsonEntity) {
+ return executePost(UPDATE + loopName, HttpStatus.SC_OK) != null;
+ }
+
+ /**
+ * Deploy.
+ *
+ * @param loopName the loopName
+ * @return true
+ */
+ public boolean deploy(String loopName) { // DCAE
+ return executePut(DEPLOY + loopName, HttpStatus.SC_ACCEPTED);
+ }
+
+ /**
+ * Get Status.
+ *
+ * @param loopName the loopName
+ * @return the Loop object or null if error occurred
+ */
+ public Loop getstatus(String loopName) {
+ return executeGet(STATUS + loopName, HttpStatus.SC_OK);
+ }
+
+ /**
+ * Undeploy.
+ *
+ * @param loopName the loopName
+ * @return true
+ */
+ public boolean undeploy(String loopName) {
+ return executePut(UNDEPLOY + loopName, HttpStatus.SC_ACCEPTED);
+ }
+
+ /**
+ * Stop.
+ *
+ * @param loopName the loopName
+ * @return true
+ */
+ public boolean stop(String loopName) {
+ return executePut(STOP + loopName, HttpStatus.SC_OK);
+ }
+
+ /**
+ * Delete.
+ *
+ * @param loopName the loopName
+ * @return true
+ */
+ public boolean delete(String loopName) {
+ return executePut(DELETE + loopName, HttpStatus.SC_OK);
+ }
+
+ /**
+ * return status from Loop object.
+ *
+ * @param loop Loop
+ * @return status
+ */
+ public static String getStatusCode(Loop loop) {
+ if (loop == null || loop.getComponents() == null || loop.getComponents().isEmpty()) {
+ return STATUS_NOT_FOUND;
+ }
+ ExternalComponent externalComponent = loop.getComponents().get("DCAE");
+ if (externalComponent == null || externalComponent.getComponentState() == null) {
+ return STATUS_NOT_FOUND;
+ }
+
+ return externalComponent.getComponentState().getStateName();
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java
new file mode 100644
index 000000000..cd84a2feb
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java
@@ -0,0 +1,46 @@
+/*-
+ * ============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.dcae.httpclient;
+
+import org.apache.http.HttpStatus;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+
+public class ConsulDcaeHttpClient extends AbstractHttpClient {
+
+ private static final String DEPLOY = "/v1/kv/dcae-pmsh:policy";
+
+ /**
+ * constructor.
+ */
+ public ConsulDcaeHttpClient(RestServerParameters restServerParameters) {
+ super(restServerParameters);
+ }
+
+ /**
+ * call consult.
+ *
+ * @param jsonEntity the Entity
+ * @return true
+ */
+ public boolean deploy(String jsonEntity) {
+ return executePut(DEPLOY + jsonEntity, HttpStatus.SC_ACCEPTED);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java
new file mode 100644
index 000000000..96677f320
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java
@@ -0,0 +1,197 @@
+/*-
+ * ============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.dcae.main.handler;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.time.Instant;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+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.participant.dcae.httpclient.ClampHttpClient;
+import org.onap.policy.clamp.controlloop.participant.dcae.httpclient.ConsulDcaeHttpClient;
+import org.onap.policy.clamp.controlloop.participant.dcae.model.Loop;
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class handles implementation of controlLoopElement updates.
+ */
+public class ControlLoopElementHandler implements ControlLoopElementListener, Closeable {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopElementHandler.class);
+ private final ClampHttpClient clampClient;
+ private final ConsulDcaeHttpClient consulClient;
+
+ private static final String LOOP = "pmsh_loop";
+ private static final String TEMPLATE = "LOOP_TEMPLATE_k8s_pmsh";
+
+ private static final String BLUEPRINT_DEPLOYED = "BLUEPRINT_DEPLOYED";
+ private static final String MICROSERVICE_INSTALLED_SUCCESSFULLY = "MICROSERVICE_INSTALLED_SUCCESSFULLY";
+ private static final int CHECK_COUNT = 10;
+
+ private static final String BODY_CONSUL =
+ "{ \"subscription\": { \"subscriptionName\": \"subscriptiona\", \"administrativeState\": \"UNLOCKED\", "
+ + "\"fileBasedGP\": 15, \"fileLocation\": \"/pm/pm.xml\", \"nfFilter\": "
+ + "{ \"nfNames\": [ \"^pnf1.*\" ], \"modelInvariantIDs\": "
+ + "[ \"5845y423-g654-6fju-po78-8n53154532k6\", \"7129e420-d396-4efb-af02-6b83499b12f8\" ], "
+ + "\"modelVersionIDs\": [ \"e80a6ae3-cafd-4d24-850d-e14c084a5ca9\" ] }, \"measurementGroups\": "
+ + "[ { \"measurementGroup\": { \"measurementTypes\": [ { \"measurementType\": \"countera\" }, "
+ + "{ \"measurementType\": \"counterb\" } ], \"managedObjectDNsBasic\": [ { \"DN\": \"dna\" }, "
+ + "{ \"DN\": \"dnb\" } ] } }, { \"measurementGroup\": { \"measurementTypes\": "
+ + "[ { \"measurementType\": \"counterc\" }, { \"measurementType\": \"counterd\" } ], "
+ + "\"managedObjectDNsBasic\": " + "[ { \"DN\": \"dnc\" }, { \"DN\": \"dnd\" } ] } } ] } }";
+
+ /**
+ * Constructor.
+ */
+ public ControlLoopElementHandler(RestServerParameters clampParameters, RestServerParameters consulParameters) {
+ clampClient = new ClampHttpClient(clampParameters);
+ consulClient = new ConsulDcaeHttpClient(consulParameters);
+ }
+
+ /**
+ * Callback method to handle a control loop element state change.
+ *
+ * @param controlLoopElementId the ID of the control loop element
+ * @param currentState the current state of the control loop element
+ * @param newState the state to which the control loop element is changing to
+ */
+ @Override
+ public void controlLoopElementStateChange(UUID controlLoopElementId, ControlLoopState currentState,
+ ControlLoopOrderedState newState) {
+ switch (newState) {
+ case UNINITIALISED:
+ Loop loop = clampClient.getstatus(LOOP);
+ if (loop != null) {
+ clampClient.undeploy(LOOP);
+ DcaeHandler.getInstance().getDcaeProvider().getIntermediaryApi()
+ .updateControlLoopElementState(controlLoopElementId, newState, ControlLoopState.UNINITIALISED);
+ }
+ break;
+ case PASSIVE:
+ DcaeHandler.getInstance().getDcaeProvider().getIntermediaryApi()
+ .updateControlLoopElementState(controlLoopElementId, newState, ControlLoopState.PASSIVE);
+ break;
+ case RUNNING:
+ DcaeHandler.getInstance().getDcaeProvider().getIntermediaryApi()
+ .updateControlLoopElementState(controlLoopElementId, newState, ControlLoopState.RUNNING);
+ break;
+ default:
+ LOGGER.debug("Unknown orderedstate {}", newState);
+ break;
+ }
+ }
+
+ private Loop getStatus() throws PfModelException {
+ Loop loop = clampClient.getstatus(LOOP);
+ if (loop == null) {
+ loop = clampClient.create(LOOP, TEMPLATE);
+ }
+ if (loop == null) {
+ throw new PfModelException(null, "");
+ }
+ return loop;
+ }
+
+ private void deploy() throws PfModelException {
+ if (!consulClient.deploy(BODY_CONSUL)) {
+ throw new PfModelException(null, "deploy to consul failed");
+ }
+ if (!clampClient.deploy(LOOP)) {
+ throw new PfModelException(null, "deploy failed");
+ }
+ }
+
+ /**
+ * Callback method to handle an update on a control loop element.
+ *
+ * @param element the information on the control loop element
+ * @param controlLoopDefinition toscaServiceTemplate
+ * @throws PfModelException in case of an exception
+ */
+ @Override
+ public void controlLoopElementUpdate(ControlLoopElement element, ToscaServiceTemplate controlLoopDefinition)
+ throws PfModelException {
+ try {
+ Loop loop = getStatus();
+
+ if (BLUEPRINT_DEPLOYED.equals(ClampHttpClient.getStatusCode(loop))) {
+ deploy();
+ boolean deployedFlag = false;
+ for (int i = 0; i < CHECK_COUNT; i++) {
+ //sleep 10 seconds
+ TimeUnit.SECONDS.sleep(CHECK_COUNT);
+ loop = getStatus();
+ String status = ClampHttpClient.getStatusCode(loop);
+ if (MICROSERVICE_INSTALLED_SUCCESSFULLY.equals(status)) {
+ DcaeHandler.getInstance().getDcaeProvider().getIntermediaryApi()
+ .updateControlLoopElementState(element.getId(), element.getOrderedState(),
+ ControlLoopState.PASSIVE);
+ deployedFlag = true;
+ break;
+ }
+ }
+ if (!deployedFlag) {
+ LOGGER.warn("DCAE is not deployed properly, ClElement state will be UNINITIALISED2PASSIVE");
+ DcaeHandler.getInstance().getDcaeProvider().getIntermediaryApi()
+ .updateControlLoopElementState(element.getId(), element.getOrderedState(),
+ ControlLoopState.UNINITIALISED2PASSIVE);
+ }
+ }
+ } catch (PfModelException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new PfModelException(null, e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Handle controlLoopElement statistics.
+ *
+ * @param controlLoopElementId controlloop element id
+ */
+ @Override
+ public void handleStatistics(UUID controlLoopElementId) {
+ ControlLoopElement clElement = DcaeHandler.getInstance().getDcaeProvider()
+ .getIntermediaryApi().getControlLoopElement(controlLoopElementId);
+ if (clElement != null) {
+ ClElementStatistics clElementStatistics = new ClElementStatistics();
+ clElementStatistics.setControlLoopState(clElement.getState());
+ clElementStatistics.setTimeStamp(Instant.now());
+ DcaeHandler.getInstance().getDcaeProvider().getIntermediaryApi()
+ .updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ clampClient.close();
+ consulClient.close();
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/DcaeHandler.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/DcaeHandler.java
new file mode 100644
index 000000000..1963e38b1
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/DcaeHandler.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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.dcae.main.handler;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.base.PfModelRuntimeException;
+
+/**
+ * This class handles dcae of participants and control loop elements.
+ *
+ * </p>
+ * It is effectively a singleton that is started at system start.
+ */
+public class DcaeHandler extends ControlLoopHandler {
+
+ private final ParticipantDcaeParameters parameters;
+ @Getter
+ private DcaeProvider dcaeProvider;
+
+ /**
+ * Create a handler.
+ *
+ * @param parameters the parameters for access to the database
+ */
+ public DcaeHandler(ParticipantDcaeParameters parameters) {
+ super(parameters.getDatabaseProviderParameters());
+ this.parameters = parameters;
+ }
+
+ public static DcaeHandler getInstance() {
+ return Registry.get(DcaeHandler.class.getName());
+ }
+
+ @Override
+ public Set<Class<?>> getProviderClasses() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public void startProviders() {
+ dcaeProvider = new DcaeProvider(parameters);
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ dcaeProvider.close();
+ } catch (IOException e) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
+ } finally {
+ dcaeProvider = null;
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/DcaeProvider.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/DcaeProvider.java
new file mode 100644
index 000000000..afaf1c754
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/DcaeProvider.java
@@ -0,0 +1,133 @@
+/*-
+ * ============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.dcae.main.handler;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
+import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryFactory;
+
+/**
+ * This provider class dcae of participants and control loop elements.
+ */
+public class DcaeProvider implements Closeable {
+ @Getter
+ private final ParticipantIntermediaryApi intermediaryApi;
+
+ private final ControlLoopElementHandler clElementHandler;
+
+ /**
+ * Create a participant dcae provider.
+ *
+ * @throws ControlLoopRuntimeException on errors creating the provider
+ */
+ public DcaeProvider(ParticipantDcaeParameters parameters) throws ControlLoopRuntimeException {
+ intermediaryApi = new ParticipantIntermediaryFactory().createApiImplementation();
+ intermediaryApi.init(parameters.getIntermediaryParameters());
+ clElementHandler = new ControlLoopElementHandler(parameters.getClampClientParameters(),
+ parameters.getConsulClientParameters());
+ intermediaryApi.registerControlLoopElementListener(clElementHandler);
+ }
+
+ @Override
+ public void close() throws IOException {
+ intermediaryApi.close();
+ clElementHandler.close();
+ }
+
+ /**
+ * Get the control loops.
+ *
+ * @param name the controlLoop, null to get all
+ * @param version the controlLoop, null to get all
+ * @return the control loops
+ * @throws ControlLoopException on errors getting the control loops
+ */
+ public ControlLoops getControlLoops(String name, String version) throws ControlLoopException {
+ return intermediaryApi.getControlLoops(name, version);
+ }
+
+ /**
+ * Get the dcae control loop elements.
+ *
+ * @param name the controlLoopElement, null to get all
+ * @param version the controlLoopElement, null to get all
+ * @return the control loop elements
+ * @throws ControlLoopException on errors getting the control loop elements
+ */
+ public Map<UUID, ControlLoopElement> getControlLoopElements(String name, String version)
+ throws ControlLoopException {
+ return intermediaryApi.getControlLoopElements(name, version);
+ }
+
+ /**
+ * Update the given control loop element in the dcae.
+ *
+ * @param element the control loop element to update
+ * @return response simple response returned
+ * @throws ControlLoopException on errors updating the control loop element
+ */
+ public TypedSimpleResponse<ControlLoopElement> updateControlLoopElement(ControlLoopElement element)
+ throws ControlLoopException {
+ TypedSimpleResponse<ControlLoopElement> response = new TypedSimpleResponse<>();
+ response.setResponse(intermediaryApi.updateControlLoopElementState(element.getId(),
+ element.getOrderedState(), element.getState()));
+ return response;
+ }
+
+ /**
+ * Get the current dcae participants.
+ *
+ * @param name the participant, null to get all
+ * @param version the participant, null to get all
+ * @return the list of participants
+ * @throws ControlLoopException on errors getting the participants
+ */
+ public List<Participant> getParticipants(String name, String version) throws ControlLoopException {
+ return intermediaryApi.getParticipants(name, version);
+ }
+
+ /**
+ * Update a dcae participant.
+ *
+ * @param participant the participant to update
+ * @return TypedSimpleResponse simple response
+ * @throws ControlLoopException on errors updating the participant
+ */
+
+ public TypedSimpleResponse<Participant> updateParticipant(Participant participant) throws ControlLoopException {
+ TypedSimpleResponse<Participant> response = new TypedSimpleResponse<>();
+ response.setResponse(
+ intermediaryApi.updateParticipantState(participant.getDefinition(), participant.getParticipantState()));
+ return response;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameterHandler.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameterHandler.java
new file mode 100644
index 000000000..8d9bef98c
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameterHandler.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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.dcae.main.parameters;
+
+import java.io.File;
+import javax.ws.rs.core.Response;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.startstop.ParticipantDcaeCommandLineArguments;
+import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+
+/**
+ * This class handles reading, parsing and validating of control loop runtime parameters from JSON files.
+ */
+public class ParticipantDcaeParameterHandler {
+
+ private static final Coder CODER = new StandardCoder();
+
+ /**
+ * Read the parameters from the parameter file.
+ *
+ * @param arguments the arguments passed to dcae
+ * @return the parameters read from the configuration file
+ * @throws ControlLoopException on parameter exceptions
+ */
+ public ParticipantDcaeParameters getParameters(final ParticipantDcaeCommandLineArguments arguments)
+ throws ControlLoopException {
+ ParticipantDcaeParameters parameters = null;
+
+ // Read the parameters
+ try {
+ // Read the parameters from JSON
+ File file = new File(arguments.getFullConfigurationFilePath());
+ parameters = CODER.decode(file, ParticipantDcaeParameters.class);
+ } catch (final CoderException e) {
+ final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
+ + "\"\n" + "(" + e.getClass().getSimpleName() + ")";
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage, e);
+ }
+
+ // The JSON processing returns null if there is an empty file
+ if (parameters == null) {
+ final String errorMessage = "no parameters found in \"" + arguments.getConfigurationFilePath() + "\"";
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage);
+ }
+
+ // validate the parameters
+ final ValidationResult validationResult = parameters.validate();
+ if (!validationResult.isValid()) {
+ String returnMessage =
+ "validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
+ returnMessage += validationResult.getResult();
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, returnMessage);
+ }
+
+ return parameters;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java
new file mode 100644
index 000000000..beb273086
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.dcae.main.parameters;
+
+import javax.validation.constraints.NotBlank;
+import lombok.Getter;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+
+/**
+ * Class to hold all parameters needed for the participant dcae.
+ *
+ */
+@NotNull
+@NotBlank
+@Getter
+public class ParticipantDcaeParameters extends ParameterGroupImpl {
+ @Valid
+ private RestServerParameters clampClientParameters;
+
+ @Valid
+ private RestServerParameters consulClientParameters;
+
+ private ParticipantIntermediaryParameters intermediaryParameters;
+ private PolicyModelsProviderParameters databaseProviderParameters;
+
+ /**
+ * Create the participant dcae parameter group.
+ *
+ * @param name the parameter group name
+ */
+ public ParticipantDcaeParameters(final String name) {
+ super(name);
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public BeanValidationResult validate() {
+ BeanValidationResult result = super.validate();
+ if (result.isValid()) {
+ result.addResult(checkMissingMandatoryParams(clampClientParameters));
+ result.addResult(checkMissingMandatoryParams(consulClientParameters));
+ }
+ return result;
+ }
+
+ private BeanValidationResult checkMissingMandatoryParams(RestServerParameters clientParameters) {
+ BeanValidationResult result = new BeanValidationResult(clientParameters.getName(), clientParameters);
+ if (StringUtils.isBlank(clientParameters.getHost())) {
+ result.addResult("Host", clientParameters.getHost(), ValidationStatus.INVALID, "is blank");
+ }
+ if (StringUtils.isBlank(clientParameters.getName())) {
+ result.addResult("Name", clientParameters.getName(), ValidationStatus.INVALID, "is blank");
+ }
+ if (StringUtils.isBlank(clientParameters.getPassword())) {
+ result.addResult("Password", clientParameters.getPassword(), ValidationStatus.INVALID, "is blank");
+ }
+ if (StringUtils.isBlank(clientParameters.getUserName())) {
+ result.addResult("UserName", clientParameters.getUserName(), ValidationStatus.INVALID, "is blank");
+ }
+ if (clientParameters.getPort() <= 0 || clientParameters.getPort() >= 65535) {
+ result.addResult("Port", clientParameters.getPort(), ValidationStatus.INVALID, "is not valid");
+ }
+ return result;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/Main.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/Main.java
new file mode 100644
index 000000000..2b47a2c13
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/Main.java
@@ -0,0 +1,151 @@
+/*-
+ * ============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.dcae.main.startstop;
+
+import java.util.Arrays;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.ControlLoopConstants;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameterHandler;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
+import org.onap.policy.common.utils.resources.MessageConstants;
+import org.onap.policy.common.utils.services.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class initiates ONAP Policy Framework Control Loop participant component.
+ */
+public class Main {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
+
+ private ParticipantDcaeActivator activator;
+
+ @Getter
+ private ParticipantDcaeParameters parameterGroup;
+
+ /**
+ * Instantiates the control loop participant service.
+ *
+ * @param args the command line arguments
+ */
+ public Main(final String[] args) {
+ final String argumentString = Arrays.toString(args);
+ LOGGER.info("Starting the control loop participant service with arguments - {}", argumentString);
+
+ // Check the arguments
+ final ParticipantDcaeCommandLineArguments arguments = new ParticipantDcaeCommandLineArguments();
+ try {
+ // The arguments return a string if there is a message to print and we should exit
+ final String argumentMessage = arguments.parse(args);
+ if (argumentMessage != null) {
+ LOGGER.info(argumentMessage);
+ return;
+ }
+ // Validate that the arguments are sane
+ arguments.validate();
+
+ // Read the parameters
+ parameterGroup = new ParticipantDcaeParameterHandler().getParameters(arguments);
+
+ // Now, create the activator for the service
+ activator = new ParticipantDcaeActivator(parameterGroup);
+ Registry.register(ControlLoopConstants.REG_CLRUNTIME_ACTIVATOR, activator);
+
+ // Start the activator
+ activator.start();
+ } catch (Exception exp) {
+ if (null != activator) {
+ Registry.unregister(ControlLoopConstants.REG_CLRUNTIME_ACTIVATOR);
+ }
+ throw new ControlLoopRuntimeException(Response.Status.BAD_REQUEST,
+ String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP), exp);
+ }
+
+ // Add a shutdown hook to shut everything down in an orderly manner
+ Runtime.getRuntime().addShutdownHook(new ClRuntimeShutdownHookClass());
+ String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_CLAMP);
+ LOGGER.info(successMsg);
+ }
+
+ /**
+ * Check if main is running.
+ */
+ public boolean isRunning() {
+ return activator != null && activator.isAlive();
+ }
+
+ /**
+ * Shut down Execution.
+ *
+ * @throws ControlLoopException on shutdown errors
+ */
+ public void shutdown() throws ControlLoopException {
+ // clear the parameterGroup variable
+ parameterGroup = null;
+
+ // clear the cl participant activator
+ if (activator != null) {
+ activator.stop();
+ }
+ }
+
+ /**
+ * The Class ClRuntimeShutdownHookClass terminates the control loop participant service
+ * when its run method is called.
+ */
+ private class ClRuntimeShutdownHookClass extends Thread {
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ if (!activator.isAlive()) {
+ return;
+ }
+
+ try {
+ // Shutdown the control loop participant service and wait for everything to stop
+ activator.stop();
+ } catch (final RuntimeException e) {
+ LOGGER.warn("error occured during shut down of the control loop participant service", e);
+ }
+ }
+ }
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(final String[] args) { // NOSONAR
+ /*
+ * NOTE: arguments are validated by the constructor, thus sonar is disabled.
+ */
+
+ new Main(args);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/ParticipantDcaeActivator.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/ParticipantDcaeActivator.java
new file mode 100644
index 000000000..d485895cf
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/ParticipantDcaeActivator.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.dcae.main.startstop;
+
+import java.util.concurrent.atomic.AtomicReference;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.handler.DcaeHandler;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
+import org.onap.policy.common.utils.services.ServiceManagerContainer;
+
+/**
+ * This class activates the control loop runtime component as a complete service together with all its controllers,
+ * listeners & handlers.
+ */
+public class ParticipantDcaeActivator extends ServiceManagerContainer {
+ @Getter
+ private final ParticipantDcaeParameters parameters;
+
+ /**
+ * Instantiate the activator for the dcae as a complete service.
+ *
+ * @param parameters the parameters for the control loop runtime service
+ */
+ public ParticipantDcaeActivator(final ParticipantDcaeParameters parameters) {
+ this.parameters = parameters;
+
+ final AtomicReference<DcaeHandler> dcaeHandler = new AtomicReference<>();
+
+ // @formatter:off
+ addAction("Dcae Handler",
+ () -> dcaeHandler.set(new DcaeHandler(parameters)),
+ () -> dcaeHandler.get().close());
+
+ addAction("Dcae Providers",
+ () -> dcaeHandler.get().startProviders(),
+ () -> dcaeHandler.get().stopProviders());
+
+ // @formatter:on
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/ParticipantDcaeCommandLineArguments.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/ParticipantDcaeCommandLineArguments.java
new file mode 100644
index 000000000..0bf382ab1
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/ParticipantDcaeCommandLineArguments.java
@@ -0,0 +1,151 @@
+/*-
+ * ============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.dcae.main.startstop;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Arrays;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.common.startstop.CommonCommandLineArguments;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+
+/**
+ * This class reads and handles command line parameters for the control loop runtime service.
+ *
+ */
+public class ParticipantDcaeCommandLineArguments {
+ private static final String FILE_MESSAGE_PREAMBLE = " file \"";
+ private static final int HELP_LINE_LENGTH = 120;
+
+ private final Options options;
+ private final CommonCommandLineArguments commonCommandLineArguments;
+
+ @Getter()
+ @Setter()
+ private String configurationFilePath = null;
+
+ /**
+ * Construct the options for the dcae participant.
+ */
+ public ParticipantDcaeCommandLineArguments() {
+ options = new Options();
+ commonCommandLineArguments = new CommonCommandLineArguments(options);
+ }
+
+ /**
+ * Construct the options for the CLI editor and parse in the given arguments.
+ *
+ * @param args The command line arguments
+ */
+ public ParticipantDcaeCommandLineArguments(final String[] args) {
+ // Set up the options with the default constructor
+ this();
+
+ // Parse the arguments
+ try {
+ parse(args);
+ } catch (final ControlLoopException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
+ "parse error on dcae participant parameters", e);
+ }
+ }
+
+ /**
+ * Parse the command line options.
+ *
+ * @param args The command line arguments
+ * @return a string with a message for help and version, or null if there is no message
+ * @throws ControlLoopException on command argument errors
+ */
+ public String parse(final String[] args) throws ControlLoopException {
+ // Clear all our arguments
+ setConfigurationFilePath(null);
+ CommandLine commandLine = null;
+ try {
+ commandLine = new DefaultParser().parse(options, args);
+ } catch (final ParseException e) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ "invalid command line arguments specified : " + e.getMessage());
+ }
+
+ // Arguments left over after Commons CLI does its stuff
+ final String[] remainingArgs = commandLine.getArgs();
+
+ if (remainingArgs.length > 0) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ "too many command line arguments specified : " + Arrays.toString(args));
+ }
+
+ if (commandLine.hasOption('h')) {
+ return commonCommandLineArguments.help(Main.class.getName(), options);
+ }
+
+ if (commandLine.hasOption('v')) {
+ return commonCommandLineArguments.version();
+ }
+
+ if (commandLine.hasOption('c')) {
+ setConfigurationFilePath(commandLine.getOptionValue('c'));
+ }
+
+ return null;
+ }
+
+ /**
+ * Validate the command line options.
+ *
+ * @throws ControlLoopException on command argument validation errors
+ */
+ public void validate() throws ControlLoopException {
+ commonCommandLineArguments.validate(configurationFilePath);
+ }
+
+ /**
+ * Gets the full expanded configuration file path.
+ *
+ * @return the configuration file path
+ */
+ public String getFullConfigurationFilePath() {
+ return ResourceUtils.getFilePath4Resource(getConfigurationFilePath());
+ }
+
+ /**
+ * Check set configuration file path.
+ *
+ * @return true, if check set configuration file path
+ */
+ public boolean checkSetConfigurationFilePath() {
+ return !StringUtils.isEmpty(configurationFilePath);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/ExternalComponent.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/ExternalComponent.java
new file mode 100644
index 000000000..01a514f43
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/ExternalComponent.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.dcae.model;
+
+import java.io.Serializable;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ExternalComponent implements Serializable {
+
+ private static final long serialVersionUID = -10;
+
+ private ExternalComponentState componentState;
+
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/ExternalComponentState.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/ExternalComponentState.java
new file mode 100644
index 000000000..da7360a9b
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/ExternalComponentState.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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.dcae.model;
+
+import java.io.Serializable;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ExternalComponentState implements Serializable {
+
+ private static final long serialVersionUID = -10;
+
+ private String stateName;
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/Loop.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/Loop.java
new file mode 100644
index 000000000..d84270500
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/model/Loop.java
@@ -0,0 +1,36 @@
+/*-
+ * ============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.dcae.model;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class Loop implements Serializable {
+
+ private static final long serialVersionUID = -10;
+
+ private Map<String, ExternalComponent> components = new HashMap<>();
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/resources/config/DCAEParticipantConfig.json b/participant/participant-impl/participant-impl-dcae/src/main/resources/config/DCAEParticipantConfig.json
new file mode 100644
index 000000000..863c135d5
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/resources/config/DCAEParticipantConfig.json
@@ -0,0 +1,71 @@
+{
+ "name": "ControlLoopParticipantDcae",
+ "clampClientParameters": {
+ "name": "Clamp",
+ "host": "0.0.0.0",
+ "port": 8443,
+ "userName": "admin",
+ "password": "password",
+ "https": true,
+ "aaf": false
+ },
+ "consulClientParameters": {
+ "name": "Consul",
+ "host": "consul",
+ "port": 31321,
+ "userName": "admin",
+ "password": "password",
+ "https": false,
+ "aaf": false
+ },
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantId": {
+ "name": "DCAEParticipant0",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/resources/version.txt b/participant/participant-impl/participant-impl-dcae/src/main/resources/version.txt
new file mode 100644
index 000000000..dbd67585f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/resources/version.txt
@@ -0,0 +1,4 @@
+ONAP Tosca defined control loop Participant
+Version: ${project.version}
+Built (UTC): ${maven.build.timestamp}
+ONAP https://wiki.onap.org
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java
new file mode 100644
index 000000000..040b33f5e
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java
@@ -0,0 +1,128 @@
+/*-
+ * ============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.dcae.httpclient;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.junit.Assert.assertTrue;
+import static org.mockserver.model.HttpRequest.request;
+import static org.mockserver.model.HttpResponse.response;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockserver.integration.ClientAndServer;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
+import org.onap.policy.clamp.controlloop.participant.dcae.model.Loop;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
+
+/**
+ * Class to perform unit test of {@link ClampHttpClient}.
+ *
+ */
+public class ClampHttpClientTest {
+
+ private static final String LOOP = "pmsh_loop";
+ private static final String BLUEPRINT_DEPLOYED = "BLUEPRINT_DEPLOYED";
+
+ private static ClientAndServer mockServer;
+ private static ParticipantDcaeParameters parameters;
+ public static final Coder CODER = new StandardCoder();
+
+ /**
+ * Set up.
+ */
+ @BeforeClass
+ public static void setUp() {
+ CommonTestData commonTestData = new CommonTestData();
+
+ parameters = commonTestData.toObject(
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
+ ParticipantDcaeParameters.class);
+
+ mockServer = ClientAndServer.startClientAndServer(parameters.getClampClientParameters().getPort());
+
+ mockServer.when(request().withMethod("GET").withPath("/restservices/clds/v2/loop/getstatus/" + LOOP))
+ .respond(response().withBody(CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED)).withStatusCode(200));
+
+ mockServer.when(request().withMethod("PUT").withPath("/restservices/clds/v2/loop/deploy/" + LOOP))
+ .respond(response().withStatusCode(202));
+
+ mockServer.when(request().withMethod("PUT").withPath("/restservices/clds/v2/loop/undeploy/" + LOOP))
+ .respond(response().withStatusCode(202));
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ mockServer.stop();
+ mockServer = null;
+ }
+
+ @Test
+ public void test_getstatus() throws Exception {
+ try (ClampHttpClient client = new ClampHttpClient(parameters.getClampClientParameters())) {
+
+ Loop status = client.getstatus(LOOP);
+
+ String json = CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED);
+ Loop loop = CODER.convert(json, Loop.class);
+
+ assertThat(ClampHttpClient.getStatusCode(status)).isEqualTo(ClampHttpClient.getStatusCode(loop));
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void test_deploy() throws Exception {
+ try (ClampHttpClient client = new ClampHttpClient(parameters.getClampClientParameters())) {
+
+ assertTrue(client.deploy(LOOP));
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void test_undeploy() throws Exception {
+ try (ClampHttpClient client = new ClampHttpClient(parameters.getClampClientParameters())) {
+
+ assertTrue(client.undeploy(LOOP));
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void test_getStatusCodeNull() {
+ assertThat(ClampHttpClient.getStatusCode(null)).isEqualTo(ClampHttpClient.STATUS_NOT_FOUND);
+ }
+
+ @Test
+ public void test_getStatusEmptyMap() {
+ assertThat(ClampHttpClient.getStatusCode(new Loop())).isEqualTo(ClampHttpClient.STATUS_NOT_FOUND);
+ }
+}
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
new file mode 100644
index 000000000..bcfaf8bb9
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java
@@ -0,0 +1,294 @@
+/*-
+ * ============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.dcae.main.parameters;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import javax.ws.rs.core.Response;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to hold/create all parameters for test cases.
+ */
+public class CommonTestData {
+ public static final String PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup";
+ public static final String DESCRIPTION = "Participant description";
+ public static final long TIME_INTERVAL = 2000;
+ public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
+ private static final String REST_CLIENT_PASSWORD = "password";
+ private static final String REST_CLIENT_USER = "admin";
+ private static final int REST_CLAMP_PORT = 8443;
+ private static final int REST_CONSUL_PORT = 31321;
+ private static final String REST_CLAMP_HOST = "localhost";
+ private static final String REST_CONSUL_HOST = "consul";
+ private static final boolean REST_CLAMP_HTTPS = false;
+ private static final boolean REST_CONSUL_HTTPS = false;
+ private static final boolean REST_CLIENT_AAF = false;
+
+ public static final Coder coder = new StandardCoder();
+
+ /**
+ * Converts the contents of a map to a parameter class.
+ *
+ * @param source property map
+ * @param clazz class of object to be created from the map
+ * @return a new object represented by the map
+ */
+ public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
+ try {
+ return coder.convert(source, clazz);
+
+ } catch (final CoderException e) {
+ throw new RuntimeException("cannot create " + clazz.getName() + " from map", e);
+ }
+ }
+
+ /**
+ * Returns a property map for a ApexStarterParameterGroup map for test cases.
+ *
+ * @param name name of the parameters
+ *
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getParticipantParameterGroupMap(final String name) {
+ final Map<String, Object> map = new TreeMap<>();
+
+ map.put("name", name);
+ map.put("clampClientParameters", getClampClientParametersMap(false));
+ map.put("consulClientParameters", getConsulClientParametersMap(false));
+ map.put("intermediaryParameters", getIntermediaryParametersMap(false));
+ map.put("databaseProviderParameters", getDatabaseProviderParametersMap(false));
+ return map;
+ }
+
+ /**
+ * Returns a property map for a RestServerParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getClampClientParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ map.put("https", REST_CLAMP_HTTPS);
+ map.put("aaf", REST_CLIENT_AAF);
+
+ if (!isEmpty) {
+ map.put("host", REST_CLAMP_HOST);
+ map.put("port", REST_CLAMP_PORT);
+ map.put("userName", REST_CLIENT_USER);
+ map.put("password", REST_CLIENT_PASSWORD);
+ }
+
+ return map;
+ }
+
+ /**
+ * Returns a property map for a RestServerParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getConsulClientParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ map.put("https", REST_CONSUL_HTTPS);
+ map.put("aaf", REST_CLIENT_AAF);
+
+ if (!isEmpty) {
+ map.put("host", REST_CONSUL_HOST);
+ map.put("port", REST_CONSUL_PORT);
+ map.put("userName", REST_CLIENT_USER);
+ map.put("password", REST_CLIENT_PASSWORD);
+ }
+
+ return map;
+ }
+
+ /**
+ * Returns a property map for a databaseProviderParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getDatabaseProviderParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("name", "PolicyProviderParameterGroup");
+ map.put("implementation", "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
+ map.put("databaseDriver", "org.h2.Driver");
+ map.put("databaseUrl", "jdbc:h2:mem:testdb");
+ map.put("databaseUser", "policy");
+ map.put("databasePassword", "P01icY");
+ map.put("persistenceUnit", "ToscaConceptTest");
+ }
+
+ return map;
+ }
+
+ /**
+ * Returns a property map for a intermediaryParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("name", "Participant parameters");
+ map.put("reportingTimeInterval", TIME_INTERVAL);
+ map.put("description", DESCRIPTION);
+ map.put("participantId", getParticipantId());
+ map.put("participantType", getParticipantId());
+ map.put("clampControlLoopTopics", getTopicParametersMap(false));
+ }
+
+ return map;
+ }
+
+ /**
+ * Returns a property map for a TopicParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("topicSources", TOPIC_PARAMS);
+ map.put("topicSinks", TOPIC_PARAMS);
+ }
+ return map;
+ }
+
+ /**
+ * Returns topic parameters for test cases.
+ *
+ * @return topic parameters
+ */
+ public static TopicParameters getTopicParams() {
+ final TopicParameters topicParams = new TopicParameters();
+ topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT");
+ topicParams.setTopicCommInfrastructure("dmaap");
+ topicParams.setServers(Arrays.asList("localhost"));
+ return topicParams;
+ }
+
+ /**
+ * Returns participantId for test cases.
+ *
+ * @return participant Id
+ */
+ public static ToscaConceptIdentifier getParticipantId() {
+ final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
+ participantId.setName("CDSParticipant0");
+ participantId.setVersion("1.0.0");
+ return participantId;
+ }
+
+ /**
+ * Gets the standard participant parameters.
+ *
+ * @param port port to be inserted into the parameters
+ * @return the standard participant parameters
+ */
+ public ParticipantDcaeParameters getParticipantParameterGroup(int port) {
+ try {
+ return coder.decode(getParticipantParameterGroupAsString(port), ParticipantDcaeParameters.class);
+
+ } catch (CoderException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
+ e);
+ }
+ }
+
+ /**
+ * Gets the standard participant parameters, as a String.
+ *
+ * @param port port to be inserted into the parameters
+ * @return the standard participant parameters
+ */
+ public static String getParticipantParameterGroupAsString(int port) {
+
+ try {
+ File file = new File(getParamFile());
+ String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
+
+ json = json.replace("${port}", String.valueOf(port));
+ json = json.replace("${dbName}", "jdbc:h2:mem:testdb");
+
+ return json;
+
+ } catch (IOException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
+ e);
+
+ }
+ }
+
+ /**
+ * Gets the full path to the parameter file, which may vary depending on whether or
+ * not this is an end-to-end test.
+ *
+ * @return the parameter file name
+ */
+ private static String getParamFile() {
+ return "src/test/resources/parameters/TestParametersStd.json";
+ }
+
+ /**
+ * Nulls out a field within a JSON string.
+ *
+ * @param json JSON string
+ * @param field field to be nulled out
+ * @return a new JSON string with the field nulled out
+ */
+ public String nullifyField(String json, String field) {
+ return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\"");
+ }
+
+ /**
+ * create Json response from getstatus call.
+ *
+ * @param status the status of Partecipant
+ * @return the JSON
+ */
+ public static String createJsonStatus(String status) {
+ try {
+ File file = new File("src/test/resources/rest/status.json");
+ String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
+ return json.replace("${status}", status);
+
+ } catch (IOException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read json file", e);
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameterHandler.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameterHandler.java
new file mode 100644
index 000000000..058a3dae4
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameterHandler.java
@@ -0,0 +1,102 @@
+/*-
+ * ============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.dcae.main.parameters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileNotFoundException;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameterHandler;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.startstop.ParticipantDcaeCommandLineArguments;
+import org.onap.policy.common.utils.coder.CoderException;
+
+/**
+ * Class to perform unit test of {@link ParticipantParameterHandler}.
+ *
+ */
+public class TestParticipantDcaeParameterHandler {
+
+ @Test
+ public void testParameterHandlerNoParameterFile() throws ControlLoopException {
+ final String[] emptyArgumentString = { "-c", "src/test/resources/parameters/NoParametersFile.json" };
+
+ final ParticipantDcaeCommandLineArguments emptyArguments = new ParticipantDcaeCommandLineArguments();
+ emptyArguments.parse(emptyArgumentString);
+
+ assertThatThrownBy(() -> new ParticipantDcaeParameterHandler().getParameters(emptyArguments))
+ .hasCauseInstanceOf(CoderException.class)
+ .hasRootCauseInstanceOf(FileNotFoundException.class);
+ }
+
+ @Test
+ public void testParameterHandlerInvalidParameters() throws ControlLoopException {
+ final String[] invalidArgumentString = { "-c", "src/test/resources/parameters/InvalidParameters.json" };
+
+ final ParticipantDcaeCommandLineArguments invalidArguments =
+ new ParticipantDcaeCommandLineArguments();
+ invalidArguments.parse(invalidArgumentString);
+
+ assertThatThrownBy(() -> new ParticipantDcaeParameterHandler().getParameters(invalidArguments))
+ .hasMessageStartingWith("error reading parameters from")
+ .hasCauseInstanceOf(CoderException.class);
+ }
+
+ @Test
+ public void testParticipantParameterGroup() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-c", "src/test/resources/parameters/TestParameters.json" };
+
+ final ParticipantDcaeCommandLineArguments arguments = new ParticipantDcaeCommandLineArguments();
+ arguments.parse(participantConfigParameters);
+
+ final ParticipantDcaeParameters parGroup = new ParticipantDcaeParameterHandler()
+ .getParameters(arguments);
+ assertTrue(arguments.checkSetConfigurationFilePath());
+ assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, parGroup.getName());
+ }
+
+ @Test
+ public void testParticipantVersion() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-v" };
+ final ParticipantDcaeCommandLineArguments arguments = new ParticipantDcaeCommandLineArguments();
+ assertThat(arguments.parse(participantConfigParameters)).startsWith(
+ "ONAP Tosca defined control loop Participant");
+ }
+
+ @Test
+ public void testParticipantHelp() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-h" };
+ final ParticipantDcaeCommandLineArguments arguments = new ParticipantDcaeCommandLineArguments();
+ assertThat(arguments.parse(participantConfigParameters)).startsWith("usage:");
+ }
+
+ @Test
+ public void testParticipantInvalidOption() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-d" };
+ final ParticipantDcaeCommandLineArguments arguments = new ParticipantDcaeCommandLineArguments();
+ assertThatThrownBy(() -> arguments.parse(participantConfigParameters))
+ .hasMessageStartingWith("invalid command line arguments specified");
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameters.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameters.java
new file mode 100644
index 000000000..edb429322
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameters.java
@@ -0,0 +1,90 @@
+/*-
+ * ============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.dcae.main.parameters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
+import org.onap.policy.common.parameters.ValidationResult;
+
+/**
+ * Class to perform unit test of {@link ParticipantParameterGroup}.
+ *
+ */
+public class TestParticipantDcaeParameters {
+ CommonTestData commonTestData = new CommonTestData();
+
+ @Test
+ public void testParticipantParameterGroup_Named() {
+ final ParticipantDcaeParameters participantParameters = new ParticipantDcaeParameters("my-name");
+ assertEquals("my-name", participantParameters.getName());
+ }
+
+ @Test
+ public void testParticipantParameterGroup() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.toObject(
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
+ ParticipantDcaeParameters.class);
+ final ParticipantIntermediaryParameters participantIntermediaryParameters = participantParameters
+ .getIntermediaryParameters();
+ final TopicParameterGroup topicParameterGroup = participantParameters.getIntermediaryParameters()
+ .getClampControlLoopTopics();
+ final ValidationResult validationResult = participantParameters.validate();
+ assertTrue(validationResult.isValid());
+ assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, participantParameters.getName());
+ assertEquals(CommonTestData.TIME_INTERVAL, participantIntermediaryParameters.getReportingTimeInterval());
+ assertEquals(CommonTestData.DESCRIPTION, participantIntermediaryParameters.getDescription());
+ assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSinks());
+ assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSources());
+ }
+
+ @Test
+ public void testParticipantParameterGroup_EmptyParticipantIntermediaryParameters() {
+ final Map<String, Object> map =
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME);
+ map.replace("intermediaryParameters", commonTestData.getIntermediaryParametersMap(true));
+ final ParticipantDcaeParameters participantParameters =
+ commonTestData.toObject(map, ParticipantDcaeParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertNull(validationResult.getResult());
+ }
+
+ @Test
+ public void testParticipantParameterGroup_EmptyTopicParameters() {
+ final Map<String, Object> map =
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME);
+ final Map<String, Object> intermediaryParametersMap = commonTestData.getIntermediaryParametersMap(false);
+ intermediaryParametersMap.put("clampControlLoopTopics", commonTestData.getTopicParametersMap(true));
+ map.replace("intermediaryParameters", intermediaryParametersMap);
+
+ final ParticipantDcaeParameters participantParameters =
+ commonTestData.toObject(map, ParticipantDcaeParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertNull(validationResult.getResult());
+ }
+}
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
new file mode 100644
index 000000000..c3cc8b755
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java
@@ -0,0 +1,255 @@
+/*-
+ * ============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.dcae.main.rest;
+
+import java.io.File;
+import java.time.Instant;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+import lombok.Getter;
+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.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.ParticipantHealthCheck;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.handler.DcaeProvider;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+public class TestListenerUtils {
+
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+ private static final Coder CODER = new StandardCoder();
+ private static final String TOSCA_TEMPLATE_YAML = "examples/controlloop/PMSubscriptionHandling.yaml";
+ static CommonTestData commonTestData = new CommonTestData();
+
+ @Getter
+ private static ParticipantHandler participantHandler;
+
+ /**
+ * Method to initialize participantHandler.
+ */
+ public static void initParticipantHandler() {
+
+ final ParticipantDcaeParameters parameters = commonTestData.toObject(
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
+ ParticipantDcaeParameters.class);
+
+ DcaeProvider dcaeProvider = new DcaeProvider(parameters);
+
+ participantHandler = dcaeProvider.getIntermediaryApi().getParticipantHandler();
+ }
+
+ /**
+ * Method to create a controlLoop from a yaml file.
+ *
+ * @return ControlLoop controlloop
+ */
+ public static ControlLoop createControlLoop() {
+ ControlLoop controlLoop = new ControlLoop();
+ Map<UUID, ControlLoopElement> elements = new LinkedHashMap<>();
+ ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
+ Map<String, ToscaNodeTemplate> nodeTemplatesMap =
+ toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
+ ControlLoopElement clElement = new ControlLoopElement();
+ clElement.setId(UUID.randomUUID());
+
+ ToscaConceptIdentifier clElementParticipantId = new ToscaConceptIdentifier();
+ clElementParticipantId.setName(toscaInputEntry.getKey());
+ clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
+ clElement.setParticipantId(clElementParticipantId);
+
+ clElement.setDefinition(clElementParticipantId);
+ clElement.setState(ControlLoopState.UNINITIALISED);
+ clElement.setDescription(toscaInputEntry.getValue().getDescription());
+ clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ elements.put(clElement.getId(), clElement);
+ }
+ controlLoop.setElements(elements);
+ controlLoop.setName("PMSHInstance0");
+ controlLoop.setVersion("1.0.0");
+
+ ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
+ definition.setName("PMSHInstance0");
+ definition.setVersion("1.0.0");
+ controlLoop.setDefinition(definition);
+
+ return controlLoop;
+ }
+
+ /**
+ * 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("CDSParticipant0");
+ 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
+ */
+ public static ParticipantControlLoopStateChange createControlLoopStateChangeMsg(
+ final ControlLoopOrderedState controlLoopOrderedState) {
+ final ParticipantControlLoopStateChange participantClStateChangeMsg = new ParticipantControlLoopStateChange();
+
+ ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier();
+ controlLoopId.setName("PMSHInstance0");
+ controlLoopId.setVersion("1.0.0");
+
+ ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
+ participantId.setName("CDSParticipant0");
+ participantId.setVersion("1.0.0");
+
+ participantClStateChangeMsg.setControlLoopId(controlLoopId);
+ participantClStateChangeMsg.setParticipantId(participantId);
+ participantClStateChangeMsg.setTimestamp(Instant.now());
+ participantClStateChangeMsg.setOrderedState(controlLoopOrderedState);
+
+ return participantClStateChangeMsg;
+ }
+
+ /**
+ * Method to create ControlLoopUpdateMsg.
+ *
+ * @return ParticipantControlLoopUpdate message
+ */
+ public static ParticipantControlLoopUpdate createControlLoopUpdateMsg() {
+ final ParticipantControlLoopUpdate clUpdateMsg = new ParticipantControlLoopUpdate();
+ ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier();
+ controlLoopId.setName("PMSHInstance0");
+ controlLoopId.setVersion("1.0.0");
+
+ ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
+ participantId.setName("CDSParticipant0");
+ participantId.setVersion("1.0.0");
+
+ clUpdateMsg.setControlLoopId(controlLoopId);
+ clUpdateMsg.setParticipantId(participantId);
+
+ ControlLoop controlLoop = new ControlLoop();
+ Map<UUID, ControlLoopElement> elements = new LinkedHashMap<>();
+ ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
+ Map<String, ToscaNodeTemplate> nodeTemplatesMap =
+ toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
+ ControlLoopElement clElement = new ControlLoopElement();
+ clElement.setId(UUID.randomUUID());
+
+ ToscaConceptIdentifier clElementParticipantId = new ToscaConceptIdentifier();
+ clElementParticipantId.setName(toscaInputEntry.getKey());
+ clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
+ clElement.setParticipantId(clElementParticipantId);
+
+ clElement.setDefinition(clElementParticipantId);
+ clElement.setState(ControlLoopState.UNINITIALISED);
+ clElement.setDescription(toscaInputEntry.getValue().getDescription());
+ clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ elements.put(clElement.getId(), clElement);
+ }
+ controlLoop.setElements(elements);
+ controlLoop.setName("PMSHInstance0");
+ controlLoop.setVersion("1.0.0");
+ controlLoop.setDefinition(controlLoopId);
+ clUpdateMsg.setControlLoop(controlLoop);
+ clUpdateMsg.setControlLoopDefinition(toscaServiceTemplate);
+
+ return clUpdateMsg;
+ }
+
+ /**
+ * Method to create ParticipantHealthCheck message.
+ *
+ * @return ParticipantHealthCheck message
+ */
+ public static ParticipantHealthCheck createParticipantHealthCheckMsg() {
+ ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
+ participantId.setName("CDSParticipant0");
+ participantId.setVersion("1.0.0");
+
+ ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier();
+ controlLoopId.setName("PMSHInstance0");
+ controlLoopId.setVersion("1.0.0");
+
+ final ParticipantHealthCheck participantHealthCheckMsg = new ParticipantHealthCheck();
+ participantHealthCheckMsg.setParticipantId(participantId);
+ participantHealthCheckMsg.setControlLoopId(controlLoopId);
+ participantHealthCheckMsg.setTimestamp(Instant.now());
+ participantHealthCheckMsg.setState(ParticipantState.PASSIVE);
+
+ return participantHealthCheckMsg;
+ }
+
+ /**
+ * Method to create ParticipantControlLoopUpdate using the arguments passed.
+ *
+ * @param jsonFilePath the path of the controlloop content
+ *
+ * @return ParticipantControlLoopUpdate message
+ * @throws CoderException exception while reading the file to object
+ */
+ public static ParticipantControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath)
+ throws CoderException {
+ ParticipantControlLoopUpdate participantControlLoopUpdateMsg =
+ CODER.decode(new File(jsonFilePath), ParticipantControlLoopUpdate.class);
+ return participantControlLoopUpdateMsg;
+ }
+
+ private static ToscaServiceTemplate testControlLoopRead() {
+ return testControlLoopYamlSerialization(TOSCA_TEMPLATE_YAML);
+ }
+
+ private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) {
+ String controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath);
+ ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(controlLoopString, ToscaServiceTemplate.class);
+ return serviceTemplate;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/TestMain.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/TestMain.java
new file mode 100644
index 000000000..f779f3a57
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/TestMain.java
@@ -0,0 +1,151 @@
+/*-
+ * ============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.dcae.main.startstop;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.ControlLoopConstants;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.startstop.Main;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.startstop.ParticipantDcaeActivator;
+import org.onap.policy.common.utils.resources.MessageConstants;
+import org.onap.policy.common.utils.services.Registry;
+
+/**
+ * Class to perform unit test of {@link Main}}.
+ */
+public class TestMain {
+
+ /**
+ * Set up.
+ */
+ @BeforeClass
+ public static void setUp() {
+ Registry.newRegistry();
+ }
+
+ /**
+ * Shuts "main" down.
+ *
+ * @throws Exception if an error occurs
+ */
+ @AfterClass
+ public static void tearDown() throws Exception {
+ // shut down activator
+ final ParticipantDcaeActivator activator =
+ Registry.getOrDefault(ControlLoopConstants.REG_CLRUNTIME_ACTIVATOR,
+ ParticipantDcaeActivator.class, null);
+ if (activator != null && activator.isAlive()) {
+ activator.shutdown();
+ }
+ }
+
+ @Test
+ public void testMain_Help() {
+ final String[] configParameters = {"-h"};
+ Main main = new Main(configParameters);
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_Version() {
+ final String[] configParameters = {"-v"};
+ Main main = new Main(configParameters);
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_Valid() {
+ final String[] configParameters = {"-c", "src/test/resources/parameters/TestParameters.json"};
+ Main main = new Main(configParameters);
+ assertTrue(main.isRunning());
+
+ // ensure items were added to the registry
+ assertNotNull(Registry.get(ControlLoopConstants.REG_CLRUNTIME_ACTIVATOR, ParticipantDcaeActivator.class));
+
+ assertThatCode(() -> main.shutdown()).doesNotThrowAnyException();
+
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_NoParameter() {
+ assertThatConfigParameterThrownException(new String[] {});
+ }
+
+ @Test
+ public void testMain_FilePathNotDefined() {
+ assertThatConfigParameterThrownException(new String[] {"-c"});
+ }
+
+ @Test
+ public void testMain_TooManyCommand() {
+ assertThatConfigParameterThrownException(new String[] {"-h", "d"});
+ }
+
+ @Test
+ public void testMain_WrongParameter() {
+ assertThatConfigParameterThrownException(new String[] {"-d"});
+ }
+
+ private void assertThatConfigParameterThrownException(final String[] configParameters) {
+ assertThatThrownBy(() -> Main.main(configParameters)).isInstanceOf(ControlLoopRuntimeException.class)
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP));
+ }
+
+ @Test
+ public void testParticipant_NoFileWithThisName() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/NoFileWithThisName.json");
+ }
+
+ @Test
+ public void testParticipant_NotValidFile() {
+ assertThatConfigFileThrownException("src/test/resources/parameters");
+ }
+
+ @Test
+ public void testParticipant_NoParameters() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/NoParameters.json");
+ }
+
+ @Test
+ public void testParticipant_InvalidParameters() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/InvalidParameters.json");
+ }
+
+ @Test
+ public void testParticipant_WrongJsonFormat() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/Unreadable.json");
+ }
+
+ private void assertThatConfigFileThrownException(final String configFilePath) {
+ final String[] configParameters = new String[] {"-c", configFilePath};
+ assertThatThrownBy(() -> new Main(configParameters)).isInstanceOf(ControlLoopRuntimeException.class)
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP));
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/TestParticipantDcaeActivator.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/TestParticipantDcaeActivator.java
new file mode 100644
index 000000000..1903868e2
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/startstop/TestParticipantDcaeActivator.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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.dcae.main.startstop;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameterHandler;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.startstop.ParticipantDcaeActivator;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.startstop.ParticipantDcaeCommandLineArguments;
+import org.onap.policy.common.utils.services.Registry;
+
+/**
+ * Class to perform unit test of {@link ParticipantDcaeActivator}}.
+ *
+ */
+public class TestParticipantDcaeActivator {
+
+ private static ParticipantDcaeActivator activator;
+
+ /**
+ * Initializes an activator.
+ *
+ * @throws Exception if an error occurs
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Registry.newRegistry();
+ final String[] participantConfigParameters = { "-c", "src/test/resources/parameters/TestParameters.json"};
+ final ParticipantDcaeCommandLineArguments arguments =
+ new ParticipantDcaeCommandLineArguments(participantConfigParameters);
+ final ParticipantDcaeParameters parGroup =
+ new ParticipantDcaeParameterHandler().getParameters(arguments);
+ activator = new ParticipantDcaeActivator(parGroup);
+ }
+
+ /**
+ * Method for cleanup after each test.
+ *
+ * @throws Exception if an error occurs
+ */
+ @AfterClass
+ public static void teardown() throws Exception {
+ // shut down activator
+ if (activator != null && activator.isAlive()) {
+ activator.shutdown();
+ }
+ }
+
+ @Test
+ public void testParticipantActivator() {
+ activator.start();
+ assertTrue(activator.isAlive());
+ assertTrue(activator.getParameters().isValid());
+ assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, activator.getParameters().getName());
+
+ // repeat - should throw an exception
+ assertThatIllegalStateException().isThrownBy(() -> activator.start());
+ assertTrue(activator.isAlive());
+ assertTrue(activator.getParameters().isValid());
+
+ activator.shutdown();
+ assertFalse(activator.isAlive());
+
+ // repeat - should throw an exception
+ assertThatIllegalStateException().isThrownBy(() -> activator.shutdown());
+ assertFalse(activator.isAlive());
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/InvalidParameters.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/InvalidParameters.json
new file mode 100644
index 000000000..1035ccb67
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/InvalidParameters.json
@@ -0,0 +1,3 @@
+{
+ "name": "
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/MinimumParametersH2.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/MinimumParametersH2.json
new file mode 100644
index 000000000..1ee2955b9
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/MinimumParametersH2.json
@@ -0,0 +1,61 @@
+{
+ "name": "ControlLoopParticipantGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantId": {
+ "name": "DCAEParticipant0",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/NoParameters.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/NoParameters.json
new file mode 100644
index 000000000..7a73a41bf
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/NoParameters.json
@@ -0,0 +1,2 @@
+{
+} \ No newline at end of file
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestCLParams.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestCLParams.json
new file mode 100644
index 000000000..a4258622d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestCLParams.json
@@ -0,0 +1,160 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+data_types:
+ onap.datatypes.ToscaConceptIdentifier:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ required: true
+ version:
+ type: string
+ required: true
+node_types:
+ org.onap.policy.clamp.controlloop.Participant:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ org.onap.policy.clamp.controlloop.ControlLoopElement:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ participant_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.ControlLoop:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ elements:
+ type: list
+ required: true
+ entry_schema:
+ type: onap.datatypes.ToscaConceptIdentifier
+ org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ dcae_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ policy_type_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.CDSControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ cds_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+topology_template:
+ node_templates:
+ org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant:
+ version: 2.3.4
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.policy.controlloop.MonitoringPolicyControlLoopParticipant:
+ version: 2.3.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.policy.controlloop.OperationalPolicyControlLoopParticipant:
+ version: 3.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant:
+ version: 2.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.domain.pmsh.PMSH_DCAEMicroservice:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ dcae_blueprint_id:
+ name: org.onap.dcae.blueprints.PMSHBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.MonitoringPolicyControlLoopParticipant
+ version: 2.3.1
+ policy_type_id:
+ name: onap.policies.monitoring.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.OperationalPolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for CDS for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_Id:
+ name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
+ version: 3.2.1
+ cds_blueprint_id:
+ name: org.onap.ccsdk.cds.PMSHCdsBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSHControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ elements:
+ - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement
+ version: 1.2.3
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParameters.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParameters.json
new file mode 100644
index 000000000..789fc7bbd
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParameters.json
@@ -0,0 +1,71 @@
+{
+ "name": "ControlLoopParticipantGroup",
+ "clampClientParameters": {
+ "name": "Clamp",
+ "host": "0.0.0.0",
+ "port": 8443,
+ "userName": "admin",
+ "password": "password",
+ "https": true,
+ "aaf": false
+ },
+ "consulClientParameters": {
+ "name": "Clamp",
+ "host": "consul",
+ "port": 31321,
+ "userName": "admin",
+ "password": "password",
+ "https": false,
+ "aaf": false
+ },
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantId": {
+ "name": "DCAEParticipant0",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParametersStd.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParametersStd.json
new file mode 100644
index 000000000..789fc7bbd
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParametersStd.json
@@ -0,0 +1,71 @@
+{
+ "name": "ControlLoopParticipantGroup",
+ "clampClientParameters": {
+ "name": "Clamp",
+ "host": "0.0.0.0",
+ "port": 8443,
+ "userName": "admin",
+ "password": "password",
+ "https": true,
+ "aaf": false
+ },
+ "consulClientParameters": {
+ "name": "Clamp",
+ "host": "consul",
+ "port": 31321,
+ "userName": "admin",
+ "password": "password",
+ "https": false,
+ "aaf": false
+ },
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantId": {
+ "name": "DCAEParticipant0",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json
new file mode 100644
index 000000000..581ce8f4f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json
@@ -0,0 +1,81 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": ${port},
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "${dbName}",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ },
+ "healthCheckRestClientParameters": [
+ {
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }
+ ]
+}
+
+
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/logback-test.xml b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/logback-test.xml
new file mode 100644
index 000000000..cf6b89eb9
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/logback-test.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+
+<configuration>
+
+ <contextName>Participant</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/clamp_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.onap.policy.clamp.controlloop.participant" level="trace" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml b/participant/participant-impl/participant-impl-dcae/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml
new file mode 100644
index 000000000..01f825fc9
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml
@@ -0,0 +1,452 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+capability_types:
+ org.onap.EventProducer:
+ properties:
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ event_format:
+ type: string
+ required: true
+ event_format_version:
+ type: string
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+ org.onap.EventConsumer:
+ properties:
+ responding_capability:
+ type: string
+ required: false
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ - all valid values should be added here
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured,
+ etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+node_types:
+ org.onap.DynamicConfig:
+ properties:
+ application_name:
+ type: string
+ description: Value used to tie the config to an application ? should we be
+ using a relationship here instead?
+ required: true
+ application_version:
+ type: string
+ required: true
+ application_provider:
+ type: string
+ required: false
+ data_types:
+ type: object
+ required: false
+ schema:
+ type: object
+ required: false
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.APP:
+ properties:
+ application_name:
+ type: string
+ description: Human readable name for the application Product
+ required: false
+ provider:
+ type: string
+ description: Provider of the application and of the descriptor
+ required: true
+ application_version:
+ type: string
+ description: Software version of the application
+ required: true
+ blueprint_id:
+ type: string
+ description: A reference to the app blueprint
+ required: false
+ monitoring_policy:
+ type: string
+ description: A reference to the monitoring policy
+ required: false
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.EventRelay:
+ properties:
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: true
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key is relayed
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ supported_carrier_protocols:
+ type: map
+ description: 'A map describing supported carrier protocols and translations.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ supported_data_formats:
+ type: map
+ description: 'Is a map describing supported data formats and translation.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+relationship_types:
+ org.onap.PropagateEvent:
+ properties:
+ config_keys:
+ type: list
+ description: The relationship type used on requirements to org.onap.EventProducer
+ and org.onap.EventConsumer capabilities. Filters events by specific config_keys
+ to be transferred by this relationship. That is, any event with a specific
+ config_key found in the list is transferred. If list is not defined or is
+ empty, events with all config_keys are transferred.
+ required: false
+ entry_schema:
+ type: string
+ version: 0.0.1
+ derived_from: tosca.relationships.Root
+topology_template:
+ inputs:
+ pm_subscription_topic:
+ type: string
+ pm_subscription_response_topic:
+ type: string
+ pm_subscription_handler_blueprint_id:
+ type: string
+ pm_subscription_operational_policy_id:
+ type: string
+ pm_subscription_cds_blueprint_id:
+ type: string
+ enable_tls:
+ type: string
+ node_templates:
+ org.onap.PM_Subscription_Handler:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription Handler
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_handler_blueprint_id
+ description: Is this a reference to the DCAE Cloudify Blueprint that is
+ already stored(or will be stored before CL configuration & instatiation)
+ in DCAE Inventory?
+ artifact_config:
+ enable_tls:
+ get_input: enable_tls
+ pmsh_publish_topic_name:
+ get_input: pm_subscription_topic
+ capabilities:
+ pm-subscription-event-publisher:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-format
+ event_format_version: 1.0.0
+ attributes:
+ type: org.onap.EventProducer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ pm-subscription-event-receiver:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ relationships:
+ - type: tosca.relationships.DependsOn
+ - description: any ideas on a better realtionship ? or is it better to
+ just use the root realtionship ?
+ - target: org.onap.PM_Monitoring_Policy
+ attributes:
+ type: org.onap.EventConsumer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_Monitoring_Policy:
+ type: org.onap.DynamicConfig
+ properties:
+ application_name: PM Subscription Handler
+ application_version: 1.0.0
+ provider: Ericsson
+ data_types:
+ measurementType:
+ type: string
+ DN:
+ type: string
+ nfFilter:
+ properties:
+ nfNames:
+ type: list
+ entry_schema: string
+ modelInvariantIDs:
+ type: list
+ entry_schema:
+ type: string
+ modelVersionIDs:
+ type: list
+ entry_schema:
+ type: string
+ measurementGroup:
+ properties:
+ masurementTypes:
+ type: list
+ entry_schema:
+ type: measurementType
+ managedObjectDNsBasic:
+ type: list
+ entry_schema:
+ type: DN
+ schema:
+ subscription:
+ subscriptionName:
+ type: string
+ required: true
+ administrativeState:
+ type: string
+ required: true
+ filebasedGP:
+ type: integer
+ required: true
+ fileLocation:
+ type: string
+ required: true
+ nfFilter:
+ type: nfFilter
+ measurementGroups:
+ type: list
+ entry_schema:
+ type: measurementGroup
+ version: 0.0.0
+ description: Should I be showing a dependency between PM Subscription Handler
+ and the PM Monitoring Policy
+ org.onap.PM_Policy:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription Operational Policy
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_operational_policy_id
+ artifact_config: NOT_DEFINED
+ requirements:
+ - receive_0:
+ capability: pm-subscription-event-publisher
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_topic
+ version: 0.0.0
+ - send_0:
+ capability: cds-rest-receive
+ node: org.onap.CDS
+ version: 0.0.0
+ - receive_1:
+ capability: cds-rest-response
+ node: org.onap.CDS
+ version: 0.0.0
+ - send_1:
+ capability: pm-subscription-event-receiver
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_response_topic
+ version: 0.0.0
+ capabilities:
+ pm-subscription-response-event-publisher:
+ properties:
+ type: org.onap.EventProducer
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_CDS_Blueprint:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription CDS Blueprint
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_cds_blueprint_id
+ capabilities:
+ cds-rest-receive:
+ properties:
+ type: org.onap.EventConsumer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_format
+ event_format_version: 1.0.0
+ responding_capability: cds-rest-response
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ cds-rest-response:
+ properties:
+ type: org.onap.EventProducer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_response_format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.controlloop0:
+ type: org.onap.APP
+ properties:
+ application_name: Test Control Loop
+ provider: Ericsson
+ application_version: 1.0.0
+ status: NOT_DEPLOYED
+ version: 0.0.0
+version: 0.0.0
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/rest/status.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/rest/status.json
new file mode 100644
index 000000000..143ef635d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/rest/status.json
@@ -0,0 +1,3918 @@
+{
+ "name": "pmsh_loop",
+ "globalPropertiesJson": {
+ "dcaeDeployParameters": {
+ "uniqueBlueprintParameters": {
+ "tag_version": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2",
+ "replicas": 1,
+ "operational_policy_name": "pmsh-operational-policy",
+ "control_loop_name": "pmsh-control-loop",
+ "pmsh_publish_topic_name": "unauthenticated.DCAE_CL_OUTPUT",
+ "policy_feedback_topic_name": "unauthenticated.PMSH_CL_INPUT",
+ "aai_notification_topic_name": "AAI-EVENT",
+ "publisher_client_role": "org.onap.dcae.pmPublisher",
+ "subscriber_client_role": "org.onap.dcae.pmSubscriber",
+ "dcae_location": "san-francisco",
+ "cpu_limit": "1000m",
+ "cpu_request": "1000m",
+ "memory_limit": "1024Mi",
+ "memory_request": "1024Mi",
+ "pgaas_cluster_name": "dcae-pg-primary.onap",
+ "enable_tls": true,
+ "protocol": "https",
+ "policy_model_id": "onap.policies.monitoring.dcae-pm-subscription-handler",
+ "policy_id": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh"
+ }
+ }
+ },
+ "modelService": {
+ "serviceDetails": {
+ "serviceType": "",
+ "serviceRole": "",
+ "description": "vLBMS",
+ "type": "Service",
+ "instantiationType": "A-la-carte",
+ "namingPolicy": "",
+ "serviceEcompNaming": "true",
+ "environmentContext": "General_Revenue-Bearing",
+ "name": "vLoadBalancerMS",
+ "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f",
+ "ecompGeneratedNaming": "true",
+ "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0",
+ "category": "Network L4+"
+ },
+ "resourceDetails": {
+ "CP": {},
+ "VL": {},
+ "VF": {
+ "vLoadBalancerMS 0": {
+ "resourceVendor": "Test",
+ "name": "vLoadBalancerMS",
+ "resourceVendorModelNumber": "",
+ "description": "vLBMS",
+ "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506",
+ "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6",
+ "type": "VF",
+ "category": "Application L4+",
+ "subcategory": "Load Balancer",
+ "version": "1.0",
+ "customizationUUID": "465246dc-7748-45f4-a013-308d92922552",
+ "resourceVendorRelease": "1.0",
+ "controllerProperties": {
+ "sdnc_model_name": "baseconfiguration",
+ "sdnc_model_version": "1.0.0",
+ "workflows": {
+ "resource-assignment": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "activate": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "activate-restconf": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "activate-cli": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "assign-activate": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "imperative-test-wf": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "CR": {},
+ "VFC": {},
+ "PNF": {},
+ "Service": {},
+ "CVFC": {},
+ "Service Proxy": {},
+ "Configuration": {},
+ "AllottedResource": {},
+ "VFModule": {
+ "Vloadbalancerms..vpkg..module-1": {
+ "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043",
+ "vfModuleModelVersion": "1",
+ "vfModuleModelName": "Vloadbalancerms..vpkg..module-1",
+ "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc",
+ "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52",
+ "min_vf_module_instances": 0,
+ "vf_module_label": "vpkg",
+ "max_vf_module_instances": 1,
+ "vf_module_type": "Expansion",
+ "isBase": false,
+ "initial_count": 0,
+ "volume_group": false
+ },
+ "Vloadbalancerms..vdns..module-3": {
+ "vfModuleModelInvariantUUID": "4c10ba9b-f88f-415e-9de3-5d33336047fa",
+ "vfModuleModelVersion": "1",
+ "vfModuleModelName": "Vloadbalancerms..vdns..module-3",
+ "vfModuleModelUUID": "4fa73b49-8a6c-493e-816b-eb401567b720",
+ "vfModuleModelCustomizationUUID": "bafcdab0-801d-4d81-9ead-f464640a38b1",
+ "min_vf_module_instances": 0,
+ "vf_module_label": "vdns",
+ "max_vf_module_instances": 50,
+ "vf_module_type": "Expansion",
+ "isBase": false,
+ "initial_count": 0,
+ "volume_group": false
+ },
+ "Vloadbalancerms..base_template..module-0": {
+ "vfModuleModelInvariantUUID": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3",
+ "vfModuleModelVersion": "1",
+ "vfModuleModelName": "Vloadbalancerms..base_template..module-0",
+ "vfModuleModelUUID": "63734409-f745-4e4d-a38b-131638a0edce",
+ "vfModuleModelCustomizationUUID": "86baddea-c730-4fb8-9410-cd2e17fd7f27",
+ "min_vf_module_instances": 1,
+ "vf_module_label": "base_template",
+ "max_vf_module_instances": 1,
+ "vf_module_type": "Base",
+ "isBase": true,
+ "initial_count": 1,
+ "volume_group": false
+ },
+ "Vloadbalancerms..vlb..module-2": {
+ "vfModuleModelInvariantUUID": "a772a1f4-0064-412c-833d-4749b15828dd",
+ "vfModuleModelVersion": "1",
+ "vfModuleModelName": "Vloadbalancerms..vlb..module-2",
+ "vfModuleModelUUID": "0f5c3f6a-650a-4303-abb6-fff3e573a07a",
+ "vfModuleModelCustomizationUUID": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806",
+ "min_vf_module_instances": 0,
+ "vf_module_label": "vlb",
+ "max_vf_module_instances": 1,
+ "vf_module_type": "Expansion",
+ "isBase": false,
+ "initial_count": 0,
+ "volume_group": false
+ }
+ }
+ }
+ },
+ "lastComputedState": "DESIGN",
+ "components": {
+ "POLICY": {
+ "componentState": {
+ "stateName": "NOT_SENT",
+ "description": "The policies defined have NOT yet been created on the policy engine"
+ }
+ },
+ "DCAE": {
+ "componentState": {
+ "stateName": "${status}",
+ "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop"
+ }
+ }
+ },
+ "operationalPolicies": [],
+ "microServicePolicies": [
+ {
+ "name": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh",
+ "shared": false,
+ "jsonRepresentation": {
+ "title": "onap.policies.monitoring.dcae-pm-subscription-handler",
+ "type": "object",
+ "required": [],
+ "properties": {
+ "pmsh_policy": {
+ "title": "onap.datatypes.monitoring.subscription",
+ "type": "object",
+ "required": [
+ "measurementGroups",
+ "fileBasedGP",
+ "fileLocation",
+ "subscriptionName",
+ "administrativeState",
+ "nfFilter"
+ ],
+ "properties": {
+ "measurementGroups": {
+ "type": "array",
+ "description": "Measurement Groups",
+ "items": {
+ "title": "onap.datatypes.monitoring.measurementGroups",
+ "type": "object",
+ "required": [
+ "measurementGroup"
+ ],
+ "properties": {
+ "measurementGroup": {
+ "type": "object",
+ "description": "Measurement Group",
+ "properties": {
+ "onap.datatypes.monitoring.measurementGroup": {
+ "title": "onap.datatypes.monitoring.measurementGroup",
+ "type": "object",
+ "required": [
+ "measurementTypes",
+ "managedObjectDNsBasic"
+ ],
+ "properties": {
+ "measurementTypes": {
+ "type": "array",
+ "description": "List of measurement types",
+ "items": {
+ "title": "onap.datatypes.monitoring.measurementTypes",
+ "type": "object",
+ "required": [
+ "measurementType"
+ ],
+ "properties": {
+ "measurementType": {
+ "type": "object",
+ "description": "Measurement type object",
+ "properties": {
+ "onap.datatypes.monitoring.measurementType": {
+ "title": "onap.datatypes.monitoring.measurementType",
+ "type": "object",
+ "required": [
+ "measurementType"
+ ],
+ "properties": {
+ "measurementType": {
+ "type": "string",
+ "description": "Measurement type"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "format": "tabs-top"
+ },
+ "managedObjectDNsBasic": {
+ "type": "array",
+ "description": "List of managed object distinguished names",
+ "items": {
+ "title": "onap.datatypes.monitoring.managedObjectDNsBasics",
+ "type": "object",
+ "required": [
+ "managedObjectDNsBasic"
+ ],
+ "properties": {
+ "managedObjectDNsBasic": {
+ "type": "object",
+ "description": "Managed object distinguished name object",
+ "properties": {
+ "onap.datatypes.monitoring.managedObjectDNsBasic": {
+ "title": "onap.datatypes.monitoring.managedObjectDNsBasic",
+ "type": "object",
+ "required": [
+ "DN"
+ ],
+ "properties": {
+ "DN": {
+ "type": "string",
+ "description": "Managed object distinguished name"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "format": "tabs-top"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "format": "tabs-top"
+ },
+ "fileBasedGP": {
+ "type": "integer",
+ "description": "File based granularity period"
+ },
+ "fileLocation": {
+ "type": "string",
+ "description": "ROP file location"
+ },
+ "subscriptionName": {
+ "type": "string",
+ "description": "Name of the subscription"
+ },
+ "administrativeState": {
+ "type": "string",
+ "description": "State of the subscription",
+ "enum": [
+ "LOCKED",
+ "UNLOCKED"
+ ]
+ },
+ "nfFilter": {
+ "type": "object",
+ "description": "Network function filter",
+ "properties": {
+ "onap.datatypes.monitoring.nfFilter": {
+ "title": "onap.datatypes.monitoring.nfFilter",
+ "type": "object",
+ "required": [
+ "modelVersionIDs",
+ "modelInvariantIDs",
+ "modelNames",
+ "nfNames"
+ ],
+ "properties": {
+ "modelVersionIDs": {
+ "type": "array",
+ "description": "List of model version IDs",
+ "items": {
+ "type": "string"
+ },
+ "format": "tabs-top"
+ },
+ "modelInvariantIDs": {
+ "type": "array",
+ "description": "List of model invariant IDs",
+ "items": {
+ "type": "string"
+ },
+ "format": "tabs-top"
+ },
+ "modelNames": {
+ "type": "array",
+ "description": "List of model names",
+ "items": {
+ "type": "string"
+ },
+ "format": "tabs-top"
+ },
+ "nfNames": {
+ "type": "array",
+ "description": "List of network functions",
+ "items": {
+ "type": "string"
+ },
+ "format": "tabs-top"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "loopElementModel": {
+ "name": "onap.policies.monitoring.dcae-pm-subscription-handler",
+ "loopElementType": "MICRO_SERVICE_TYPE",
+ "policyModels": [
+ {
+ "policyModelType": "onap.policies.monitoring.dcae-pm-subscription-handler",
+ "version": "1.0.0",
+ "policyAcronym": "dcae-pm-subscription-handler",
+ "policyPdpGroup": {
+ "supportedPdpGroups": [
+ {
+ "ControlLoopGroup": [
+ "apex",
+ "xacml"
+ ]
+ },
+ {
+ "defaultGroup": [
+ "xacml"
+ ]
+ }
+ ]
+ },
+ "createdDate": "2021-03-30T09:55:52.261232Z",
+ "updatedDate": "2021-03-30T09:56:17.502284Z",
+ "updatedBy": "Not found",
+ "createdBy": "Not found"
+ }
+ ],
+ "createdDate": "2021-03-30T08:48:21Z",
+ "updatedDate": "2021-03-30T08:48:21Z",
+ "updatedBy": "Not found",
+ "createdBy": "Not found"
+ },
+ "policyModel": {
+ "policyModelType": "onap.policies.monitoring.dcae-pm-subscription-handler",
+ "version": "1.0.0",
+ "policyAcronym": "dcae-pm-subscription-handler",
+ "policyPdpGroup": {
+ "supportedPdpGroups": [
+ {
+ "ControlLoopGroup": [
+ "apex",
+ "xacml"
+ ]
+ },
+ {
+ "defaultGroup": [
+ "xacml"
+ ]
+ }
+ ]
+ },
+ "createdDate": "2021-03-30T09:55:52.261232Z",
+ "updatedDate": "2021-03-30T09:56:17.502284Z",
+ "updatedBy": "Not found",
+ "createdBy": "Not found"
+ },
+ "createdDate": "2021-03-30T13:07:07.960379Z",
+ "updatedDate": "2021-03-30T13:07:07.960379Z",
+ "updatedBy": "admin",
+ "createdBy": "admin"
+ }
+ ],
+ "loopLogs": [
+ {
+ "id": 478,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-05-07T09:32:44Z"
+ },
+ {
+ "id": 477,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-05-07T09:32:44Z"
+ },
+ {
+ "id": 476,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-05-07T09:32:43Z"
+ },
+ {
+ "id": 475,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-05-07T09:32:43Z"
+ },
+ {
+ "id": 474,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-05-07T09:32:43Z"
+ },
+ {
+ "id": 473,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-05-07T09:32:43Z"
+ },
+ {
+ "id": 472,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-05-07T09:32:39Z"
+ },
+ {
+ "id": 471,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-05-07T09:32:39Z"
+ },
+ {
+ "id": 470,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-05-07T09:32:35Z"
+ },
+ {
+ "id": 451,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-07T13:34:30Z"
+ },
+ {
+ "id": 450,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-07T13:34:30Z"
+ },
+ {
+ "id": 449,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-07T13:34:30Z"
+ },
+ {
+ "id": 448,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-07T13:34:30Z"
+ },
+ {
+ "id": 447,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-07T13:34:30Z"
+ },
+ {
+ "id": 446,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-07T13:34:30Z"
+ },
+ {
+ "id": 445,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-07T13:34:26Z"
+ },
+ {
+ "id": 444,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-07T13:34:26Z"
+ },
+ {
+ "id": 443,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-07T13:34:22Z"
+ },
+ {
+ "id": 442,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "PDP Group remove ALL status - : ",
+ "logInstant": "2021-04-07T08:32:06Z"
+ },
+ {
+ "id": 441,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "STOP request",
+ "logInstant": "2021-04-07T08:32:02Z"
+ },
+ {
+ "id": 440,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-07T08:23:46Z"
+ },
+ {
+ "id": 439,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-07T08:23:46Z"
+ },
+ {
+ "id": 438,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-07T08:23:46Z"
+ },
+ {
+ "id": 437,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-07T08:23:46Z"
+ },
+ {
+ "id": 436,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-07T08:23:46Z"
+ },
+ {
+ "id": 435,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-07T08:23:46Z"
+ },
+ {
+ "id": 434,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-07T08:23:42Z"
+ },
+ {
+ "id": 433,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-07T08:23:41Z"
+ },
+ {
+ "id": 432,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-07T08:23:37Z"
+ },
+ {
+ "id": 431,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-06T15:06:27Z"
+ },
+ {
+ "id": 430,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-06T15:06:27Z"
+ },
+ {
+ "id": 429,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-06T15:06:27Z"
+ },
+ {
+ "id": 428,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-06T15:06:27Z"
+ },
+ {
+ "id": 427,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-06T15:06:27Z"
+ },
+ {
+ "id": 426,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T15:06:27Z"
+ },
+ {
+ "id": 425,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-06T15:06:22Z"
+ },
+ {
+ "id": 424,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T15:06:22Z"
+ },
+ {
+ "id": 423,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-06T15:06:18Z"
+ },
+ {
+ "id": 422,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "PDP Group remove ALL status - : ",
+ "logInstant": "2021-04-06T15:06:04Z"
+ },
+ {
+ "id": 421,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "STOP request",
+ "logInstant": "2021-04-06T15:06:00Z"
+ },
+ {
+ "id": 420,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-06T15:05:28Z"
+ },
+ {
+ "id": 419,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-06T15:05:28Z"
+ },
+ {
+ "id": 418,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-06T15:05:28Z"
+ },
+ {
+ "id": 417,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-06T15:05:28Z"
+ },
+ {
+ "id": 416,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-06T15:05:28Z"
+ },
+ {
+ "id": 415,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T15:05:28Z"
+ },
+ {
+ "id": 414,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-06T15:05:24Z"
+ },
+ {
+ "id": 413,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T15:05:23Z"
+ },
+ {
+ "id": 412,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-06T15:05:19Z"
+ },
+ {
+ "id": 411,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "UNDEPLOY request successfully executed",
+ "logInstant": "2021-04-06T15:05:07Z"
+ },
+ {
+ "id": 410,
+ "logType": "WARNING",
+ "logComponent": "CLAMP",
+ "message": "Cannot Undeploy for the loop: pmsh_loop, the Deployment ID does not exist !",
+ "logInstant": "2021-04-06T15:05:07Z"
+ },
+ {
+ "id": 409,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "DCAE UNDEPLOY request",
+ "logInstant": "2021-04-06T15:05:07Z"
+ },
+ {
+ "id": 408,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DEPLOY loop status\n (Dep-id:CLAMP_7ae6f14d-80c8-4403-a174-ecb215d04c81,\n StatusUrl:) - : ",
+ "logInstant": "2021-04-06T15:02:46Z"
+ },
+ {
+ "id": 407,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "DCAE DEPLOY request",
+ "logInstant": "2021-04-06T15:02:42Z"
+ },
+ {
+ "id": 406,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-06T15:02:26Z"
+ },
+ {
+ "id": 405,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-06T15:02:26Z"
+ },
+ {
+ "id": 404,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-06T15:02:26Z"
+ },
+ {
+ "id": 403,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-06T15:02:26Z"
+ },
+ {
+ "id": 402,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-06T15:02:25Z"
+ },
+ {
+ "id": 401,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T15:02:25Z"
+ },
+ {
+ "id": 400,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-06T15:02:21Z"
+ },
+ {
+ "id": 399,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T15:02:21Z"
+ },
+ {
+ "id": 398,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-06T15:02:17Z"
+ },
+ {
+ "id": 397,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-06T14:32:53Z"
+ },
+ {
+ "id": 396,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-06T14:32:53Z"
+ },
+ {
+ "id": 395,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-06T14:32:53Z"
+ },
+ {
+ "id": 394,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-06T14:32:53Z"
+ },
+ {
+ "id": 393,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-06T14:32:53Z"
+ },
+ {
+ "id": 392,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T14:32:53Z"
+ },
+ {
+ "id": 391,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-06T14:32:49Z"
+ },
+ {
+ "id": 390,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T14:32:49Z"
+ },
+ {
+ "id": 389,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-06T14:32:44Z"
+ },
+ {
+ "id": 388,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-06T14:31:37Z"
+ },
+ {
+ "id": 387,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-06T14:31:37Z"
+ },
+ {
+ "id": 386,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-06T14:31:37Z"
+ },
+ {
+ "id": 385,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-06T14:31:37Z"
+ },
+ {
+ "id": 384,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-06T14:31:37Z"
+ },
+ {
+ "id": 383,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T14:31:37Z"
+ },
+ {
+ "id": 382,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-06T14:31:33Z"
+ },
+ {
+ "id": 381,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T14:31:33Z"
+ },
+ {
+ "id": 380,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-06T14:31:28Z"
+ },
+ {
+ "id": 379,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-06T14:30:35Z"
+ },
+ {
+ "id": 378,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-06T14:30:35Z"
+ },
+ {
+ "id": 377,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-06T14:30:34Z"
+ },
+ {
+ "id": 376,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-06T14:30:34Z"
+ },
+ {
+ "id": 375,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-06T14:30:34Z"
+ },
+ {
+ "id": 374,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T14:30:34Z"
+ },
+ {
+ "id": 373,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-06T14:30:30Z"
+ },
+ {
+ "id": 372,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T14:30:30Z"
+ },
+ {
+ "id": 371,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-06T14:30:26Z"
+ },
+ {
+ "id": 370,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "PDP Group remove ALL status - : ",
+ "logInstant": "2021-04-06T14:04:21Z"
+ },
+ {
+ "id": 369,
+ "logType": "WARNING",
+ "logComponent": "CLAMP",
+ "message": "Cannot Undeploy for the loop: pmsh_loop, the Deployment ID does not exist !",
+ "logInstant": "2021-04-06T14:04:17Z"
+ },
+ {
+ "id": 368,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "DELETE request",
+ "logInstant": "2021-04-06T14:04:17Z"
+ },
+ {
+ "id": 367,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-06T14:03:52Z"
+ },
+ {
+ "id": 366,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-06T14:03:52Z"
+ },
+ {
+ "id": 365,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-06T14:03:51Z"
+ },
+ {
+ "id": 364,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-06T14:03:51Z"
+ },
+ {
+ "id": 363,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-06T14:03:51Z"
+ },
+ {
+ "id": 362,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T14:03:51Z"
+ },
+ {
+ "id": 361,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-06T14:03:47Z"
+ },
+ {
+ "id": 360,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T14:03:47Z"
+ },
+ {
+ "id": 359,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-06T14:03:43Z"
+ },
+ {
+ "id": 358,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "UNDEPLOY request successfully executed",
+ "logInstant": "2021-04-06T14:03:35Z"
+ },
+ {
+ "id": 357,
+ "logType": "WARNING",
+ "logComponent": "CLAMP",
+ "message": "Cannot Undeploy for the loop: pmsh_loop, the Deployment ID does not exist !",
+ "logInstant": "2021-04-06T14:03:35Z"
+ },
+ {
+ "id": 356,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "DCAE UNDEPLOY request",
+ "logInstant": "2021-04-06T14:03:35Z"
+ },
+ {
+ "id": 355,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-06T13:57:38Z"
+ },
+ {
+ "id": 354,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-06T13:57:38Z"
+ },
+ {
+ "id": 353,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-06T13:57:38Z"
+ },
+ {
+ "id": 352,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-06T13:57:38Z"
+ },
+ {
+ "id": 351,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-06T13:57:37Z"
+ },
+ {
+ "id": 350,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T13:57:37Z"
+ },
+ {
+ "id": 349,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-06T13:57:33Z"
+ },
+ {
+ "id": 348,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T13:57:33Z"
+ },
+ {
+ "id": 347,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-06T13:57:29Z"
+ },
+ {
+ "id": 346,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "PDP Group remove ALL status - : ",
+ "logInstant": "2021-04-06T13:57:21Z"
+ },
+ {
+ "id": 345,
+ "logType": "WARNING",
+ "logComponent": "CLAMP",
+ "message": "Cannot Undeploy for the loop: pmsh_loop, the Deployment ID does not exist !",
+ "logInstant": "2021-04-06T13:57:16Z"
+ },
+ {
+ "id": 344,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "DELETE request",
+ "logInstant": "2021-04-06T13:57:16Z"
+ },
+ {
+ "id": 343,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-06T13:16:29Z"
+ },
+ {
+ "id": 342,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-06T13:16:29Z"
+ },
+ {
+ "id": 341,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-06T13:16:29Z"
+ },
+ {
+ "id": 340,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-06T13:16:29Z"
+ },
+ {
+ "id": 339,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-06T13:16:29Z"
+ },
+ {
+ "id": 338,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T13:16:29Z"
+ },
+ {
+ "id": 337,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-06T13:16:24Z"
+ },
+ {
+ "id": 336,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-06T13:16:24Z"
+ },
+ {
+ "id": 335,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-06T13:16:20Z"
+ },
+ {
+ "id": 334,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "Micro Service policies UPDATED",
+ "logInstant": "2021-04-01T16:12:47Z"
+ },
+ {
+ "id": 333,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T16:09:36Z"
+ },
+ {
+ "id": 332,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T16:09:36Z"
+ },
+ {
+ "id": 331,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T16:09:36Z"
+ },
+ {
+ "id": 330,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T16:09:36Z"
+ },
+ {
+ "id": 329,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T16:09:36Z"
+ },
+ {
+ "id": 328,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T16:09:36Z"
+ },
+ {
+ "id": 327,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T16:09:32Z"
+ },
+ {
+ "id": 326,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T16:09:32Z"
+ },
+ {
+ "id": 325,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T16:09:27Z"
+ },
+ {
+ "id": 324,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "Micro Service policies UPDATED",
+ "logInstant": "2021-04-01T15:16:20Z"
+ },
+ {
+ "id": 323,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T15:15:57Z"
+ },
+ {
+ "id": 322,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T15:15:57Z"
+ },
+ {
+ "id": 321,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T15:15:57Z"
+ },
+ {
+ "id": 320,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T15:15:57Z"
+ },
+ {
+ "id": 319,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T15:15:57Z"
+ },
+ {
+ "id": 318,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T15:15:57Z"
+ },
+ {
+ "id": 317,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T15:15:52Z"
+ },
+ {
+ "id": 316,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T15:15:52Z"
+ },
+ {
+ "id": 315,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T15:15:48Z"
+ },
+ {
+ "id": 314,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T15:14:19Z"
+ },
+ {
+ "id": 313,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T15:14:19Z"
+ },
+ {
+ "id": 312,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T15:14:19Z"
+ },
+ {
+ "id": 311,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T15:14:19Z"
+ },
+ {
+ "id": 310,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T15:14:19Z"
+ },
+ {
+ "id": 309,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T15:14:19Z"
+ },
+ {
+ "id": 308,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T15:14:15Z"
+ },
+ {
+ "id": 307,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T15:14:15Z"
+ },
+ {
+ "id": 306,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T15:14:10Z"
+ },
+ {
+ "id": 305,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T15:10:59Z"
+ },
+ {
+ "id": 304,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T15:10:59Z"
+ },
+ {
+ "id": 303,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T15:10:59Z"
+ },
+ {
+ "id": 302,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T15:10:59Z"
+ },
+ {
+ "id": 301,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T15:10:59Z"
+ },
+ {
+ "id": 300,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T15:10:59Z"
+ },
+ {
+ "id": 299,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T15:10:55Z"
+ },
+ {
+ "id": 298,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T15:10:54Z"
+ },
+ {
+ "id": 297,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T15:10:50Z"
+ },
+ {
+ "id": 287,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T14:31:38Z"
+ },
+ {
+ "id": 286,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T14:31:38Z"
+ },
+ {
+ "id": 285,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T14:31:37Z"
+ },
+ {
+ "id": 284,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T14:31:37Z"
+ },
+ {
+ "id": 283,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T14:31:37Z"
+ },
+ {
+ "id": 282,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T14:31:37Z"
+ },
+ {
+ "id": 281,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T14:31:33Z"
+ },
+ {
+ "id": 280,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T14:31:33Z"
+ },
+ {
+ "id": 279,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "Micro Service policies UPDATED",
+ "logInstant": "2021-04-01T14:31:32Z"
+ },
+ {
+ "id": 278,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T14:31:31Z"
+ },
+ {
+ "id": 277,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T14:31:31Z"
+ },
+ {
+ "id": 276,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T14:31:30Z"
+ },
+ {
+ "id": 275,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T14:31:30Z"
+ },
+ {
+ "id": 274,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 273,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 272,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 271,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 270,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 269,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 268,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 267,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 266,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 265,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 264,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 263,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 262,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 261,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 260,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 259,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 258,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T14:31:29Z"
+ },
+ {
+ "id": 257,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-04-01T14:31:28Z"
+ },
+ {
+ "id": 256,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T14:31:28Z"
+ },
+ {
+ "id": 255,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T14:31:28Z"
+ },
+ {
+ "id": 254,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-04-01T14:31:28Z"
+ },
+ {
+ "id": 253,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T14:31:28Z"
+ },
+ {
+ "id": 252,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T14:31:28Z"
+ },
+ {
+ "id": 251,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T14:31:28Z"
+ },
+ {
+ "id": 250,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "Micro Service policies UPDATED",
+ "logInstant": "2021-04-01T12:39:55Z"
+ },
+ {
+ "id": 249,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T12:38:31Z"
+ },
+ {
+ "id": 248,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T12:38:31Z"
+ },
+ {
+ "id": 247,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T12:38:30Z"
+ },
+ {
+ "id": 246,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T12:38:30Z"
+ },
+ {
+ "id": 245,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T12:38:30Z"
+ },
+ {
+ "id": 244,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T12:38:30Z"
+ },
+ {
+ "id": 243,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T12:38:26Z"
+ },
+ {
+ "id": 242,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T12:38:26Z"
+ },
+ {
+ "id": 241,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T12:38:22Z"
+ },
+ {
+ "id": 240,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "Micro Service policies UPDATED",
+ "logInstant": "2021-04-01T12:37:20Z"
+ },
+ {
+ "id": 239,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T12:37:19Z"
+ },
+ {
+ "id": 238,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T12:37:19Z"
+ },
+ {
+ "id": 237,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T12:37:19Z"
+ },
+ {
+ "id": 236,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T12:37:19Z"
+ },
+ {
+ "id": 235,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T12:37:19Z"
+ },
+ {
+ "id": 234,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T12:37:19Z"
+ },
+ {
+ "id": 233,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T12:37:14Z"
+ },
+ {
+ "id": 232,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T12:37:14Z"
+ },
+ {
+ "id": 231,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T12:37:10Z"
+ },
+ {
+ "id": 221,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "Micro Service policies UPDATED",
+ "logInstant": "2021-04-01T11:57:59Z"
+ },
+ {
+ "id": 220,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-04-01T11:57:34Z"
+ },
+ {
+ "id": 219,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-04-01T11:57:34Z"
+ },
+ {
+ "id": 218,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-04-01T11:57:34Z"
+ },
+ {
+ "id": 217,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-04-01T11:57:33Z"
+ },
+ {
+ "id": 216,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-04-01T11:57:33Z"
+ },
+ {
+ "id": 215,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T11:57:33Z"
+ },
+ {
+ "id": 214,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-04-01T11:57:29Z"
+ },
+ {
+ "id": 213,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-04-01T11:57:29Z"
+ },
+ {
+ "id": 212,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-04-01T11:57:25Z"
+ },
+ {
+ "id": 211,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T15:50:20Z"
+ },
+ {
+ "id": 210,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T15:50:20Z"
+ },
+ {
+ "id": 209,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T15:50:20Z"
+ },
+ {
+ "id": 208,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T15:50:20Z"
+ },
+ {
+ "id": 207,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T15:50:20Z"
+ },
+ {
+ "id": 206,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:50:20Z"
+ },
+ {
+ "id": 205,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T15:50:16Z"
+ },
+ {
+ "id": 204,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:50:16Z"
+ },
+ {
+ "id": 203,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T15:50:11Z"
+ },
+ {
+ "id": 202,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T15:49:39Z"
+ },
+ {
+ "id": 201,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T15:49:39Z"
+ },
+ {
+ "id": 200,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T15:49:39Z"
+ },
+ {
+ "id": 199,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T15:49:39Z"
+ },
+ {
+ "id": 198,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T15:49:39Z"
+ },
+ {
+ "id": 197,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:49:39Z"
+ },
+ {
+ "id": 196,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T15:49:35Z"
+ },
+ {
+ "id": 195,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:49:35Z"
+ },
+ {
+ "id": 194,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T15:49:30Z"
+ },
+ {
+ "id": 193,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T15:49:06Z"
+ },
+ {
+ "id": 192,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T15:49:06Z"
+ },
+ {
+ "id": 191,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T15:49:06Z"
+ },
+ {
+ "id": 190,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T15:49:06Z"
+ },
+ {
+ "id": 189,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T15:49:06Z"
+ },
+ {
+ "id": 188,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:49:06Z"
+ },
+ {
+ "id": 187,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T15:49:01Z"
+ },
+ {
+ "id": 186,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:49:01Z"
+ },
+ {
+ "id": 185,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T15:48:57Z"
+ },
+ {
+ "id": 184,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T15:47:28Z"
+ },
+ {
+ "id": 183,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T15:47:28Z"
+ },
+ {
+ "id": 182,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T15:47:28Z"
+ },
+ {
+ "id": 181,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T15:47:28Z"
+ },
+ {
+ "id": 180,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T15:47:27Z"
+ },
+ {
+ "id": 179,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:47:27Z"
+ },
+ {
+ "id": 178,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T15:47:23Z"
+ },
+ {
+ "id": 177,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:47:23Z"
+ },
+ {
+ "id": 176,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T15:47:19Z"
+ },
+ {
+ "id": 175,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T15:43:41Z"
+ },
+ {
+ "id": 174,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T15:43:41Z"
+ },
+ {
+ "id": 173,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T15:43:41Z"
+ },
+ {
+ "id": 172,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T15:43:41Z"
+ },
+ {
+ "id": 171,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T15:43:41Z"
+ },
+ {
+ "id": 170,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:43:41Z"
+ },
+ {
+ "id": 169,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T15:43:36Z"
+ },
+ {
+ "id": 168,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T15:43:36Z"
+ },
+ {
+ "id": 167,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T15:43:34Z"
+ },
+ {
+ "id": 166,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T15:43:34Z"
+ },
+ {
+ "id": 165,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T15:43:34Z"
+ },
+ {
+ "id": 164,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T15:43:34Z"
+ },
+ {
+ "id": 163,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T15:43:34Z"
+ },
+ {
+ "id": 162,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T15:43:34Z"
+ },
+ {
+ "id": 161,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 160,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 159,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 158,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 157,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 156,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 155,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 154,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 153,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 152,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 151,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 150,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-03-31T15:43:33Z"
+ },
+ {
+ "id": 149,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 148,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 147,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 146,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 145,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 144,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connection is still allocated",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 143,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 142,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 141,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 140,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T15:43:32Z"
+ },
+ {
+ "id": 139,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T10:13:01Z"
+ },
+ {
+ "id": 138,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T10:13:01Z"
+ },
+ {
+ "id": 137,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T10:13:00Z"
+ },
+ {
+ "id": 136,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T10:13:00Z"
+ },
+ {
+ "id": 135,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T10:13:00Z"
+ },
+ {
+ "id": 134,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T10:13:00Z"
+ },
+ {
+ "id": 133,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T10:12:56Z"
+ },
+ {
+ "id": 132,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T10:12:56Z"
+ },
+ {
+ "id": 131,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T10:12:52Z"
+ },
+ {
+ "id": 130,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T09:55:12Z"
+ },
+ {
+ "id": 129,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T09:55:12Z"
+ },
+ {
+ "id": 128,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T09:55:12Z"
+ },
+ {
+ "id": 127,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T09:55:12Z"
+ },
+ {
+ "id": 126,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T09:55:12Z"
+ },
+ {
+ "id": 125,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T09:55:12Z"
+ },
+ {
+ "id": 124,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T09:55:08Z"
+ },
+ {
+ "id": 123,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T09:55:07Z"
+ },
+ {
+ "id": 122,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T09:55:03Z"
+ },
+ {
+ "id": 121,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T09:46:18Z"
+ },
+ {
+ "id": 120,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T09:46:18Z"
+ },
+ {
+ "id": 119,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T09:46:18Z"
+ },
+ {
+ "id": 118,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T09:46:18Z"
+ },
+ {
+ "id": 117,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T09:46:18Z"
+ },
+ {
+ "id": 116,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T09:46:18Z"
+ },
+ {
+ "id": 115,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T09:46:13Z"
+ },
+ {
+ "id": 114,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T09:46:13Z"
+ },
+ {
+ "id": 113,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T09:46:09Z"
+ },
+ {
+ "id": 112,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-31T09:45:56Z"
+ },
+ {
+ "id": 111,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-31T09:45:56Z"
+ },
+ {
+ "id": 110,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-31T09:45:56Z"
+ },
+ {
+ "id": 109,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-31T09:45:56Z"
+ },
+ {
+ "id": 108,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-31T09:45:56Z"
+ },
+ {
+ "id": 107,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T09:45:55Z"
+ },
+ {
+ "id": 106,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-31T09:45:51Z"
+ },
+ {
+ "id": 105,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-31T09:45:51Z"
+ },
+ {
+ "id": 104,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-31T09:45:47Z"
+ },
+ {
+ "id": 103,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-30T16:00:55Z"
+ },
+ {
+ "id": 102,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-30T16:00:55Z"
+ },
+ {
+ "id": 101,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-30T16:00:55Z"
+ },
+ {
+ "id": 100,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-30T16:00:55Z"
+ },
+ {
+ "id": 99,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-30T16:00:55Z"
+ },
+ {
+ "id": 98,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T16:00:54Z"
+ },
+ {
+ "id": 97,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-30T16:00:50Z"
+ },
+ {
+ "id": 96,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T16:00:50Z"
+ },
+ {
+ "id": 95,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-30T16:00:46Z"
+ },
+ {
+ "id": 94,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-30T15:58:05Z"
+ },
+ {
+ "id": 93,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-30T15:58:05Z"
+ },
+ {
+ "id": 92,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-30T15:58:05Z"
+ },
+ {
+ "id": 91,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-30T15:58:05Z"
+ },
+ {
+ "id": 90,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-30T15:58:05Z"
+ },
+ {
+ "id": 89,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T15:58:05Z"
+ },
+ {
+ "id": 88,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-30T15:58:00Z"
+ },
+ {
+ "id": 87,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T15:58:00Z"
+ },
+ {
+ "id": 86,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-30T15:57:56Z"
+ },
+ {
+ "id": 85,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-30T15:00:21Z"
+ },
+ {
+ "id": 84,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-30T15:00:21Z"
+ },
+ {
+ "id": 83,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-30T15:00:21Z"
+ },
+ {
+ "id": 82,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-30T15:00:21Z"
+ },
+ {
+ "id": 81,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-30T15:00:21Z"
+ },
+ {
+ "id": 80,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T15:00:21Z"
+ },
+ {
+ "id": 79,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-30T15:00:17Z"
+ },
+ {
+ "id": 78,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T15:00:17Z"
+ },
+ {
+ "id": 77,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-30T15:00:12Z"
+ },
+ {
+ "id": 76,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-30T14:51:24Z"
+ },
+ {
+ "id": 75,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-30T14:51:23Z"
+ },
+ {
+ "id": 74,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-30T14:51:23Z"
+ },
+ {
+ "id": 73,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-30T14:51:23Z"
+ },
+ {
+ "id": 72,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-30T14:51:23Z"
+ },
+ {
+ "id": 71,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T14:51:23Z"
+ },
+ {
+ "id": 70,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-30T14:51:19Z"
+ },
+ {
+ "id": 69,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T14:51:19Z"
+ },
+ {
+ "id": 68,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-30T14:51:15Z"
+ },
+ {
+ "id": 67,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-30T14:45:06Z"
+ },
+ {
+ "id": 66,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-30T14:45:06Z"
+ },
+ {
+ "id": 65,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-30T14:45:06Z"
+ },
+ {
+ "id": 64,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-30T14:45:06Z"
+ },
+ {
+ "id": 63,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-30T14:45:06Z"
+ },
+ {
+ "id": 62,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T14:45:06Z"
+ },
+ {
+ "id": 61,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-30T14:45:02Z"
+ },
+ {
+ "id": 60,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T14:45:02Z"
+ },
+ {
+ "id": 59,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-30T14:44:57Z"
+ },
+ {
+ "id": 58,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-30T14:44:31Z"
+ },
+ {
+ "id": 57,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-30T14:44:31Z"
+ },
+ {
+ "id": 56,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-30T14:44:31Z"
+ },
+ {
+ "id": 55,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-30T14:44:31Z"
+ },
+ {
+ "id": 54,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-30T14:44:31Z"
+ },
+ {
+ "id": 53,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T14:44:31Z"
+ },
+ {
+ "id": 52,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-30T14:44:27Z"
+ },
+ {
+ "id": 51,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T14:44:26Z"
+ },
+ {
+ "id": 50,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-30T14:44:22Z"
+ },
+ {
+ "id": 49,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-30T14:32:12Z"
+ },
+ {
+ "id": 48,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-30T14:32:12Z"
+ },
+ {
+ "id": 47,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-30T14:32:12Z"
+ },
+ {
+ "id": 46,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-30T14:32:12Z"
+ },
+ {
+ "id": 45,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-30T14:32:12Z"
+ },
+ {
+ "id": 44,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T14:32:11Z"
+ },
+ {
+ "id": 43,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-30T14:32:07Z"
+ },
+ {
+ "id": 42,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T14:32:07Z"
+ },
+ {
+ "id": 41,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-30T14:32:03Z"
+ },
+ {
+ "id": 40,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request successfully executed",
+ "logInstant": "2021-03-30T13:07:24Z"
+ },
+ {
+ "id": 39,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "New loop state is: DESIGN",
+ "logInstant": "2021-03-30T13:07:24Z"
+ },
+ {
+ "id": 38,
+ "logType": "INFO",
+ "logComponent": "DCAE",
+ "message": "DCAE state set to: BLUEPRINT_DEPLOYED - message: ",
+ "logInstant": "2021-03-30T13:07:24Z"
+ },
+ {
+ "id": 37,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "Policy state set to: NOT_SENT",
+ "logInstant": "2021-03-30T13:07:24Z"
+ },
+ {
+ "id": 36,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET Policy deployment\n status - : ",
+ "logInstant": "2021-03-30T13:07:24Z"
+ },
+ {
+ "id": 35,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T13:07:24Z"
+ },
+ {
+ "id": 34,
+ "logType": "INFO",
+ "logComponent": "POLICY",
+ "message": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0_mHh GET\n Policy status - : ",
+ "logInstant": "2021-03-30T13:07:19Z"
+ },
+ {
+ "id": 33,
+ "logType": "ERROR",
+ "logComponent": "CLAMP",
+ "message": "GET policy request failed, Error reported: Connect to localhost:8085 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect",
+ "logInstant": "2021-03-30T13:07:19Z"
+ },
+ {
+ "id": 32,
+ "logType": "INFO",
+ "logComponent": "CLAMP",
+ "message": "GET STATUS request",
+ "logInstant": "2021-03-30T13:07:15Z"
+ }
+ ],
+ "loopTemplate": {
+ "name": "LOOP_TEMPLATE_k8s_pmsh",
+ "dcaeBlueprintId": "9dc5dba0-e685-4d5a-b144-8f4d84cfa01f",
+ "loopElementModelsUsed": [
+ {
+ "loopElementModel": {
+ "name": "onap.policies.monitoring.dcae-pm-subscription-handler",
+ "loopElementType": "MICRO_SERVICE_TYPE",
+ "policyModels": [
+ {
+ "policyModelType": "onap.policies.monitoring.dcae-pm-subscription-handler",
+ "version": "1.0.0",
+ "policyAcronym": "dcae-pm-subscription-handler",
+ "policyPdpGroup": {
+ "supportedPdpGroups": [
+ {
+ "ControlLoopGroup": [
+ "apex",
+ "xacml"
+ ]
+ },
+ {
+ "defaultGroup": [
+ "xacml"
+ ]
+ }
+ ]
+ },
+ "createdDate": "2021-03-30T09:55:52.261232Z",
+ "updatedDate": "2021-03-30T09:56:17.502284Z",
+ "updatedBy": "Not found",
+ "createdBy": "Not found"
+ }
+ ],
+ "createdDate": "2021-03-30T08:48:21Z",
+ "updatedDate": "2021-03-30T08:48:21Z",
+ "updatedBy": "Not found",
+ "createdBy": "Not found"
+ },
+ "flowOrder": 0
+ }
+ ],
+ "modelService": {
+ "serviceDetails": {
+ "serviceType": "",
+ "serviceRole": "",
+ "description": "vLBMS",
+ "type": "Service",
+ "instantiationType": "A-la-carte",
+ "namingPolicy": "",
+ "serviceEcompNaming": "true",
+ "environmentContext": "General_Revenue-Bearing",
+ "name": "vLoadBalancerMS",
+ "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f",
+ "ecompGeneratedNaming": "true",
+ "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0",
+ "category": "Network L4+"
+ },
+ "resourceDetails": {
+ "CP": {},
+ "VL": {},
+ "VF": {
+ "vLoadBalancerMS 0": {
+ "resourceVendor": "Test",
+ "name": "vLoadBalancerMS",
+ "resourceVendorModelNumber": "",
+ "description": "vLBMS",
+ "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506",
+ "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6",
+ "type": "VF",
+ "category": "Application L4+",
+ "subcategory": "Load Balancer",
+ "version": "1.0",
+ "customizationUUID": "465246dc-7748-45f4-a013-308d92922552",
+ "resourceVendorRelease": "1.0",
+ "controllerProperties": {
+ "sdnc_model_name": "baseconfiguration",
+ "sdnc_model_version": "1.0.0",
+ "workflows": {
+ "resource-assignment": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "activate": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "activate-restconf": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "activate-cli": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "assign-activate": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "imperative-test-wf": {
+ "inputs": {
+ "resource-assignment-properties": {
+ "type": "object",
+ "properties": {
+ "request-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "hostname": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "request-info": {
+ "type": "object",
+ "properties": {
+ "prop1": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ },
+ "prop2": {
+ "required": true,
+ "type": "string",
+ "input-param": true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "CR": {},
+ "VFC": {},
+ "PNF": {},
+ "Service": {},
+ "CVFC": {},
+ "Service Proxy": {},
+ "Configuration": {},
+ "AllottedResource": {},
+ "VFModule": {
+ "Vloadbalancerms..vpkg..module-1": {
+ "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043",
+ "vfModuleModelVersion": "1",
+ "vfModuleModelName": "Vloadbalancerms..vpkg..module-1",
+ "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc",
+ "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52",
+ "min_vf_module_instances": 0,
+ "vf_module_label": "vpkg",
+ "max_vf_module_instances": 1,
+ "vf_module_type": "Expansion",
+ "isBase": false,
+ "initial_count": 0,
+ "volume_group": false
+ },
+ "Vloadbalancerms..vdns..module-3": {
+ "vfModuleModelInvariantUUID": "4c10ba9b-f88f-415e-9de3-5d33336047fa",
+ "vfModuleModelVersion": "1",
+ "vfModuleModelName": "Vloadbalancerms..vdns..module-3",
+ "vfModuleModelUUID": "4fa73b49-8a6c-493e-816b-eb401567b720",
+ "vfModuleModelCustomizationUUID": "bafcdab0-801d-4d81-9ead-f464640a38b1",
+ "min_vf_module_instances": 0,
+ "vf_module_label": "vdns",
+ "max_vf_module_instances": 50,
+ "vf_module_type": "Expansion",
+ "isBase": false,
+ "initial_count": 0,
+ "volume_group": false
+ },
+ "Vloadbalancerms..base_template..module-0": {
+ "vfModuleModelInvariantUUID": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3",
+ "vfModuleModelVersion": "1",
+ "vfModuleModelName": "Vloadbalancerms..base_template..module-0",
+ "vfModuleModelUUID": "63734409-f745-4e4d-a38b-131638a0edce",
+ "vfModuleModelCustomizationUUID": "86baddea-c730-4fb8-9410-cd2e17fd7f27",
+ "min_vf_module_instances": 1,
+ "vf_module_label": "base_template",
+ "max_vf_module_instances": 1,
+ "vf_module_type": "Base",
+ "isBase": true,
+ "initial_count": 1,
+ "volume_group": false
+ },
+ "Vloadbalancerms..vlb..module-2": {
+ "vfModuleModelInvariantUUID": "a772a1f4-0064-412c-833d-4749b15828dd",
+ "vfModuleModelVersion": "1",
+ "vfModuleModelName": "Vloadbalancerms..vlb..module-2",
+ "vfModuleModelUUID": "0f5c3f6a-650a-4303-abb6-fff3e573a07a",
+ "vfModuleModelCustomizationUUID": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806",
+ "min_vf_module_instances": 0,
+ "vf_module_label": "vlb",
+ "max_vf_module_instances": 1,
+ "vf_module_type": "Expansion",
+ "isBase": false,
+ "initial_count": 0,
+ "volume_group": false
+ }
+ }
+ }
+ },
+ "maximumInstancesAllowed": 0,
+ "uniqueBlueprint": true,
+ "allowedLoopType": "CLOSED",
+ "createdDate": "2021-03-30T08:48:21Z",
+ "updatedDate": "2021-03-30T08:48:21Z",
+ "updatedBy": "Not found",
+ "createdBy": "Not found"
+ },
+ "createdDate": "2021-03-30T13:07:07.901081Z",
+ "updatedDate": "2021-03-30T13:07:07.901081Z",
+ "updatedBy": "admin",
+ "createdBy": "admin"
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java
new file mode 100644
index 000000000..932ebbece
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java
@@ -0,0 +1,159 @@
+/*-
+ * ============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.policy.main.handler;
+
+import java.time.Instant;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.UUID;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+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.participant.intermediary.api.ControlLoopElementListener;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class handles implementation of controlLoopElement updates.
+ */
+public class ControlLoopElementHandler implements ControlLoopElementListener {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopElementHandler.class);
+ private static final Map<String, String> policyTypeMap = new LinkedHashMap<>();
+ private static final Map<String, String> policyMap = new LinkedHashMap<>();
+
+ /**
+ * Callback method to handle a control loop element state change.
+ *
+ * @param controlLoopElementId the ID of the control loop element
+ * @param currentState the current state of the control loop element
+ * @param newState the state to which the control loop element is changing to
+ * @throws PfModelException in case of an exception
+ */
+ @Override
+ public void controlLoopElementStateChange(UUID controlLoopElementId,
+ ControlLoopState currentState,
+ ControlLoopOrderedState newState) throws PfModelException {
+ PolicyProvider policyProvider = PolicyHandler.getInstance().getPolicyProvider();
+ switch (newState) {
+ case UNINITIALISED:
+ try {
+ deletePolicyData(controlLoopElementId, newState);
+ } catch (PfModelRuntimeException e) {
+ LOGGER.debug("Delete policytpes failed", e);
+ }
+ break;
+ case PASSIVE:
+ policyProvider.getIntermediaryApi()
+ .updateControlLoopElementState(controlLoopElementId, newState,
+ ControlLoopState.PASSIVE);
+ break;
+ case RUNNING:
+ policyProvider.getIntermediaryApi()
+ .updateControlLoopElementState(controlLoopElementId, newState,
+ ControlLoopState.RUNNING);
+ break;
+ default:
+ LOGGER.debug("Unknown orderedstate {}", newState);
+ break;
+ }
+ }
+
+ private void deletePolicyData(UUID controlLoopElementId,
+ ControlLoopOrderedState newState) throws PfModelException {
+ PolicyModelsProvider dbProvider = PolicyHandler.getInstance().getDatabaseProvider();
+ PolicyProvider policyProvider = PolicyHandler.getInstance().getPolicyProvider();
+ if (policyMap != null) {
+ // Delete all policies of this controlLoop from policy framework
+ for (Entry<String, String> policy : policyMap.entrySet()) {
+ dbProvider.deletePolicy(policy.getKey(), policy.getValue());
+ }
+ }
+ if (policyTypeMap != null) {
+ // Delete all policy types of this control loop from policy framework
+ for (Entry<String, String> policy : policyTypeMap.entrySet()) {
+ dbProvider.deletePolicyType(policy.getKey(), policy.getValue());
+ }
+ }
+ policyProvider.getIntermediaryApi()
+ .updateControlLoopElementState(controlLoopElementId, newState,
+ ControlLoopState.UNINITIALISED);
+ }
+
+ /**
+ * Callback method to handle an update on a control loop element.
+ *
+ * @param element the information on the control loop element
+ * @param controlLoopDefinition toscaServiceTemplate
+ * @throws PfModelException in case of an exception
+ */
+ @Override
+ public void controlLoopElementUpdate(ControlLoopElement element,
+ ToscaServiceTemplate controlLoopDefinition) throws PfModelException {
+ PolicyModelsProvider dbProvider = PolicyHandler.getInstance().getDatabaseProvider();
+ PolicyProvider policyProvider = PolicyHandler.getInstance().getPolicyProvider();
+
+ policyProvider.getIntermediaryApi()
+ .updateControlLoopElementState(element.getId(), element.getOrderedState(), ControlLoopState.PASSIVE);
+ if (controlLoopDefinition.getPolicyTypes() != null) {
+ for (ToscaPolicyType policyType : controlLoopDefinition.getPolicyTypes().values()) {
+ policyTypeMap.put(policyType.getName(), policyType.getVersion());
+ }
+ dbProvider.createPolicyTypes(controlLoopDefinition);
+ }
+ if (controlLoopDefinition.getToscaTopologyTemplate().getPolicies() != null) {
+ for (Map<String, ToscaPolicy> foundPolicyMap : controlLoopDefinition
+ .getToscaTopologyTemplate().getPolicies()) {
+ for (ToscaPolicy policy : foundPolicyMap.values()) {
+ policyMap.put(policy.getName(), policy.getVersion());
+ }
+ }
+ dbProvider.createPolicies(controlLoopDefinition);
+ }
+ }
+
+ /**
+ * Handle controlLoopElement statistics.
+ *
+ * @param controlLoopElementId controlloop element id
+ */
+ @Override
+ public void handleStatistics(UUID controlLoopElementId) {
+ PolicyProvider policyProvider = PolicyHandler.getInstance().getPolicyProvider();
+ ControlLoopElement clElement = policyProvider.getIntermediaryApi()
+ .getControlLoopElement(controlLoopElementId);
+ if (clElement != null) {
+ ClElementStatistics clElementStatistics = new ClElementStatistics();
+ clElementStatistics.setControlLoopState(clElement.getState());
+ clElementStatistics.setTimeStamp(Instant.now());
+ policyProvider.getIntermediaryApi()
+ .updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics);
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/PolicyHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/PolicyHandler.java
new file mode 100644
index 000000000..d62e5f9f3
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/PolicyHandler.java
@@ -0,0 +1,100 @@
+/*-
+ * ============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.policy.main.handler;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameters;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
+
+/**
+ * This class handles policy participant and control loop elements.
+ *
+ * <p/>It is effectively a singleton that is started at system start.
+ */
+public class PolicyHandler extends ControlLoopHandler {
+
+ private final ParticipantIntermediaryParameters participantParameters;
+ private final ParticipantPolicyParameters policyParameters;
+
+ @Getter
+ private PolicyProvider policyProvider;
+ @Getter
+ private PolicyModelsProvider databaseProvider;
+
+ /**
+ * Create a handler.
+ *
+ * @param parameters the parameters for access to the database
+ * @throws PfModelException in case of an exception
+ */
+ public PolicyHandler(ParticipantPolicyParameters parameters) throws PfModelException {
+ super(parameters.getDatabaseProviderParameters());
+ participantParameters = parameters.getIntermediaryParameters();
+ policyParameters = parameters;
+ }
+
+ public static PolicyHandler getInstance() {
+ return Registry.get(PolicyHandler.class.getName());
+ }
+
+ @Override
+ public Set<Class<?>> getProviderClasses() {
+ return null;
+ }
+
+ @Override
+ public void startProviders() {
+ try {
+ policyProvider = new PolicyProvider(participantParameters);
+ databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(
+ policyParameters.getDatabaseProviderParameters());
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "Start providers failed ", e);
+ }
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ policyProvider.close();
+ } catch (IOException e) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "Stop providers failed ", e);
+ }
+
+ try {
+ databaseProvider.close();
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "Stop providers failed ", e);
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/PolicyProvider.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/PolicyProvider.java
new file mode 100644
index 000000000..420c77ee3
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/PolicyProvider.java
@@ -0,0 +1,57 @@
+/*-
+ * ============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.policy.main.handler;
+
+import java.io.Closeable;
+import java.io.IOException;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryFactory;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+
+/**
+ * Provider class for policy participant.
+ */
+public class PolicyProvider implements Closeable {
+ @Getter
+ private final ParticipantIntermediaryApi intermediaryApi;
+
+ private final ControlLoopElementHandler controlLoopElementHandler;
+
+ /**
+ * Create a policy participant provider.
+ *
+ * @throws ControlLoopRuntimeException on errors creating the provider
+ */
+ public PolicyProvider(ParticipantIntermediaryParameters participantParameters)
+ throws ControlLoopRuntimeException {
+ intermediaryApi = new ParticipantIntermediaryFactory().createApiImplementation();
+ intermediaryApi.init(participantParameters);
+ controlLoopElementHandler = new ControlLoopElementHandler();
+ intermediaryApi.registerControlLoopElementListener(controlLoopElementHandler);
+ }
+
+ @Override
+ public void close() throws IOException {
+ intermediaryApi.close();
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameterHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameterHandler.java
new file mode 100644
index 000000000..98cea821a
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameterHandler.java
@@ -0,0 +1,79 @@
+/*-
+ * ============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.policy.main.parameters;
+
+import java.io.File;
+import javax.ws.rs.core.Response;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.participant.policy.main.startstop.ParticipantPolicyCommandLineArguments;
+import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+
+/**
+ * This class handles reading, parsing and validating of policy participant parameters from JSON files.
+ */
+public class ParticipantPolicyParameterHandler {
+
+ private static final Coder CODER = new StandardCoder();
+
+ /**
+ * Read the parameters from the parameter file.
+ *
+ * @param arguments the arguments passed to policy
+ * @return the parameters read from the configuration file
+ * @throws ControlLoopException on parameter exceptions
+ */
+ public ParticipantPolicyParameters getParameters(final ParticipantPolicyCommandLineArguments arguments)
+ throws ControlLoopException {
+ ParticipantPolicyParameters parameters = null;
+
+ // Read the parameters
+ try {
+ // Read the parameters from JSON
+ File file = new File(arguments.getFullConfigurationFilePath());
+ parameters = CODER.decode(file, ParticipantPolicyParameters.class);
+ } catch (final CoderException e) {
+ final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
+ + "\"\n" + "(" + e.getClass().getSimpleName() + ")";
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage, e);
+ }
+
+ // The JSON processing returns null if there is an empty file
+ if (parameters == null) {
+ final String errorMessage = "no parameters found in \"" + arguments.getConfigurationFilePath() + "\"";
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage);
+ }
+
+ // validate the parameters
+ final ValidationResult validationResult = parameters.validate();
+ if (!validationResult.isValid()) {
+ String returnMessage =
+ "validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
+ returnMessage += validationResult.getResult();
+
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, returnMessage);
+ }
+
+ return parameters;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java
new file mode 100644
index 000000000..13d89faba
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java
@@ -0,0 +1,49 @@
+/*-
+ * ============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.policy.main.parameters;
+
+import javax.validation.constraints.NotBlank;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+
+/**
+ * Class to hold all parameters needed for the policy participant.
+ *
+ */
+@NotNull
+@NotBlank
+@Getter
+public class ParticipantPolicyParameters extends ParameterGroupImpl {
+ private ParticipantIntermediaryParameters intermediaryParameters;
+ private PolicyModelsProviderParameters databaseProviderParameters;
+
+ /**
+ * Create the policy participant parameter group.
+ *
+ * @param name the parameter group name
+ */
+ public ParticipantPolicyParameters(final String name) {
+ super(name);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/Main.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/Main.java
new file mode 100644
index 000000000..9a6bfdf7d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/Main.java
@@ -0,0 +1,141 @@
+/*-
+ * ============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.policy.main.startstop;
+
+import java.util.Arrays;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameterHandler;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameters;
+import org.onap.policy.common.utils.resources.MessageConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class initiates Policy Participant.
+ */
+public class Main {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
+
+ private ParticipantPolicyActivator activator;
+
+ @Getter
+ private ParticipantPolicyParameters parameterGroup;
+
+ /**
+ * Instantiates policy participant.
+ *
+ * @param args the command line arguments
+ */
+ public Main(final String[] args) {
+ final String argumentString = Arrays.toString(args);
+ LOGGER.info("Starting the control loop participant service with arguments - {}", argumentString);
+
+ // Check the arguments
+ final ParticipantPolicyCommandLineArguments arguments = new ParticipantPolicyCommandLineArguments();
+ try {
+ // The arguments return a string if there is a message to print and we should exit
+ final String argumentMessage = arguments.parse(args);
+ if (argumentMessage != null) {
+ LOGGER.info(argumentMessage);
+ return;
+ }
+ // Validate that the arguments are sane
+ arguments.validate();
+
+ // Read the parameters
+ parameterGroup = new ParticipantPolicyParameterHandler().getParameters(arguments);
+
+ // Now, create the activator for the service
+ activator = new ParticipantPolicyActivator(parameterGroup);
+
+ // Start the activator
+ activator.start();
+ } catch (Exception exp) {
+ throw new ControlLoopRuntimeException(Response.Status.BAD_REQUEST,
+ String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP), exp);
+ }
+
+ // Add a shutdown hook to shut everything down in an orderly manner
+ Runtime.getRuntime().addShutdownHook(new ClRuntimeShutdownHookClass());
+ String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_CLAMP);
+ LOGGER.info(successMsg);
+ }
+
+ /**
+ * Check if main is running.
+ */
+ public boolean isRunning() {
+ return activator != null && activator.isAlive();
+ }
+
+ /**
+ * Shut down Execution.
+ *
+ * @throws ControlLoopException on shutdown errors
+ */
+ public void shutdown() throws ControlLoopException {
+ // clear the parameterGroup variable
+ parameterGroup = null;
+
+ // clear the cl participant activator
+ if (activator != null) {
+ activator.stop();
+ }
+ }
+
+ /**
+ * The Class ClRuntimeShutdownHookClass terminates the policy participant
+ * when its run method is called.
+ */
+ private class ClRuntimeShutdownHookClass extends Thread {
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ try {
+ // Shutdown the control loop participant service and wait for everything to stop
+ shutdown();
+ } catch (final RuntimeException | ControlLoopException e) {
+ LOGGER.warn("error occured during shut down of the policy participant", e);
+ }
+ }
+ }
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(final String[] args) { // NOSONAR
+ /*
+ * NOTE: arguments are validated by the constructor, thus sonar is disabled.
+ */
+
+ new Main(args);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/ParticipantPolicyActivator.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/ParticipantPolicyActivator.java
new file mode 100644
index 000000000..760f8267d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/ParticipantPolicyActivator.java
@@ -0,0 +1,57 @@
+/*-
+ * ============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.policy.main.startstop;
+
+import java.util.concurrent.atomic.AtomicReference;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.participant.policy.main.handler.PolicyHandler;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameters;
+import org.onap.policy.common.utils.services.ServiceManagerContainer;
+
+/**
+ * This class activates the policy participant.
+ *
+ */
+public class ParticipantPolicyActivator extends ServiceManagerContainer {
+ @Getter
+ private final ParticipantPolicyParameters parameters;
+
+ /**
+ * Instantiate the activator for the policy participant.
+ *
+ * @param parameters the parameters for the policy participant
+ */
+ public ParticipantPolicyActivator(final ParticipantPolicyParameters parameters) {
+ this.parameters = parameters;
+
+ final AtomicReference<PolicyHandler> policyHandler = new AtomicReference<>();
+
+ // @formatter:off
+ addAction("Policy Handler",
+ () -> policyHandler.set(new PolicyHandler(parameters)),
+ () -> policyHandler.get().close());
+
+ addAction("Policy Providers",
+ () -> policyHandler.get().startProviders(),
+ () -> policyHandler.get().stopProviders());
+ // @formatter:on
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/ParticipantPolicyCommandLineArguments.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/ParticipantPolicyCommandLineArguments.java
new file mode 100644
index 000000000..af7a189f6
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/ParticipantPolicyCommandLineArguments.java
@@ -0,0 +1,145 @@
+/*-
+ * ============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.policy.main.startstop;
+
+import java.util.Arrays;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.common.startstop.CommonCommandLineArguments;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+
+/**
+ * This class reads and handles command line parameters for the policy participant.
+ *
+ */
+public class ParticipantPolicyCommandLineArguments {
+ private static final String FILE_MESSAGE_PREAMBLE = " file \"";
+ private static final int HELP_LINE_LENGTH = 120;
+
+ private final Options options;
+ private final CommonCommandLineArguments commonCommandLineArguments;
+
+ @Getter()
+ @Setter()
+ private String configurationFilePath = null;
+
+ /**
+ * Construct the options for the policy participant.
+ */
+ public ParticipantPolicyCommandLineArguments() {
+ options = new Options();
+ commonCommandLineArguments = new CommonCommandLineArguments(options);
+ }
+
+ /**
+ * Construct the options for the CLI editor and parse in the given arguments.
+ *
+ * @param args The command line arguments
+ */
+ public ParticipantPolicyCommandLineArguments(final String[] args) {
+ // Set up the options with the default constructor
+ this();
+
+ // Parse the arguments
+ try {
+ parse(args);
+ } catch (final ControlLoopException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
+ "parse error on policy participant parameters", e);
+ }
+ }
+
+ /**
+ * Parse the command line options.
+ *
+ * @param args The command line arguments
+ * @return a string with a message for help and version, or null if there is no message
+ * @throws ControlLoopException on command argument errors
+ */
+ public String parse(final String[] args) throws ControlLoopException {
+ // Clear all our arguments
+ setConfigurationFilePath(null);
+ CommandLine commandLine = null;
+ try {
+ commandLine = new DefaultParser().parse(options, args);
+ } catch (final ParseException e) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ "invalid command line arguments specified : " + e.getMessage());
+ }
+
+ // Arguments left over after Commons CLI does its stuff
+ final String[] remainingArgs = commandLine.getArgs();
+
+ if (remainingArgs.length > 0) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ "too many command line arguments specified : " + Arrays.toString(args));
+ }
+
+ if (commandLine.hasOption('h')) {
+ return commonCommandLineArguments.help(Main.class.getName(), options);
+ }
+
+ if (commandLine.hasOption('v')) {
+ return commonCommandLineArguments.version();
+ }
+
+ if (commandLine.hasOption('c')) {
+ setConfigurationFilePath(commandLine.getOptionValue('c'));
+ }
+
+ return null;
+ }
+
+ /**
+ * Validate the command line options.
+ *
+ * @throws ControlLoopException on command argument validation errors
+ */
+ public void validate() throws ControlLoopException {
+ commonCommandLineArguments.validate(configurationFilePath);
+ }
+
+ /**
+ * Gets the full expanded configuration file path.
+ *
+ * @return the configuration file path
+ */
+ public String getFullConfigurationFilePath() {
+ return ResourceUtils.getFilePath4Resource(getConfigurationFilePath());
+ }
+
+ /**
+ * Check set configuration file path.
+ *
+ * @return true, if check set configuration file path
+ */
+ public boolean checkSetConfigurationFilePath() {
+ return !StringUtils.isEmpty(configurationFilePath);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml b/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 000000000..46db712b6
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="ToscaConceptTest" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.base.PfConceptKey</class>
+ <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
+ <class>org.onap.policy.models.dao.converters.Uuid2String</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpStatistics</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+
+ <!-- property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL" /-->
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+</persistence>
+
diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/config/PolicyParticipantConfig.json b/participant/participant-impl/participant-impl-policy/src/main/resources/config/PolicyParticipantConfig.json
new file mode 100644
index 000000000..e6b3c8eb1
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/resources/config/PolicyParticipantConfig.json
@@ -0,0 +1,31 @@
+{
+ "name":"ParticipantParameterGroup",
+ "participantStatusParameters":{
+ "timeIntervalMs":10000,
+ "description":"Participant Status",
+ "participantId":{
+ "name": "PolicyParticipant0",
+ "version":"1.0.0"
+ },
+ "participantType":{
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version":"2.3.1"
+ },
+ "participantDefinition":{
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version":"2.3.1"
+ }
+ },
+ "topicParameterGroup": {
+ "topicSources" : [{
+ "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers" : [ "127.0.0.1:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers" : [ "127.0.0.1:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/version.txt b/participant/participant-impl/participant-impl-policy/src/main/resources/version.txt
new file mode 100644
index 000000000..dbd67585f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/main/resources/version.txt
@@ -0,0 +1,4 @@
+ONAP Tosca defined control loop Participant
+Version: ${project.version}
+Built (UTC): ${maven.build.timestamp}
+ONAP https://wiki.onap.org
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/TestPolicyHandler.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/TestPolicyHandler.java
new file mode 100644
index 000000000..abc3e71b8
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/TestPolicyHandler.java
@@ -0,0 +1,134 @@
+/*-
+ * ============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.policy.main.handler;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.ControlLoopConstants;
+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.participant.intermediary.comm.ControlLoopStateChangeListener;
+import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.policy.main.startstop.Main;
+import org.onap.policy.clamp.controlloop.participant.policy.main.startstop.ParticipantPolicyActivator;
+import org.onap.policy.clamp.controlloop.participant.policy.main.utils.TestListenerUtils;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.utils.services.Registry;
+
+public class TestPolicyHandler {
+
+ private static ControlLoopUpdateListener clUpdateListener;
+ private ControlLoopStateChangeListener clStateChangeListener;
+ private static ParticipantControlLoopUpdate participantControlLoopUpdateMsg;
+ private ParticipantControlLoopStateChange participantControlLoopStateChangeMsg;
+ private static final String PARTICIPANTS_ENDPOINT = "participants";
+ private static final String ELEMENTS_ENDPOINT = "elements";
+ private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
+ private static final String TOPIC = "my-topic";
+ private static final Object lockit = new Object();
+ static CommonTestData commonTestData = new CommonTestData();
+
+ /**
+ * Setup before class, instantiate Main.
+ *
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ Registry.newRegistry();
+ final String[] configParameters = {"-c", "src/test/resources/parameters/TestParameters.json"};
+ Main main = new Main(configParameters);
+ assertTrue(main.isRunning());
+ TestListenerUtils.initParticipantHandler();
+
+ clUpdateListener = new ControlLoopUpdateListener(
+ PolicyHandler.getInstance()
+ .getPolicyProvider()
+ .getIntermediaryApi()
+ .getParticipantHandler());
+ participantControlLoopUpdateMsg =
+ TestListenerUtils.createControlLoopUpdateMsg();
+ participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE);
+ }
+
+ @Test
+ public void testUpdatePolicyTypes() throws Exception {
+ // Verify that the ToscaServicetemplate has policy_types
+ assertNotNull(participantControlLoopUpdateMsg.getControlLoopDefinition().getPolicyTypes());
+
+ synchronized (lockit) {
+ clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
+ }
+ // Verify the result of GET participants with what is stored
+ assertEquals("org.onap.PM_Policy",
+ TestListenerUtils.getParticipantHandler().getParticipantId().getName());
+ }
+
+ @Test
+ public void testUpdatePolicies() throws Exception {
+ // Add policies to the toscaServiceTemplate
+ TestListenerUtils.addPoliciesToToscaServiceTemplate(participantControlLoopUpdateMsg.getControlLoopDefinition());
+
+ // Verify that the ToscaServicetemplate has policies
+ assertNotNull(participantControlLoopUpdateMsg.getControlLoopDefinition()
+ .getToscaTopologyTemplate().getPolicies());
+
+ synchronized (lockit) {
+ clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
+ }
+ // Verify the result of GET participants with what is stored
+ assertEquals("org.onap.PM_Policy",
+ TestListenerUtils.getParticipantHandler().getParticipantId().getName());
+ }
+
+ @Test
+ public void testDeletePoliciesAndPolicyTypes() throws Exception {
+ // Add policies to the toscaServiceTemplate
+ TestListenerUtils.addPoliciesToToscaServiceTemplate(participantControlLoopUpdateMsg.getControlLoopDefinition());
+
+ // Verify that the ToscaServicetemplate has policies
+ assertNotNull(participantControlLoopUpdateMsg.getControlLoopDefinition()
+ .getToscaTopologyTemplate().getPolicies());
+
+ synchronized (lockit) {
+ clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
+ }
+ // Verify the result of GET participants with what is stored
+ assertEquals("org.onap.PM_Policy",
+ TestListenerUtils.getParticipantHandler().getParticipantId().getName());
+
+ clStateChangeListener = new ControlLoopStateChangeListener(TestListenerUtils.getParticipantHandler());
+ participantControlLoopStateChangeMsg =
+ TestListenerUtils.createControlLoopStateChangeMsg(ControlLoopOrderedState.UNINITIALISED);
+ participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg);
+
+ // Verify the result of GET participants with what is stored
+ assertEquals("org.onap.PM_Policy",
+ TestListenerUtils.getParticipantHandler().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
new file mode 100644
index 000000000..e3d7e3aa5
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java
@@ -0,0 +1,221 @@
+/*-
+ * ============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.policy.main.parameters;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import javax.ws.rs.core.Response;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to hold/create all parameters for test cases.
+ */
+public class CommonTestData {
+ public static final String PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup";
+ public static final String DESCRIPTION = "Participant description";
+ public static final long TIME_INTERVAL = 2000;
+ public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
+
+ public static final Coder coder = new StandardCoder();
+
+ /**
+ * Converts the contents of a map to a parameter class.
+ *
+ * @param source property map
+ * @param clazz class of object to be created from the map
+ * @return a new object represented by the map
+ */
+ public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
+ try {
+ return coder.convert(source, clazz);
+ } catch (final CoderException e) {
+ throw new RuntimeException("cannot create " + clazz.getName() + " from map", e);
+ }
+ }
+
+ /**
+ * Returns a property map for a ParticipantPolicyParameters map for test cases.
+ *
+ * @param name name of the parameters
+ *
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getParticipantPolicyParametersMap(final String name) {
+ final Map<String, Object> map = new TreeMap<>();
+
+ map.put("name", name);
+ map.put("intermediaryParameters", getIntermediaryParametersMap(false));
+ map.put("databaseProviderParameters", getDatabaseProviderParametersMap(false));
+ return map;
+ }
+
+ /**
+ * Returns a property map for a databaseProviderParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getDatabaseProviderParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("name", "PolicyProviderParameterGroup");
+ map.put("implementation", "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
+ map.put("databaseDriver", "org.h2.Driver");
+ map.put("databaseUrl", "jdbc:h2:mem:testdb");
+ map.put("databaseUser", "policy");
+ map.put("databasePassword", "P01icY");
+ map.put("persistenceUnit", "ToscaConceptTest");
+ }
+
+ return map;
+ }
+
+ /**
+ * Returns a property map for a intermediaryParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("name", "Participant parameters");
+ map.put("reportingTimeInterval", TIME_INTERVAL);
+ map.put("description", DESCRIPTION);
+ map.put("participantId", getParticipantId());
+ map.put("participantType", getParticipantId());
+ map.put("clampControlLoopTopics", getTopicParametersMap(false));
+ }
+
+ return map;
+ }
+
+ /**
+ * Returns a property map for a TopicParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("topicSources", TOPIC_PARAMS);
+ map.put("topicSinks", TOPIC_PARAMS);
+ }
+ return map;
+ }
+
+ /**
+ * Returns topic parameters for test cases.
+ *
+ * @return topic parameters
+ */
+ public static TopicParameters getTopicParams() {
+ final TopicParameters topicParams = new TopicParameters();
+ topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT");
+ topicParams.setTopicCommInfrastructure("dmaap");
+ topicParams.setServers(Arrays.asList("localhost"));
+ return topicParams;
+ }
+
+ /**
+ * Returns participantId for test cases.
+ *
+ * @return participant Id
+ */
+ public static ToscaConceptIdentifier getParticipantId() {
+ final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
+ return participantId;
+ }
+
+ /**
+ * Gets the standard participant parameters.
+ *
+ * @param port port to be inserted into the parameters
+ * @return the standard participant parameters
+ */
+ public ParticipantPolicyParameters getParticipantPolicyParameters(int port) {
+ try {
+ return coder.decode(getParticipantPolicyParametersAsString(port), ParticipantPolicyParameters.class);
+
+ } catch (CoderException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
+ "cannot read participant parameters", e);
+ }
+ }
+
+ /**
+ * Gets the standard participant parameters, as a String.
+ *
+ * @param port port to be inserted into the parameters
+ * @return the standard participant parameters
+ */
+ public static String getParticipantPolicyParametersAsString(int port) {
+
+ try {
+ File file = new File(getParamFile());
+ String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
+
+ json = json.replace("${port}", String.valueOf(port));
+ json = json.replace("${dbName}", "jdbc:h2:mem:testdb");
+
+ return json;
+
+ } catch (IOException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
+ "cannot read participant parameters", e);
+
+ }
+ }
+
+ /**
+ * Gets the full path to the parameter file, which may vary depending on whether or
+ * not this is an end-to-end test.
+ *
+ * @return the parameter file name
+ */
+ private static String getParamFile() {
+ String paramFile = "src/test/resources/parameters/TestParametersStd.json";
+ return paramFile;
+ }
+
+ /**
+ * Nulls out a field within a JSON string.
+ * @param json JSON string
+ * @param field field to be nulled out
+ * @return a new JSON string with the field nulled out
+ */
+ public String nullifyField(String json, String field) {
+ return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\"");
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameterHandler.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameterHandler.java
new file mode 100644
index 000000000..dd62dbfc4
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameterHandler.java
@@ -0,0 +1,98 @@
+/*-
+ * ============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.policy.main.parameters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileNotFoundException;
+import org.apache.commons.io.DirectoryWalker.CancelException;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.participant.policy.main.startstop.ParticipantPolicyCommandLineArguments;
+import org.onap.policy.common.utils.coder.CoderException;
+
+public class TestParticipantPolicyParameterHandler {
+
+ @Test
+ public void testParameterHandlerNoParameterFile() throws ControlLoopException {
+ final String[] emptyArgumentString = { "-c", "src/test/resources/parameters/NoParametersFile.json" };
+
+ final ParticipantPolicyCommandLineArguments emptyArguments = new ParticipantPolicyCommandLineArguments();
+ emptyArguments.parse(emptyArgumentString);
+
+ assertThatThrownBy(() -> new ParticipantPolicyParameterHandler().getParameters(emptyArguments))
+ .hasCauseInstanceOf(CoderException.class)
+ .hasRootCauseInstanceOf(FileNotFoundException.class);
+ }
+
+ @Test
+ public void testParameterHandlerInvalidParameters() throws ControlLoopException {
+ final String[] invalidArgumentString = { "-c", "src/test/resources/parameters/InvalidParameters.json" };
+
+ final ParticipantPolicyCommandLineArguments invalidArguments =
+ new ParticipantPolicyCommandLineArguments();
+ invalidArguments.parse(invalidArgumentString);
+
+ assertThatThrownBy(() -> new ParticipantPolicyParameterHandler().getParameters(invalidArguments))
+ .hasMessageStartingWith("error reading parameters from")
+ .hasCauseInstanceOf(CoderException.class);
+ }
+
+ @Test
+ public void testParticipantPolicyParameters() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-c", "src/test/resources/parameters/TestParameters.json" };
+
+ final ParticipantPolicyCommandLineArguments arguments = new ParticipantPolicyCommandLineArguments();
+ arguments.parse(participantConfigParameters);
+
+ final ParticipantPolicyParameters parGroup = new ParticipantPolicyParameterHandler()
+ .getParameters(arguments);
+ assertTrue(arguments.checkSetConfigurationFilePath());
+ assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, parGroup.getName());
+ }
+
+ @Test
+ public void testParticipantVersion() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-v" };
+ final ParticipantPolicyCommandLineArguments arguments = new ParticipantPolicyCommandLineArguments();
+ final String version = arguments.parse(participantConfigParameters);
+ assertThat(arguments.parse(participantConfigParameters)).startsWith(
+ "ONAP Tosca defined control loop Participant");
+ }
+
+ @Test
+ public void testParticipantHelp() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-h" };
+ final ParticipantPolicyCommandLineArguments arguments = new ParticipantPolicyCommandLineArguments();
+ assertThat(arguments.parse(participantConfigParameters)).startsWith("usage:");
+ }
+
+ @Test
+ public void testParticipantInvalidOption() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-d" };
+ final ParticipantPolicyCommandLineArguments arguments = new ParticipantPolicyCommandLineArguments();
+ assertThatThrownBy(() -> arguments.parse(participantConfigParameters))
+ .hasMessageStartingWith("invalid command line arguments specified");
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameters.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameters.java
new file mode 100644
index 000000000..5ffe5101d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameters.java
@@ -0,0 +1,106 @@
+/*-
+ * ============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.policy.main.parameters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+
+import java.util.Map;
+import org.junit.Test;
+import org.onap.policy.common.parameters.ValidationResult;
+
+public class TestParticipantPolicyParameters {
+ CommonTestData commonTestData = new CommonTestData();
+
+ @Test
+ public void testParticipantPolicyParameters_Named() {
+ final ParticipantPolicyParameters participantParameters = new ParticipantPolicyParameters("my-name");
+ assertEquals("my-name", participantParameters.getName());
+ }
+
+ @Test
+ public void testParticipantPolicyParameters() {
+ final ParticipantPolicyParameters participantParameters = commonTestData.toObject(
+ commonTestData.getParticipantPolicyParametersMap(CommonTestData.PARTICIPANT_GROUP_NAME),
+ ParticipantPolicyParameters.class);
+ assertThat(participantParameters.validate().isValid()).isTrue();
+ }
+
+ @Test
+ public void testParticipantPolicyParameters_NullName() {
+ final ParticipantPolicyParameters participantParameters = commonTestData
+ .toObject(commonTestData.getParticipantPolicyParametersMap(null),
+ ParticipantPolicyParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertFalse(validationResult.isValid());
+ assertEquals(null, participantParameters.getName());
+ assertThat(validationResult.getResult()).contains("is null");
+ }
+
+ @Test
+ public void testParticipantPolicyParameters_EmptyName() {
+ final ParticipantPolicyParameters participantParameters = commonTestData
+ .toObject(commonTestData.getParticipantPolicyParametersMap(""),
+ ParticipantPolicyParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertFalse(validationResult.isValid());
+ assertEquals("", participantParameters.getName());
+ assertThat(validationResult.getResult()).contains(
+ "item \"name\" value \"\" INVALID, " + "is blank");
+ }
+
+ @Test
+ public void testParticipantPolicyParameters_SetName() {
+ final ParticipantPolicyParameters participantParameters = commonTestData.toObject(
+ commonTestData.getParticipantPolicyParametersMap(CommonTestData.PARTICIPANT_GROUP_NAME),
+ ParticipantPolicyParameters.class);
+ participantParameters.setName("ParticipantNewGroup");
+ assertThat(participantParameters.validate().isValid()).isTrue();
+ assertEquals("ParticipantNewGroup", participantParameters.getName());
+ }
+
+ @Test
+ public void testParticipantPolicyParameters_EmptyParticipantIntermediaryParameters() {
+ final Map<String, Object> map =
+ commonTestData.getParticipantPolicyParametersMap(CommonTestData.PARTICIPANT_GROUP_NAME);
+ map.replace("intermediaryParameters", commonTestData.getIntermediaryParametersMap(true));
+ final ParticipantPolicyParameters participantParameters =
+ commonTestData.toObject(map, ParticipantPolicyParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertNull(validationResult.getResult());
+ }
+
+ @Test
+ public void testParticipantPolicyParametersp_EmptyTopicParameters() {
+ final Map<String, Object> map =
+ commonTestData.getParticipantPolicyParametersMap(CommonTestData.PARTICIPANT_GROUP_NAME);
+ final Map<String, Object> intermediaryParametersMap = commonTestData.getIntermediaryParametersMap(false);
+ intermediaryParametersMap.put("clampControlLoopTopics", commonTestData.getTopicParametersMap(true));
+ map.replace("intermediaryParameters", intermediaryParametersMap);
+
+ final ParticipantPolicyParameters participantParameters =
+ commonTestData.toObject(map, ParticipantPolicyParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertNull(validationResult.getResult());
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/TestMain.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/TestMain.java
new file mode 100644
index 000000000..f77b678c0
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/TestMain.java
@@ -0,0 +1,143 @@
+/*-
+ * ============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.policy.main.startstop;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.ControlLoopConstants;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.common.utils.resources.MessageConstants;
+import org.onap.policy.common.utils.services.Registry;
+
+public class TestMain {
+
+ /**
+ * Set up.
+ */
+ @BeforeClass
+ public static void setUp() {
+ Registry.newRegistry();
+ }
+
+ /**
+ * Shuts "main" down.
+ *
+ * @throws Exception if an error occurs
+ */
+ @AfterClass
+ public static void tearDown() throws Exception {
+ // shut down activator
+ final ParticipantPolicyActivator activator =
+ Registry.getOrDefault(ControlLoopConstants.REG_CLRUNTIME_ACTIVATOR,
+ ParticipantPolicyActivator.class, null);
+ if (activator != null && activator.isAlive()) {
+ activator.shutdown();
+ }
+ }
+
+ @Test
+ public void testMain_Help() {
+ final String[] configParameters = {"-h"};
+ Main main = new Main(configParameters);
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_Version() {
+ final String[] configParameters = {"-v"};
+ Main main = new Main(configParameters);
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_Valid() {
+ final String[] configParameters = {"-c", "src/test/resources/parameters/TestParameters.json"};
+ Main main = new Main(configParameters);
+ assertTrue(main.isRunning());
+
+ assertThatCode(() -> main.shutdown()).doesNotThrowAnyException();
+
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_NoParameter() {
+ assertThatConfigParameterThrownException(new String[] {});
+ }
+
+ @Test
+ public void testMain_FilePathNotDefined() {
+ assertThatConfigParameterThrownException(new String[] {"-c"});
+ }
+
+ @Test
+ public void testMain_TooManyCommand() {
+ assertThatConfigParameterThrownException(new String[] {"-h", "d"});
+ }
+
+ @Test
+ public void testMain_WrongParameter() {
+ assertThatConfigParameterThrownException(new String[] {"-d"});
+ }
+
+ private void assertThatConfigParameterThrownException(final String[] configParameters) {
+ assertThatThrownBy(() -> Main.main(configParameters)).isInstanceOf(ControlLoopRuntimeException.class)
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP));
+ }
+
+ @Test
+ public void testParticipant_NoFileWithThisName() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/NoFileWithThisName.json");
+ }
+
+ @Test
+ public void testParticipant_NotValidFile() {
+ assertThatConfigFileThrownException("src/test/resources/parameters");
+ }
+
+ @Test
+ public void testParticipant_NoParameters() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/NoParameters.json");
+ }
+
+ @Test
+ public void testParticipant_InvalidParameters() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/InvalidParameters.json");
+ }
+
+ @Test
+ public void testParticipant_WrongJsonFormat() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/Unreadable.json");
+ }
+
+ private void assertThatConfigFileThrownException(final String configFilePath) {
+ final String[] configParameters = new String[] {"-c", configFilePath};
+ assertThatThrownBy(() -> new Main(configParameters)).isInstanceOf(ControlLoopRuntimeException.class)
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP));
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/TestParticipantPolicyActivator.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/TestParticipantPolicyActivator.java
new file mode 100644
index 000000000..afb0f6cb4
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/startstop/TestParticipantPolicyActivator.java
@@ -0,0 +1,88 @@
+/*-
+ * ============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.policy.main.startstop;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameterHandler;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameters;
+import org.onap.policy.common.utils.services.Registry;
+
+public class TestParticipantPolicyActivator {
+
+ private static ParticipantPolicyActivator activator;
+
+ /**
+ * Initializes an activator.
+ *
+ * @throws Exception if an error occurs
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Registry.newRegistry();
+ final String[] participantConfigParameters = { "-c", "src/test/resources/parameters/TestParameters.json"};
+ final ParticipantPolicyCommandLineArguments arguments =
+ new ParticipantPolicyCommandLineArguments(participantConfigParameters);
+ final ParticipantPolicyParameters parGroup =
+ new ParticipantPolicyParameterHandler().getParameters(arguments);
+ activator = new ParticipantPolicyActivator(parGroup);
+ }
+
+ /**
+ * Method for cleanup after each test.
+ *
+ * @throws Exception if an error occurs
+ */
+ @AfterClass
+ public static void teardown() throws Exception {
+ // shut down activator
+ if (activator != null && activator.isAlive()) {
+ activator.shutdown();
+ }
+ }
+
+ @Test
+ public void testParticipantActivator() {
+ activator.start();
+ assertTrue(activator.isAlive());
+ assertTrue(activator.getParameters().isValid());
+ assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, activator.getParameters().getName());
+
+ // repeat - should throw an exception
+ assertThatIllegalStateException().isThrownBy(() -> activator.start());
+ assertTrue(activator.isAlive());
+ assertTrue(activator.getParameters().isValid());
+
+ activator.shutdown();
+ assertFalse(activator.isAlive());
+
+ // repeat - should throw an exception
+ assertThatIllegalStateException().isThrownBy(() -> activator.shutdown());
+ assertFalse(activator.isAlive());
+ }
+}
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
new file mode 100644
index 000000000..4f3d6d62c
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
@@ -0,0 +1,343 @@
+/*-
+ * ============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.policy.main.utils;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.time.Instant;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import lombok.Getter;
+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.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.ParticipantHealthCheck;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.controlloop.participant.policy.main.handler.PolicyProvider;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameters;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestListenerUtils {
+
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+ private static final Coder CODER = new StandardCoder();
+ static CommonTestData commonTestData = new CommonTestData();
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class);
+
+ @Getter
+ private static ParticipantHandler participantHandler;
+
+ private TestListenerUtils() {}
+
+ /**
+ * Method to initialize participantHandler.
+ */
+ public static void initParticipantHandler() {
+
+ final ParticipantPolicyParameters participantParameters = commonTestData.toObject(
+ commonTestData.getParticipantPolicyParametersMap(CommonTestData.PARTICIPANT_GROUP_NAME),
+ ParticipantPolicyParameters.class);
+
+ PolicyProvider policyProvider =
+ new PolicyProvider(participantParameters.getIntermediaryParameters());
+
+ participantHandler = policyProvider.getIntermediaryApi().getParticipantHandler();
+ }
+
+ /**
+ * Method to create a controlLoop from a yaml file.
+ *
+ * @return ControlLoop controlloop
+ */
+ public static ControlLoop createControlLoop() {
+ ControlLoop controlLoop = new ControlLoop();
+ Map<UUID, ControlLoopElement> elements = new LinkedHashMap<>();
+ ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
+ Map<String, ToscaNodeTemplate> nodeTemplatesMap =
+ toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
+ ControlLoopElement clElement = new ControlLoopElement();
+ clElement.setId(UUID.randomUUID());
+
+ ToscaConceptIdentifier clElementParticipantId = new ToscaConceptIdentifier();
+ clElementParticipantId.setName(toscaInputEntry.getKey());
+ clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
+ clElement.setParticipantId(clElementParticipantId);
+
+ clElement.setDefinition(clElementParticipantId);
+ clElement.setState(ControlLoopState.UNINITIALISED);
+ clElement.setDescription(toscaInputEntry.getValue().getDescription());
+ clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ elements.put(clElement.getId(), clElement);
+ }
+ controlLoop.setElements(elements);
+ controlLoop.setName("PMSHInstance0");
+ controlLoop.setVersion("1.0.0");
+
+ ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
+ definition.setName("PMSHInstance0");
+ definition.setVersion("1.0.0");
+ controlLoop.setDefinition(definition);
+
+ return controlLoop;
+ }
+
+ /**
+ * 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
+ */
+ public static ParticipantControlLoopStateChange createControlLoopStateChangeMsg(
+ final ControlLoopOrderedState controlLoopOrderedState) {
+ final ParticipantControlLoopStateChange participantClStateChangeMsg = new ParticipantControlLoopStateChange();
+
+ ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier();
+ controlLoopId.setName("PMSHInstance0");
+ controlLoopId.setVersion("1.0.0");
+
+ ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
+ participantId.setName("org.onap.PM_Policy");
+ participantId.setVersion("0.0.0");
+
+ participantClStateChangeMsg.setControlLoopId(controlLoopId);
+ participantClStateChangeMsg.setParticipantId(participantId);
+ participantClStateChangeMsg.setTimestamp(Instant.now());
+ participantClStateChangeMsg.setOrderedState(controlLoopOrderedState);
+
+ return participantClStateChangeMsg;
+ }
+
+ /**
+ * Method to create ControlLoopUpdateMsg.
+ *
+ * @return ParticipantControlLoopUpdate message
+ */
+ public static ParticipantControlLoopUpdate createControlLoopUpdateMsg() {
+ final ParticipantControlLoopUpdate clUpdateMsg = new ParticipantControlLoopUpdate();
+ ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier();
+ controlLoopId.setName("PMSHInstance0");
+ controlLoopId.setVersion("1.0.0");
+
+ ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
+ participantId.setName("org.onap.PM_Policy");
+ participantId.setVersion("0.0.0");
+
+ clUpdateMsg.setControlLoopId(controlLoopId);
+ clUpdateMsg.setParticipantId(participantId);
+
+ ControlLoop controlLoop = new ControlLoop();
+ Map<UUID, ControlLoopElement> elements = new LinkedHashMap<>();
+ ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
+ Map<String, ToscaNodeTemplate> nodeTemplatesMap =
+ toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
+ ControlLoopElement clElement = new ControlLoopElement();
+ clElement.setId(UUID.randomUUID());
+
+ ToscaConceptIdentifier clElementParticipantId = new ToscaConceptIdentifier();
+ clElementParticipantId.setName(toscaInputEntry.getKey());
+ clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
+ clElement.setParticipantId(clElementParticipantId);
+
+ clElement.setDefinition(clElementParticipantId);
+ clElement.setState(ControlLoopState.UNINITIALISED);
+ clElement.setDescription(toscaInputEntry.getValue().getDescription());
+ clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ elements.put(clElement.getId(), clElement);
+ }
+ controlLoop.setElements(elements);
+ controlLoop.setName("PMSHInstance0");
+ controlLoop.setVersion("1.0.0");
+ controlLoop.setDefinition(controlLoopId);
+ clUpdateMsg.setControlLoop(controlLoop);
+ clUpdateMsg.setControlLoopDefinition(toscaServiceTemplate);
+
+ return clUpdateMsg;
+ }
+
+ /**
+ * Method to create ParticipantHealthCheck message.
+ *
+ * @return ParticipantHealthCheck message
+ */
+ public static ParticipantHealthCheck createParticipantHealthCheckMsg() {
+ ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
+ participantId.setName("org.onap.PM_Policy");
+ participantId.setVersion("0.0.0");
+
+ ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier();
+ controlLoopId.setName("PMSHInstance0");
+ controlLoopId.setVersion("1.0.0");
+
+ final ParticipantHealthCheck participantHealthCheckMsg = new ParticipantHealthCheck();
+ participantHealthCheckMsg.setParticipantId(participantId);
+ participantHealthCheckMsg.setControlLoopId(controlLoopId);
+ participantHealthCheckMsg.setTimestamp(Instant.now());
+ participantHealthCheckMsg.setState(ParticipantState.PASSIVE);
+
+ return participantHealthCheckMsg;
+ }
+
+ /**
+ * Method to create ParticipantControlLoopUpdate using the arguments passed.
+ *
+ * @param jsonFilePath the path of the controlloop content
+ *
+ * @return ParticipantControlLoopUpdate message
+ * @throws CoderException exception while reading the file to object
+ */
+ public static ParticipantControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath)
+ throws CoderException {
+ ParticipantControlLoopUpdate participantControlLoopUpdateMsg =
+ CODER.decode(new File(jsonFilePath), ParticipantControlLoopUpdate.class);
+ return participantControlLoopUpdateMsg;
+ }
+
+ private static ToscaServiceTemplate testControlLoopRead() {
+ Set<String> controlLoopDirectoryContents =
+ ResourceUtils.getDirectoryContents("src/test/resources/utils/servicetemplates");
+
+ boolean atLeastOneControlLoopTested = false;
+ ToscaServiceTemplate toscaServiceTemplate = null;
+
+ for (String controlLoopFilePath : controlLoopDirectoryContents) {
+ if (!controlLoopFilePath.endsWith(".yaml")) {
+ continue;
+ }
+ atLeastOneControlLoopTested = true;
+ toscaServiceTemplate = testControlLoopYamlSerialization(controlLoopFilePath);
+ }
+
+ // Add policy_types to the toscaServiceTemplate
+ addPolicyTypesToToscaServiceTemplate(toscaServiceTemplate);
+
+ assertTrue(atLeastOneControlLoopTested);
+ return toscaServiceTemplate;
+ }
+
+ private static void addPolicyTypesToToscaServiceTemplate(
+ ToscaServiceTemplate toscaServiceTemplate) {
+ Set<String> policyTypeDirectoryContents = ResourceUtils.getDirectoryContents("policytypes");
+
+ for (String policyTypeFilePath : policyTypeDirectoryContents) {
+ String policyTypeString = ResourceUtils.getResourceAsString(policyTypeFilePath);
+
+ ToscaServiceTemplate foundPolicyTypeSt =
+ yamlTranslator.fromYaml(policyTypeString, ToscaServiceTemplate.class);
+
+ toscaServiceTemplate.setDerivedFrom(foundPolicyTypeSt.getDerivedFrom());
+ toscaServiceTemplate.setDescription(foundPolicyTypeSt.getDescription());
+ toscaServiceTemplate.setMetadata(foundPolicyTypeSt.getMetadata());
+ toscaServiceTemplate.setName(foundPolicyTypeSt.getName());
+ toscaServiceTemplate.setToscaDefinitionsVersion(foundPolicyTypeSt.getToscaDefinitionsVersion());
+ toscaServiceTemplate.setVersion(foundPolicyTypeSt.getVersion());
+
+ if (foundPolicyTypeSt.getDataTypes() != null) {
+ if (toscaServiceTemplate.getDataTypes() == null) {
+ toscaServiceTemplate.setDataTypes(foundPolicyTypeSt.getDataTypes());
+ } else {
+ toscaServiceTemplate.getDataTypes().putAll(foundPolicyTypeSt.getDataTypes());
+ }
+ }
+
+ if (toscaServiceTemplate.getPolicyTypes() == null) {
+ toscaServiceTemplate.setPolicyTypes(foundPolicyTypeSt.getPolicyTypes());
+ } else {
+ toscaServiceTemplate.getPolicyTypes().putAll(foundPolicyTypeSt.getPolicyTypes());
+ }
+ }
+ }
+
+ /**
+ * Method to add polcies to the toscaServiceTemplate.
+ *
+ * @param toscaServiceTemplate to add policies
+ */
+ public static void addPoliciesToToscaServiceTemplate(ToscaServiceTemplate toscaServiceTemplate) {
+ Set<String> policiesDirectoryContents = ResourceUtils.getDirectoryContents("policies");
+
+ for (String policiesFilePath : policiesDirectoryContents) {
+ String policiesString = ResourceUtils.getResourceAsString(policiesFilePath);
+
+ ToscaServiceTemplate foundPoliciesSt =
+ yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class);
+ toscaServiceTemplate.getToscaTopologyTemplate().setPolicies(
+ foundPoliciesSt.getToscaTopologyTemplate().getPolicies());
+ }
+ }
+
+ private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) {
+ try {
+ String controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath);
+ if (controlLoopString == null) {
+ throw new FileNotFoundException(controlLoopFilePath);
+ }
+
+ ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(
+ controlLoopString, ToscaServiceTemplate.class);
+ return serviceTemplate;
+ } catch (FileNotFoundException e) {
+ LOGGER.error("cannot find YAML file", controlLoopFilePath);
+ throw new IllegalArgumentException(e);
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/InvalidParameters.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/InvalidParameters.json
new file mode 100644
index 000000000..1035ccb67
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/InvalidParameters.json
@@ -0,0 +1,3 @@
+{
+ "name": "
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/MinimumParametersH2.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/MinimumParametersH2.json
new file mode 100644
index 000000000..30250be68
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/MinimumParametersH2.json
@@ -0,0 +1,53 @@
+{
+ "name": "ControlLoopParticipantGroup",
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantType":{
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version":"2.3.1"
+ },
+ "participantId": {
+ "name": "org.onap.PM_Policy",
+ "version": "1.0.0"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/NoParameters.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/NoParameters.json
new file mode 100644
index 000000000..7a73a41bf
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/NoParameters.json
@@ -0,0 +1,2 @@
+{
+} \ No newline at end of file
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestCLParams.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestCLParams.yaml
new file mode 100644
index 000000000..c2ffb40a9
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestCLParams.yaml
@@ -0,0 +1,161 @@
+tosca_definitions_version: "tosca_simple_yaml_1_3"
+data_types:
+ onap.datatypes.ToscaConceptIdentifier:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ required: true
+ version:
+ type: string
+ required: true
+node_types:
+ org.onap.policy.clamp.controlloop.Participant:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ org.onap.policy.clamp.controlloop.ControlLoopElement:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ participant_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.ControlLoop:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ elements:
+ type: list
+ required: true
+ entry_schema:
+ type: onap.datatypes.ToscaConceptIdentifier
+ org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ dcae_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ policy_type_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.CDSControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ cds_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+topology_template:
+ node_templates:
+ org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant:
+ version: 2.3.4
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.policy.controlloop.MonitoringPolicyControlLoopParticipant:
+ version: 2.3.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.policy.controlloop.OperationalPolicyControlLoopParticipant:
+ version: 3.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant:
+ version: 2.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.domain.pmsh.PMSH_DCAEMicroservice:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ dcae_blueprint_id:
+ name: org.onap.dcae.blueprints.PMSHBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.MonitoringPolicyControlLoopParticipant
+ version: 2.3.1
+ policy_type_id:
+ name: onap.policies.monitoring.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.OperationalPolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for CDS for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_Id:
+ name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
+ version: 3.2.1
+ cds_blueprint_id:
+ name: org.onap.ccsdk.cds.PMSHCdsBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSHControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ elements:
+ - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement
+ version: 1.2.3
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParameters.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParameters.json
new file mode 100644
index 000000000..30250be68
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParameters.json
@@ -0,0 +1,53 @@
+{
+ "name": "ControlLoopParticipantGroup",
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantType":{
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version":"2.3.1"
+ },
+ "participantId": {
+ "name": "org.onap.PM_Policy",
+ "version": "1.0.0"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParametersStd.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParametersStd.json
new file mode 100644
index 000000000..79540631a
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParametersStd.json
@@ -0,0 +1,53 @@
+{
+ "name": "ControlLoopParticipantGroup",
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "participantId": {
+ "name": "org.onap.PM_Policy",
+ "version": "1.0.0"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json
new file mode 100644
index 000000000..efbfbe29f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json
@@ -0,0 +1,73 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ },
+ "healthCheckRestClientParameters": [
+ {
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }
+ ]
+}
+
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/logback-test.xml b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/logback-test.xml
new file mode 100644
index 000000000..cf6b89eb9
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/logback-test.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+
+<configuration>
+
+ <contextName>Participant</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/clamp_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.onap.policy.clamp.controlloop.participant" level="trace" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policies/vCPE.policies.optimization.input.tosca.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policies/vCPE.policies.optimization.input.tosca.yaml
new file mode 100644
index 000000000..126e8e6e2
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policies/vCPE.policies.optimization.input.tosca.yaml
@@ -0,0 +1,348 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+topology_template:
+ policies:
+ -
+ OSDF_CASABLANCA.Affinity_Default:
+ type: onap.policies.optimization.resource.AffinityPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.Affinity_Default
+ metadata:
+ policy-id: OSDF_CASABLANCA.Affinity_Default
+ policy-version: 1
+ properties:
+ scope: []
+ services: []
+ resources: []
+ geography: []
+ identity: affinity_vCPE
+ applicableResources: any
+ affinityProperties:
+ qualifier: same
+ category: complex
+ -
+ OSDF_CASABLANCA.Affinity_Default_US:
+ type: onap.policies.optimization.resource.AffinityPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.Affinity_Default_US
+ metadata:
+ policy-id: OSDF_CASABLANCA.Affinity_Default_US
+ policy-version: 1
+ properties:
+ scope: []
+ services: []
+ resources: []
+ geography: [US]
+ identity: affinity_vCPE
+ applicableResources: any
+ affinityProperties:
+ qualifier: same
+ category: complex
+ -
+ OSDF_CASABLANCA.Affinity_Default_vCPE_US_0:
+ type: onap.policies.optimization.resource.AffinityPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.Affinity_Default_vCPE_US_0
+ metadata:
+ policy-id: OSDF_CASABLANCA.Affinity_Default_vCPE_US_0
+ policy-version: 1
+ properties:
+ scope: []
+ services: [vCPE]
+ resources: []
+ geography: [US]
+ identity: affinity_vCPE
+ applicableResources: any
+ affinityProperties:
+ qualifier: different
+ category: complex
+ -
+ OSDF_CASABLANCA.Affinity_vCPE_US_Gold_1:
+ type: onap.policies.optimization.resource.AffinityPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.Affinity_vCPE_US_Gold_1
+ metadata:
+ policy-id: OSDF_CASABLANCA.Affinity_vCPE_1
+ policy-version: 1
+ properties:
+ scope: [gold]
+ services: [vCPE]
+ resources: [vGMuxInfra, vG]
+ geography: [US, INTERNATIONAL]
+ identity: affinity_vCPE
+ applicableResources: any
+ affinityProperties:
+ qualifier: same
+ category: availabilityZone
+ -
+ OSDF_CASABLANCA.Affinity_vCPE_US_Platinum_1:
+ type: onap.policies.optimization.resource.AffinityPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.Affinity_vCPE_US_Platinum_1
+ metadata:
+ policy-id: OSDF_CASABLANCA.Affinity_vCPE_1
+ policy-version: 1
+ properties:
+ scope: [platinum]
+ services: [vCPE]
+ resources: [vGMuxInfra, vG]
+ geography: [US, INTERNATIONAL]
+ identity: affinity_vCPE
+ applicableResources: any
+ affinityProperties:
+ qualifier: different
+ category: availabilityZone
+ -
+ OSDF_CASABLANCA.Capacity_vG_1:
+ type: onap.policies.optimization.resource.Vim_fit
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.Capacity_vG_1
+ metadata:
+ policy-id: OSDF_CASABLANCA.Capacity_vG_1
+ policy-version: 1
+ properties:
+ scope: []
+ services: [vCPE]
+ resources: [vG]
+ geography: [US, INTERNATIONAL]
+ identity: capacity_vG
+ applicableResources: any
+ capacityProperty:
+ controller: multicloud
+ request: "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}"
+ -
+ OSDF_CASABLANCA.Capacity_vG_2:
+ type: onap.policies.optimization.resource.Vim_fit
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.Capacity_vG_2
+ metadata:
+ policy-id: OSDF_CASABLANCA.Capacity_vG_2
+ policy-version: 1
+ properties:
+ scope: []
+ services: [vCPE]
+ resources: [vG]
+ geography: [US, INTERNATIONAL]
+ identity: capacity_vG
+ applicableResources: any
+ capacityProperty:
+ controller: multicloud
+ request: "{\"vCPU\": 15, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"MB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}"
+ -
+ OSDF_CASABLANCA.Distance_vG_1:
+ type: onap.policies.optimization.resource.DistancePolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.Distance_vG_1
+ metadata:
+ policy-id: OSDF_CASABLANCA.Distance_vG_1
+ policy-version: 1
+ properties:
+ scope: [platinum]
+ services: [vCPE]
+ resources: [vG]
+ geography: [US, INTERNATIONAL]
+ identity: distance-vG
+ applicableResources: any
+ distanceProperties:
+ locationInfo: customer_loc
+ distance:
+ value: 1500
+ operator: "<"
+ unit: km
+ -
+ OSDF_CASABLANCA.hpa_policy_Default:
+ type: onap.policies.optimization.resource.HpaPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.hpa_policy_Default
+ metadata:
+ policy-id: OSDF_CASABLANCA.hpa_policy_Default
+ policy-version: 1
+ properties:
+ scope: []
+ services: []
+ resources: []
+ geography: []
+ identity: hpa-vG
+ flavorFeatures:
+ -
+ id: vg_1
+ type: vnfc
+ directives:
+ - type: flavor_directives
+ attributes:
+ - attribute_name: flavor_label_vm_01
+ attribute_value: ""
+ flavorProperties:
+ -
+ hpa-feature: basicCapabilities
+ mandatory: True
+ architecture: generic
+ directives: []
+ hpa-feature-attributes:
+ - hpa-attribute-key: numVirtualCpu
+ hpa-attribute-value: 8
+ operator: ['>=']
+ unit: ""
+ - hpa-attribute-key: virtualMemSize
+ hpa-attribute-value: 6
+ operator: ['<=']
+ unit: ""
+ -
+ hpa-feature: ovsDpdk
+ mandatory: False
+ architecture: generic
+ directives: []
+ hpa-feature-attributes:
+ - hpa-attribute-key: dataProcessingAccelerationLibrary
+ hpa-attribute-value: ovsDpdk_version
+ operator: [=]
+ unit: ""
+ -
+ OSDF_CASABLANCA.hpa_policy_vG_1:
+ type: onap.policies.optimization.resource.HpaPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.hpa_policy_vG_1
+ metadata:
+ policy-id: OSDF_CASABLANCA.hpa_policy_vG_1
+ policy-version: 1
+ properties:
+ scope: []
+ services: [vCPE, vOtherService]
+ resources: [vG]
+ geography: []
+ identity: hpa-vG
+ flavorFeatures:
+ -
+ id: vg_1
+ type: vnfc
+ directives:
+ - type: flavor_directives
+ attributes:
+ - attribute_name: flavor_label_vm_01
+ attribute_value: ""
+ flavorProperties:
+ -
+ hpa-feature: basicCapabilities
+ mandatory: True
+ architecture: generic
+ directives: []
+ hpa-feature-attributes:
+ - hpa-attribute-key: numVirtualCpu
+ hpa-attribute-value: 6
+ operator: ['>=']
+ unit: ""
+ - hpa-attribute-key: virtualMemSize
+ hpa-attribute-value: 4
+ operator: ['<=']
+ unit: ""
+ -
+ hpa-feature: ovsDpdk
+ mandatory: False
+ architecture: generic
+ directives: []
+ hpa-feature-attributes:
+ - hpa-attribute-key: dataProcessingAccelerationLibrary
+ hpa-attribute-value: ovsDpdk_version
+ operator: [=]
+ unit: ""
+ -
+ OSDF_CASABLANCA.queryPolicy_vCPE:
+ type: onap.policies.optimization.service.QueryPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.queryPolicy_vCPE
+ metadata:
+ policy-id: OSDF_CASABLANCA.queryPolicy_vCPE
+ policy-version: 1
+ properties:
+ scope: []
+ services: [vCPE]
+ geography: [US, INTERNATIONAL]
+ identity: vCPE_Query_Policy
+ queryProperties:
+ -
+ attribute: locationId
+ attribute_location: customerLocation
+ value: ""
+ -
+ attribute: id
+ attribute_location: "vpnInfo.vpnId"
+ value: ""
+ -
+ attribute: upstreamBW
+ attribute_location: "vpnInfo.upstreamBW"
+ value: ""
+ -
+ attribute: customerLatitude
+ attribute_location: customerLatitude
+ value: 1.1
+ -
+ attribute: customerLongitude
+ attribute_location: customerLongitude
+ value: 2.2
+ -
+ OSDF_CASABLANCA.SubscriberPolicy_v1:
+ type: onap.policies.optimization.service.SubscriberPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.SubscriberPolicy_v1
+ metadata:
+ policy-id: OSDF_CASABLANCA.SubscriberPolicy_v1
+ policy-version: 1
+ properties:
+ scope: []
+ services: [vCPE]
+ identity: subscriber_vCPE
+ subscriberProperties:
+ subscriberName: [subscriber_x, subscriber_y]
+ subscriberRole: [platinum]
+ provStatus: [CAPPED]
+ -
+ OSDF_CASABLANCA.SubscriberPolicy_v2:
+ type: onap.policies.optimization.service.SubscriberPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.SubscriberPolicy_v2
+ metadata:
+ policy-id: OSDF_CASABLANCA.SubscriberPolicy_v2
+ policy-version: 1
+ properties:
+ scope: []
+ services: [vCPE]
+ identity: subscriber_vCPE
+ subscriberProperties:
+ subscriberName: [subscriber_a, subscriber_b]
+ subscriberRole: [gold]
+ provStatus: [CAPPED]
+ -
+ OSDF_CASABLANCA.vnfPolicy_vG:
+ type: onap.policies.optimization.resource.VnfPolicy
+ version: 1.0.0
+ type_version: 1.0.0
+ name: OSDF_CASABLANCA.vnfPolicy_vG
+ metadata:
+ policy-id: OSDF_CASABLANCA.vnfPolicy_vG
+ policy-version: 1
+ properties:
+ scope: []
+ services: [vCPE]
+ resources: [vG]
+ geography: [US, INTERNATIONAL]
+ identity: vnf_vG
+ applicableResources: any
+ vnfProperties:
+ -
+ inventoryProvider: aai
+ serviceType: ""
+ inventoryType: cloudRegionId
+ customerId: ""
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Match.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Match.yaml
new file mode 100644
index 000000000..88b870580
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Match.yaml
@@ -0,0 +1,8 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Match:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.Match
+ description: Base Policy Type for matchable Policies
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Naming.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Naming.yaml
new file mode 100644
index 000000000..bde730cd7
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Naming.yaml
@@ -0,0 +1,102 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Naming:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.Naming
+ description: Virtual policy node for naming
+ properties:
+ policy-instance-name:
+ type: string
+ naming-models:
+ type: list
+ entry_schema:
+ type: policy.data.naming-model-entity
+data_types:
+ policy.data.naming-model-entity:
+ derived_from: tosca.datatypes.Root
+ properties:
+ nfRole:
+ type: string
+ required: false
+ metadata:
+ matchable: true
+ naming-type:
+ type: string
+ required: true
+ metadata:
+ matchable: true
+ naming-recipe:
+ type: string
+ required: true
+ name-operation:
+ type: string
+ required: false
+ naming-properties:
+ type: list
+ required: true
+ entry_schema:
+ type: policy.data.naming-property
+ policy.data.naming-property:
+ derived_from: tosca.datatypes.Root
+ properties:
+ property-name:
+ type: string
+ required: true
+ metadata:
+ matchable: true
+ property-value:
+ type: string
+ required: false
+ property-operation:
+ type: string
+ required: false
+ source-system:
+ type: string
+ required: false
+ source-endpoint:
+ type: string
+ required: false
+ increment-sequence:
+ type: policy.data.increment-sequence
+ required: false
+ policy.data.increment-sequence:
+ derived_from: tosca.datatypes.Root
+ properties:
+ scope:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - CLOUD_REGION_ID
+ - LOCATION_CLLI
+ - VNF
+ - VM
+ - VFMODULE
+ - PRECEEDING
+ - TRAILING
+ - ENTIRETY
+ sequence-type:
+ type: string
+ require: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - numeric
+ - alpha-numeric
+ start-value:
+ type: string
+ required: true
+ max:
+ type: string
+ required: false
+ increment:
+ type: string
+ required: true
+ length:
+ type: string
+ required: true
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Optimization.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Optimization.yaml
new file mode 100644
index 000000000..7fe0e59de
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Optimization.yaml
@@ -0,0 +1,33 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Optimization:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.Optimization
+ description: The base policy type for all policies that govern optimization
+ properties:
+ scope:
+ description: Scope for the policy - could be for a specific release.
+ type: list
+ metadata:
+ matchable: true
+ required: true
+ entry_schema:
+ type: string
+ geography:
+ description: One or more geographic regions
+ type: list
+ metadata:
+ matchable: true
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - US
+ - International
+ identity:
+ description: Used internally for identification
+ type: string
+ required: true
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.Common.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.Common.yaml
new file mode 100644
index 000000000..3dc979220
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.Common.yaml
@@ -0,0 +1,28 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.Common:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.controlloop.guard.Common
+ description: |
+ This is the base Policy Type for Guard policies that guard the execution of Operational
+ Policies.
+ properties:
+ actor:
+ type: string
+ description: Specifies the Actor the guard applies to.
+ required: true
+ operation:
+ type: string
+ description: Specified the operation that the actor is performing the guard applies to.
+ required: true
+ timeRange:
+ type: tosca.datatypes.TimeInterval
+ description: |
+ An optional range of time during the day the guard policy is valid for.
+ required: false
+ id:
+ type: string
+ description: The Control Loop id this applies to.
+ required: false
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml
new file mode 100644
index 000000000..f2b67e18f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml
@@ -0,0 +1,16 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.common.Blacklist:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ name: onap.policies.controlloop.guard.common.Blacklist
+ description: Supports blacklist of entity id's from performing control loop actions on.
+ properties:
+ blacklist:
+ type: list
+ description: List of entity id's not allowed to have control loop operations on.
+ required: true
+ entry_schema:
+ type: string
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Filter.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Filter.yaml
new file mode 100644
index 000000000..ea8e92aaf
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Filter.yaml
@@ -0,0 +1,66 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.common.Filter:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ name: onap.policies.controlloop.guard.common.Filter
+ description: Supports filtering of A&AI entities such as vnf-id, type, service, geographic region, etc.
+ properties:
+ algorithm:
+ type: string
+ description: Designates the precendence of blacklist vs whitelist
+ required: true
+ default: blacklist-overrides
+ constraints:
+ - valid_values: ["blacklist-overrides", "whitelist-overrides"]
+ filters:
+ type: list
+ description: List of filters to be applied.
+ required: true
+ entry_schema:
+ type: onap.datatypes.guard.filter
+data_types:
+ onap.datatypes.guard.filter:
+ derived_from: tosca.nodes.Root
+ properties:
+ field:
+ type: string
+ description: Name of the field to perform the filter on using the A&AI <node>.<property> syntax.
+ required: true
+ constraints:
+ - valid_values:
+ - generic-vnf.vnf-name
+ - generic-vnf.vnf-id
+ - generic-vnf.vnf-type
+ - generic-vnf.nf-naming-code
+ - vserver.vserver-id
+ - cloud-region.cloud-region-id
+ filter:
+ type: string
+ description: The filter value itself. For example, "RegionOne" "vFWCL*"
+ required: true
+ function:
+ type: string
+ description: The function applied to the filter.
+ required: true
+ constraints:
+ - valid_values:
+ - string-equal
+ - string-equal-ignore-case
+ - string-regexp-match
+ - string-contains
+ - string-greater-than
+ - string-greater-than-or-equal
+ - string-less-than
+ - string-less-than-or-equal
+ - string-starts-with
+ - string-ends-with
+ blacklist:
+ type: boolean
+ description: |
+ Indicates if the filter should be treated as a blacklist (true)
+ or whitelist (false).
+ required: true
+ default: true
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml
new file mode 100644
index 000000000..3e31ec218
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml
@@ -0,0 +1,26 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.common.FrequencyLimiter:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ name: onap.policies.controlloop.guard.common.FrequencyLimiter
+ description: Supports limiting the frequency of actions being taken by a Actor.
+ properties:
+ timeWindow:
+ type: integer
+ description: The time window to count the actions against.
+ required: true
+ timeUnits:
+ type: string
+ description: The units of time the window is counting.
+ required: true
+ constraints:
+ - valid_values: ["second", "minute", "hour", "day", "week", "month", "year"]
+ limit:
+ type: integer
+ description: The limit
+ required: true
+ constraints:
+ - greater_than: 0
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml
new file mode 100644
index 000000000..8f93572bf
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml
@@ -0,0 +1,24 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.common.MinMax:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ name: onap.policies.controlloop.guard.common.MinMax
+ description: |
+ Supports Min/Max number of entity for scaling operations. Although min and max fields are marked as not
+ required, you need to have at least one or the other.
+ properties:
+ target:
+ type: string
+ required: true
+ description: The target entity that has scaling restricted
+ min:
+ type: integer
+ required: false
+ description: The minimum instances of this entity
+ max:
+ type: integer
+ required: false
+ description: The maximum instances of this entity
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml
new file mode 100644
index 000000000..eaeee605d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml
@@ -0,0 +1,27 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.Guard:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.controlloop.Guard
+ description: Guard Policies for Control Loop Operational Policies
+ onap.policies.controlloop.guard.Coordination:
+ derived_from: onap.policies.controlloop.Guard
+ version: 1.0.0
+ name: onap.policies.controlloop.guard.Coordination
+ description: Guard Policies for Control Loop Coordination
+ onap.policies.controlloop.guard.coordination.FirstBlocksSecond:
+ derived_from: onap.policies.controlloop.guard.Coordination
+ version: 1.0.0
+ name: onap.policies.controlloop.guard.coordination.FirstBlocksSecond
+ description: Supports one Control Loop blocking another
+ properties:
+ controlLoop:
+ type: list
+ description: Specific Control Loops to which to apply this guard
+ required: true
+ constraint:
+ length: 2
+ entry_schema:
+ type: string
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.Common.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.Common.yaml
new file mode 100644
index 000000000..9b3b057b8
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.Common.yaml
@@ -0,0 +1,143 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.operational.Common:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.controlloop.operational.Common
+ description: |
+ Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant
+ Policy Types. This does NOT support the legacy Policy YAML policy type.
+ properties:
+ id:
+ type: string
+ description: The unique control loop id.
+ required: true
+ timeout:
+ type: integer
+ description: |
+ Overall timeout for executing all the operations. This timeout should equal or exceed the total
+ timeout for each operation listed.
+ required: true
+ abatement:
+ type: boolean
+ description: Whether an abatement event message will be expected for the control loop from DCAE.
+ required: true
+ default: false
+ trigger:
+ type: string
+ description: Initial operation to execute upon receiving an Onset event message for the Control Loop.
+ required: true
+ operations:
+ type: list
+ description: List of operations to be performed when Control Loop is triggered.
+ required: true
+ entry_schema:
+ type: onap.datatype.controlloop.Operation
+
+data_types:
+ onap.datatype.controlloop.Target:
+ derived_from: tosca.datatypes.Root
+ description: Definition for a entity in A&AI to perform a control loop operation on
+ properties:
+ targetType:
+ type: string
+ description: Category for the target type
+ required: true
+ constraints:
+ - valid_values: [VNF, VM, VFMODULE, PNF]
+ entityIds:
+ type: map
+ description: |
+ Map of values that identify the resource. If none are provided, it is assumed that the
+ entity that generated the ONSET event will be the target.
+ required: false
+ metadata:
+ clamp_possible_values: ClampExecution:CSAR_RESOURCES
+ entry_schema:
+ type: string
+
+ onap.datatype.controlloop.Actor:
+ derived_from: tosca.datatypes.Root
+ description: An actor/operation/target definition
+ properties:
+ actor:
+ type: string
+ description: The actor performing the operation.
+ required: true
+ metadata:
+ clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor
+ operation:
+ type: string
+ description: The operation the actor is performing.
+ metadata:
+ clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation
+ required: true
+ target:
+ type: onap.datatype.controlloop.Target
+ description: The resource the operation should be performed on.
+ required: true
+ payload:
+ type: map
+ description: Name/value pairs of payload information passed by Policy to the actor
+ required: false
+ metadata:
+ clamp_possible_values: ClampExecution:CDS/payload
+ entry_schema:
+ type: string
+
+ onap.datatype.controlloop.Operation:
+ derived_from: tosca.datatypes.Root
+ description: An operation supported by an actor
+ properties:
+ id:
+ type: string
+ description: Unique identifier for the operation
+ required: true
+ description:
+ type: string
+ description: A user-friendly description of the intent for the operation
+ required: false
+ operation:
+ type: onap.datatype.controlloop.Actor
+ description: The definition of the operation to be performed.
+ required: true
+ timeout:
+ type: integer
+ description: The amount of time for the actor to perform the operation.
+ required: true
+ retries:
+ type: integer
+ description: The number of retries the actor should attempt to perform the operation.
+ required: true
+ default: 0
+ success:
+ type: string
+ description: Points to the operation to invoke on success. A value of "final_success" indicates and end to the operation.
+ required: false
+ default: final_success
+ failure:
+ type: string
+ description: Points to the operation to invoke on Actor operation failure.
+ required: false
+ default: final_failure
+ failure_timeout:
+ type: string
+ description: Points to the operation to invoke when the time out for the operation occurs.
+ required: false
+ default: final_failure_timeout
+ failure_retries:
+ type: string
+ description: Points to the operation to invoke when the current operation has exceeded its max retries.
+ required: false
+ default: final_failure_retries
+ failure_exception:
+ type: string
+ description: Points to the operation to invoke when the current operation causes an exception.
+ required: false
+ default: final_failure_exception
+ failure_guard:
+ type: string
+ description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.
+ required: false
+ default: final_failure_guard
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml
new file mode 100644
index 000000000..a0c5b2456
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml
@@ -0,0 +1,26 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.operational.common.Apex:
+ derived_from: onap.policies.controlloop.operational.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ name: onap.policies.controlloop.operational.common.Apex
+ description: Operational policies for Apex PDP
+ properties:
+ engineServiceParameters:
+ type: string
+ description: The engine parameters like name, instanceCount, policy implementation, parameters etc.
+ required: true
+ eventInputParameters:
+ type: string
+ description: The event input parameters.
+ required: true
+ eventOutputParameters:
+ type: string
+ description: The event output parameters.
+ required: true
+ javaProperties:
+ type: string
+ description: Name/value pairs of properties to be set for APEX if needed.
+ required: false
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml
new file mode 100644
index 000000000..69d73db58
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml
@@ -0,0 +1,14 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.operational.common.Drools:
+ derived_from: onap.policies.controlloop.operational.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ name: onap.policies.controlloop.operational.common.Drools
+ description: Operational policies for Drools PDP
+ properties:
+ controllerName:
+ type: string
+ description: Drools controller properties
+ required: false
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml
new file mode 100644
index 000000000..c50392eca
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml
@@ -0,0 +1,50 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Monitoring:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.Monitoring
+ description: a base policy type for all policies that govern monitoring provisioning
+ onap.policies.monitoring.dcae-pm-mapper:
+ derived_from: onap.policies.Monitoring
+ version: 1.0.0
+ properties:
+ pm-mapper-filter:
+ type: map
+ description: PM mapper filter on measInfo, measInfoId, measType, instanceId
+ entry_schema:
+ type: onap.datatypes.monitoring.pm-mapper-filter
+data_types:
+ onap.datatypes.monitoring.pm-mapper-filter:
+ derived_from: tosca.datatypes.Root
+ properties:
+ filters:
+ type: list
+ description: Filter configuration
+ #default: []
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.filters
+ onap.datatypes.monitoring.filters:
+ derived_from: tosca.datatypes.Root
+ properties:
+ pmDefVsn:
+ type: string
+ description: PM Dictionary version
+ required: true
+ nfType:
+ type: string
+ description: NF type
+ required: true
+ vendor:
+ type: string
+ description: Vendor name
+ required: true
+ measTypes:
+ type: list
+ description: Measurement types to collect
+ #default: []
+ required: true
+ entry_schema:
+ type: string
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml
new file mode 100644
index 000000000..8ac9b7484
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml
@@ -0,0 +1,132 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Monitoring:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.Monitoring
+ description: a base policy type for all policies that govern monitoring provisioning
+ onap.policies.monitoring.dcae-pm-subscription-handler:
+ derived_from: onap.policies.Monitoring
+ version: 1.0.0
+ properties:
+ subscription:
+ type: map
+ description: PM Subscription Handler Subscription
+ entry_schema:
+ type: onap.datatypes.monitoring.subscription
+data_types:
+ onap.datatypes.monitoring.subscription:
+ derived_from: tosca.datatypes.Root
+ properties:
+ subscriptionName:
+ type: string
+ description: Name of the subscription
+ required: true
+ administrativeState:
+ type: string
+ description: State of the subscription
+ required: true
+ constraints:
+ - valid_values:
+ - LOCKED
+ - UNLOCKED
+ fileBasedGP:
+ type: integer
+ description: File based granularity period
+ required: true
+ fileLocation:
+ type: string
+ description: ROP file location
+ required: true
+ nfTypeModelInvariantId:
+ type: string
+ description: Network function invariant ID
+ required: true
+ nfFilter:
+ type: map
+ description: Network function filter
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.nfFilter
+ measurementGroups:
+ type: list
+ description: Measurement Groups
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementGroups
+ onap.datatypes.monitoring.nfFilter:
+ derived_from: tosca.datatypes.Root
+ properties:
+ nfNames:
+ type: list
+ description: List of network functions
+ required: true
+ #default: []
+ entry_schema:
+ type: string
+ swVersions:
+ type: list
+ description: List of software versions
+ required: true
+ #default: []
+ entry_schema:
+ type: string
+ onap.datatypes.monitoring.measurementGroups:
+ derived_from: tosca.datatypes.Root
+ properties:
+ measurementGroup:
+ type: map
+ description: Measurement Group
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementGroup
+ onap.datatypes.monitoring.measurementGroup:
+ derived_from: tosca.datatypes.Root
+ properties:
+ measurementTypes:
+ type: list
+ description: List of measurement types
+ required: true
+ #default: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementTypes
+ managedObjectDNsBasic:
+ type: list
+ description: List of managed object distinguished names
+ required: true
+ #default: []
+ entry_schema:
+ type: onap.datatypes.monitoring.managedObjectDNsBasics
+ onap.datatypes.monitoring.measurementTypes:
+ derived_from: tosca.datatypes.Root
+ properties:
+ measurementType:
+ type: map
+ description: Measurement type object
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementType
+ onap.datatypes.monitoring.measurementType:
+ derived_from: tosca.datatypes.Root
+ properties:
+ measurementType:
+ type: string
+ description: Measurement type
+ required: true
+ onap.datatypes.monitoring.managedObjectDNsBasics:
+ derived_from: tosca.datatypes.Root
+ properties:
+ managedObjectDNsBasic:
+ type: map
+ description: Managed object distinguished name object
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.managedObjectDNsBasic
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ derived_from: tosca.datatypes.Root
+ properties:
+ DN:
+ type: string
+ description: Managed object distinguished name
+ required: true
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml
new file mode 100644
index 000000000..58e60e98d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml
@@ -0,0 +1,128 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Monitoring:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.Monitoring
+ description: a base policy type for all policies that govern monitoring provisioning
+ onap.policies.monitoring.dcae-restconfcollector:
+ derived_from: onap.policies.Monitoring
+ version: 1.0.0
+ properties:
+ rcc_policy:
+ type: list
+ description: RCC Policy JSON
+ entry_schema:
+ type: onap.datatypes.monitoring.rcc_policy
+data_types:
+ onap.datatypes.monitoring.rcc_policy:
+ derived_from: tosca.datatypes.Root
+ properties:
+ controller_name:
+ type: string
+ description: Name of controller
+ required: true
+ controller_restapiUrl:
+ type: string
+ description: Controller's ip and port
+ required: true
+ controller_restapiUser:
+ type: string
+ description: Controller's username
+ required: true
+ controller_restapiPassword:
+ type: string
+ description: Controller's password
+ required: true
+ controller_accessTokenUrl:
+ type: string
+ description: URL to get access token
+ required: true
+ controller_accessTokenFile:
+ type: string
+ description: Access token file path
+ required: true
+ controller_accessTokenMethod:
+ type: string
+ description: Access token method POST/GET/PUT etc
+ required: true
+ constraints:
+ - valid_values:
+ - post
+ - get
+ - put
+ controller_subsMethod:
+ type: string
+ description: Subscription method POST/GET/PUT etc
+ required: true
+ default: post
+ constraints:
+ - valid_values:
+ - post
+ - get
+ - put
+ controller_subscriptionUrl:
+ type: string
+ description: URL to establish subscription
+ required: true
+ controller_disableSsl:
+ type: boolean
+ description: Option to disable ssl
+ required: true
+ default: true
+ event_details:
+ type: list
+ description: event details
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.rcc_event_details
+ onap.datatypes.monitoring.rcc_event_details:
+ derived_from: tosca.datatypes.Root
+ properties:
+ event_name:
+ type: string
+ description: event name
+ required: true
+ event_description:
+ type: string
+ description: description of event
+ required: false
+ event_sseventUrlEmbed:
+ type: boolean
+ description: Whether SSE url is embedded in subscription response
+ required: true
+ default: true
+ event_sseventsField:
+ type: string
+ description: Field name to access SSE url in subscription response
+ required: true
+ event_sseventsUrl:
+ type: string
+ description: Explicit SSE url
+ required: true
+ event_subscriptionTemplate:
+ type: string
+ description: Subscription template file path
+ required: true
+ event_unSubscriptionTemplate:
+ type: string
+ description: Unsubscription template file path
+ required: false
+ event_ruleId:
+ type: integer
+ description: Rule Id
+ required: false
+ modifyData:
+ type: boolean
+ description: Whether to modify the received SSE event
+ required: true
+ default: false
+ modifyMethod:
+ type: string
+ description: The java method name to modify data
+ required: false
+ userData:
+ type: string
+ description: The user specific data
+ required: false
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml
new file mode 100644
index 000000000..408e8cd00
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml
@@ -0,0 +1,19 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Monitoring:
+ derived_from: tosca.policies.Root
+ description: a base policy type for all policies that govern monitoring provisioning
+ version: 1.0.0
+ name: onap.policies.Monitoring
+ onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server:
+ derived_from: onap.policies.Monitoring
+ version: 1.0.0
+ name: onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server
+ properties:
+ buscontroller_feed_publishing_endpoint:
+ type: string
+ description: DMAAP Bus Controller feed endpoint
+ datafile.policy:
+ type: string
+ description: datafile Policy JSON as string
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.tcagen2.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.tcagen2.yaml
new file mode 100644
index 000000000..04026b323
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.tcagen2.yaml
@@ -0,0 +1,161 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Monitoring:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.Monitoring
+ description: a base policy type for all policies that govern monitoring provisioning
+ onap.policies.monitoring.tcagen2:
+ derived_from: onap.policies.Monitoring
+ version: 1.0.0
+ name: onap.policies.monitoring.tcagen2
+ properties:
+ tca.policy:
+ type: onap.datatypes.monitoring.tca_policy
+ description: TCA Policy JSON
+ required: true
+data_types:
+ onap.datatypes.monitoring.metricsPerEventName:
+ derived_from: tosca.datatypes.Root
+ properties:
+ controlLoopSchemaType:
+ type: string
+ required: true
+ description: Specifies Control Loop Schema Type for the event Name e.g. VNF, VM
+ constraints:
+ - valid_values:
+ - VM
+ - VNF
+ eventName:
+ type: string
+ required: true
+ description: Event name to which thresholds need to be applied
+ policyName:
+ type: string
+ required: true
+ description: TCA Policy Scope Name
+ policyScope:
+ type: string
+ required: true
+ description: TCA Policy Scope
+ policyVersion:
+ type: string
+ required: true
+ description: TCA Policy Scope Version
+ thresholds:
+ type: list
+ required: true
+ description: Thresholds associated with eventName
+ entry_schema:
+ type: onap.datatypes.monitoring.thresholds
+ onap.datatypes.monitoring.tca_policy:
+ derived_from: tosca.datatypes.Root
+ properties:
+ domain:
+ type: string
+ required: true
+ description: Domain name to which TCA needs to be applied
+ default: measurementsForVfScaling
+ constraints:
+ - equal: measurementsForVfScaling
+ metricsPerEventName:
+ type: list
+ required: true
+ description: Contains eventName and threshold details that need to be applied to given eventName
+ entry_schema:
+ type: onap.datatypes.monitoring.metricsPerEventName
+ onap.datatypes.monitoring.thresholds:
+ derived_from: tosca.datatypes.Root
+ properties:
+ closedLoopControlName:
+ type: string
+ required: true
+ description: Closed Loop Control Name associated with the threshold
+ closedLoopEventStatus:
+ type: string
+ required: true
+ description: Closed Loop Event Status of the threshold
+ constraints:
+ - valid_values:
+ - ONSET
+ - ABATED
+ direction:
+ type: string
+ required: true
+ description: Direction of the threshold
+ constraints:
+ - valid_values:
+ - LESS
+ - LESS_OR_EQUAL
+ - GREATER
+ - GREATER_OR_EQUAL
+ - EQUAL
+ fieldPath:
+ type: string
+ required: true
+ description: Json field Path as per CEF message which needs to be analyzed for TCA
+ constraints:
+ - valid_values:
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsDelta
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsAccumulated
+ - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuIdle
+ - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageInterrupt
+ - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageNice
+ - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSoftIrq
+ - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSteal
+ - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSystem
+ - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuWait
+ - $.event.measurementsForVfScalingFields.cpuUsageArray[*].percentUsage
+ - $.event.measurementsForVfScalingFields.meanRequestLatency
+ - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryBuffered
+ - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryCached
+ - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryConfigured
+ - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryFree
+ - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryUsed
+ - $.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value
+ severity:
+ type: string
+ required: true
+ description: Threshold Event Severity
+ constraints:
+ - valid_values:
+ - CRITICAL
+ - MAJOR
+ - MINOR
+ - WARNING
+ - NORMAL
+ thresholdValue:
+ type: integer
+ required: true
+ description: Threshold value for the field Path inside CEF message
+ version:
+ type: string
+ required: true
+ description: Version number associated with the threshold
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Apex.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Apex.yaml
new file mode 100644
index 000000000..d2a7632f3
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Apex.yaml
@@ -0,0 +1,203 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Native:
+ derived_from: tosca.policies.Root
+ description: a base policy type for all native PDP policies
+ version: 1.0.0
+ name: onap.policies.Native
+ onap.policies.native.Apex:
+ derived_from: onap.policies.Native
+ description: a policy type for native apex policies
+ version: 1.0.0
+ name: onap.policies.native.Apex
+ properties:
+ engine_service:
+ type: onap.datatypes.native.apex.EngineService
+ description: APEX Engine Service Parameters
+ inputs:
+ type: map
+ description: Inputs for handling events coming into the APEX engine
+ entry_schema:
+ type: onap.datatypes.native.apex.EventHandler
+ outputs:
+ type: map
+ description: Outputs for handling events going out of the APEX engine
+ entry_schema:
+ type: onap.datatypes.native.apex.EventHandler
+ environment:
+ type: list
+ description: Envioronmental parameters for the APEX engine
+ entry_schema:
+ type: onap.datatypes.native.apex.Environment
+
+data_types:
+ onap.datatypes.native.apex.EngineService:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ description: Specifies the engine name
+ required: false
+ default: "ApexEngineService"
+ version:
+ type: string
+ description: Specifies the engine version in double dotted format
+ required: false
+ default: "1.0.0"
+ id:
+ type: integer
+ description: Specifies the engine id
+ required: true
+ instance_count:
+ type: integer
+ description: Specifies the number of engine threads that should be run
+ required: true
+ deployment_port:
+ type: integer
+ description: Specifies the port to connect to for engine administration
+ required: false
+ default: 1
+ policy_model_file_name:
+ type: string
+ description: The name of the file from which to read the APEX policy model
+ required: false
+ policy_type_impl:
+ type: string
+ description: The policy type implementation from which to read the APEX policy model
+ required: false
+ periodic_event_period:
+ type: string
+ description: The time interval in milliseconds for the periodic scanning event, 0 means don't scan
+ required: false
+ engine:
+ type: onap.datatypes.native.apex.engineservice.Engine
+ description: The parameters for all engines in the APEX engine service
+ required: true
+ onap.datatypes.native.apex.EventHandler:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ description: Specifies the event handler name, if not specified this is set to the key name
+ required: false
+ carrier_technology:
+ type: onap.datatypes.native.apex.CarrierTechnology
+ description: Specifies the carrier technology of the event handler (such as REST/Web Socket/Kafka)
+ required: true
+ event_protocol:
+ type: onap.datatypes.native.apex.EventProtocol
+ description: Specifies the event protocol of events for the event handler (such as Yaml/JSON/XML/POJO)
+ required: true
+ event_name:
+ type: string
+ description: Specifies the event name for events on this event handler, if not specified, the event name is read from or written to the event being received or sent
+ required: false
+ event_name_filter:
+ type: string
+ description: Specifies a filter as a regular expression, events that do not match the filter are dropped, the default is to let all events through
+ required: false
+ synchronous_mode:
+ type: boolean
+ description: Specifies the event handler is syncronous (receive event and send response)
+ required: false
+ default: false
+ synchronous_peer:
+ type: string
+ description: The peer event handler (output for input or input for output) of this event handler in synchronous mode, this parameter is mandatory if the event handler is in synchronous mode
+ required: false
+ synchronous_timeout:
+ type: integer
+ description: The timeout in milliseconds for responses to be issued by APEX torequests, this parameter is mandatory if the event handler is in synchronous mode
+ required: false
+ requestor_mode:
+ type: boolean
+ description: Specifies the event handler is in requestor mode (send event and wait for response mode)
+ required: false
+ default: false
+ requestor_peer:
+ type: string
+ description: The peer event handler (output for input or input for output) of this event handler in requestor mode, this parameter is mandatory if the event handler is in requestor mode
+ required: false
+ requestor_timeout:
+ type: integer
+ description: The timeout in milliseconds for wait for responses to requests, this parameter is mandatory if the event handler is in requestor mode
+ required: false
+ onap.datatypes.native.apex.CarrierTechnology:
+ derived_from: tosca.datatypes.Root
+ properties:
+ label:
+ type: string
+ description: The label (name) of the carrier technology (such as REST, Kafka, WebSocket)
+ required: true
+ plugin_parameter_class_name:
+ type: string
+ description: The class name of the class that overrides default handling of event input or output for this carrier technology, defaults to the supplied input or output class
+ required: false
+ onap.datatypes.native.apex.EventProtocol:
+ derived_from: tosca.datatypes.Root
+ properties:
+ label:
+ type: string
+ description: The label (name) of the event protocol (such as Yaml, JSON, XML, or POJO)
+ required: true
+ event_protocol_plugin_class:
+ type: string
+ description: The class name of the class that overrides default handling of the event protocol for this carrier technology, defaults to the supplied event protocol class
+ required: false
+ onap.datatypes.native.apex.Environment:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ description: The name of the environment variable
+ required: true
+ value:
+ type: string
+ description: The value of the environment variable
+ required: true
+ onap.datatypes.native.apex.engineservice.Engine:
+ derived_from: tosca.datatypes.Root
+ properties:
+ context:
+ type: onap.datatypes.native.apex.engineservice.engine.Context
+ description: The properties for handling context in APEX engines, defaults to using Java maps for context
+ required: false
+ executors:
+ type: map
+ description: The plugins for policy executors used in engines such as javascript, MVEL, Jython
+ required: true
+ entry_schema:
+ description: The plugin class path for this policy executor
+ type: string
+ onap.datatypes.native.apex.engineservice.engine.Context:
+ derived_from: tosca.datatypes.Root
+ properties:
+ distributor:
+ type: onap.datatypes.native.apex.Plugin
+ description: The plugin to be used for distributing context between APEX PDPs at runtime
+ required: false
+ schemas:
+ type: map
+ description: The plugins for context schemas available in APEX PDPs such as Java and Avro
+ required: false
+ entry_schema:
+ type: onap.datatypes.native.apex.Plugin
+ locking:
+ type: onap.datatypes.native.apex.Plugin
+ description: The plugin to be used for locking context in and between APEX PDPs at runtime
+ required: false
+ persistence:
+ type: onap.datatypes.native.apex.Plugin
+ description: The plugin to be used for persisting context for APEX PDPs at runtime
+ required: false
+ onap.datatypes.native.apex.Plugin:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ description: The name of the executor such as Javascript, Jython or MVEL
+ required: true
+ plugin_class_name:
+ type: string
+ description: The class path of the plugin class for this executor
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Drools.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Drools.yaml
new file mode 100644
index 000000000..0ae96dbc2
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Drools.yaml
@@ -0,0 +1,118 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Native:
+ derived_from: tosca.policies.Root
+ description: a base policy type for all native PDP policies
+ version: 1.0.0
+ name: onap.policies.Native
+ onap.policies.native.Drools:
+ derived_from: onap.policies.Native
+ description: a base policy type for all native PDP policies
+ version: 1.0.0
+ name: onap.policies.native.Drools
+ onap.policies.native.drools.Controller:
+ derived_from: onap.policies.native.Drools
+ description: a policy type for a drools controller configuration
+ version: 1.0.0
+ name: onap.policies.native.drools.Controller
+ properties:
+ controllerName:
+ type: string
+ required: true
+ description: the drools controller name
+ sourceTopics:
+ type: list
+ required: false
+ description: source topics and applicable events
+ entry_schema:
+ type: onap.datatypes.dmaap.topic
+ sinkTopics:
+ type: list
+ required: false
+ description: sink topics and applicable events
+ entry_schema:
+ type: onap.datatypes.dmaap.topic
+ customConfig:
+ type: map
+ required: false
+ description: any use case specific configurations relevant to the drools controller
+ entry_schema:
+ type: string
+ onap.policies.native.drools.Artifact:
+ derived_from: onap.policies.native.Drools
+ description: a policy type for native drools artifact policies
+ version: 1.0.0
+ name: onap.policies.native.drools.Artifact
+ properties:
+ rulesArtifact:
+ type: onap.datatypes.native.rules_artifact
+ required: true
+ description: the GAV information of the maven artifact
+ controller:
+ type: onap.datatypes.drools.controller.relation
+ required: true
+ description: the drools controller to which the current native policy is assigned
+
+data_types:
+ onap.datatypes.dmaap.topic:
+ derived_from: tosca.datatypes.Root
+ properties:
+ topicName:
+ type: string
+ required: true
+ description: the dmaap topic name
+ events:
+ type: list
+ required: true
+ description: events used by this topic
+ entry_schema:
+ type: onap.datatypes.dmaap.events
+ onap.datatypes.dmaap.events:
+ derived_from: tosca.datatypes.Root
+ properties:
+ eventClass:
+ type: string
+ required: true
+ description: the event canonical class for serialization
+ eventFilter:
+ type: string
+ required: false
+ description: the JSONPath based condition to filter out the events to serialize
+ customSerialization:
+ type: onap.datatypes.dmaap.custom_serialization
+ required: false
+ description: overrides the default serialization/deserialization mechanisms with custom ones
+ onap.datatypes.dmaap.custom_serialization:
+ derived_from: tosca.datatypes.Root
+ properties:
+ customSerializerClass:
+ type: string
+ required: true
+ description: the class that contains the JSON parser serializer/deserializer.
+ jsonParser:
+ type: string
+ required: true
+ description: static field in customSerialized class with the json parser (currently only gson supported)
+ onap.datatypes.native.rules_artifact:
+ derived_from: tosca.datatypes.Root
+ properties:
+ groupId:
+ type: string
+ required: true
+ description: the groupId of the maven artifact
+ artifactId:
+ type: string
+ required: true
+ description: the artifactId of the maven artifact
+ version:
+ type: string
+ required: true
+ description: the version of the maven artifact
+ onap.datatypes.drools.controller.relation:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ required: true
+ description: the name of drools controller policy
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Xacml.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Xacml.yaml
new file mode 100644
index 000000000..eb25cdb91
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Xacml.yaml
@@ -0,0 +1,20 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.Native:
+ derived_from: tosca.policies.Root
+ description: a base policy type for all native PDP policies
+ version: 1.0.0
+ name: onap.policies.Native
+ onap.policies.native.Xacml:
+ derived_from: onap.policies.Native
+ description: a policy type for native xacml policies
+ version: 1.0.0
+ name: onap.policies.native.Xacml
+ properties:
+ policy:
+ type: string
+ required: true
+ description: The XML XACML 3.0 PolicySet or Policy
+ metadata:
+ encoding: Base64
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Resource.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Resource.yaml
new file mode 100644
index 000000000..6b3a2460d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Resource.yaml
@@ -0,0 +1,25 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.Resource:
+ derived_from: onap.policies.Optimization
+ version: 1.0.0
+ name: onap.policies.optimization.Resource
+ description: The base policy type for all policies that govern optimization for a Resource in a Service.
+ properties:
+ services:
+ description: One or more services that the policy applies to.
+ type: list
+ metadata:
+ matchable: true
+ required: true
+ entry_schema:
+ type: string
+ resources:
+ description: One or more VNF resources that the policy applies to.
+ type: list
+ metadata:
+ matchable: true
+ required: true
+ entry_schema:
+ type: string
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Service.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Service.yaml
new file mode 100644
index 000000000..8b37a67e7
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Service.yaml
@@ -0,0 +1,17 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.Service:
+ derived_from: onap.policies.Optimization
+ version: 1.0.0
+ name: onap.policies.optimization.Service
+ description: The base policy type for all policies that govern optimization for a Service.
+ properties:
+ services:
+ description: One or more services that the policy applies to.
+ type: list
+ metadata:
+ matchable: true
+ required: true
+ entry_schema:
+ type: string
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml
new file mode 100644
index 000000000..bb6adb0aa
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml
@@ -0,0 +1,33 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.resource.AffinityPolicy:
+ derived_from: onap.policies.optimization.Resource
+ version: 1.0.0
+ name: onap.policies.optimization.resource.AffinityPolicy
+ properties:
+ applicableResources:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - any
+ - all
+ affinityProperties:
+ type: policy.data.affinityProperties_properties
+ required: true
+data_types:
+ policy.data.affinityProperties_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ qualifier:
+ type: string
+ constraints:
+ - valid_values:
+ - same
+ - different
+ category:
+ type: string
+ required: true
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml
new file mode 100644
index 000000000..f41dcfd6f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml
@@ -0,0 +1,58 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.resource.DistancePolicy:
+ derived_from: onap.policies.optimization.Resource
+ version: 1.0.0
+ name: onap.policies.optimization.resource.DistancePolicy
+ properties:
+ applicableResources:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - any
+ - all
+ distanceProperties:
+ type: policy.data.distanceProperties_properties
+ required: true
+data_types:
+ policy.data.distanceProperties_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ locationInfo:
+ type: string
+ required: true
+ distance:
+ type: policy.data.distance_properties
+ required: true
+ entry_schema:
+ type: policy.data.distance_properties
+ policy.data.distance_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ value:
+ type: string
+ required: true
+ operator:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - <
+ - <=
+ - '>'
+ - '>='
+ - =
+ unit:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - km
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml
new file mode 100644
index 000000000..dfe30774b
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml
@@ -0,0 +1,105 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.resource.HpaPolicy:
+ derived_from: onap.policies.optimization.Resource
+ version: 1.0.0
+ name: onap.policies.optimization.resource.HpaPolicy
+ properties:
+ flavorFeatures:
+ type: list
+ required: true
+ entry_schema:
+ type: policy.data.flavorFeatures_properties
+data_types:
+ policy.data.flavorFeatures_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ id:
+ type: string
+ required: true
+ type:
+ type: string
+ required: true
+ directives:
+ type: list
+ required: true
+ entry_schema:
+ type: policy.data.directives_properties
+ flavorProperties:
+ type: list
+ required: true
+ entry_schema:
+ type: policy.data.flavorProperties_properties
+ policy.data.directives_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ type:
+ type: string
+ attributes:
+ type: list
+ entry_schema:
+ type: policy.data.directives_attributes_properties
+ policy.data.directives_attributes_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ attribute_name:
+ type: string
+ attribute_value:
+ type: string
+ policy.data.flavorProperties_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ hpa-feature:
+ type: string
+ required: true
+ mandatory:
+ type: string
+ required: true
+ score:
+ type: string
+ required: false
+ architecture:
+ type: string
+ required: true
+ hpa-version:
+ type: string
+ required: true
+ directives:
+ type: list
+ required: true
+ entry_schema:
+ type: policy.data.directives_properties
+ hpa-feature-attributes:
+ type: list
+ required: true
+ entry_schema:
+ type: policy.data.hpa-feature-attributes_properties
+ policy.data.hpa-feature-attributes_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ hpa-attribute-key:
+ type: string
+ required: true
+ hpa-attribute-value:
+ type: string
+ required: true
+ operator:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - <
+ - <=
+ - '>'
+ - '>='
+ - =
+ - '!='
+ - any
+ - all
+ - subset
+ unit:
+ type: string
+ required: false
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml
new file mode 100644
index 000000000..b0f77d67e
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml
@@ -0,0 +1,68 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.resource.OptimizationPolicy:
+ derived_from: onap.policies.optimization.Resource
+ version: 1.0.0
+ name: onap.policies.optimization.resource.OptimizationPolicy
+ properties:
+ objective:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - minimize
+ - maximize
+ objectiveParameter:
+ type: policy.data.objectiveParameter_properties
+ required: true
+data_types:
+ policy.data.objectiveParameter_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ parameterAttributes:
+ type: list
+ required: true
+ entry_schema:
+ type: policy.data.parameterAttributes_properties
+ operator:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - '*'
+ - +
+ - '-'
+ - /
+ - '%'
+ policy.data.parameterAttributes_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ resources:
+ type: string
+ required: true
+ customerLocationInfo:
+ type: string
+ required: true
+ parameter:
+ type: string
+ required: true
+ weight:
+ type: string
+ required: true
+ operator:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - '*'
+ - +
+ - '-'
+ - /
+ - '%'
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml
new file mode 100644
index 000000000..e636582df
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml
@@ -0,0 +1,32 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.resource.PciPolicy:
+ derived_from: onap.policies.optimization.Resource
+ version: 1.0.0
+ name: onap.policies.optimization.resource.PciPolicy
+ properties:
+ pciProperties:
+ type: list
+ required: false
+ entry_schema:
+ type: policy.data.pciProperties_properties
+data_types:
+ policy.data.pciProperties_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ algoCategory:
+ type: string
+ required: false
+ pciOptmizationAlgoName:
+ type: string
+ required: false
+ pciOptimizationNwConstraint:
+ type: string
+ required: false
+ pciOptimizationPriority:
+ type: string
+ required: false
+ pciOptimizationTimeConstraint:
+ type: string
+ required: false
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml
new file mode 100644
index 000000000..cb387dda1
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml
@@ -0,0 +1,30 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.resource.Vim_fit:
+ derived_from: onap.policies.optimization.Resource
+ version: 1.0.0
+ name: onap.policies.optimization.resource.Vim_fit
+ properties:
+ applicableResources:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - any
+ - all
+ capacityProperties:
+ type: policy.data.capacityProperties_properties
+ required: true
+data_types:
+ policy.data.capacityProperties_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ controller:
+ type: string
+ required: true
+ request:
+ type: string
+ required: true
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml
new file mode 100644
index 000000000..30b8b7212
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml
@@ -0,0 +1,46 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.resource.VnfPolicy:
+ derived_from: onap.policies.optimization.Resource
+ version: 1.0.0
+ name: onap.policies.optimization.resource.VnfPolicy
+ properties:
+ applicableResources:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - any
+ - all
+ vnfProperties:
+ type: list
+ required: true
+ entry_schema:
+ type: policy.data.vnfProperties_properties
+data_types:
+ policy.data.vnfProperties_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ inventoryProvider:
+ type: string
+ required: true
+ serviceType:
+ type: string
+ required: true
+ inventoryType:
+ type: list
+ required: true
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - serviceInstanceId
+ - vnfName
+ - cloudRegionId
+ - vimId
+ customerId:
+ type: string
+ required: true
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml
new file mode 100644
index 000000000..2ff263b24
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml
@@ -0,0 +1,26 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.service.QueryPolicy:
+ derived_from: onap.policies.optimization.Service
+ version: 1.0.0
+ name: onap.policies.optimization.service.QueryPolicy
+ properties:
+ queryProperties:
+ type: list
+ required: true
+ entry_schema:
+ type: policy.data.queryProperties_properties
+data_types:
+ policy.data.queryProperties_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ attribute:
+ type: string
+ required: true
+ value:
+ type: string
+ required: true
+ attribute_location:
+ type: string
+ required: true
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml
new file mode 100644
index 000000000..81dea2c3c
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml
@@ -0,0 +1,36 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.optimization.service.SubscriberPolicy:
+ derived_from: onap.policies.optimization.Service
+ version: 1.0.0
+ name: onap.policies.optimization.service.SubscriberPolicy
+ properties:
+ subscriberProperties:
+ type: policy.data.subscriberProperties_properties
+ required: true
+data_types:
+ policy.data.subscriberProperties_properties:
+ derived_from: tosca.nodes.Root
+ properties:
+ subscriberName:
+ type: list
+ required: true
+ metadata:
+ contextProvider: true
+ entry_schema:
+ type: string
+ subscriberRole:
+ type: list
+ required: true
+ metadata:
+ contextMatchable: scope
+ entry_schema:
+ type: string
+ provStatus:
+ type: list
+ required: true
+ metadata:
+ contextAttribute: true
+ entry_schema:
+ type: string
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_control_loop_tosca.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_control_loop_tosca.yaml
new file mode 100644
index 000000000..7d92a0884
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_control_loop_tosca.yaml
@@ -0,0 +1,614 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+policy_types:
+ onap.policies.Monitoring:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ name: onap.policies.Monitoring
+ description: a base policy type for all policies that govern monitoring provisioning
+ onap.policies.monitoring.dcae-pm-subscription-handler:
+ derived_from: onap.policies.Monitoring
+ version: 1.0.0
+ properties:
+ subscription:
+ type: map
+ description: PM Subscription Handler Subscription
+ entry_schema:
+ type: onap.datatypes.monitoring.subscription
+data_types:
+ onap.datatypes.monitoring.subscription:
+ derived_from: tosca.datatypes.Root
+ properties:
+ subscriptionName:
+ type: string
+ description: Name of the subscription
+ required: true
+ administrativeState:
+ type: string
+ description: State of the subscription
+ required: true
+ constraints:
+ - valid_values:
+ - LOCKED
+ - UNLOCKED
+ fileBasedGP:
+ type: integer
+ description: File based granularity period
+ required: true
+ fileLocation:
+ type: string
+ description: ROP file location
+ required: true
+ nfTypeModelInvariantId:
+ type: string
+ description: Network function invariant ID
+ required: true
+ nfFilter:
+ type: map
+ description: Network function filter
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.nfFilter
+ measurementGroups:
+ type: list
+ description: Measurement Groups
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementGroups
+ onap.datatypes.monitoring.nfFilter:
+ derived_from: tosca.datatypes.Root
+ properties:
+ nfNames:
+ type: list
+ description: List of network functions
+ required: true
+ #default: []
+ entry_schema:
+ type: string
+ swVersions:
+ type: list
+ description: List of software versions
+ required: true
+ #default: []
+ entry_schema:
+ type: string
+ onap.datatypes.monitoring.measurementGroups:
+ derived_from: tosca.datatypes.Root
+ properties:
+ measurementGroup:
+ type: map
+ description: Measurement Group
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementGroup
+ onap.datatypes.monitoring.measurementGroup:
+ derived_from: tosca.datatypes.Root
+ properties:
+ measurementTypes:
+ type: list
+ description: List of measurement types
+ required: true
+ #default: []
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementTypes
+ managedObjectDNsBasic:
+ type: list
+ description: List of managed object distinguished names
+ required: true
+ #default: []
+ entry_schema:
+ type: onap.datatypes.monitoring.managedObjectDNsBasics
+ onap.datatypes.monitoring.measurementTypes:
+ derived_from: tosca.datatypes.Root
+ properties:
+ measurementType:
+ type: map
+ description: Measurement type object
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.measurementType
+ onap.datatypes.monitoring.measurementType:
+ derived_from: tosca.datatypes.Root
+ properties:
+ measurementType:
+ type: string
+ description: Measurement type
+ required: true
+ onap.datatypes.monitoring.managedObjectDNsBasics:
+ derived_from: tosca.datatypes.Root
+ properties:
+ managedObjectDNsBasic:
+ type: map
+ description: Managed object distinguished name object
+ required: true
+ entry_schema:
+ type: onap.datatypes.monitoring.managedObjectDNsBasic
+ onap.datatypes.monitoring.managedObjectDNsBasic:
+ derived_from: tosca.datatypes.Root
+ properties:
+ DN:
+ type: string
+ description: Managed object distinguished name
+ required: true
+capability_types:
+ org.onap.EventProducer:
+ properties:
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ event_format:
+ type: string
+ required: true
+ event_format_version:
+ type: string
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+ org.onap.EventConsumer:
+ properties:
+ responding_capability:
+ type: string
+ required: false
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ - all valid values should be added here
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured,
+ etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+node_types:
+ org.onap.DynamicConfig:
+ properties:
+ application_name:
+ type: string
+ description: Value used to tie the config to an application ? should we be
+ using a relationship here instead?
+ required: true
+ application_version:
+ type: string
+ required: true
+ application_provider:
+ type: string
+ required: false
+ data_types:
+ type: object
+ required: false
+ schema:
+ type: object
+ required: false
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.APP:
+ properties:
+ application_name:
+ type: string
+ description: Human readable name for the application Product
+ required: false
+ provider:
+ type: string
+ description: Provider of the application and of the descriptor
+ required: true
+ application_version:
+ type: string
+ description: Software version of the application
+ required: true
+ blueprint_id:
+ type: string
+ description: A reference to the app blueprint
+ required: false
+ monitoring_policy:
+ type: string
+ description: A reference to the monitoring policy
+ required: false
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.EventRelay:
+ properties:
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: true
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key is relayed
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ supported_carrier_protocols:
+ type: map
+ description: 'A map describing supported carrier protocols and translations.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ supported_data_formats:
+ type: map
+ description: 'Is a map describing supported data formats and translation.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+relationship_types:
+ org.onap.PropagateEvent:
+ properties:
+ config_keys:
+ type: list
+ description: The relationship type used on requirements to org.onap.EventProducer
+ and org.onap.EventConsumer capabilities. Filters events by specific config_keys
+ to be transferred by this relationship. That is, any event with a specific
+ config_key found in the list is transferred. If list is not defined or is
+ empty, events with all config_keys are transferred.
+ required: false
+ entry_schema:
+ type: string
+ version: 0.0.1
+ derived_from: tosca.relationships.Root
+topology_template:
+ inputs:
+ pm_subscription_topic:
+ type: string
+ pm_subscription_response_topic:
+ type: string
+ pm_subscription_handler_blueprint_id:
+ type: string
+ pm_subscription_operational_policy_id:
+ type: string
+ pm_subscription_cds_blueprint_id:
+ type: string
+ enable_tls:
+ type: string
+ node_templates:
+ org.onap.PM_Subscription_Handler:
+ type: org.onap.APP
+ type_version: 0.0.0
+ properties:
+ application_name: PM Subscription Handler
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_handler_blueprint_id
+ description: Is this a reference to the DCAE Cloudify Blueprint that is
+ already stored(or will be stored before CL configuration & instatiation)
+ in DCAE Inventory?
+ artifact_config:
+ enable_tls:
+ get_input: enable_tls
+ pmsh_publish_topic_name:
+ get_input: pm_subscription_topic
+ capabilities:
+ pm-subscription-event-publisher:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-format
+ event_format_version: 1.0.0
+ attributes:
+ type: org.onap.EventProducer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ pm-subscription-event-receiver:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ relationships:
+ - type: tosca.relationships.DependsOn
+ - description: any ideas on a better realtionship ? or is it better to
+ just use the root realtionship ?
+ - target: org.onap.PM_Monitoring_Policy
+ attributes:
+ type: org.onap.EventConsumer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_Monitoring_Policy:
+ type: org.onap.DynamicConfig
+ type_version: 0.0.0
+ properties:
+ application_name: PM Subscription Handler
+ application_version: 1.0.0
+ provider: Ericsson
+ data_types:
+ measurementType:
+ type: string
+ DN:
+ type: string
+ nfFilter:
+ properties:
+ nfNames:
+ type: list
+ entry_schema: string
+ modelInvariantIDs:
+ type: list
+ entry_schema:
+ type: string
+ modelVersionIDs:
+ type: list
+ entry_schema:
+ type: string
+ measurementGroup:
+ properties:
+ masurementTypes:
+ type: list
+ entry_schema:
+ type: measurementType
+ managedObjectDNsBasic:
+ type: list
+ entry_schema:
+ type: DN
+ schema:
+ subscription:
+ subscriptionName:
+ type: string
+ required: true
+ administrativeState:
+ type: string
+ required: true
+ filebasedGP:
+ type: integer
+ required: true
+ fileLocation:
+ type: string
+ required: true
+ nfFilter:
+ type: nfFilter
+ measurementGroups:
+ type: list
+ entry_schema:
+ type: measurementGroup
+ version: 0.0.0
+ description: Should I be showing a dependency between PM Subscription Handler
+ and the PM Monitoring Policy
+ org.onap.PM_Policy:
+ type: org.onap.APP
+ type_version: 0.0.0
+ properties:
+ application_name: PM Subscription Operational Policy
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_operational_policy_id
+ artifact_config: NOT_DEFINED
+ requirements:
+ - receive_0:
+ capability: pm-subscription-event-publisher
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_topic
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ - send_0:
+ capability: cds-rest-receive
+ node: org.onap.CDS
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ - receive_1:
+ capability: cds-rest-response
+ node: org.onap.CDS
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ - send_1:
+ capability: pm-subscription-event-receiver
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_response_topic
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ capabilities:
+ pm-subscription-response-event-publisher:
+ properties:
+ type: org.onap.EventProducer
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_CDS_Blueprint:
+ type: org.onap.APP
+ type_version: 0.0.0
+ properties:
+ application_name: PM Subscription CDS Blueprint
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_cds_blueprint_id
+ capabilities:
+ cds-rest-receive:
+ properties:
+ type: org.onap.EventConsumer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_format
+ event_format_version: 1.0.0
+ responding_capability: cds-rest-response
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ cds-rest-response:
+ properties:
+ type: org.onap.EventProducer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_response_format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ type: string
+ type_version: 0.0.0
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.controlloop0:
+ type: org.onap.APP
+ type_version: 0.0.0
+ properties:
+ application_name: Test Control Loop
+ provider: Ericsson
+ application_version: 1.0.0
+ status: NOT_DEPLOYED
+ version: 0.0.0
+version: 0.0.0
+
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameterHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameterHandler.java
new file mode 100644
index 000000000..42f458602
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameterHandler.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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.simulator.main.parameters;
+
+import java.io.File;
+import javax.ws.rs.core.Response;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.startstop.ParticipantSimulatorCommandLineArguments;
+import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+
+/**
+ * This class handles reading, parsing and validating of participant simulator parameters from JSON files.
+ */
+public class ParticipantSimulatorParameterHandler {
+
+ private static final Coder CODER = new StandardCoder();
+
+ /**
+ * Read the parameters from the parameter file.
+ *
+ * @param arguments the arguments passed to simulator
+ * @return the parameters read from the configuration file
+ * @throws ControlLoopException on parameter exceptions
+ */
+ public ParticipantSimulatorParameters getParameters(final ParticipantSimulatorCommandLineArguments arguments)
+ throws ControlLoopException {
+ ParticipantSimulatorParameters parameters = null;
+
+ // Read the parameters
+ try {
+ // Read the parameters from JSON
+ File file = new File(arguments.getFullConfigurationFilePath());
+ parameters = CODER.decode(file, ParticipantSimulatorParameters.class);
+ } catch (final CoderException e) {
+ final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
+ + "\"\n" + "(" + e.getClass().getSimpleName() + ")";
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage, e);
+ }
+
+ // The JSON processing returns null if there is an empty file
+ if (parameters == null) {
+ final String errorMessage = "no parameters found in \"" + arguments.getConfigurationFilePath() + "\"";
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage);
+ }
+
+ // validate the parameters
+ final ValidationResult validationResult = parameters.validate();
+ if (!validationResult.isValid()) {
+ String returnMessage =
+ "validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
+ returnMessage += validationResult.getResult();
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, returnMessage);
+ }
+
+ return parameters;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java
new file mode 100644
index 000000000..a4e62b446
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java
@@ -0,0 +1,51 @@
+/*-
+ * ============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.simulator.main.parameters;
+
+import javax.validation.constraints.NotBlank;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+
+/**
+ * Class to hold all parameters needed for the participant simulator.
+ *
+ */
+@NotNull
+@NotBlank
+@Getter
+public class ParticipantSimulatorParameters extends ParameterGroupImpl {
+ private RestServerParameters restServerParameters;
+ private ParticipantIntermediaryParameters intermediaryParameters;
+ private PolicyModelsProviderParameters databaseProviderParameters;
+
+ /**
+ * Create the participant simulator parameter group.
+ *
+ * @param name the parameter group name
+ */
+ public ParticipantSimulatorParameters(final String name) {
+ super(name);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java
new file mode 100644
index 000000000..f200f975a
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.simulator.main.rest;
+
+import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter;
+import org.onap.policy.common.utils.resources.MessageConstants;
+
+/**
+ * Class to manage AAF filters for the participant simulator component.
+ */
+public class ParticipantSimulatorAafFilter extends AafGranularAuthFilter {
+
+ public static final String AAF_NODETYPE = MessageConstants.POLICY_CLAMP + "-participant-simulator";
+ public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE;
+
+ @Override
+ public String getPermissionTypeRoot() {
+ return AAF_ROOT_PERMISSION;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RestController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RestController.java
new file mode 100644
index 000000000..444f37889
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RestController.java
@@ -0,0 +1,130 @@
+/*-
+ * ============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.simulator.main.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.BasicAuthDefinition;
+import io.swagger.annotations.Info;
+import io.swagger.annotations.SecurityDefinition;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
+import java.net.HttpURLConnection;
+import java.util.UUID;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import lombok.AccessLevel;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationHandler;
+import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationProvider;
+
+/**
+ * Common superclass to provide REST endpoints for the participant simulator.
+ */
+// @formatter:off
+@Path("/onap/participantsim/v2")
+@Api(value = "Participant Simulator API")
+@Produces({MediaType.APPLICATION_JSON, RestController.APPLICATION_YAML})
+@SwaggerDefinition(
+ info = @Info(description =
+ "Participant Simulator", version = "v1.0",
+ title = "Participant Simulator"),
+ consumes = {MediaType.APPLICATION_JSON, RestController.APPLICATION_YAML},
+ produces = {MediaType.APPLICATION_JSON, RestController.APPLICATION_YAML},
+ schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
+ tags = {@Tag(name = "participantsim", description = "Participant Simulator")},
+ securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
+// @formatter:on
+public class RestController {
+ public static final String APPLICATION_YAML = "application/yaml";
+
+ public static final String EXTENSION_NAME = "interface info";
+
+ public static final String API_VERSION_NAME = "api-version";
+ public static final String API_VERSION = "1.0.0";
+
+ public static final String LAST_MOD_NAME = "last-mod-release";
+ public static final String LAST_MOD_RELEASE = "Dublin";
+
+ public static final String VERSION_MINOR_NAME = "X-MinorVersion";
+ public static final String VERSION_MINOR_DESCRIPTION =
+ "Used to request or communicate a MINOR version back from the client"
+ + " to the server, and from the server back to the client";
+
+ public static final String VERSION_PATCH_NAME = "X-PatchVersion";
+ public static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for"
+ + " troubleshooting purposes only, and will not be provided by" + " the client on request";
+
+ public static final String VERSION_LATEST_NAME = "X-LatestVersion";
+ public static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version";
+
+ public static final String REQUEST_ID_NAME = "X-ONAP-RequestID";
+ public static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose";
+ public static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction";
+
+ public static final String AUTHORIZATION_TYPE = "basicAuth";
+
+ public static final int AUTHENTICATION_ERROR_CODE = HttpURLConnection.HTTP_UNAUTHORIZED;
+ public static final int AUTHORIZATION_ERROR_CODE = HttpURLConnection.HTTP_FORBIDDEN;
+ public static final int SERVER_ERROR_CODE = HttpURLConnection.HTTP_INTERNAL_ERROR;
+
+ public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error";
+ public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error";
+ public static final String SERVER_ERROR_MESSAGE = "Internal Server Error";
+ @Getter(AccessLevel.PROTECTED)
+ // The provider for simulation requests
+ private SimulationProvider simulationProvider;
+
+
+ /**
+ * create a Rest Controller.
+ */
+ public RestController() {
+ simulationProvider = SimulationHandler.getInstance().getSimulationProvider();
+ }
+
+ /**
+ * Adds version headers to the response.
+ *
+ * @param respBuilder response builder
+ * @return the response builder, with version headers
+ */
+ public ResponseBuilder addVersionControlHeaders(ResponseBuilder respBuilder) {
+ return respBuilder.header(VERSION_MINOR_NAME, "0").header(VERSION_PATCH_NAME, "0").header(VERSION_LATEST_NAME,
+ API_VERSION);
+ }
+
+ /**
+ * Adds logging headers to the response.
+ *
+ * @param respBuilder response builder
+ * @return the response builder, with version logging
+ */
+ public ResponseBuilder addLoggingHeaders(ResponseBuilder respBuilder, UUID requestId) {
+ if (requestId == null) {
+ // Generate a random uuid if client does not embed requestId in rest request
+ return respBuilder.header(REQUEST_ID_NAME, UUID.randomUUID());
+ }
+
+ return respBuilder.header(REQUEST_ID_NAME, requestId);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/Main.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/Main.java
new file mode 100644
index 000000000..e6c93d55d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/Main.java
@@ -0,0 +1,141 @@
+/*-
+ * ============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.simulator.main.startstop;
+
+import java.util.Arrays;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameterHandler;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameters;
+import org.onap.policy.common.utils.resources.MessageConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class initiates participant simulator.
+ */
+public class Main {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
+
+ private ParticipantSimulatorActivator activator;
+
+ @Getter
+ private ParticipantSimulatorParameters parameterGroup;
+
+ /**
+ * Instantiates the control loop participant service.
+ *
+ * @param args the command line arguments
+ */
+ public Main(final String[] args) {
+ final String argumentString = Arrays.toString(args);
+ LOGGER.info("Starting the participant service with arguments - {}", argumentString);
+
+ // Check the arguments
+ final ParticipantSimulatorCommandLineArguments arguments = new ParticipantSimulatorCommandLineArguments();
+ try {
+ // The arguments return a string if there is a message to print and we should exit
+ final String argumentMessage = arguments.parse(args);
+ if (argumentMessage != null) {
+ LOGGER.info(argumentMessage);
+ return;
+ }
+ // Validate that the arguments are sane
+ arguments.validate();
+
+ // Read the parameters
+ parameterGroup = new ParticipantSimulatorParameterHandler().getParameters(arguments);
+
+ // Now, create the activator for the service
+ activator = new ParticipantSimulatorActivator(parameterGroup);
+
+ // Start the activator
+ activator.start();
+ } catch (Exception exp) {
+ throw new ControlLoopRuntimeException(Response.Status.BAD_REQUEST,
+ String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP), exp);
+ }
+
+ // Add a shutdown hook to shut everything down in an orderly manner
+ Runtime.getRuntime().addShutdownHook(new ClParticipantSimulatorShutdownHookClass());
+ String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_CLAMP);
+ LOGGER.info(successMsg);
+ }
+
+ /**
+ * Check if main is running.
+ */
+ public boolean isRunning() {
+ return activator != null && activator.isAlive();
+ }
+
+ /**
+ * Shut down Execution.
+ *
+ * @throws ControlLoopException on shutdown errors
+ */
+ public void shutdown() throws ControlLoopException {
+ // clear the parameterGroup variable
+ parameterGroup = null;
+
+ // clear the cl participant activator
+ if (activator != null) {
+ activator.stop();
+ }
+ }
+
+ /**
+ * The Class ClParticipantSimulatorShutdownHookClass terminates the control loop participant service
+ * when its run method is called.
+ */
+ private class ClParticipantSimulatorShutdownHookClass extends Thread {
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ try {
+ // Shutdown the participant simulator and wait for everything to stop
+ shutdown();
+ } catch (final RuntimeException | ControlLoopException e) {
+ LOGGER.warn("error occured during shut down of the participant simulator", e);
+ }
+ }
+ }
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(final String[] args) { // NOSONAR
+ /*
+ * NOTE: arguments are validated by the constructor, thus sonar is disabled.
+ */
+
+ new Main(args);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/ParticipantSimulatorActivator.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/ParticipantSimulatorActivator.java
new file mode 100644
index 000000000..4daa0393f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/ParticipantSimulatorActivator.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.simulator.main.startstop;
+
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameters;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.ParticipantSimulatorAafFilter;
+import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationHandler;
+import org.onap.policy.common.endpoints.http.server.RestServer;
+import org.onap.policy.common.utils.services.ServiceManagerContainer;
+
+/**
+ * This class activates the participant simulator component as a complete service together with all its controllers,
+ * listeners and handlers.
+ */
+public class ParticipantSimulatorActivator extends ServiceManagerContainer {
+ @Getter
+ private final ParticipantSimulatorParameters parameters;
+
+ /**
+ * Instantiate the activator for the simulator as a complete service.
+ *
+ * @param parameters the parameters for the participant service
+ */
+ public ParticipantSimulatorActivator(final ParticipantSimulatorParameters parameters) {
+ this.parameters = parameters;
+
+ final AtomicReference<SimulationHandler> simulationHandler = new AtomicReference<>();
+ final AtomicReference<RestServer> restServer = new AtomicReference<>();
+
+ // @formatter:off
+ addAction("Simulation Handler",
+ () -> simulationHandler.set(new SimulationHandler(parameters)),
+ () -> simulationHandler.get().close());
+
+ addAction("Simulation Providers",
+ () -> simulationHandler.get().startProviders(),
+ () -> simulationHandler.get().stopProviders());
+
+ parameters.getRestServerParameters().setName(parameters.getName());
+
+ addAction("REST server",
+ () -> {
+ Set<Class<?>> providerClasses = simulationHandler.get().getProviderClasses();
+
+ RestServer server = new RestServer(parameters.getRestServerParameters(),
+ ParticipantSimulatorAafFilter.class,
+ providerClasses.toArray(new Class<?>[providerClasses.size()]));
+ restServer.set(server);
+ restServer.get().start();
+ },
+ () -> restServer.get().stop());
+ // @formatter:on
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/ParticipantSimulatorCommandLineArguments.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/ParticipantSimulatorCommandLineArguments.java
new file mode 100644
index 000000000..51ac3a4d5
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/ParticipantSimulatorCommandLineArguments.java
@@ -0,0 +1,151 @@
+/*-
+ * ============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.simulator.main.startstop;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Arrays;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.common.startstop.CommonCommandLineArguments;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+
+/**
+ * This class reads and handles command line parameters for the participant simulator service.
+ *
+ */
+public class ParticipantSimulatorCommandLineArguments {
+ private static final String FILE_MESSAGE_PREAMBLE = " file \"";
+ private static final int HELP_LINE_LENGTH = 120;
+
+ private final Options options;
+ private final CommonCommandLineArguments commonCommandLineArguments;
+
+ @Getter()
+ @Setter()
+ private String configurationFilePath = null;
+
+ /**
+ * Construct the options for the participant component.
+ */
+ public ParticipantSimulatorCommandLineArguments() {
+ options = new Options();
+ commonCommandLineArguments = new CommonCommandLineArguments(options);
+ }
+
+ /**
+ * Construct the options for the participant component and parse in the given arguments.
+ *
+ * @param args The command line arguments
+ */
+ public ParticipantSimulatorCommandLineArguments(final String[] args) {
+ // Set up the options with the default constructor
+ this();
+
+ // Parse the arguments
+ try {
+ parse(args);
+ } catch (final ControlLoopException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
+ "parse error on participant parameters", e);
+ }
+ }
+
+ /**
+ * Parse the command line options.
+ *
+ * @param args The command line arguments
+ * @return a string with a message for help and version, or null if there is no message
+ * @throws ControlLoopException on command argument errors
+ */
+ public String parse(final String[] args) throws ControlLoopException {
+ // Clear all our arguments
+ setConfigurationFilePath(null);
+ CommandLine commandLine = null;
+ try {
+ commandLine = new DefaultParser().parse(options, args);
+ } catch (final ParseException e) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ "invalid command line arguments specified : " + e.getMessage());
+ }
+
+ // Arguments left over after Commons CLI does its stuff
+ final String[] remainingArgs = commandLine.getArgs();
+
+ if (remainingArgs.length > 0) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ "too many command line arguments specified : " + Arrays.toString(args));
+ }
+
+ if (commandLine.hasOption('h')) {
+ return commonCommandLineArguments.help(Main.class.getName(), options);
+ }
+
+ if (commandLine.hasOption('v')) {
+ return commonCommandLineArguments.version();
+ }
+
+ if (commandLine.hasOption('c')) {
+ setConfigurationFilePath(commandLine.getOptionValue('c'));
+ }
+
+ return null;
+ }
+
+ /**
+ * Validate the command line options.
+ *
+ * @throws ControlLoopException on command argument validation errors
+ */
+ public void validate() throws ControlLoopException {
+ commonCommandLineArguments.validate(configurationFilePath);
+ }
+
+ /**
+ * Gets the full expanded configuration file path.
+ *
+ * @return the configuration file path
+ */
+ public String getFullConfigurationFilePath() {
+ return ResourceUtils.getFilePath4Resource(getConfigurationFilePath());
+ }
+
+ /**
+ * Check set configuration file path.
+ *
+ * @return true, if check set configuration file path
+ */
+ public boolean checkSetConfigurationFilePath() {
+ return !StringUtils.isEmpty(configurationFilePath);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationHandler.java
new file mode 100644
index 000000000..df7f2a611
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationHandler.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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.simulator.simulation;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameters;
+import org.onap.policy.clamp.controlloop.participant.simulator.simulation.rest.SimulationElementController;
+import org.onap.policy.clamp.controlloop.participant.simulator.simulation.rest.SimulationParticipantController;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.base.PfModelRuntimeException;
+
+/**
+ * This class handles simulation of participants and control loop elements.
+ *
+ * <p/>It is effectively a singleton that is started at system start.
+ */
+public class SimulationHandler extends ControlLoopHandler {
+ private final ParticipantIntermediaryParameters participantParameters;
+
+ @Getter
+ private SimulationProvider simulationProvider;
+
+ /**
+ * Create a handler.
+ *
+ * @param parameters the parameters for access to the database
+ */
+ public SimulationHandler(ParticipantSimulatorParameters parameters) {
+ super(parameters.getDatabaseProviderParameters());
+ participantParameters = parameters.getIntermediaryParameters();
+ }
+
+ public static SimulationHandler getInstance() {
+ return Registry.get(SimulationHandler.class.getName());
+ }
+
+ @Override
+ public Set<Class<?>> getProviderClasses() {
+ return Set.of(SimulationElementController.class, SimulationParticipantController.class);
+ }
+
+ @Override
+ public void startProviders() {
+ simulationProvider = new SimulationProvider(participantParameters);
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ simulationProvider.close();
+ } catch (IOException e) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "Stop providers failed ", e);
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java
new file mode 100644
index 000000000..1fcbba3af
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java
@@ -0,0 +1,129 @@
+/*-
+ * ============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.simulator.simulation;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+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.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
+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.api.ParticipantIntermediaryFactory;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+
+/**
+ * This provider class simulation of participants and control loop elements.
+ */
+public class SimulationProvider implements Closeable {
+ @Getter
+ private final ParticipantIntermediaryApi intermediaryApi;
+
+ /**
+ * Create a participant simulation provider.
+ *
+ * @throws ControlLoopRuntimeException on errors creating the provider
+ */
+ public SimulationProvider(ParticipantIntermediaryParameters participantParameters)
+ throws ControlLoopRuntimeException {
+ intermediaryApi = new ParticipantIntermediaryFactory().createApiImplementation();
+ intermediaryApi.init(participantParameters);
+ }
+
+ @Override
+ public void close() throws IOException {
+ intermediaryApi.close();
+ }
+
+ /**
+ * Get the control loops.
+ *
+ * @param name the controlLoop, null to get all
+ * @param version the controlLoop, null to get all
+ * @return the control loops
+ * @throws ControlLoopException on errors getting the control loops
+ */
+ public ControlLoops getControlLoops(String name, String version) throws ControlLoopException {
+ return intermediaryApi.getControlLoops(name, version);
+ }
+
+ /**
+ * Get the simulated control loop elements.
+ *
+ * @param name the controlLoopElement, null to get all
+ * @param version the controlLoopElement, null to get all
+ * @return the control loop elements
+ * @throws ControlLoopException on errors getting the control loop elements
+ */
+ public Map<UUID, ControlLoopElement> getControlLoopElements(String name, String version)
+ throws ControlLoopException {
+ return intermediaryApi.getControlLoopElements(name, version);
+ }
+
+ /**
+ * Update the given control loop element in the simulator.
+ *
+ * @param element the control loop element to update
+ * @return response simple response returned
+ * @throws ControlLoopException on errors updating the control loop element
+ */
+ public TypedSimpleResponse<ControlLoopElement> updateControlLoopElement(ControlLoopElement element)
+ throws ControlLoopException {
+ TypedSimpleResponse<ControlLoopElement> response = new TypedSimpleResponse<>();
+ response.setResponse(intermediaryApi.updateControlLoopElementState(
+ element.getId(), element.getOrderedState(), element.getState()));
+ return response;
+ }
+
+ /**
+ * Get the current simulated participants.
+ *
+ * @param name the participant, null to get all
+ * @param version the participant, null to get all
+ * @return the list of participants
+ * @throws ControlLoopException on errors getting the participants
+ */
+ public List<Participant> getParticipants(String name, String version) throws ControlLoopException {
+ return intermediaryApi.getParticipants(name, version);
+ }
+
+ /**
+ * Update a simulated participant.
+ *
+ * @param participant the participant to update
+ * @return TypedSimpleResponse simple response
+ * @throws ControlLoopException on errors updating the participant
+ */
+
+ public TypedSimpleResponse<Participant> updateParticipant(Participant participant) throws ControlLoopException {
+ TypedSimpleResponse<Participant> response = new TypedSimpleResponse<>();
+ response.setResponse(intermediaryApi.updateParticipantState(
+ participant.getDefinition(), participant.getParticipantState()));
+ return response;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java
new file mode 100644
index 000000000..1869047c9
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java
@@ -0,0 +1,195 @@
+/*-
+ * ============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.simulator.simulation.rest;
+
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Authorization;
+import io.swagger.annotations.Extension;
+import io.swagger.annotations.ExtensionProperty;
+import io.swagger.annotations.ResponseHeader;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse;
+import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.RestController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to provide REST end points for participant simulator to query/update details of controlLoopElements.
+ */
+public class SimulationElementController extends RestController {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SimulationElementController.class);
+
+ /**
+ * Queries details of all control loop element within the simulator.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the Control Loop element to get, null to get all
+ * @param version the version of the Control Loop element to get, null to get all
+ * @return the control loop elements
+ */
+ // @formatter:off
+ @GET
+ @Path("/elements/{name}/{version}")
+ @ApiOperation(value = "Query details of the requested simulated control loop elements",
+ notes = "Queries details of the requested simulated control loop elements, "
+ + "returning all control loop element details",
+ response = ControlLoops.class,
+ tags = {
+ "Clamp Control Loop Participant Simulator API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response elements(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control loop element name", required = true) @PathParam("name") String name,
+ @ApiParam(value = "Control loop element version", required = true) @PathParam("version") String version) {
+
+ try {
+ Map<UUID, ControlLoopElement> response = getSimulationProvider().getControlLoopElements(name, version);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (ControlLoopException cle) {
+ LOGGER.warn("get of control loop elements failed", cle);
+ SimpleResponse resp = new SimpleResponse();
+ resp.setErrorDetails(cle.getErrorResponse().getErrorMessage());
+ return addLoggingHeaders(
+ addVersionControlHeaders(Response.status(cle.getErrorResponse().getResponseCode())), requestId)
+ .entity(resp).build();
+ }
+
+ }
+
+ /**
+ * Updates a control loop element in the simulator.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param body the body of a control loop element
+ * @return a response
+ */
+ // @formatter:off
+ @PUT
+ @Path("/elements")
+ @ApiOperation(
+ value = "Updates simulated control loop elements",
+ notes = "Updates simulated control loop elements, returning the updated control loop definition IDs",
+ response = TypedSimpleResponse.class,
+ tags = {
+ "Clamp Control Loop Participant Simulator API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response update(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Body of a control loop element", required = true) ControlLoopElement body) {
+
+ try {
+ TypedSimpleResponse<ControlLoopElement> response =
+ getSimulationProvider().updateControlLoopElement(body);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (ControlLoopException cle) {
+ LOGGER.warn("update of control loop element failed", cle);
+ TypedSimpleResponse<ControlLoopElement> resp = new TypedSimpleResponse<>();
+ resp.setErrorDetails(cle.getErrorResponse().getErrorMessage());
+ return addLoggingHeaders(
+ addVersionControlHeaders(Response.status(cle.getErrorResponse().getResponseCode())), requestId)
+ .entity(resp).build();
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java
new file mode 100644
index 000000000..d6ca6d0d1
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java
@@ -0,0 +1,192 @@
+/*-
+ * ============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.simulator.simulation.rest;
+
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Authorization;
+import io.swagger.annotations.Extension;
+import io.swagger.annotations.ExtensionProperty;
+import io.swagger.annotations.ResponseHeader;
+import java.util.List;
+import java.util.UUID;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
+import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse;
+import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.RestController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to provide REST end points for participant simulator to query/update details of all participants.
+ */
+public class SimulationParticipantController extends RestController {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SimulationParticipantController.class);
+
+ /**
+ * Queries details of all participants within the simulator.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the participant to get, null to get all
+ * @param version the version of the participant to get, null to get all
+ * @return the participants
+ */
+ // @formatter:off
+ @GET
+ @Path("/participants/{name}/{version}")
+ @ApiOperation(value = "Query details of the requested simulated participants",
+ notes = "Queries details of the requested simulated participants, "
+ + "returning all participant details",
+ response = List.class,
+ tags = {
+ "Clamp Control Loop Participant Simulator API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response participants(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Participant name", required = true) @PathParam("name") String name,
+ @ApiParam(value = "Participant version", required = true) @PathParam("version") String version) {
+
+ try {
+ List<Participant> response = getSimulationProvider().getParticipants(name, version);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (ControlLoopException cle) {
+ LOGGER.warn("get of participants failed", cle);
+ SimpleResponse resp = new SimpleResponse();
+ resp.setErrorDetails(cle.getErrorResponse().getErrorMessage());
+ return addLoggingHeaders(
+ addVersionControlHeaders(Response.status(cle.getErrorResponse().getResponseCode())), requestId)
+ .entity(resp).build();
+ }
+
+ }
+
+ /**
+ * Updates a participant in the simulator.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param body the body of a participant
+ * @return a response
+ */
+ // @formatter:off
+ @PUT
+ @Path("/participants")
+ @ApiOperation(
+ value = "Updates simulated participants",
+ notes = "Updates simulated participants, returning the updated control loop definition IDs",
+ response = TypedSimpleResponse.class,
+ tags = {
+ "Clamp Control Loop Participant Simulator API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response update(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Body of a participant", required = true) Participant body) {
+
+ try {
+ TypedSimpleResponse<Participant> response = getSimulationProvider().updateParticipant(body);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (ControlLoopException cle) {
+ LOGGER.warn("update of participant failed", cle);
+ TypedSimpleResponse<Participant> resp = new TypedSimpleResponse<>();
+ resp.setErrorDetails(cle.getErrorResponse().getErrorMessage());
+ return addLoggingHeaders(
+ addVersionControlHeaders(Response.status(cle.getErrorResponse().getResponseCode())), requestId)
+ .entity(resp).build();
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/CDSParticipantConfig.json b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/CDSParticipantConfig.json
new file mode 100644
index 000000000..3eca87678
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/CDSParticipantConfig.json
@@ -0,0 +1,31 @@
+{
+ "name":"ParticipantParameterGroup",
+ "participantStatusParameters":{
+ "timeIntervalMs": 10000,
+ "description":"Participant Status",
+ "participantType":{
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version":"2.2.1"
+ },
+ "participantId":{
+ "name": "CDSParticipant0",
+ "version":"1.0.0"
+ },
+ "participantDefinition":{
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version":"3.2.1"
+ }
+ },
+ "topicParameterGroup": {
+ "topicSources" : [{
+ "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers" : [ "127.0.0.1:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers" : [ "127.0.0.1:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/DCAEParticipantConfig.json b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/DCAEParticipantConfig.json
new file mode 100644
index 000000000..e80570f93
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/DCAEParticipantConfig.json
@@ -0,0 +1,31 @@
+{
+ "name":"ParticipantParameterGroup",
+ "participantStatusParameters":{
+ "timeIntervalMs": 10000,
+ "description":"Participant Status",
+ "participantType":{
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version":"2.3.4"
+ },
+ "participantId":{
+ "name": "DCAEParticipant0",
+ "version":"1.0.0"
+ },
+ "participantDefinition":{
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version":"2.3.4"
+ }
+ },
+ "topicParameterGroup": {
+ "topicSources" : [{
+ "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers" : [ "127.0.0.1:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers" : [ "127.0.0.1:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/PolicyParticipantConfig.json b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/PolicyParticipantConfig.json
new file mode 100644
index 000000000..8c8fa33cb
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/PolicyParticipantConfig.json
@@ -0,0 +1,31 @@
+{
+ "name":"ParticipantParameterGroup",
+ "participantStatusParameters":{
+ "timeIntervalMs":10000,
+ "description":"Participant Status",
+ "participantType":{
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version":"2.3.1"
+ },
+ "participantId":{
+ "name": "PolicyParticipant0",
+ "version":"1.0.0"
+ },
+ "participantDefinition":{
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version":"2.3.1"
+ }
+ },
+ "topicParameterGroup": {
+ "topicSources" : [{
+ "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers" : [ "127.0.0.1:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers" : [ "127.0.0.1:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt b/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt
new file mode 100644
index 000000000..dbd67585f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt
@@ -0,0 +1,4 @@
+ONAP Tosca defined control loop Participant
+Version: ${project.version}
+Built (UTC): ${maven.build.timestamp}
+ONAP https://wiki.onap.org
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/intermediary/TestControlLoopUpdateListener.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/intermediary/TestControlLoopUpdateListener.java
new file mode 100644
index 000000000..a307d3457
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/intermediary/TestControlLoopUpdateListener.java
@@ -0,0 +1,91 @@
+/*-
+ * ============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.simulator.main.intermediary;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
+import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.TestListenerUtils;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.utils.coder.CoderException;
+
+/**
+ * Class to perform unit test of {@link ControlLoopUpdateListener}.
+ */
+public class TestControlLoopUpdateListener {
+ private static ControlLoopUpdateListener clUpdateListener;
+ private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
+ private static final String TOPIC = "my-topic";
+ static CommonTestData commonTestData = new CommonTestData();
+
+ /**
+ * Method for setup.
+ *
+ * @throws ParticipantException if some error occurs while starting up the participant
+ * @throws FileNotFoundException if the file is missing
+ * @throws IOException if IO exception occurs
+ */
+ @BeforeClass
+ public static void setUp() throws ControlLoopException, FileNotFoundException, IOException {
+ TestListenerUtils.initParticipantHandler();
+ clUpdateListener = new ControlLoopUpdateListener(TestListenerUtils.getParticipantHandler());
+ }
+
+ @Test
+ public void testControlLoopUpdateListener_ParticipantIdNoMatch() throws CoderException {
+ ParticipantControlLoopUpdate participantControlLoopUpdateMsg = prepareMsg("DummyName");
+ clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
+
+ // Verify the content in participantHandler
+ assertNotEquals(participantControlLoopUpdateMsg.getParticipantId().getName(),
+ TestListenerUtils.getParticipantHandler().getParticipantId().getName());
+ }
+
+ @Test
+ public void testControlLoopUpdateListener() throws CoderException {
+ ParticipantControlLoopUpdate participantControlLoopUpdateMsg = prepareMsg("org.onap.PM_CDS_Blueprint");
+ clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
+
+ // Verify the content in participantHandler
+ assertEquals(TestListenerUtils.getParticipantHandler().getParticipantId(),
+ participantControlLoopUpdateMsg.getParticipantId());
+ assertThat(TestListenerUtils.getParticipantHandler().getControlLoopHandler().getControlLoops()
+ .getControlLoopList()).hasSize(1);
+ }
+
+ private ParticipantControlLoopUpdate prepareMsg(final String participantName) {
+ ParticipantControlLoopUpdate participantControlLoopUpdateMsg;
+ participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg();
+ participantControlLoopUpdateMsg.getParticipantId().setName(participantName);
+ participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE);
+ return participantControlLoopUpdateMsg;
+ }
+}
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
new file mode 100644
index 000000000..0a8754256
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
@@ -0,0 +1,249 @@
+/*-
+ * ============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.simulator.main.parameters;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import javax.ws.rs.core.Response;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to hold/create all parameters for test cases.
+ */
+public class CommonTestData {
+ public static final String PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup";
+ public static final String DESCRIPTION = "Participant description";
+ public static final long TIME_INTERVAL = 2000;
+ public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
+ private static final String REST_SERVER_PASSWORD = "zb!XztG34";
+ private static final String REST_SERVER_USER = "healthcheck";
+ private static final int REST_SERVER_PORT = 6969;
+ private static final String REST_SERVER_HOST = "0.0.0.0";
+ private static final boolean REST_SERVER_HTTPS = true;
+ private static final boolean REST_SERVER_AAF = false;
+
+ public static final Coder coder = new StandardCoder();
+
+ /**
+ * Converts the contents of a map to a parameter class.
+ *
+ * @param source property map
+ * @param clazz class of object to be created from the map
+ * @return a new object represented by the map
+ */
+ public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
+ try {
+ return coder.convert(source, clazz);
+ } catch (final CoderException e) {
+ throw new RuntimeException("cannot create " + clazz.getName() + " from map", e);
+ }
+ }
+
+ /**
+ * Returns a property map for a ApexStarterParameterGroup map for test cases.
+ *
+ * @param name name of the parameters
+ *
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getParticipantParameterGroupMap(final String name) {
+ final Map<String, Object> map = new TreeMap<>();
+
+ map.put("name", name);
+ map.put("restServerParameters", getRestServerParametersMap(false));
+ map.put("intermediaryParameters", getIntermediaryParametersMap(false));
+ map.put("databaseProviderParameters", getDatabaseProviderParametersMap(false));
+ return map;
+ }
+
+ /**
+ * Returns a property map for a RestServerParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getRestServerParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ map.put("https", REST_SERVER_HTTPS);
+ map.put("aaf", REST_SERVER_AAF);
+
+ if (!isEmpty) {
+ map.put("host", REST_SERVER_HOST);
+ map.put("port", REST_SERVER_PORT);
+ map.put("userName", REST_SERVER_USER);
+ map.put("password", REST_SERVER_PASSWORD);
+ }
+
+ return map;
+ }
+
+ /**
+ * Returns a property map for a databaseProviderParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getDatabaseProviderParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("name", "PolicyProviderParameterGroup");
+ map.put("implementation", "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
+ map.put("databaseDriver", "org.h2.Driver");
+ map.put("databaseUrl", "jdbc:h2:mem:testdb");
+ map.put("databaseUser", "policy");
+ map.put("databasePassword", "P01icY");
+ map.put("persistenceUnit", "ToscaConceptTest");
+ }
+
+ return map;
+ }
+
+ /**
+ * Returns a property map for a intermediaryParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("name", "Participant parameters");
+ map.put("reportingTimeInterval", TIME_INTERVAL);
+ map.put("description", DESCRIPTION);
+ map.put("participantId", getParticipantId());
+ map.put("participantType", getParticipantId());
+ map.put("clampControlLoopTopics", getTopicParametersMap(false));
+ }
+
+ return map;
+ }
+
+ /**
+ * Returns a property map for a TopicParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("topicSources", TOPIC_PARAMS);
+ map.put("topicSinks", TOPIC_PARAMS);
+ }
+ return map;
+ }
+
+ /**
+ * Returns topic parameters for test cases.
+ *
+ * @return topic parameters
+ */
+ public static TopicParameters getTopicParams() {
+ final TopicParameters topicParams = new TopicParameters();
+ topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT");
+ topicParams.setTopicCommInfrastructure("dmaap");
+ topicParams.setServers(Arrays.asList("localhost"));
+ return topicParams;
+ }
+
+ /**
+ * Returns participantId for test cases.
+ *
+ * @return participant Id
+ */
+ public static ToscaConceptIdentifier getParticipantId() {
+ final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
+ return participantId;
+ }
+
+ /**
+ * Gets the standard participant parameters.
+ *
+ * @param port port to be inserted into the parameters
+ * @return the standard participant parameters
+ */
+ public ParticipantSimulatorParameters getParticipantParameterGroup(int port) {
+ try {
+ return coder.decode(getParticipantParameterGroupAsString(port), ParticipantSimulatorParameters.class);
+
+ } catch (CoderException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
+ "cannot read participant parameters", e);
+ }
+ }
+
+ /**
+ * Gets the standard participant parameters, as a String.
+ *
+ * @param port port to be inserted into the parameters
+ * @return the standard participant parameters
+ */
+ public static String getParticipantParameterGroupAsString(int port) {
+
+ try {
+ File file = new File(getParamFile());
+ String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
+
+ json = json.replace("${port}", String.valueOf(port));
+ json = json.replace("${dbName}", "jdbc:h2:mem:testdb");
+
+ return json;
+
+ } catch (IOException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
+ "cannot read participant parameters", e);
+
+ }
+ }
+
+ /**
+ * Gets the full path to the parameter file, which may vary depending on whether or
+ * not this is an end-to-end test.
+ *
+ * @return the parameter file name
+ */
+ private static String getParamFile() {
+ String paramFile = "src/test/resources/parameters/TestParametersStd.json";
+ return paramFile;
+ }
+
+ /**
+ * Nulls out a field within a JSON string.
+ * @param json JSON string
+ * @param field field to be nulled out
+ * @return a new JSON string with the field nulled out
+ */
+ public String nullifyField(String json, String field) {
+ return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\"");
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameterHandler.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameterHandler.java
new file mode 100644
index 000000000..e94939af8
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameterHandler.java
@@ -0,0 +1,120 @@
+/*-
+ * ============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.simulator.main.parameters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileNotFoundException;
+import org.apache.commons.io.DirectoryWalker.CancelException;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.startstop.ParticipantSimulatorCommandLineArguments;
+import org.onap.policy.common.utils.coder.CoderException;
+
+/**
+ * Class to perform unit test of {@link ParticipantParameterHandler}.
+ */
+public class TestParticipantSimulatorParameterHandler {
+
+ @Test
+ public void testParameterHandlerNoParameterFile() throws ControlLoopException {
+ final String[] emptyArgumentString = { "-c", "src/test/resources/parameters/NoParametersFile.json" };
+
+ final ParticipantSimulatorCommandLineArguments emptyArguments = new ParticipantSimulatorCommandLineArguments();
+ emptyArguments.parse(emptyArgumentString);
+
+ assertThatThrownBy(() -> new ParticipantSimulatorParameterHandler().getParameters(emptyArguments))
+ .hasCauseInstanceOf(CoderException.class)
+ .hasRootCauseInstanceOf(FileNotFoundException.class);
+ }
+
+ @Test
+ public void testParameterHandlerInvalidParameters() throws ControlLoopException {
+ final String[] invalidArgumentString = { "-c", "src/test/resources/parameters/InvalidParameters.json" };
+
+ final ParticipantSimulatorCommandLineArguments invalidArguments =
+ new ParticipantSimulatorCommandLineArguments();
+ invalidArguments.parse(invalidArgumentString);
+
+ assertThatThrownBy(() -> new ParticipantSimulatorParameterHandler().getParameters(invalidArguments))
+ .hasMessageStartingWith("error reading parameters from")
+ .hasCauseInstanceOf(CoderException.class);
+ }
+
+ @Test
+ public void testParameterHandlerNoParameters() throws CancelException, ControlLoopException {
+ final String[] noArgumentString = { "-c", "src/test/resources/parameters/EmptyParameters.json" };
+
+ final ParticipantSimulatorCommandLineArguments noArguments = new ParticipantSimulatorCommandLineArguments();
+ noArguments.parse(noArgumentString);
+
+ assertThatThrownBy(() -> new ParticipantSimulatorParameterHandler().getParameters(noArguments))
+ .hasMessageContaining("no parameters found");
+ }
+
+ @Test
+ public void testParticipantParameterGroup() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-c", "src/test/resources/parameters/TestParameters.json"};
+
+ final ParticipantSimulatorCommandLineArguments arguments = new ParticipantSimulatorCommandLineArguments();
+ arguments.parse(participantConfigParameters);
+
+ final ParticipantSimulatorParameters parGroup = new ParticipantSimulatorParameterHandler()
+ .getParameters(arguments);
+ assertTrue(arguments.checkSetConfigurationFilePath());
+ assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, parGroup.getName());
+ }
+
+ @Test
+ public void testParticipantVersion() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-v" };
+ final ParticipantSimulatorCommandLineArguments arguments = new ParticipantSimulatorCommandLineArguments();
+ assertThat(arguments.parse(participantConfigParameters)).startsWith(
+ "ONAP Tosca defined control loop Participant");
+ }
+
+ @Test
+ public void testParticipantHelp() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-h" };
+ final ParticipantSimulatorCommandLineArguments arguments = new ParticipantSimulatorCommandLineArguments();
+ assertThat(arguments.parse(participantConfigParameters)).startsWith("usage:");
+ }
+
+ @Test
+ public void testParticipant_TooManyArguments() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-c", "src/test/resources/parameters/TestParameters.json",
+ "TooMany"};
+ final ParticipantSimulatorCommandLineArguments arguments = new ParticipantSimulatorCommandLineArguments();
+ assertThatThrownBy(() -> arguments.parse(participantConfigParameters))
+ .hasMessageStartingWith("too many command line arguments specified");
+ }
+
+ @Test
+ public void testParticipantInvalidOption() throws ControlLoopException {
+ final String[] participantConfigParameters = { "-d" };
+ final ParticipantSimulatorCommandLineArguments arguments = new ParticipantSimulatorCommandLineArguments();
+ assertThatThrownBy(() -> arguments.parse(participantConfigParameters))
+ .hasMessageStartingWith("invalid command line arguments specified");
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
new file mode 100644
index 000000000..8027d6f08
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
@@ -0,0 +1,110 @@
+/*-
+ * ============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.simulator.main.parameters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+
+import java.util.Map;
+import org.junit.Test;
+import org.onap.policy.common.parameters.ValidationResult;
+
+/**
+ * Class to perform unit test of {@link ParticipantParameterGroup}.
+ */
+public class TestParticipantSimulatorParameters {
+ CommonTestData commonTestData = new CommonTestData();
+
+ @Test
+ public void testParticipantParameterGroup_Named() {
+ final ParticipantSimulatorParameters participantParameters = new ParticipantSimulatorParameters("my-name");
+ assertEquals("my-name", participantParameters.getName());
+ }
+
+ @Test
+ public void testParticipantParameterGroup() {
+ final ParticipantSimulatorParameters participantParameters = commonTestData.toObject(
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
+ ParticipantSimulatorParameters.class);
+ assertThat(participantParameters.validate().isValid()).isTrue();
+ assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, participantParameters.getName());
+ }
+
+ @Test
+ public void testParticipantParameterGroup_NullName() {
+ final ParticipantSimulatorParameters participantParameters = commonTestData
+ .toObject(commonTestData.getParticipantParameterGroupMap(null),
+ ParticipantSimulatorParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertFalse(validationResult.isValid());
+ assertEquals(null, participantParameters.getName());
+ assertThat(validationResult.getResult()).contains("is null");
+ }
+
+ @Test
+ public void testParticipantParameterGroup_EmptyName() {
+ final ParticipantSimulatorParameters participantParameters = commonTestData
+ .toObject(commonTestData.getParticipantParameterGroupMap(""),
+ ParticipantSimulatorParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertFalse(validationResult.isValid());
+ assertEquals("", participantParameters.getName());
+ assertThat(validationResult.getResult()).contains(
+ "item \"name\" value \"\" INVALID, " + "is blank");
+ }
+
+ @Test
+ public void testParticipantParameterGroup_SetName() {
+ final ParticipantSimulatorParameters participantParameters = commonTestData.toObject(
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
+ ParticipantSimulatorParameters.class);
+ participantParameters.setName("ParticipantNewGroup");
+ assertThat(participantParameters.validate().isValid()).isTrue();
+ assertEquals("ParticipantNewGroup", participantParameters.getName());
+ }
+
+ @Test
+ public void testParticipantParameterGroup_EmptyParticipantIntermediaryParameters() {
+ final Map<String, Object> map =
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME);
+ map.replace("intermediaryParameters", commonTestData.getIntermediaryParametersMap(true));
+ final ParticipantSimulatorParameters participantParameters =
+ commonTestData.toObject(map, ParticipantSimulatorParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertNull(validationResult.getResult());
+ }
+
+ @Test
+ public void testParticipantParameterGroupp_EmptyTopicParameters() {
+ final Map<String, Object> map =
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME);
+ final Map<String, Object> intermediaryParametersMap = commonTestData.getIntermediaryParametersMap(false);
+ intermediaryParametersMap.put("clampControlLoopTopics", commonTestData.getTopicParametersMap(true));
+ map.replace("intermediaryParameters", intermediaryParametersMap);
+
+ final ParticipantSimulatorParameters participantParameters =
+ commonTestData.toObject(map, ParticipantSimulatorParameters.class);
+ final ValidationResult validationResult = participantParameters.validate();
+ assertNull(validationResult.getResult());
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/CommonParticipantRestServer.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/CommonParticipantRestServer.java
new file mode 100644
index 000000000..ae004de49
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/CommonParticipantRestServer.java
@@ -0,0 +1,227 @@
+
+/*-
+ * ============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.simulator.main.rest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import org.glassfish.jersey.client.ClientProperties;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.startstop.Main;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
+import org.onap.policy.common.utils.network.NetworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to perform Rest unit tests.
+ *
+ */
+
+public class CommonParticipantRestServer {
+
+ private static final String CONFIG_FILE = "src/test/resources/parameters/TestConfigParameters.json";
+ private static final Logger LOGGER = LoggerFactory.getLogger(CommonParticipantRestServer.class);
+ public static final String SELF = NetworkUtil.getHostname();
+ public static final String ENDPOINT_PREFIX = "onap/participantsim/v2/";
+ private static int port;
+ private static String httpPrefix;
+ private static Main main;
+
+ /**
+ * Allocates a port for the server, writes a config file, and then starts Main.
+ *
+ * @throws Exception if an error occurs
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ setUpBeforeClass(true);
+ }
+
+ /**
+ * Allocates a port for the server, writes a config file, and then starts Main, if
+ * specified.
+ *
+ * @param shouldStart {@code true} if Main should be started, {@code false} otherwise
+ * @throws Exception if an error occurs
+ */
+ public static void setUpBeforeClass(boolean shouldStart) throws Exception {
+ port = NetworkUtil.allocPort();
+ httpPrefix = "http://localhost:" + port + "/";
+
+ makeConfigFile();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ TopicEndpointManager.getManager().shutdown();
+
+ if (shouldStart) {
+ startMain();
+ }
+ }
+
+ /**
+ * Stops Main.
+ */
+ @AfterClass
+ public static void teardownAfterClass() {
+ try {
+ stopMain();
+
+ } catch (ControlLoopException exp) {
+ LOGGER.error("cannot stop main", exp);
+ }
+ }
+
+ /**
+ * Set up.
+ *
+ * @throws Exception if an error occurs
+ */
+ @Before
+ public void setUp() throws Exception {
+ // restart, if not currently running
+ if (main == null) {
+ startMain();
+ }
+ }
+
+ /**
+ * Verifies that an endpoint appears within the swagger response.
+ *
+ * @param endpoint the endpoint of interest
+ * @throws Exception if an error occurs
+ */
+ protected void testSwagger(final String endpoint) throws Exception {
+ final Invocation.Builder invocationBuilder = sendFqeRequest(httpPrefix + "swagger.yaml", true);
+ assertThat(invocationBuilder.get(String.class)).contains(ENDPOINT_PREFIX + endpoint + ":");
+ }
+
+ /**
+ * Makes a parameter configuration file.
+ *
+ * @throws IOException if an error occurs writing the configuration file
+ * @throws FileNotFoundException if an error occurs writing the configuration file
+ *
+ * @throws Exception if an error occurs
+ */
+ private static void makeConfigFile() throws FileNotFoundException, IOException {
+ String json = CommonTestData.getParticipantParameterGroupAsString(port);
+ File file = new File(String.format(CONFIG_FILE, port));
+ file.deleteOnExit();
+ try (FileOutputStream output = new FileOutputStream(file)) {
+ output.write(json.getBytes(StandardCharsets.UTF_8));
+ }
+ }
+
+ /**
+ * Starts the "Main".
+ *
+ * @throws InterruptedException
+ *
+ * @throws Exception if an error occurs
+ */
+ protected static void startMain() throws InterruptedException {
+ // make sure port is available
+ if (NetworkUtil.isTcpPortOpen("localhost", port, 1, 1L)) {
+ throw new IllegalStateException("port " + port + " is still in use");
+ }
+
+ final String[] configParameters = { "-c", CONFIG_FILE };
+
+ main = new Main(configParameters);
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", port, 40, 250L)) {
+ throw new IllegalStateException("server is not listening on port " + port);
+ }
+ }
+
+ /**
+ * Stops the "Main".
+ *
+ * @throws ControlLoopException
+ *
+ * @throws Exception if an error occurs
+ */
+ private static void stopMain() throws ControlLoopException {
+ if (main != null) {
+ main.shutdown();
+ main = null;
+ }
+ }
+
+ /**
+ * Sends a request to an endpoint.
+ *
+ * @param endpoint the target endpoint
+ * @return a request builder
+ * @throws Exception if an error occurs
+ */
+ protected Invocation.Builder sendRequest(final String endpoint) throws Exception {
+ return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, true);
+ }
+
+ /**
+ * Sends a request to an endpoint, without any authorization header.
+ *
+ * @param endpoint the target endpoint
+ * @return a request builder
+ * @throws Exception if an error occurs
+ */
+ protected Invocation.Builder sendNoAuthRequest(final String endpoint) throws Exception {
+ return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, false);
+ }
+
+ /**
+ * Sends a request to a fully qualified endpoint.
+ *
+ * @param fullyQualifiedEndpoint the fully qualified target endpoint
+ * @param includeAuth if authorization header should be included
+ * @return a request builder
+ * @throws Exception if an error occurs
+ */
+ protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth)
+ throws Exception {
+ final Client client = ClientBuilder.newBuilder().build();
+ client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
+ client.register(GsonMessageBodyHandler.class);
+ if (includeAuth) {
+ client.register(HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34"));
+ }
+ final WebTarget webTarget = client.target(fullyQualifiedEndpoint);
+ return webTarget.request(MediaType.APPLICATION_JSON);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RestControllerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RestControllerTest.java
new file mode 100644
index 000000000..1311eee35
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RestControllerTest.java
@@ -0,0 +1,95 @@
+/*
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.participant.simulator.main.rest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.UUID;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationHandler;
+import org.onap.policy.common.utils.services.Registry;
+
+public class RestControllerTest {
+
+ private RestController ctlr;
+ private ResponseBuilder bldr;
+
+ /**
+ * Setup before class, instantiate SimulationHandler.
+ *
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ Registry.newRegistry();
+ Registry.register(SimulationHandler.class.getName(), Mockito.mock(SimulationHandler.class));
+ }
+
+ @AfterClass
+ public static void teardownAfterClass() throws Exception {
+ Registry.unregister(SimulationHandler.class.getName());
+ }
+
+ /**
+ * set Up.
+ */
+ @Before
+ public void setUp() {
+ ctlr = new RestController();
+ bldr = Response.status(Response.Status.OK);
+ }
+
+ @Test
+ public void testProduces() {
+ Produces annotation = RestController.class.getAnnotation(Produces.class);
+ assertNotNull(annotation);
+ assertThat(annotation.value()).contains(MediaType.APPLICATION_JSON)
+ .contains(RestController.APPLICATION_YAML);
+ }
+
+ @Test
+ public void testAddVersionControlHeaders() {
+ Response resp = ctlr.addVersionControlHeaders(bldr).build();
+ assertEquals("0", resp.getHeaderString(RestController.VERSION_MINOR_NAME));
+ assertEquals("0", resp.getHeaderString(RestController.VERSION_PATCH_NAME));
+ assertEquals("1.0.0", resp.getHeaderString(RestController.VERSION_LATEST_NAME));
+ }
+
+ @Test
+ public void testAddLoggingHeaders_Null() {
+ Response resp = ctlr.addLoggingHeaders(bldr, null).build();
+ assertNotNull(resp.getHeaderString(RestController.REQUEST_ID_NAME));
+ }
+
+ @Test
+ public void testAddLoggingHeaders_NonNull() {
+ UUID uuid = UUID.randomUUID();
+ Response resp = ctlr.addLoggingHeaders(bldr, uuid).build();
+ assertEquals(uuid.toString(), resp.getHeaderString(RestController.REQUEST_ID_NAME));
+ }
+}
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
new file mode 100644
index 000000000..9c20ffe22
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java
@@ -0,0 +1,258 @@
+/*-
+ * ============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.simulator.main.rest;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import lombok.Getter;
+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.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.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameters;
+import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationProvider;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestListenerUtils {
+
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+ private static final Coder CODER = new StandardCoder();
+ static CommonTestData commonTestData = new CommonTestData();
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class);
+
+ private TestListenerUtils() {}
+
+ @Getter
+ private static ParticipantHandler participantHandler;
+
+ /**
+ * Method to initialize participantHandler.
+ */
+ public static void initParticipantHandler() {
+
+ final ParticipantSimulatorParameters participantParameters = commonTestData.toObject(
+ commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
+ ParticipantSimulatorParameters.class);
+
+ SimulationProvider simulationProvider =
+ new SimulationProvider(participantParameters.getIntermediaryParameters());
+
+ participantHandler = simulationProvider.getIntermediaryApi().getParticipantHandler();
+ }
+
+ /**
+ * Method to create a controlLoop from a yaml file.
+ *
+ * @return ControlLoop controlloop
+ */
+ public static ControlLoop createControlLoop() {
+ ControlLoop controlLoop = new ControlLoop();
+ Map<UUID, ControlLoopElement> elements = new LinkedHashMap<>();
+ ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
+ Map<String, ToscaNodeTemplate> nodeTemplatesMap =
+ toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
+ ControlLoopElement clElement = new ControlLoopElement();
+ clElement.setId(UUID.randomUUID());
+
+ ToscaConceptIdentifier clElementParticipantId = new ToscaConceptIdentifier();
+ clElementParticipantId.setName(toscaInputEntry.getKey());
+ clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
+ clElement.setParticipantId(clElementParticipantId);
+ clElement.setParticipantType(clElementParticipantId);
+
+ clElement.setDefinition(clElementParticipantId);
+ clElement.setState(ControlLoopState.UNINITIALISED);
+ clElement.setDescription(toscaInputEntry.getValue().getDescription());
+ clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ elements.put(clElement.getId(), clElement);
+ }
+ controlLoop.setElements(elements);
+ controlLoop.setName("PMSHInstance0");
+ controlLoop.setVersion("1.0.0");
+
+ ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
+ definition.setName("PMSHInstance0");
+ definition.setVersion("1.0.0");
+ controlLoop.setDefinition(definition);
+
+ return controlLoop;
+ }
+
+ /**
+ * 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
+ */
+ public static ParticipantControlLoopStateChange createControlLoopStateChangeMsg(
+ final ControlLoopOrderedState controlLoopOrderedState) {
+ final ParticipantControlLoopStateChange participantClStateChangeMsg = new ParticipantControlLoopStateChange();
+
+ 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);
+
+ return participantClStateChangeMsg;
+ }
+
+ /**
+ * Method to create ControlLoopUpdateMsg.
+ *
+ * @return ParticipantControlLoopUpdate message
+ */
+ public static ParticipantControlLoopUpdate createControlLoopUpdateMsg() {
+ final ParticipantControlLoopUpdate clUpdateMsg = new ParticipantControlLoopUpdate();
+ ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
+ ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
+
+ clUpdateMsg.setControlLoopId(controlLoopId);
+ clUpdateMsg.setParticipantId(participantId);
+ clUpdateMsg.setParticipantType(participantId);
+
+ ControlLoop controlLoop = new ControlLoop();
+ Map<UUID, ControlLoopElement> elements = new LinkedHashMap<>();
+ ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
+ Map<String, ToscaNodeTemplate> nodeTemplatesMap =
+ toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
+ ControlLoopElement clElement = new ControlLoopElement();
+ clElement.setId(UUID.randomUUID());
+
+ ToscaConceptIdentifier clElementParticipantId = new ToscaConceptIdentifier();
+ clElementParticipantId.setName(toscaInputEntry.getKey());
+ clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
+ clElement.setParticipantId(clElementParticipantId);
+ clElement.setParticipantType(clElementParticipantId);
+
+ clElement.setDefinition(clElementParticipantId);
+ clElement.setState(ControlLoopState.UNINITIALISED);
+ clElement.setDescription(toscaInputEntry.getValue().getDescription());
+ clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ elements.put(clElement.getId(), clElement);
+ }
+ controlLoop.setElements(elements);
+ controlLoop.setName("PMSHInstance0");
+ controlLoop.setVersion("1.0.0");
+ controlLoop.setDefinition(controlLoopId);
+ clUpdateMsg.setControlLoop(controlLoop);
+ clUpdateMsg.setControlLoopDefinition(toscaServiceTemplate);
+
+ return clUpdateMsg;
+ }
+
+ /**
+ * Method to create ParticipantControlLoopUpdate using the arguments passed.
+ *
+ * @param jsonFilePath the path of the controlloop content
+ *
+ * @return ParticipantControlLoopUpdate message
+ * @throws CoderException exception while reading the file to object
+ */
+ public static ParticipantControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath)
+ throws CoderException {
+ ParticipantControlLoopUpdate participantControlLoopUpdateMsg =
+ CODER.decode(new File(jsonFilePath), ParticipantControlLoopUpdate.class);
+ return participantControlLoopUpdateMsg;
+ }
+
+ private static ToscaServiceTemplate testControlLoopRead() {
+ Set<String> controlLoopDirectoryContents =
+ ResourceUtils.getDirectoryContents("src/test/resources/rest/servicetemplates");
+
+ boolean atLeastOneControlLoopTested = false;
+ ToscaServiceTemplate toscaServiceTemplate = null;
+
+ for (String controlLoopFilePath : controlLoopDirectoryContents) {
+ if (!controlLoopFilePath.endsWith(".yaml")) {
+ continue;
+ }
+ atLeastOneControlLoopTested = true;
+ toscaServiceTemplate = testControlLoopYamlSerialization(controlLoopFilePath);
+ }
+
+ assertTrue(atLeastOneControlLoopTested);
+ return toscaServiceTemplate;
+ }
+
+ private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) {
+ try {
+ String controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath);
+ if (controlLoopString == null) {
+ throw new FileNotFoundException(controlLoopFilePath);
+ }
+
+ ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(
+ controlLoopString, ToscaServiceTemplate.class);
+ return serviceTemplate;
+ } catch (FileNotFoundException e) {
+ LOGGER.error("cannot find YAML file", controlLoopFilePath);
+ throw new IllegalArgumentException(e);
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestSimulationRestController.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestSimulationRestController.java
new file mode 100644
index 000000000..472b4beee
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestSimulationRestController.java
@@ -0,0 +1,186 @@
+/*-
+ * ============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.simulator.main.rest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+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.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.rest.TypedSimpleResponse;
+import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationHandler;
+import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationProvider;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+
+/**
+ * Class to perform unit test of {@link TestSimulationRestController}.
+ */
+public class TestSimulationRestController extends CommonParticipantRestServer {
+
+ private static ControlLoopUpdateListener clUpdateListener;
+ private static final String PARTICIPANTS_ENDPOINT = "participants";
+ private static final String ELEMENTS_ENDPOINT = "elements";
+ private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
+ private static final String TOPIC = "my-topic";
+ static CommonTestData commonTestData = new CommonTestData();
+
+ /**
+ * Setup before class.
+ *
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ CommonParticipantRestServer.setUpBeforeClass();
+ clUpdateListener = new ControlLoopUpdateListener(
+ SimulationHandler.getInstance()
+ .getSimulationProvider()
+ .getIntermediaryApi()
+ .getParticipantHandler());
+ ParticipantControlLoopUpdate participantControlLoopUpdateMsg =
+ TestListenerUtils.createControlLoopUpdateMsg();
+ participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE);
+ clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
+ }
+
+ @AfterClass
+ public static void teardownAfterClass() {
+ CommonParticipantRestServer.teardownAfterClass();
+ }
+
+ @Test
+ public void testSwagger() throws Exception {
+ super.testSwagger(ELEMENTS_ENDPOINT);
+ }
+
+ @Test
+ public void testQuery_Unauthorized() throws Exception {
+ Invocation.Builder invocationBuilder = super.sendNoAuthRequest(ELEMENTS_ENDPOINT);
+ Response rawresp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
+ }
+
+ @Test
+ public void testQueryParticipants() throws Exception {
+ Participant participant = new Participant();
+ ToscaConceptIdentifier participantId = CommonTestData.getParticipantId();
+ participant.setDefinition(participantId);
+ participant.setName(participantId.getName());
+ participant.setVersion(participantId.getVersion());
+
+ // GET REST call for querying the participants
+ Invocation.Builder invocationBuilder =
+ super.sendRequest(PARTICIPANTS_ENDPOINT + "/" + participant.getKey().getName()
+ + "/" + participant.getVersion());
+
+ Response rawresp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ List<Participant> returnValue = rawresp.readEntity(new GenericType<List<Participant>>() {});
+ assertNotNull(returnValue);
+ assertThat(returnValue).hasSize(1);
+ // Verify the result of GET participants with what is stored
+ assertEquals(participant.getDefinition(), returnValue.get(0).getDefinition());
+ }
+
+ @Test
+ public void testQueryControlLoopElements() throws Exception {
+ // GET REST call for querying the controlLoop elements
+ Invocation.Builder invocationBuilder = super.sendRequest(ELEMENTS_ENDPOINT + "/"
+ + "PMSHInstance0" + "/" + "1.0.0");
+
+ Response rawresp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ Map<UUID, ControlLoopElement> returnValue =
+ rawresp.readEntity(new GenericType<Map<UUID, ControlLoopElement>>() {});
+ assertNotNull(returnValue);
+ // Verify the result of GET controlloop elements with what is stored
+ assertThat(returnValue).hasSize(1);
+ returnValue.values().forEach(element -> assertEquals("org.onap.PM_CDS_Blueprint",
+ element.getDefinition().getName()));
+ }
+
+ @Test
+ public void testUpdateParticipant() throws Exception {
+ SimulationProvider provider = SimulationHandler.getInstance().getSimulationProvider();
+ List<Participant> participants = provider.getParticipants(CommonTestData.getParticipantId().getName(),
+ CommonTestData.getParticipantId().getVersion());
+ assertEquals(ParticipantState.UNKNOWN, participants.get(0).getParticipantState());
+ // Change the state of the participant to PASSIVE from UNKNOWN
+ participants.get(0).setParticipantState(ParticipantState.PASSIVE);
+ Entity<Participant> entParticipant = Entity.entity(participants.get(0), MediaType.APPLICATION_JSON);
+
+ // PUT REST call for updating Participant
+ Invocation.Builder invocationBuilder = sendRequest(PARTICIPANTS_ENDPOINT);
+ Response rawresp = invocationBuilder.put(entParticipant);
+ TypedSimpleResponse<Participant> resp = rawresp.readEntity(TypedSimpleResponse.class);
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ assertNotNull(resp.getResponse());
+ // Verify the response and state returned by PUT REST call for updating participants
+ assertThat(resp.toString()).contains("definition={name=org.onap.PM_CDS_Blueprint, version=1.0.0}");
+ assertThat(resp.toString()).contains("participantState=PASSIVE");
+ }
+
+ @Test
+ public void testUpdateControlLoopElement() throws Exception {
+ ControlLoop controlLoop = TestListenerUtils.createControlLoop();
+ SimulationProvider provider = SimulationHandler.getInstance().getSimulationProvider();
+ Map<UUID, ControlLoopElement> controlLoopElements = provider.getControlLoopElements(
+ controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
+
+ for (Map.Entry<UUID, ControlLoopElement> clElement : controlLoopElements.entrySet()) {
+ // Check the initial state on the ControlLoopElement, which is UNINITIALISED
+ assertEquals(ControlLoopOrderedState.UNINITIALISED, clElement.getValue().getOrderedState());
+ // Change the state of the ControlLoopElement to PASSIVE from UNINITIALISED
+ clElement.getValue().setOrderedState(ControlLoopOrderedState.PASSIVE);
+ Entity<ControlLoopElement> entClElement = Entity.entity(clElement.getValue(), MediaType.APPLICATION_JSON);
+
+ // PUT REST call for updating ControlLoopElement
+ Invocation.Builder invocationBuilder = sendRequest(ELEMENTS_ENDPOINT);
+ Response rawresp = invocationBuilder.put(entClElement);
+ TypedSimpleResponse<ControlLoopElement> resp = rawresp.readEntity(TypedSimpleResponse.class);
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ assertNotNull(resp.getResponse());
+ // Verify the response and state returned by PUT REST call for updating participants
+ assertThat(resp.toString()).contains("definition={name=org.onap.PM_CDS_Blueprint, version=1.0.0}");
+ assertThat(resp.toString()).contains("orderedState=PASSIVE");
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/TestMain.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/TestMain.java
new file mode 100644
index 000000000..5a5ad8931
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/TestMain.java
@@ -0,0 +1,117 @@
+/*-
+ * ============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.simulator.main.startstop;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.common.utils.resources.MessageConstants;
+
+/**
+ * Class to perform unit test of {@link Main}}.
+ */
+public class TestMain {
+
+ @Test
+ public void testMain_Help() {
+ final String[] configParameters = {"-h"};
+ Main main = new Main(configParameters);
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_Version() {
+ final String[] configParameters = {"-v"};
+ Main main = new Main(configParameters);
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_Valid() {
+ final String[] configParameters = {"-c", "src/test/resources/parameters/TestParameters.json"};
+ Main main = new Main(configParameters);
+ assertTrue(main.isRunning());
+
+ assertThatCode(() -> main.shutdown()).doesNotThrowAnyException();
+
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_NoParameter() {
+ assertThatConfigParameterThrownException(new String[] {});
+ }
+
+ @Test
+ public void testMain_FilePathNotDefined() {
+ assertThatConfigParameterThrownException(new String[] {"-c"});
+ }
+
+ @Test
+ public void testMain_TooManyCommand() {
+ assertThatConfigParameterThrownException(new String[] {"-h", "d"});
+ }
+
+ @Test
+ public void testMain_WrongParameter() {
+ assertThatConfigParameterThrownException(new String[] {"-d"});
+ }
+
+ private void assertThatConfigParameterThrownException(final String[] configParameters) {
+ assertThatThrownBy(() -> Main.main(configParameters)).isInstanceOf(ControlLoopRuntimeException.class)
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP));
+ }
+
+ @Test
+ public void testParticipant_NoFileWithThisName() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/NoFileWithThisName.json");
+ }
+
+ @Test
+ public void testParticipant_NotValidFile() {
+ assertThatConfigFileThrownException("src/test/resources/parameters");
+ }
+
+ @Test
+ public void testParticipant_FileEmpty() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/EmptyParameters.json");
+ }
+
+ @Test
+ public void testParticipant_NoParameters() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/NoParameters.json");
+ }
+
+ @Test
+ public void testParticipant_InvalidParameters() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/InvalidParameters.json");
+ }
+
+ private void assertThatConfigFileThrownException(final String configFilePath) {
+ final String[] configParameters = new String[] {"-c", configFilePath};
+ assertThatThrownBy(() -> new Main(configParameters)).isInstanceOf(ControlLoopRuntimeException.class)
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP));
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/TestParticipantSimulatorActivator.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/TestParticipantSimulatorActivator.java
new file mode 100644
index 000000000..c695d5f24
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/startstop/TestParticipantSimulatorActivator.java
@@ -0,0 +1,89 @@
+/*-
+ * ============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.simulator.main.startstop;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameterHandler;
+import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameters;
+
+/**
+ * Class to perform unit test of {@link ParticipantActivator}}.
+ */
+public class TestParticipantSimulatorActivator {
+
+ private static ParticipantSimulatorActivator activator;
+
+ /**
+ * Initializes an activator.
+ *
+ * @throws Exception if an error occurs
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final String[] participantConfigParameters = { "-c", "src/test/resources/parameters/TestParameters.json"};
+ final ParticipantSimulatorCommandLineArguments arguments =
+ new ParticipantSimulatorCommandLineArguments(participantConfigParameters);
+ final ParticipantSimulatorParameters parGroup =
+ new ParticipantSimulatorParameterHandler().getParameters(arguments);
+ activator = new ParticipantSimulatorActivator(parGroup);
+ }
+
+ /**
+ * Method for cleanup after each test.
+ *
+ * @throws Exception if an error occurs
+ */
+ @AfterClass
+ public static void teardown() throws Exception {
+ // shut down activator
+ if (activator != null && activator.isAlive()) {
+ activator.shutdown();
+ }
+ }
+
+ @Test
+ public void testParticipantActivator() {
+ activator.start();
+ assertTrue(activator.isAlive());
+ assertTrue(activator.getParameters().isValid());
+ assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, activator.getParameters().getName());
+
+ // repeat - should throw an exception
+ assertThatIllegalStateException().isThrownBy(() -> activator.start());
+ assertTrue(activator.isAlive());
+ assertTrue(activator.getParameters().isValid());
+
+ activator.shutdown();
+ assertFalse(activator.isAlive());
+
+ // repeat - should throw an exception
+ assertThatIllegalStateException().isThrownBy(() -> activator.shutdown());
+ assertFalse(activator.isAlive());
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/EmptyParameters.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/EmptyParameters.json
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/EmptyParameters.json
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/InvalidParameters.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/InvalidParameters.json
new file mode 100644
index 000000000..1035ccb67
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/InvalidParameters.json
@@ -0,0 +1,3 @@
+{
+ "name": "
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/NoParameters.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/NoParameters.json
new file mode 100644
index 000000000..7a73a41bf
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/NoParameters.json
@@ -0,0 +1,2 @@
+{
+} \ No newline at end of file
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParameters.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParameters.json
new file mode 100644
index 000000000..8c594044b
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParameters.json
@@ -0,0 +1,61 @@
+{
+ "name": "ControlLoopParticipantGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantId": {
+ "name": "org.onap.PM_CDS_Blueprint",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.PM_CDS_Blueprint",
+ "version": "1.0.0"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParametersStd.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParametersStd.json
new file mode 100644
index 000000000..0295a8f91
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParametersStd.json
@@ -0,0 +1,61 @@
+{
+ "name": "ControlLoopParticipantGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": ${port},
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantId": {
+ "name": "org.onap.PM_CDS_Blueprint",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.PM_CDS_Blueprint",
+ "version": "1.0.0"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json
new file mode 100644
index 000000000..f11bd8c95
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json
@@ -0,0 +1,81 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ },
+ "healthCheckRestClientParameters": [
+ {
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }
+ ]
+}
+
+
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml b/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml
new file mode 100644
index 000000000..99dd0ed68
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml
@@ -0,0 +1,452 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+capability_types:
+ org.onap.EventProducer:
+ properties:
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ event_format:
+ type: string
+ required: true
+ event_format_version:
+ type: string
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+ org.onap.EventConsumer:
+ properties:
+ responding_capability:
+ type: string
+ required: false
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ - all valid values should be added here
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured,
+ etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+node_types:
+ org.onap.DynamicConfig:
+ properties:
+ application_name:
+ type: string
+ description: Value used to tie the config to an application ? should we be
+ using a relationship here instead?
+ required: true
+ application_version:
+ type: string
+ required: true
+ application_provider:
+ type: string
+ required: false
+ data_types:
+ type: object
+ required: false
+ schema:
+ type: object
+ required: false
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.APP:
+ properties:
+ application_name:
+ type: string
+ description: Human readable name for the application Product
+ required: false
+ provider:
+ type: string
+ description: Provider of the application and of the descriptor
+ required: true
+ application_version:
+ type: string
+ description: Software version of the application
+ required: true
+ blueprint_id:
+ type: string
+ description: A reference to the app blueprint
+ required: false
+ monitoring_policy:
+ type: string
+ description: A reference to the monitoring policy
+ required: false
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.EventRelay:
+ properties:
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: true
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key is relayed
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ supported_carrier_protocols:
+ type: map
+ description: 'A map describing supported carrier protocols and translations.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ supported_data_formats:
+ type: map
+ description: 'Is a map describing supported data formats and translation.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+relationship_types:
+ org.onap.PropagateEvent:
+ properties:
+ config_keys:
+ type: list
+ description: The relationship type used on requirements to org.onap.EventProducer
+ and org.onap.EventConsumer capabilities. Filters events by specific config_keys
+ to be transferred by this relationship. That is, any event with a specific
+ config_key found in the list is transferred. If list is not defined or is
+ empty, events with all config_keys are transferred.
+ required: false
+ entry_schema:
+ type: string
+ version: 0.0.1
+ derived_from: tosca.relationships.Root
+topology_template:
+ inputs:
+ pm_subscription_topic:
+ type: string
+ pm_subscription_response_topic:
+ type: string
+ pm_subscription_handler_blueprint_id:
+ type: string
+ pm_subscription_operational_policy_id:
+ type: string
+ pm_subscription_cds_blueprint_id:
+ type: string
+ enable_tls:
+ type: string
+ node_templates:
+ org.onap.PM_Subscription_Handler:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription Handler
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_handler_blueprint_id
+ description: Is this a reference to the DCAE Cloudify Blueprint that is
+ already stored(or will be stored before CL configuration & instatiation)
+ in DCAE Inventory?
+ artifact_config:
+ enable_tls:
+ get_input: enable_tls
+ pmsh_publish_topic_name:
+ get_input: pm_subscription_topic
+ capabilities:
+ pm-subscription-event-publisher:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-format
+ event_format_version: 1.0.0
+ attributes:
+ type: org.onap.EventProducer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ pm-subscription-event-receiver:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ relationships:
+ - type: tosca.relationships.DependsOn
+ - description: any ideas on a better realtionship ? or is it better to
+ just use the root realtionship ?
+ - target: org.onap.PM_Monitoring_Policy
+ attributes:
+ type: org.onap.EventConsumer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_Monitoring_Policy:
+ type: org.onap.DynamicConfig
+ properties:
+ application_name: PM Subscription Handler
+ application_version: 1.0.0
+ provider: Ericsson
+ data_types:
+ measurementType:
+ type: string
+ DN:
+ type: string
+ nfFilter:
+ properties:
+ nfNames:
+ type: list
+ entry_schema: string
+ modelInvariantIDs:
+ type: list
+ entry_schema:
+ type: string
+ modelVersionIDs:
+ type: list
+ entry_schema:
+ type: string
+ measurementGroup:
+ properties:
+ masurementTypes:
+ type: list
+ entry_schema:
+ type: measurementType
+ managedObjectDNsBasic:
+ type: list
+ entry_schema:
+ type: DN
+ schema:
+ subscription:
+ subscriptionName:
+ type: string
+ required: true
+ administrativeState:
+ type: string
+ required: true
+ filebasedGP:
+ type: integer
+ required: true
+ fileLocation:
+ type: string
+ required: true
+ nfFilter:
+ type: nfFilter
+ measurementGroups:
+ type: list
+ entry_schema:
+ type: measurementGroup
+ version: 0.0.0
+ description: Should I be showing a dependency between PM Subscription Handler
+ and the PM Monitoring Policy
+ org.onap.PM_Policy:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription Operational Policy
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_operational_policy_id
+ artifact_config: NOT_DEFINED
+ requirements:
+ - receive_0:
+ capability: pm-subscription-event-publisher
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_topic
+ version: 0.0.0
+ - send_0:
+ capability: cds-rest-receive
+ node: org.onap.CDS
+ version: 0.0.0
+ - receive_1:
+ capability: cds-rest-response
+ node: org.onap.CDS
+ version: 0.0.0
+ - send_1:
+ capability: pm-subscription-event-receiver
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_response_topic
+ version: 0.0.0
+ capabilities:
+ pm-subscription-response-event-publisher:
+ properties:
+ type: org.onap.EventProducer
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_CDS_Blueprint:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription CDS Blueprint
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_cds_blueprint_id
+ capabilities:
+ cds-rest-receive:
+ properties:
+ type: org.onap.EventConsumer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_format
+ event_format_version: 1.0.0
+ responding_capability: cds-rest-response
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ cds-rest-response:
+ properties:
+ type: org.onap.EventProducer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_response_format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ version: 0.0.0
+ version: 1.0.0
+ org.onap.controlloop0:
+ type: org.onap.APP
+ properties:
+ application_name: Test Control Loop
+ provider: Ericsson
+ application_version: 1.0.0
+ status: NOT_DEPLOYED
+ version: 0.0.0
+version: 0.0.0
diff --git a/participant/participant-impl/pom.xml b/participant/participant-impl/pom.xml
index 6c67bfa51..8afd81045 100644
--- a/participant/participant-impl/pom.xml
+++ b/participant/participant-impl/pom.xml
@@ -40,4 +40,12 @@
<module>participant-impl-cds</module>
<module>participant-impl-kubernetes</module>
</modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.clamp.participant</groupId>
+ <artifactId>policy-clamp-participant-intermediary</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java
new file mode 100644
index 000000000..9e5d2c663
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.api;
+
+import java.util.UUID;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+/**
+ * This interface is implemented by participant implementations to receive updates on control loop elements.
+ */
+public interface ControlLoopElementListener {
+ /**
+ * Handle a control loop element state change.
+ *
+ * @param controlLoopElementId the ID of the control loop element
+ * @param currentState the current state of the control loop element
+ * @param newState the state to which the control loop element is changing to
+ * @throws PfModelException in case of a model exception
+ */
+ public void controlLoopElementStateChange(UUID controlLoopElementId, ControlLoopState currentState,
+ ControlLoopOrderedState newState) throws PfModelException;
+
+ /**
+ * Handle an update on a control loop element.
+ *
+ * @param element the information on the control loop element
+ * @param controlLoopDefinition toscaServiceTemplate
+ * @throws PfModelException from Policy framework
+ */
+ public void controlLoopElementUpdate(ControlLoopElement element,
+ ToscaServiceTemplate controlLoopDefinition) throws PfModelException;
+
+ /**
+ * Handle controlLoopElement statistics.
+ *
+ * @param controlLoopElementId controlLoopElement id
+ * @throws PfModelException in case of a model exception
+ */
+ public void handleStatistics(UUID controlLoopElementId) throws PfModelException;
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
new file mode 100644
index 000000000..d31ae1082
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
@@ -0,0 +1,139 @@
+/*-
+ * ============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.api;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+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.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.controlloop.concepts.Participant;
+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.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * This interface is used by participant implementations to use the participant intermediary.
+ */
+public interface ParticipantIntermediaryApi {
+ /**
+ * Initialise the participant intermediary.
+ *
+ * @param parameters the parameters for the intermediary
+ */
+ void init(ParticipantIntermediaryParameters parameters);
+
+ /**
+ * Close the intermediary.
+ */
+ void close();
+
+ /**
+ * Register a listener for control loop elements that are mediated by the intermediary.
+ *
+ * @param controlLoopElementListener The control loop element listener to register
+ */
+ void registerControlLoopElementListener(ControlLoopElementListener controlLoopElementListener);
+
+ /**
+ * Get participants loops from the intermediary API.
+ *
+ * @param name the participant name, null for all
+ * @param version the participant version, null for all
+ * @return the participants
+ */
+ List<Participant> getParticipants(String name, String version);
+
+ /**
+ * Update the state of a participant.
+ *
+ * @param definition the definition of the participant to update the state on
+ * @param state the state of the participant
+ * @return the participant
+ */
+ Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state);
+
+ /**
+ * Update the statistics of a participant.
+ *
+ * @param participantStatistics the statistics of the participant
+ */
+ void updateParticipantStatistics(ParticipantStatistics participantStatistics);
+
+ /**
+ * Get control loops from the intermediary API.
+ *
+ * @param name the control loop element name, null for all
+ * @param version the control loop element version, null for all
+ * @return the control loop elements
+ */
+ ControlLoops getControlLoops(String name, String version);
+
+ /**
+ * Get control loop elements from the intermediary API.
+ *
+ * @param name the control loop element name, null for all
+ * @param version the control loop element version, null for all
+ * @return the control loop elements
+ */
+ Map<UUID, ControlLoopElement> getControlLoopElements(String name, String version);
+
+ /**
+ * Get control loop element from the intermediary API.
+ *
+ * @param id control loop element ID
+ * @return the control loop element
+ */
+ ControlLoopElement getControlLoopElement(UUID id);
+
+ /**
+ * Update the state of a control loop element.
+ *
+ * @param id the ID of the control loop element to update the state on
+ * @param currentState the state of the control loop element
+ * @param newState the state of the control loop element
+ * @return ControlLoopElement updated control loop element
+ */
+ ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState currentState,
+ ControlLoopState newState);
+
+ /**
+ * Update the control loop element statistics.
+ *
+ * @param id the ID of the control loop element to update the state on
+ * @param elementStatistics the updated statistics
+ */
+ void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics);
+
+ /**
+ * Return participantHandler, This will not be used in real world, but for junits,
+ * if participantHandler is not returned, there is no way to test state change messages
+ * without dmaap simulator.
+ *
+ */
+ ParticipantHandler getParticipantHandler();
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryFactory.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryFactory.java
new file mode 100644
index 000000000..d7cc4b2ed
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryFactory.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.api;
+
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.impl.ParticipantIntermediaryApiImpl;
+
+/**
+ * Factory class for creating {@link ParticipantIntermediaryApi} instances.
+ */
+public class ParticipantIntermediaryFactory {
+
+ /**
+ * Create an implementation of the {@link ParticipantIntermediaryApi} interface.
+ *
+ * @return the implementation of the API
+ */
+ public ParticipantIntermediaryApi createApiImplementation() {
+ return new ParticipantIntermediaryApiImpl();
+ }
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
new file mode 100644
index 000000000..839088d72
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
@@ -0,0 +1,133 @@
+/*-
+ * ============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.api.impl;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+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.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.controlloop.concepts.Participant;
+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.participant.intermediary.api.ControlLoopElementListener;
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.IntermediaryActivator;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * This class is api implementation used by participant intermediary.
+ */
+public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryApi {
+
+ // The activator for the participant intermediary
+ private IntermediaryActivator activator;
+
+ @Override
+ public void init(ParticipantIntermediaryParameters parameters) {
+ activator = new IntermediaryActivator(parameters);
+
+ activator.start();
+ }
+
+ @Override
+ public void close() {
+ activator.shutdown();
+ }
+
+ @Override
+ public void registerControlLoopElementListener(ControlLoopElementListener controlLoopElementListener) {
+ activator.getParticipantHandler().getControlLoopHandler()
+ .registerControlLoopElementListener(controlLoopElementListener);
+ }
+
+ @Override
+ public List<Participant> getParticipants(String name, String version) {
+ return List.of(activator.getParticipantHandler().getParticipant(name, version));
+ }
+
+ @Override
+ public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state) {
+ return activator.getParticipantHandler().updateParticipantState(definition, state);
+ }
+
+ @Override
+ public void updateParticipantStatistics(ParticipantStatistics participantStatistics) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public ControlLoops getControlLoops(String name, String version) {
+ return activator.getParticipantHandler().getControlLoopHandler().getControlLoops();
+ }
+
+ @Override
+ public Map<UUID, ControlLoopElement> getControlLoopElements(String name, String version) {
+ List<ControlLoop> controlLoops = activator.getParticipantHandler()
+ .getControlLoopHandler().getControlLoops().getControlLoopList();
+
+ for (ControlLoop controlLoop : controlLoops) {
+ if (name.equals(controlLoop.getDefinition().getName())) {
+ return controlLoop.getElements();
+ }
+ }
+ return new LinkedHashMap<>();
+ }
+
+ @Override
+ public ControlLoopElement getControlLoopElement(UUID id) {
+ List<ControlLoop> controlLoops = activator.getParticipantHandler()
+ .getControlLoopHandler().getControlLoops().getControlLoopList();
+
+ for (ControlLoop controlLoop : controlLoops) {
+ ControlLoopElement clElement = controlLoop.getElements().get(id);
+ if (clElement != null) {
+ return clElement;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState currentState,
+ ControlLoopState newState) {
+ return activator.getParticipantHandler().getControlLoopHandler()
+ .updateControlLoopElementState(id, currentState, newState);
+ }
+
+ @Override
+ public void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics) {
+ activator.getParticipantHandler().getControlLoopHandler()
+ .updateControlLoopElementStatistics(id, elementStatistics);
+ }
+
+ @Override
+ public ParticipantHandler getParticipantHandler() {
+ return activator.getParticipantHandler();
+ }
+}
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
new file mode 100644
index 000000000..50b8b9cdc
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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 java.io.Closeable;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Listener for Participant State Change messages sent by CLAMP.
+ */
+public class ControlLoopStateChangeListener extends ScoListener<ParticipantControlLoopStateChange>
+ implements Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopStateChangeListener.class);
+
+ private final ParticipantHandler participantHandler;
+
+ /**
+ * Constructs the object.
+ *
+ * @param participantHandler the handler for managing the state of the participant
+ */
+ public ControlLoopStateChangeListener(final ParticipantHandler participantHandler) {
+ super(ParticipantControlLoopStateChange.class);
+ this.participantHandler = participantHandler;
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantControlLoopStateChange controlLoopStateChangeMsg) {
+ LOGGER.debug("Control Loop State Change received from CLAMP - {}", controlLoopStateChangeMsg);
+
+ if (participantHandler.canHandle(controlLoopStateChangeMsg)) {
+ LOGGER.debug("Message for this participant");
+ participantHandler.getControlLoopHandler().handleControlLoopStateChange(controlLoopStateChangeMsg);
+ } else {
+ LOGGER.debug("Message not for this participant");
+ }
+ }
+
+ @Override
+ public void close() {
+ // No explicit action on this class
+ }
+}
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
new file mode 100644
index 000000000..ab2437c1c
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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 java.io.Closeable;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Listener for Control Loop Update messages sent by CLAMP.
+ */
+public class ControlLoopUpdateListener extends ScoListener<ParticipantControlLoopUpdate> implements Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopUpdateListener.class);
+
+ private final ParticipantHandler participantHandler;
+
+ /**
+ * Constructs the object.
+ *
+ * @param participantHandler the handler for managing the state of the participant
+ */
+ public ControlLoopUpdateListener(final ParticipantHandler participantHandler) {
+ super(ParticipantControlLoopUpdate.class);
+ this.participantHandler = participantHandler;
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantControlLoopUpdate participantControlLoopUpdateMsg) {
+ LOGGER.debug("Control Loop update received from CLAMP - {}", participantControlLoopUpdateMsg);
+
+ if (participantHandler.canHandle(participantControlLoopUpdateMsg)) {
+ LOGGER.debug("Message for this participant");
+ participantHandler.getControlLoopHandler().handleControlLoopUpdate(participantControlLoopUpdateMsg);
+ } else {
+ LOGGER.debug("Message not for this participant");
+ }
+ }
+
+ @Override
+ public void close() {
+ // No explicit action on this class
+ }
+}
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
new file mode 100644
index 000000000..3128f1eaa
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java
@@ -0,0 +1,162 @@
+/*-
+ * ============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 java.io.Closeable;
+import java.time.Instant;
+import java.util.TimerTask;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+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.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
+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.ParticipantStatus;
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
+import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantStatusPublisher;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class sends messages from participants to CLAMP.
+ */
+public class MessageSender extends TimerTask implements Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MessageSender.class);
+
+ private final ParticipantHandler participantHandler;
+ private final ParticipantStatusPublisher publisher;
+ private ScheduledExecutorService timerPool;
+
+ /**
+ * Constructor, set the publisher.
+ *
+ * @param participantHandler the participant handler to use for gathering information
+ * @param publisher the publisher to use for sending messages
+ * @param interval time interval to send Participant Status periodic messages
+ */
+ public MessageSender(ParticipantHandler participantHandler, ParticipantStatusPublisher publisher,
+ long interval) {
+ this.participantHandler = participantHandler;
+ this.publisher = publisher;
+
+ // Kick off the timer
+ timerPool = makeTimerPool();
+ timerPool.scheduleAtFixedRate(this, 0, interval, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void run() {
+ LOGGER.debug("Sent heartbeat to CLAMP");
+
+ ParticipantResponseDetails response = new ParticipantResponseDetails();
+
+ response.setResponseTo(null);
+ response.setResponseStatus(ParticipantResponseStatus.PERIODIC);
+ response.setResponseMessage("Periodic response from participant");
+ }
+
+ @Override
+ public void close() {
+ timerPool.shutdown();
+ }
+
+ /**
+ * Send a response message for this participant.
+ *
+ * @param response the details to include in the response message
+ */
+ public void sendResponse(ParticipantResponseDetails response) {
+ sendResponse(null, response);
+ }
+
+ /**
+ * Dispatch a response message for this participant.
+ *
+ * @param controlLoopId the control loop to which this message is a response
+ * @param response the details to include in the response message
+ */
+ public void sendResponse(ToscaConceptIdentifier controlLoopId, ParticipantResponseDetails response) {
+ ParticipantStatus status = new ParticipantStatus();
+
+ // Participant related fields
+ status.setParticipantType(participantHandler.getParticipantType());
+ status.setParticipantId(participantHandler.getParticipantId());
+ status.setState(participantHandler.getState());
+ status.setHealthStatus(participantHandler.getHealthStatus());
+
+ // Control loop related fields
+ ControlLoops controlLoops = participantHandler.getControlLoopHandler().getControlLoops();
+ status.setControlLoopId(controlLoopId);
+ status.setControlLoops(controlLoops);
+ status.setResponse(response);
+
+ ParticipantStatistics participantStatistics = new ParticipantStatistics();
+ participantStatistics.setTimeStamp(Instant.now());
+ participantStatistics.setParticipantId(participantHandler.getParticipantId());
+ participantStatistics.setHealthStatus(participantHandler.getHealthStatus());
+ participantStatistics.setState(participantHandler.getState());
+ status.setParticipantStatistics(participantStatistics);
+
+ for (ControlLoopElementListener clElementListener :
+ participantHandler.getControlLoopHandler().getListeners()) {
+ updateClElementStatistics(controlLoops, clElementListener);
+ }
+
+ status.setControlLoops(controlLoops);
+
+ publisher.send(status);
+ }
+
+ /**
+ * 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.
+ *
+ * @param controlLoops the control loops
+ * @param clElementListener control loop element listener
+ */
+ public void updateClElementStatistics(ControlLoops controlLoops, ControlLoopElementListener clElementListener) {
+ for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ try {
+ clElementListener.handleStatistics(element.getId());
+ } catch (PfModelException e) {
+ LOGGER.debug("Getting statistics for Control loop element failed");
+ }
+ }
+ }
+ }
+
+ /**
+ * Makes a new timer pool.
+ *
+ * @return a new timer pool
+ */
+ protected ScheduledExecutorService makeTimerPool() {
+ return Executors.newScheduledThreadPool(1);
+ }
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantHealthCheckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantHealthCheckListener.java
new file mode 100644
index 000000000..e0e6be329
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantHealthCheckListener.java
@@ -0,0 +1,69 @@
+/*-
+ * ============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 java.io.Closeable;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Listener for Participant health status messages sent by CLAMP.
+ */
+public class ParticipantHealthCheckListener extends ScoListener<ParticipantHealthCheck> implements Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantHealthCheckListener.class);
+
+ private final ParticipantHandler participantHandler;
+
+ /**
+ * Constructs the object.
+ *
+ * @param participantHandler the handler for managing the state and health of the participant
+ */
+ public ParticipantHealthCheckListener(final ParticipantHandler participantHandler) {
+ super(ParticipantHealthCheck.class);
+ this.participantHandler = participantHandler;
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantHealthCheck participantHealthCheckMsg) {
+ LOGGER.debug("Participant Health Check message received from CLAMP - {}", participantHealthCheckMsg);
+
+
+ if (participantHandler.canHandle(participantHealthCheckMsg)) {
+ LOGGER.debug("Message for this participant");
+ participantHandler.handleParticipantHealthCheck(participantHealthCheckMsg);
+ } else {
+ LOGGER.debug("Message not for this participant");
+ }
+
+ }
+
+ @Override
+ public void close() {
+ // No explicit action on this class
+ }
+}
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
new file mode 100644
index 000000000..c1a8b5b4a
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStateChangeListener.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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 java.io.Closeable;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Listener for Participant State Change messages sent by CLAMP.
+ *
+ */
+public class ParticipantStateChangeListener extends ScoListener<ParticipantStateChange> implements Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStateChangeListener.class);
+
+ private final ParticipantHandler participantHandler;
+
+ /**
+ * Constructs the object.
+ *
+ * @param participantHandler the handler for managing the state of the participant
+ */
+ public ParticipantStateChangeListener(final ParticipantHandler participantHandler) {
+ super(ParticipantStateChange.class);
+ this.participantHandler = participantHandler;
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantStateChange participantStateChangeMsg) {
+ LOGGER.debug("Participant State Change received from CLAMP - {}", participantStateChangeMsg);
+
+ if (participantHandler.canHandle(participantStateChangeMsg)) {
+ LOGGER.debug("Message for this participant");
+ participantHandler.handleParticipantStateChange(participantStateChangeMsg);
+ } else {
+ LOGGER.debug("Message not for this participant");
+ }
+ }
+
+ @Override
+ public void close() {
+ // No explicit action on this class
+ }
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusPublisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusPublisher.java
new file mode 100644
index 000000000..bc53b4e9d
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusPublisher.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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 java.io.Closeable;
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send Participant Status messages to clamp using TopicSinkClient.
+ *
+ */
+public class ParticipantStatusPublisher implements Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusPublisher.class);
+
+ private final TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantStatusPublisher.
+ *
+ * @param topicSinks the topic sinks
+ */
+ public ParticipantStatusPublisher(List<TopicSink> topicSinks) {
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Method to send Participant Status message to clamp on demand.
+ *
+ * @param participantStatus the Participant Status
+ */
+ public void send(final ParticipantStatus participantStatus) {
+ topicSinkClient.send(participantStatus);
+ LOGGER.debug("Sent Participant Status message to CLAMP - {}", participantStatus);
+ }
+
+ @Override
+ public void close() {
+ // No explicit action on this class
+ }
+}
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
new file mode 100644
index 000000000..cc2a66b58
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
@@ -0,0 +1,323 @@
+/*-
+ * ============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.handler;
+
+import java.io.Closeable;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import lombok.Getter;
+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.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.ParticipantResponseDetails;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantResponseStatus;
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
+import org.onap.policy.clamp.controlloop.participant.intermediary.comm.MessageSender;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*
+ * This class is responsible for managing the state of all control loops in the participant.
+ */
+public class ControlLoopHandler implements Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopHandler.class);
+
+ private ToscaConceptIdentifier participantType = null;
+ private ToscaConceptIdentifier participantId = null;
+ private MessageSender messageSender = null;
+
+ private final Map<ToscaConceptIdentifier, ControlLoop> controlLoopMap = new LinkedHashMap<>();
+
+ private final Map<UUID, ControlLoopElement> elementsOnThisParticipant = new LinkedHashMap<>();
+
+ @Getter
+ private List<ControlLoopElementListener> listeners = new ArrayList<>();
+
+ public ControlLoopHandler() {}
+
+ /**
+ * Constructor, set the participant ID and messageSender.
+ *
+ * @param parameters the parameters of the participant
+ * @param messageSender the messageSender for sending responses to messages
+ */
+ public ControlLoopHandler(ParticipantIntermediaryParameters parameters, MessageSender messageSender) {
+ this.participantType = parameters.getParticipantType();
+ this.participantId = parameters.getParticipantId();
+ this.messageSender = messageSender;
+ }
+
+ @Override
+ public void close() {
+ // No explicit action on this class
+ }
+
+ public void registerControlLoopElementListener(ControlLoopElementListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Handle a control loop element state change message.
+ *
+ * @param id controlloop element id
+ * @param orderedState the current state
+ * @param newState the ordered state
+ * @return controlLoopElement the updated controlloop element
+ */
+ public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState orderedState,
+ ControlLoopState newState) {
+
+ if (id == null) {
+ return null;
+ }
+
+ ControlLoopElement clElement = elementsOnThisParticipant.get(id);
+ if (clElement != null) {
+ clElement.setOrderedState(orderedState);
+ clElement.setState(newState);
+ LOGGER.debug("Control loop element {} state changed to {}", id, newState);
+ ParticipantResponseDetails response = new ParticipantResponseDetails();
+ response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
+ response.setResponseMessage("ControlLoopElement state changed to {} " + newState);
+ messageSender.sendResponse(response);
+ return clElement;
+ }
+
+ return null;
+ }
+
+ /**
+ * Handle a control loop element statistics.
+ *
+ * @param id controlloop element id
+ * @param elementStatistics control loop element Statistics
+ */
+ public void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics) {
+ ControlLoopElement clElement = elementsOnThisParticipant.get(id);
+ if (clElement != null) {
+ elementStatistics.setParticipantId(participantId);
+ elementStatistics.setId(id);
+ clElement.setClElementStatistics(elementStatistics);
+ }
+ }
+
+ /**
+ * Handle a control loop state change message.
+ *
+ * @param stateChangeMsg the state change message
+ */
+ public void handleControlLoopStateChange(ParticipantControlLoopStateChange stateChangeMsg) {
+ if (stateChangeMsg.getControlLoopId() == null) {
+ return;
+ }
+
+ ControlLoop controlLoop = controlLoopMap.get(stateChangeMsg.getControlLoopId());
+
+ if (controlLoop == null) {
+ LOGGER.debug("Control loop {} does not use this participant", stateChangeMsg.getControlLoopId());
+ return;
+ }
+
+ ParticipantResponseDetails response = new ParticipantResponseDetails(stateChangeMsg);
+ handleState(controlLoop, response, stateChangeMsg.getOrderedState());
+ messageSender.sendResponse(response);
+ }
+
+ /**
+ * Method to handle state changes.
+ *
+ * @param controlLoop participant response
+ * @param response participant response
+ * @param orderedState controlloop ordered state
+ */
+ private void handleState(final ControlLoop controlLoop, final ParticipantResponseDetails response,
+ ControlLoopOrderedState orderedState) {
+ switch (orderedState) {
+ case UNINITIALISED:
+ handleUninitialisedState(controlLoop, orderedState, response);
+ break;
+ case PASSIVE:
+ handlePassiveState(controlLoop, orderedState, response);
+ break;
+ case RUNNING:
+ handleRunningState(controlLoop, orderedState, response);
+ break;
+ default:
+ LOGGER.debug("StateChange message has no state, state is null {}", controlLoop.getDefinition());
+ break;
+ }
+ }
+
+ /**
+ * Handle a control loop update message.
+ *
+ * @param updateMsg the update message
+ */
+ public void handleControlLoopUpdate(ParticipantControlLoopUpdate updateMsg) {
+
+ if (!updateMsg.appliesTo(participantType, participantId)) {
+ return;
+ }
+
+ ControlLoop controlLoop = controlLoopMap.get(updateMsg.getControlLoopId());
+
+ ParticipantResponseDetails response = new ParticipantResponseDetails(updateMsg);
+
+ // TODO: Updates to existing ControlLoops are not supported yet (Addition/Removal of ControlLoop
+ // elements to existing ControlLoop has to be supported).
+ if (controlLoop != null) {
+ response.setResponseStatus(ParticipantResponseStatus.FAIL);
+ response.setResponseMessage("Control loop " + updateMsg.getControlLoopId()
+ + " already defined on participant " + participantId);
+
+ messageSender.sendResponse(response);
+ return;
+ }
+
+ controlLoop = updateMsg.getControlLoop();
+ controlLoop.getElements().values().removeIf(element -> !participantType.equals(element.getParticipantType()));
+
+ controlLoopMap.put(updateMsg.getControlLoopId(), controlLoop);
+ for (ControlLoopElement element : updateMsg.getControlLoop().getElements().values()) {
+ element.setState(element.getOrderedState().asState());
+ element.setParticipantId(participantId);
+ elementsOnThisParticipant.put(element.getId(), element);
+ }
+
+ for (ControlLoopElementListener clElementListener : listeners) {
+ try {
+ for (ControlLoopElement element : updateMsg.getControlLoop().getElements().values()) {
+ clElementListener.controlLoopElementUpdate(element, updateMsg.getControlLoopDefinition());
+ }
+ } catch (PfModelException e) {
+ LOGGER.debug("Control loop element update failed {}", updateMsg.getControlLoopId());
+ }
+ }
+
+ response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
+ response.setResponseMessage(
+ "Control loop " + updateMsg.getControlLoopId() + " defined on participant " + participantId);
+
+ messageSender.sendResponse(response);
+ }
+
+ /**
+ * Method to handle when the new state from participant is UNINITIALISED state.
+ *
+ * @param controlLoop participant response
+ * @param orderedState orderedState
+ * @param response participant response
+ */
+ private void handleUninitialisedState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
+ final ParticipantResponseDetails response) {
+ handleStateChange(controlLoop, orderedState, ControlLoopState.UNINITIALISED, response);
+ controlLoopMap.remove(controlLoop.getKey().asIdentifier());
+
+ for (ControlLoopElementListener clElementListener : listeners) {
+ try {
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ clElementListener.controlLoopElementStateChange(element.getId(), element.getState(),
+ orderedState);
+ }
+ } catch (PfModelException e) {
+ LOGGER.debug("Control loop element update failed {}", controlLoop.getDefinition());
+ }
+ }
+ }
+
+ /**
+ * Method to handle when the new state from participant is PASSIVE state.
+ *
+ * @param controlLoop participant response
+ * @param orderedState orderedState
+ * @param response participant response
+ */
+ private void handlePassiveState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
+ final ParticipantResponseDetails response) {
+ handleStateChange(controlLoop, orderedState, ControlLoopState.PASSIVE, response);
+ }
+
+ /**
+ * Method to handle when the new state from participant is RUNNING state.
+ *
+ * @param controlLoop participant response
+ * @param orderedState orderedState
+ * @param response participant response
+ */
+ private void handleRunningState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
+ final ParticipantResponseDetails response) {
+ handleStateChange(controlLoop, orderedState, ControlLoopState.RUNNING, response);
+ }
+
+ /**
+ * Method to update the state of control loop elements.
+ *
+ * @param controlLoop participant status in memory
+ * @param orderedState orderedState
+ * @param state new state of the control loop elements
+ */
+ private void handleStateChange(ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
+ ControlLoopState newState, ParticipantResponseDetails response) {
+
+ if (orderedState.equals(controlLoop.getOrderedState())) {
+ response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
+ response.setResponseMessage("Control loop is already in state " + orderedState);
+ return;
+ }
+
+ if (!CollectionUtils.isEmpty(controlLoop.getElements().values())) {
+ controlLoop.getElements().values().forEach(element -> {
+ element.setState(newState);
+ element.setOrderedState(orderedState);
+ }
+ );
+ }
+
+ response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
+ response.setResponseMessage("ControlLoop state changed from " + controlLoop.getOrderedState()
+ + " to " + orderedState);
+ controlLoop.setOrderedState(orderedState);
+ }
+
+
+ /**
+ * Get control loops as a {@link ConrolLoops} class.
+ *
+ * @return the control loops
+ */
+ public ControlLoops getControlLoops() {
+ ControlLoops controlLoops = new ControlLoops();
+ controlLoops.setControlLoopList(new ArrayList<>(controlLoopMap.values()));
+ return controlLoops;
+ }
+}
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
new file mode 100644
index 000000000..be2fa1a30
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java
@@ -0,0 +1,165 @@
+/*-
+ * ============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.handler;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.ws.rs.core.Response.Status;
+import lombok.Getter;
+import lombok.experimental.Delegate;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+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.ParticipantHealthCheck;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
+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.ParticipantHealthCheckListener;
+import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantStateChangeListener;
+import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantStatusPublisher;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.TopicSource;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.services.ServiceManagerContainer;
+
+/**
+ * This class activates the Participant Intermediary together with all its handlers.
+ */
+public class IntermediaryActivator extends ServiceManagerContainer {
+ // Name of the message type for messages on topics
+ private static final String[] MSG_TYPE_NAMES = {"messageType"};
+
+ @Getter
+ private final ParticipantIntermediaryParameters parameters;
+
+ // Topics from which the participant receives and to which the participant sends messages
+ private List<TopicSink> topicSinks;
+ private List<TopicSource> topicSources;
+
+ // The participant handler for this intermediary
+ final AtomicReference<ParticipantHandler> participantHandler = new AtomicReference<>();
+
+ /**
+ * Listens for messages on the topic, decodes them into a message, and then dispatches them.
+ */
+ private final MessageTypeDispatcher msgDispatcher;
+
+ /**
+ * Instantiate the activator for participant.
+ *
+ * @param parameters the parameters for the participant intermediary
+ */
+ public IntermediaryActivator(final ParticipantIntermediaryParameters parameters) {
+ this.parameters = parameters;
+
+ topicSinks =
+ TopicEndpointManager.getManager().addTopicSinks(parameters.getClampControlLoopTopics().getTopicSinks());
+
+ topicSources = TopicEndpointManager.getManager()
+ .addTopicSources(parameters.getClampControlLoopTopics().getTopicSources());
+
+ try {
+ this.msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES);
+ } catch (final RuntimeException e) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "topic message dispatcher failed to start", e);
+ }
+
+ // @formatter:off
+ final AtomicReference<ParticipantStatusPublisher> statusPublisher = new AtomicReference<>();
+ final AtomicReference<ParticipantStateChangeListener> participantStateChangeListener = new AtomicReference<>();
+ final AtomicReference<ParticipantHealthCheckListener> participantHealthCheckListener = new AtomicReference<>();
+ final AtomicReference<ControlLoopStateChangeListener> controlLoopStateChangeListener = new AtomicReference<>();
+ final AtomicReference<ControlLoopUpdateListener> controlLoopUpdateListener = new AtomicReference<>();
+
+ addAction("Topic endpoint management",
+ () -> TopicEndpointManager.getManager().start(),
+ () -> TopicEndpointManager.getManager().shutdown());
+
+ addAction("Participant Status Publisher",
+ () -> statusPublisher.set(new ParticipantStatusPublisher(topicSinks)),
+ () -> statusPublisher.get().close());
+
+ addAction("Participant Handler",
+ () -> participantHandler.set(new ParticipantHandler(parameters, statusPublisher.get())),
+ () -> participantHandler.get().close());
+
+ addAction("Participant State Change Listener",
+ () -> participantStateChangeListener.set(new ParticipantStateChangeListener(participantHandler.get())),
+ () -> participantStateChangeListener.get().close());
+
+ addAction("Participant Health Check Listener",
+ () -> participantHealthCheckListener.set(new ParticipantHealthCheckListener(participantHandler.get())),
+ () -> participantHealthCheckListener.get().close());
+
+ addAction("Control Loop State Change Listener",
+ () -> controlLoopStateChangeListener.set(new ControlLoopStateChangeListener(participantHandler.get())),
+ () -> controlLoopStateChangeListener.get().close());
+
+ addAction("Control Loop Update Listener",
+ () -> controlLoopUpdateListener.set(new ControlLoopUpdateListener(participantHandler.get())),
+ () -> controlLoopUpdateListener.get().close());
+
+ addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher);
+ // @formatter:on
+ }
+
+ /**
+ * Registers the dispatcher with the topic source(s).
+ */
+ private void registerMsgDispatcher() {
+ msgDispatcher.register(ParticipantMessageType.PARTICIPANT_STATE_CHANGE.name(),
+ (ScoListener<ParticipantStateChange>) new ParticipantStateChangeListener(
+ participantHandler.get()));
+ msgDispatcher.register(ParticipantMessageType.PARTICIPANT_HEALTH_CHECK.name(),
+ (ScoListener<ParticipantHealthCheck>) new ParticipantHealthCheckListener(
+ participantHandler.get()));
+ msgDispatcher.register(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_STATE_CHANGE.name(),
+ (ScoListener<ParticipantControlLoopStateChange>) new ControlLoopStateChangeListener(
+ participantHandler.get()));
+ msgDispatcher.register(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_UPDATE.name(),
+ (ScoListener<ParticipantControlLoopUpdate>) new ControlLoopUpdateListener(
+ participantHandler.get()));
+ for (final TopicSource source : topicSources) {
+ source.register(msgDispatcher);
+ }
+ }
+
+ /**
+ * Unregisters the dispatcher from the topic source(s).
+ */
+ private void unregisterMsgDispatcher() {
+ for (final TopicSource source : topicSources) {
+ source.unregister(msgDispatcher);
+ }
+ }
+
+ /**
+ * Return the participant handler.
+ */
+ public ParticipantHandler getParticipantHandler() {
+ return participantHandler.get();
+ }
+}
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
new file mode 100644
index 000000000..980ab6ec1
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
@@ -0,0 +1,235 @@
+/*-
+ * ============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.handler;
+
+import java.io.Closeable;
+import java.util.Objects;
+import lombok.Getter;
+import lombok.Setter;
+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.ParticipantHealthCheck;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage;
+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.participant.intermediary.comm.MessageSender;
+import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantStatusPublisher;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is responsible for managing the state of a participant.
+ */
+@Getter
+public class ParticipantHandler implements Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantHandler.class);
+
+ private final ToscaConceptIdentifier participantType;
+ private final ToscaConceptIdentifier participantId;
+ private final MessageSender sender;
+ private final ControlLoopHandler controlLoopHandler;
+ private final ParticipantStatistics participantStatistics;
+
+ @Setter
+ private ParticipantState state = ParticipantState.UNKNOWN;
+
+ @Setter
+ private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN;
+
+ /**
+ * Constructor, set the participant ID and sender.
+ *
+ * @param parameters the parameters of the participant
+ * @param publisher the publisher for sending responses to messages
+ */
+ public ParticipantHandler(ParticipantIntermediaryParameters parameters, ParticipantStatusPublisher publisher) {
+ this.participantType = parameters.getParticipantType();
+ this.participantId = parameters.getParticipantId();
+ this.sender = new MessageSender(this, publisher, parameters.getReportingTimeInterval());
+ this.controlLoopHandler = new ControlLoopHandler(parameters, sender);
+ this.participantStatistics = new ParticipantStatistics();
+ }
+
+ @Override
+ public void close() {
+ sender.close();
+ controlLoopHandler.close();
+ }
+
+ /**
+ * 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;
+ }
+
+ ParticipantResponseDetails 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
+ */
+ public void handleParticipantHealthCheck(final ParticipantHealthCheck healthCheckMsg) {
+ ParticipantResponseDetails response = new ParticipantResponseDetails(healthCheckMsg);
+ response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
+ response.setResponseMessage(healthStatus.toString());
+
+ sender.sendResponse(response);
+ }
+
+ /**
+ * 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);
+ response.setResponseMessage("Participant already in state " + newParticipantState);
+ } else {
+ response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
+ response.setResponseMessage("Participant state changed from " + state + " to " + newParticipantState);
+ state = newParticipantState;
+ }
+ }
+
+ /**
+ * Method to update participant state.
+ *
+ * @param definition participant definition
+ * @param participantState participant state
+ */
+ public Participant updateParticipantState(ToscaConceptIdentifier definition,
+ ParticipantState participantState) {
+ if (!Objects.equals(definition, participantId)) {
+ LOGGER.debug("No participant with this ID {}", definition.getName());
+ return null;
+ }
+ ParticipantResponseDetails response = new ParticipantResponseDetails();
+ handleStateChange(participantState, response);
+ sender.sendResponse(response);
+ return getParticipant(definition.getName(), definition.getVersion());
+ }
+
+ /**
+ * Get participants as a {@link Participant} class.
+ *
+ * @return the participant
+ */
+ public Participant getParticipant(String name, String version) {
+ if (participantId.getName().equals(name)) {
+ Participant participant = new Participant();
+ participant.setDefinition(participantId);
+ participant.setParticipantState(state);
+ participant.setHealthStatus(healthStatus);
+ return participant;
+ }
+ return null;
+ }
+
+ /**
+ * Check if a participant message applies to this participant handler.
+ *
+ * @param partipantMsg the message to check
+ * @return true if it applies, false otherwise
+ */
+ public boolean canHandle(ParticipantMessage partipantMsg) {
+ return partipantMsg.appliesTo(participantType, participantId);
+ }
+}
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
new file mode 100644
index 000000000..8e3440e42
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.parameters;
+
+import lombok.Getter;
+import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to hold all parameters needed for participant component.
+ */
+@NotNull
+@NotBlank
+@Getter
+public class ParticipantIntermediaryParameters extends ParameterGroupImpl {
+ // The ID and description of this participant
+ private ToscaConceptIdentifier participantId;
+ private String description;
+
+ // The participant type of this participant
+ private ToscaConceptIdentifier participantType;
+
+ // The time interval for periodic reporting of status to the CLAMP control loop server
+ private long reportingTimeInterval;
+
+ // DMaaP topics for communicating with the CLAMP control loop server
+ private TopicParameterGroup clampControlLoopTopics;
+
+ /**
+ * Create the participant parameter group.
+ *
+ * @param instanceId instance id of the event.
+ */
+ public ParticipantIntermediaryParameters(final String instanceId) {
+ super(instanceId);
+ }
+}
diff --git a/participant/pom.xml b/participant/pom.xml
index c18ee14d0..b0ee3c084 100644
--- a/participant/pom.xml
+++ b/participant/pom.xml
@@ -39,4 +39,36 @@
<module>participant-intermediary</module>
<module>participant-impl</module>
</modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp-models</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.onap.policy.clamp.controlloop.participant.simulator.main.startstop.Main</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
diff --git a/pom.xml b/pom.xml
index 6f86ff513..d9640b45d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,7 @@
<module>common</module>
<module>models</module>
<module>runtime</module>
+ <module>runtime-controlloop</module>
<module>participant</module>
</modules>
@@ -67,5 +68,74 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>common-parameters</artifactId>
+ <version>${policy.common.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils</artifactId>
+ <version>${policy.common.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${policy.common.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>gson</artifactId>
+ <version>${policy.common.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.models</groupId>
+ <artifactId>policy-models-provider</artifactId>
+ <version>${policy.models.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils-test</artifactId>
+ <version>${policy.common.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/runtime-controlloop/pom.xml b/runtime-controlloop/pom.xml
new file mode 100644
index 000000000..ab72deb91
--- /dev/null
+++ b/runtime-controlloop/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp</artifactId>
+ <version>6.1.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>policy-clamp-runtime-controlloop</artifactId>
+ <name>${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp-models</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
new file mode 100644
index 000000000..88e8b1df9
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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.runtime.commissioning;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.rest.CommissioningController;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.base.PfModelRuntimeException;
+
+/**
+ * This class handles commissioning of control loop definitions.
+ */
+public final class CommissioningHandler extends ControlLoopHandler {
+
+ @Getter
+ private CommissioningProvider provider;
+
+ /**
+ * Gets the CommissioningHandler.
+ *
+ * @return CommissioningHandler
+ */
+ public static CommissioningHandler getInstance() {
+ return Registry.get(CommissioningHandler.class.getName());
+ }
+
+ /**
+ * Create a handler.
+ *
+ * @param controlLoopParameters the parameters for access to the database
+ */
+ public CommissioningHandler(ClRuntimeParameterGroup controlLoopParameters) {
+ super(controlLoopParameters.getDatabaseProviderParameters());
+ }
+
+ @Override
+ public Set<Class<?>> getProviderClasses() {
+ return Set.of(CommissioningController.class);
+ }
+
+ @Override
+ public void startProviders() {
+ provider = new CommissioningProvider(getDatabaseProviderParameters());
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ provider.close();
+ } catch (IOException e) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
+ "an error has occured while stopping commissioning providers", e);
+ }
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
new file mode 100644
index 000000000..50f6787b9
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
@@ -0,0 +1,208 @@
+/*-
+ * ============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.runtime.commissioning;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+
+/**
+ * This class provides the create, read and delete actions on Commissioning of Control Loop concepts in the database to
+ * the callers.
+ */
+public class CommissioningProvider implements Closeable {
+ public static final String CONTROL_LOOP_NODE_TYPE = "org.onap.policy.clamp.controlloop.ControlLoop";
+
+ private final PolicyModelsProvider modelsProvider;
+ private final ControlLoopProvider clProvider;
+
+ private static final Object lockit = new Object();
+
+ /**
+ * Create a commissioning provider.
+ *
+ * @throws ControlLoopRuntimeException on errors creating the provider
+ */
+ public CommissioningProvider(PolicyModelsProviderParameters databaseProviderParameters)
+ throws ControlLoopRuntimeException {
+ try {
+ modelsProvider = new PolicyModelsProviderFactory()
+ .createPolicyModelsProvider(databaseProviderParameters);
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(e);
+ }
+
+ try {
+ clProvider = new ControlLoopProvider(databaseProviderParameters);
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ modelsProvider.close();
+ } catch (PfModelException e) {
+ throw new IOException("error closing modelsProvider", e);
+ }
+ }
+
+ /**
+ * Create control loops from a service template.
+ *
+ * @param serviceTemplate the service template
+ * @return the result of the commissioning operation
+ * @throws PfModelException on creation errors
+ */
+ public CommissioningResponse createControlLoopDefinitions(ToscaServiceTemplate serviceTemplate)
+ throws PfModelException {
+ synchronized (lockit) {
+ modelsProvider.createServiceTemplate(serviceTemplate);
+ }
+
+ CommissioningResponse response = new CommissioningResponse();
+ // @formatter:off
+ response.setAffectedControlLoopDefinitions(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates()
+ .values()
+ .stream()
+ .map(template -> template.getKey().asIdentifier())
+ .collect(Collectors.toList()));
+ // @formatter:on
+
+ return response;
+ }
+
+ /**
+ * Delete the control loop definition with the given name and version.
+ *
+ * @param name the name of the control loop definition to delete
+ * @param version the version of the control loop to delete
+ * @return the result of the deletion
+ * @throws PfModelException on deletion errors
+ */
+ public CommissioningResponse deleteControlLoopDefinition(String name, String version) throws PfModelException {
+ synchronized (lockit) {
+ modelsProvider.deleteServiceTemplate(name, version);
+ }
+
+ CommissioningResponse response = new CommissioningResponse();
+ response.setAffectedControlLoopDefinitions(
+ Collections.singletonList(new ToscaConceptIdentifier(name, version)));
+
+ return response;
+ }
+
+ /**
+ * Get control loop node templates.
+ *
+ * @param clName the name of the control loop, null for all
+ * @param clVersion the version of the control loop, null for all
+ * @return list of control loop node templates
+ * @throws PfModelException on errors getting control loop definitions
+ */
+ public List<ToscaNodeTemplate> getControlLoopDefinitions(String clName, String clVersion) throws PfModelException {
+
+ // @formatter:off
+ ToscaTypedEntityFilter<ToscaNodeTemplate> nodeTemplateFilter = ToscaTypedEntityFilter
+ .<ToscaNodeTemplate>builder()
+ .name(clName)
+ .version(clVersion)
+ .type(CONTROL_LOOP_NODE_TYPE)
+ .build();
+ // @formatter:on
+
+ return clProvider.getFilteredNodeTemplates(nodeTemplateFilter);
+ }
+
+ /**
+ * Get the control loop elements from a control loop node template.
+ *
+ * @param controlLoopNodeTemplate the control loop node template
+ * @return a list of the control loop element node templates in a control loop node template
+ * @throws PfModelException on errors get control loop element node templates
+ */
+ public List<ToscaNodeTemplate> getControlLoopElementDefinitions(ToscaNodeTemplate controlLoopNodeTemplate)
+ throws PfModelException {
+ if (!CONTROL_LOOP_NODE_TYPE.equals(controlLoopNodeTemplate.getType())) {
+ return Collections.emptyList();
+ }
+
+ if (MapUtils.isEmpty(controlLoopNodeTemplate.getProperties())) {
+ return Collections.emptyList();
+ }
+
+ @SuppressWarnings("unchecked")
+ List<Map<String, String>> controlLoopElements =
+ (List<Map<String, String>>) controlLoopNodeTemplate.getProperties().get("elements");
+
+ if (CollectionUtils.isEmpty(controlLoopElements)) {
+ return Collections.emptyList();
+ }
+
+ List<ToscaNodeTemplate> controlLoopElementList = new ArrayList<>();
+ // @formatter:off
+ controlLoopElementList.addAll(
+ controlLoopElements
+ .stream()
+ .map(elementMap -> clProvider.getNodeTemplates(elementMap.get("name"),
+ elementMap.get("version")))
+ .flatMap(List::stream)
+ .collect(Collectors.toList())
+ );
+ // @formatter:on
+
+ return controlLoopElementList;
+ }
+
+ /**
+ * Get the requested control loop definitions.
+ *
+ * @param name the name of the definition to get, null for all definitions
+ * @param version the version of the definition to get, null for all definitions
+ * @return the control loop definitions
+ * @throws PfModelException on errors getting control loop definitions
+ */
+ public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException {
+ ToscaServiceTemplates serviceTemplates = new ToscaServiceTemplates();
+ serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
+ return serviceTemplates.getServiceTemplates().get(0);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
new file mode 100644
index 000000000..18e1f7787
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
@@ -0,0 +1,360 @@
+/*-
+ * ============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.runtime.commissioning.rest;
+
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Authorization;
+import io.swagger.annotations.Extension;
+import io.swagger.annotations.ExtensionProperty;
+import io.swagger.annotations.ResponseHeader;
+import java.util.List;
+import java.util.UUID;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningHandler;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
+import org.onap.policy.clamp.controlloop.runtime.main.rest.RestController;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.errors.concepts.ErrorResponse;
+import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to provide REST end points for creating, deleting, querying commissioned control loops.
+ */
+public class CommissioningController extends RestController {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CommissioningController.class);
+
+ private final CommissioningProvider provider;
+
+ /**
+ * create Commissioning Controller.
+ */
+ public CommissioningController() {
+ this.provider = CommissioningHandler.getInstance().getProvider();
+ }
+
+ /**
+ * Creates a control loop definition.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param body the body of control loop following TOSCA definition
+ * @return a response
+ */
+ // @formatter:off
+ @POST
+ @Path("/commission")
+ @ApiOperation(
+ value = "Commissions control loop definitions",
+ notes = "Commissions control loop definitions, returning the commissioned control loop definition IDs",
+ response = CommissioningResponse.class,
+ tags = {
+ "Control Loop Commissioning API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response create(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Entity Body of Control Loop", required = true) ToscaServiceTemplate body) {
+
+ try {
+ CommissioningResponse response = provider.createControlLoopDefinitions(body);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId)
+ .entity(response).build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("Commissioning of the control loops failed", e);
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
+ }
+
+ }
+
+ /**
+ * Deletes a control loop definition.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the control loop definition to delete
+ * @param version the version of the control loop definition to delete
+ * @return a response
+ */
+ // @formatter:off
+ @DELETE
+ @Path("/commission")
+ @ApiOperation(value = "Delete a commissioned control loop",
+ notes = "Deletes a Commissioned Control Loop, returning optional error details",
+ response = CommissioningResponse.class,
+ tags = {
+ "Clamp Control Loop Commissioning API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response delete(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true)
+ @QueryParam("version") String version) {
+
+ try {
+ CommissioningResponse response = provider.deleteControlLoopDefinition(name, version);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId)
+ .entity(response).build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("Decommisssioning of control loop failed", e);
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
+ }
+
+ }
+
+ /**
+ * Queries details of all or specific control loop definitions.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the control loop definition to get, null for all definitions
+ * @param version the version of the control loop definition to get, null for all definitions
+ * @return the control loop definitions
+ */
+ // @formatter:off
+ @GET
+ @Path("/commission")
+ @ApiOperation(value = "Query details of the requested commissioned control loop definitions",
+ notes = "Queries details of the requested commissioned control loop definitions, "
+ + "returning all control loop details",
+ response = ToscaNodeTemplate.class,
+ tags = {
+ "Clamp Control Loop Commissioning API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response query(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop definition name", required = true)
+ @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true)
+ @QueryParam("version") String version) {
+
+ try {
+ List<ToscaNodeTemplate> response = provider.getControlLoopDefinitions(name, version);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("Get of control loop definitions failed", e);
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
+ }
+
+ }
+
+ /**
+ * Queries the elements of a specific control loop.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the control loop definition to get
+ * @param version the version of the control loop definition to get
+ * @return the control loop element definitions
+ */
+ // @formatter:off
+ @GET
+ @Path("/commission/elements")
+ @ApiOperation(value = "Query details of the requested commissioned control loop element definitions",
+ notes = "Queries details of the requested commissioned control loop element definitions, "
+ + "returning all control loop elements' details",
+ response = ToscaNodeTemplate.class,
+ tags = {
+ "Clamp Control Loop Commissioning API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response queryElements(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop definition name", required = true)
+ @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true)
+ @QueryParam("version") String version) throws Exception {
+
+ try {
+ List<ToscaNodeTemplate> nodeTemplate = provider.getControlLoopDefinitions(name, version);
+ //Prevent ambiguous queries with multiple returns
+ if (nodeTemplate.size() > 1) {
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails("Multiple ControlLoops are not supported");
+ return returnResponse(Response.Status.NOT_ACCEPTABLE, requestId, resp);
+ }
+
+ List<ToscaNodeTemplate> response = provider.getControlLoopElementDefinitions(nodeTemplate.get(0));
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("Get of control loop element definitions failed", e);
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
+ }
+
+ }
+
+ private Response returnResponse(Response.Status status, UUID requestId, CommissioningResponse resp) {
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(status)),
+ requestId).entity(resp).build();
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
new file mode 100644
index 000000000..eb72d9219
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
@@ -0,0 +1,276 @@
+/*-
+ * ============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.runtime.instantiation;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.function.UnaryOperator;
+import java.util.stream.Collectors;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+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.ControlLoopState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.ObjectValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+
+/**
+ * This class is dedicated to the Instantiation of Commissioned control loop.
+ */
+public class ControlLoopInstantiationProvider implements Closeable {
+ private final ControlLoopProvider controlLoopProvider;
+ private final CommissioningProvider commissioningProvider;
+
+ private static final Object lockit = new Object();
+
+ /**
+ * Create a instantiation provider.
+ *
+ * @param databaseProviderParameters the parameters for database access
+ */
+ public ControlLoopInstantiationProvider(PolicyModelsProviderParameters databaseProviderParameters) {
+ try {
+ controlLoopProvider = new ControlLoopProvider(databaseProviderParameters);
+ commissioningProvider = new CommissioningProvider(databaseProviderParameters);
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ controlLoopProvider.close();
+ }
+
+ /**
+ * Create control loops.
+ *
+ * @param controlLoops the control loop
+ * @return the result of the instantiation operation
+ * @throws PfModelException on creation errors
+ */
+ public InstantiationResponse createControlLoops(ControlLoops controlLoops) throws PfModelException {
+
+ synchronized (lockit) {
+ for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
+ ControlLoop checkControlLoop = controlLoopProvider.getControlLoop(controlLoop.getKey().asIdentifier());
+ if (checkControlLoop != null) {
+ throw new PfModelException(Response.Status.BAD_REQUEST,
+ controlLoop.getKey().asIdentifier() + " already defined");
+ }
+ }
+ BeanValidationResult validationResult = validateControlLoops(controlLoops);
+ if (!validationResult.isValid()) {
+ throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
+ controlLoopProvider.createControlLoops(controlLoops.getControlLoopList());
+ }
+
+ InstantiationResponse response = new InstantiationResponse();
+ response.setAffectedControlLoops(controlLoops.getControlLoopList().stream()
+ .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
+
+ return response;
+ }
+
+ /**
+ * Update control loops.
+ *
+ * @param controlLoops the control loop
+ * @return the result of the instantiation operation
+ * @throws PfModelException on update errors
+ */
+ public InstantiationResponse updateControlLoops(ControlLoops controlLoops) throws PfModelException {
+ synchronized (lockit) {
+ BeanValidationResult validationResult = validateControlLoops(controlLoops);
+ if (!validationResult.isValid()) {
+ throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
+ controlLoopProvider.updateControlLoops(controlLoops.getControlLoopList());
+ }
+
+ InstantiationResponse response = new InstantiationResponse();
+ response.setAffectedControlLoops(controlLoops.getControlLoopList().stream()
+ .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
+
+ return response;
+ }
+
+ /**
+ * Validate ControlLoops.
+ *
+ * @param controlLoops ControlLoops to validate
+ * @result the result of validation
+ * @throws PfModelException if controlLoops is not valid
+ */
+ private BeanValidationResult validateControlLoops(ControlLoops controlLoops) throws PfModelException {
+
+ BeanValidationResult result = new BeanValidationResult("ControlLoops", controlLoops);
+
+ for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
+ BeanValidationResult subResult = new BeanValidationResult(
+ "entry " + controlLoop.getDefinition().getName(), controlLoop);
+
+ List<ToscaNodeTemplate> toscaNodeTemplates = commissioningProvider.getControlLoopDefinitions(
+ controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
+
+ if (toscaNodeTemplates.isEmpty()) {
+ subResult
+ .addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
+ ValidationStatus.INVALID, "Commissioned control loop definition not FOUND"));
+ } else if (toscaNodeTemplates.size() > 1) {
+ subResult
+ .addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
+ ValidationStatus.INVALID, "Commissioned control loop definition not VALID"));
+ } else {
+
+ List<ToscaNodeTemplate> clElementDefinitions =
+ commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplates.get(0));
+
+ // @formatter:off
+ Map<String, ToscaConceptIdentifier> definitions = clElementDefinitions
+ .stream()
+ .map(nodeTemplate -> nodeTemplate.getKey().asIdentifier())
+ .collect(Collectors.toMap(ToscaConceptIdentifier::getName, UnaryOperator.identity()));
+ // @formatter:on
+
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ subResult.addResult(validateDefinition(definitions, element.getDefinition()));
+ }
+ }
+ result.addResult(subResult);
+ }
+ return result;
+ }
+
+ /**
+ * Validate ToscaConceptIdentifier, checking if exist in ToscaConceptIdentifiers map.
+ *
+ * @param definitions map of all ToscaConceptIdentifiers
+ * @param definition ToscaConceptIdentifier to validate
+ * @result result the validation result
+ */
+ private ValidationResult validateDefinition(Map<String, ToscaConceptIdentifier> definitions,
+ ToscaConceptIdentifier definition) {
+ BeanValidationResult result = new BeanValidationResult("entry " + definition.getName(), definition);
+ ToscaConceptIdentifier identifier = definitions.get(definition.getName());
+ if (identifier == null) {
+ result.setResult(ValidationStatus.INVALID, "Not FOUND");
+ } else if (!identifier.equals(definition)) {
+ result.setResult(ValidationStatus.INVALID, "Version not matching");
+ }
+ return (result.isClean() ? null : result);
+ }
+
+ /**
+ * Delete the control loop with the given name and version.
+ *
+ * @param name the name of the control loop to delete
+ * @param version the version of the control loop to delete
+ * @return the result of the deletion
+ * @throws PfModelException on deletion errors
+ */
+ public InstantiationResponse deleteControlLoop(String name, String version) throws PfModelException {
+ InstantiationResponse response = new InstantiationResponse();
+ synchronized (lockit) {
+ List<ControlLoop> controlLoops = controlLoopProvider.getControlLoops(name, version);
+ if (controlLoops.isEmpty()) {
+ throw new PfModelException(Response.Status.NOT_FOUND, "Control Loop not found");
+ }
+ for (ControlLoop controlLoop : controlLoops) {
+ if (!ControlLoopState.UNINITIALISED.equals(controlLoop.getState())) {
+ throw new PfModelException(Response.Status.BAD_REQUEST,
+ "Control Loop State is still " + controlLoop.getState());
+ }
+ }
+
+ response.setAffectedControlLoops(Collections
+ .singletonList(controlLoopProvider.deleteControlLoop(name, version).getKey().asIdentifier()));
+ }
+ return response;
+ }
+
+ /**
+ * Get the requested control loops.
+ *
+ * @param name the name of the control loop to get, null for all control loops
+ * @param version the version of the control loop to get, null for all control loops
+ * @return the control loops
+ * @throws PfModelException on errors getting control loops
+ */
+ public ControlLoops getControlLoops(String name, String version) throws PfModelException {
+ ControlLoops controlLoops = new ControlLoops();
+ controlLoops.setControlLoopList(controlLoopProvider.getControlLoops(name, version));
+
+ return controlLoops;
+ }
+
+ /**
+ * Issue a command to control loops, setting their ordered state.
+ *
+ * @param command the command to issue to control loops
+ * @return the result of the initiation command
+ * @throws PfModelException on errors setting the ordered state on the control loops
+ * @throws ControlLoopException on ordered state invalid
+ */
+ public InstantiationResponse issueControlLoopCommand(InstantiationCommand command)
+ throws ControlLoopException, PfModelException {
+
+ if (command.getOrderedState() == null) {
+ throw new ControlLoopException(Status.BAD_REQUEST, "ordered state invalid or not specified on command");
+ }
+
+ synchronized (lockit) {
+ List<ControlLoop> controlLoops = new ArrayList<>(command.getControlLoopIdentifierList().size());
+ for (ToscaConceptIdentifier id : command.getControlLoopIdentifierList()) {
+ ControlLoop controlLoop = controlLoopProvider.getControlLoop(id);
+ controlLoop.setCascadedOrderedState(command.getOrderedState());
+ controlLoops.add(controlLoop);
+ }
+ controlLoopProvider.updateControlLoops(controlLoops);
+ }
+
+ SupervisionHandler supervisionHandler = SupervisionHandler.getInstance();
+ supervisionHandler.triggerControlLoopSupervision(command.getControlLoopIdentifierList());
+ InstantiationResponse response = new InstantiationResponse();
+ response.setAffectedControlLoops(command.getControlLoopIdentifierList());
+
+ return response;
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
new file mode 100644
index 000000000..d81e54ccf
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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.runtime.instantiation;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+import org.onap.policy.clamp.controlloop.runtime.instantiation.rest.InstantiationController;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.base.PfModelRuntimeException;
+
+/**
+ * This class handles instantiation of control loop instances.
+ *
+ * <p/>It is effectively a singleton that is started at system start
+ */
+public final class InstantiationHandler extends ControlLoopHandler {
+
+ @Getter
+ private ControlLoopInstantiationProvider controlLoopInstantiationProvider;
+
+ /**
+ * Gets the InstantiationHandler.
+ *
+ * @return InstantiationHandler
+ */
+ public static InstantiationHandler getInstance() {
+ return Registry.get(InstantiationHandler.class.getName());
+ }
+
+ /**
+ * Create a handler.
+ *
+ * @param controlLoopParameters the parameters for access to the database
+ */
+ public InstantiationHandler(ClRuntimeParameterGroup controlLoopParameters) {
+ super(controlLoopParameters.getDatabaseProviderParameters());
+ }
+
+ @Override
+ public Set<Class<?>> getProviderClasses() {
+ return Set.of(InstantiationController.class);
+ }
+
+ @Override
+ public void startProviders() {
+ controlLoopInstantiationProvider = new ControlLoopInstantiationProvider(getDatabaseProviderParameters());
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ controlLoopInstantiationProvider.close();
+ } catch (IOException e) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
+ }
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
new file mode 100644
index 000000000..7581aaf74
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
@@ -0,0 +1,416 @@
+/*-
+ * ============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.runtime.instantiation.rest;
+
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Authorization;
+import io.swagger.annotations.Extension;
+import io.swagger.annotations.ExtensionProperty;
+import io.swagger.annotations.ResponseHeader;
+import java.util.UUID;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
+import org.onap.policy.clamp.controlloop.runtime.instantiation.ControlLoopInstantiationProvider;
+import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationHandler;
+import org.onap.policy.clamp.controlloop.runtime.main.rest.RestController;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to provide REST end points for creating, deleting, query and commanding a control loop definition.
+ */
+public class InstantiationController extends RestController {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(InstantiationController.class);
+
+ // The CL provider for instantiation requests
+ private final ControlLoopInstantiationProvider provider;
+
+ /**
+ * create Instantiation Controller.
+ */
+ public InstantiationController() {
+ this.provider = InstantiationHandler.getInstance().getControlLoopInstantiationProvider();
+ }
+
+ /**
+ * Creates a control loop.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param controlLoops the control loops
+ * @return a response
+ */
+ // @formatter:off
+ @POST
+ @Path("/instantiation")
+ @ApiOperation(
+ value = "Commissions control loop definitions",
+ notes = "Commissions control loop definitions, returning the control loop IDs",
+ response = InstantiationResponse.class,
+ tags = {
+ "Control Loop Instantiation API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response create(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Entity Body of Control Loop", required = true) ControlLoops controlLoops) {
+
+ try {
+ InstantiationResponse response = provider.createControlLoops(controlLoops);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("creation of control loop failed", e);
+ return createInstantiationErrorResponse(e, requestId);
+ }
+ }
+
+ /**
+ * Queries details of all control loops.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the control loop to get, null for all control loops
+ * @param version the version of the control loop to get, null for all control loops
+ * @return the control loops
+ */
+ // @formatter:off
+ @GET
+ @Path("/instantiation")
+ @ApiOperation(value = "Query details of the requested control loops",
+ notes = "Queries details of the requested control loops, returning all control loop details",
+ response = ControlLoops.class,
+ tags = {
+ "Clamp control loop Instantiation API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response query(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version",
+ required = true) @QueryParam("version") String version) {
+
+ try {
+ ControlLoops response = provider.getControlLoops(name, version);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("commisssioning of control loop failed", e);
+ return createInstantiationErrorResponse(e, requestId);
+ }
+
+ }
+
+ /**
+ * Updates a control loop.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param controlLoops the control loops
+ * @return a response
+ */
+ // @formatter:off
+ @PUT
+ @Path("/instantiation")
+ @ApiOperation(
+ value = "Updates control loop definitions",
+ notes = "Updates control loop definitions, returning the updated control loop definition IDs",
+ response = InstantiationResponse.class,
+ tags = {
+ "Control Loop Instantiation API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response update(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Entity Body of Control Loop", required = true) ControlLoops controlLoops) {
+
+ try {
+ InstantiationResponse response = provider.updateControlLoops(controlLoops);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("update of control loops failed", e);
+ return createInstantiationErrorResponse(e, requestId);
+ }
+ }
+
+ /**
+ * Deletes a control loop definition.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the control loop to delete
+ * @param version the version of the control loop to delete
+ * @return a response
+ */
+ // @formatter:off
+ @DELETE
+ @Path("/instantiation")
+ @ApiOperation(value = "Delete a control loop",
+ notes = "Deletes a control loop, returning optional error details",
+ response = InstantiationResponse.class,
+ tags = {
+ "Clamp Control Loop Instantiation API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+
+ public Response delete(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true)
+ @QueryParam("version") String version) {
+
+ try {
+ InstantiationResponse response = provider.deleteControlLoop(name, version);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("delete of control loop failed", e);
+ return createInstantiationErrorResponse(e, requestId);
+ }
+ }
+
+ /**
+ * Issues control loop commands to control loops.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param command the command to issue to control loops
+ * @return the control loop definitions
+ */
+ // @formatter:off
+ @PUT
+ @Path("/instantiation/command")
+ @ApiOperation(value = "Issue a command to the requested control loops",
+ notes = "Issues a command to a control loop, ordering a state change on the control loop",
+ response = InstantiationResponse.class,
+ tags = {
+ "Clamp Control Loop Instantiation API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response issueControlLoopCommand(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Entity Body of control loop command", required = true) InstantiationCommand command) {
+
+ try {
+ InstantiationResponse response = provider.issueControlLoopCommand(command);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.ACCEPTED)), requestId)
+ .entity(response).build();
+
+ } catch (PfModelRuntimeException | PfModelException | ControlLoopException e) {
+ LOGGER.warn("creation of control loop failed", e);
+ return createInstantiationErrorResponse(e, requestId);
+ }
+ }
+
+ /**
+ * create a Instantiation Response from an exception.
+ * @param e the error
+ * @param requestId request ID used in ONAP logging
+ * @return the Instantiation Response
+ */
+ private Response createInstantiationErrorResponse(ErrorResponseInfo e, UUID requestId) {
+ InstantiationResponse resp = new InstantiationResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
+ requestId).entity(resp).build();
+ }
+}
+
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
new file mode 100644
index 000000000..4c99b8e57
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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.runtime.main.parameters;
+
+import java.util.List;
+import javax.validation.constraints.NotBlank;
+import lombok.Getter;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+
+/**
+ * Class to hold all parameters needed for the Control Loop runtime component.
+ *
+ */
+@NotNull
+@NotBlank
+@Getter
+public class ClRuntimeParameterGroup extends ParameterGroupImpl {
+ private RestServerParameters restServerParameters;
+ private PolicyModelsProviderParameters databaseProviderParameters;
+ private ParticipantParameters participantParameters;
+ private TopicParameterGroup topicParameterGroup;
+ private List<BusTopicParams> healthCheckRestClientParameters;
+
+ /**
+ * Create the Control Loop parameter group.
+ *
+ * @param name the parameter group name
+ */
+ public ClRuntimeParameterGroup(final String name) {
+ super(name);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java
new file mode 100644
index 000000000..a463ad171
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java
@@ -0,0 +1,77 @@
+/*-
+ * ============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.runtime.main.parameters;
+
+import java.io.File;
+import javax.ws.rs.core.Response;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.runtime.main.startstop.ClRuntimeCommandLineArguments;
+import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+
+/**
+ * This class handles reading, parsing and validating of control loop runtime parameters from JSON files.
+ */
+public class ClRuntimeParameterHandler {
+
+ private static final Coder CODER = new StandardCoder();
+
+ /**
+ * Read the parameters from the parameter file.
+ *
+ * @param arguments the arguments passed to control loop runtime
+ * @return the parameters read from the configuration file
+ * @throws ControlLoopException on parameter exceptions
+ */
+ public ClRuntimeParameterGroup getParameters(final ClRuntimeCommandLineArguments arguments)
+ throws ControlLoopException {
+ ClRuntimeParameterGroup clRuntimeParameterGroup = null;
+
+ // Read the parameters
+ try {
+ // Read the parameters from JSON
+ File file = new File(arguments.getFullConfigurationFilePath());
+ clRuntimeParameterGroup = CODER.decode(file, ClRuntimeParameterGroup.class);
+ } catch (final CoderException e) {
+ throw new ControlLoopException(
+ Response.Status.NOT_ACCEPTABLE, "error reading parameters from \""
+ + arguments.getConfigurationFilePath() + "\"\n" + "(" + e.getClass().getSimpleName() + ")",
+ e);
+ }
+
+ // The JSON processing returns null if there is an empty file
+ if (clRuntimeParameterGroup == null) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ "no parameters found in \"" + arguments.getConfigurationFilePath() + "\"");
+ }
+
+ // validate the parameters
+ final ValidationResult validationResult = clRuntimeParameterGroup.validate();
+ if (!validationResult.isValid()) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, "validation error(s) on parameters from \""
+ + arguments.getConfigurationFilePath() + "\"\n" + validationResult.getResult());
+ }
+
+ return clRuntimeParameterGroup;
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java
new file mode 100644
index 000000000..dfc1b2806
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.main.parameters;
+
+import java.util.concurrent.TimeUnit;
+import lombok.Getter;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.Min;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+
+/**
+ * Parameters for communicating with participants.
+ */
+@NotNull
+@NotBlank
+@Getter
+public class ParticipantParameters extends ParameterGroupImpl {
+
+ /**
+ * Default maximum message age, in milliseconds, that should be examined. Any message
+ * older than this is discarded.
+ */
+ public static final long DEFAULT_MAX_AGE_MS = TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES);
+
+
+ @Min(1)
+ private long heartBeatMs;
+
+ @Min(1)
+ private long maxMessageAgeMs = DEFAULT_MAX_AGE_MS;
+
+ private ParticipantUpdateParameters updateParameters;
+ private ParticipantStateChangeParameters stateChangeParameters;
+
+
+ /**
+ * Constructs the object.
+ */
+ public ParticipantParameters() {
+ super(ParticipantParameters.class.getSimpleName());
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java
new file mode 100644
index 000000000..2eea4ab51
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java
@@ -0,0 +1,53 @@
+/*
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.main.parameters;
+
+import lombok.Getter;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.Min;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+
+/**
+ * Parameters for Participant STATE-CHANGE requests.
+ */
+@NotNull
+@NotBlank
+@Getter
+public class ParticipantStateChangeParameters extends ParameterGroupImpl {
+
+ /**
+ * Maximum number of times to re-send a request to a PDP.
+ */
+ @Min(value = 0)
+ private int maxRetryCount;
+
+ /**
+ * Maximum time to wait, in milliseconds, for a PDP response.
+ */
+ @Min(value = 0)
+ private long maxWaitMs;
+
+ /**
+ * Constructs the object.
+ */
+ public ParticipantStateChangeParameters() {
+ super(ParticipantStateChangeParameters.class.getSimpleName());
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
new file mode 100644
index 000000000..2af5be534
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
@@ -0,0 +1,54 @@
+/*
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.main.parameters;
+
+import lombok.Getter;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.Min;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+
+/**
+ * Parameters for Participant UPDATE requests.
+ */
+@NotNull
+@NotBlank
+@Getter
+public class ParticipantUpdateParameters extends ParameterGroupImpl {
+
+ /**
+ * Maximum number of times to re-send a request to a PDP.
+ */
+ @Min(value = 0)
+ private int maxRetryCount;
+
+ /**
+ * Maximum time to wait, in milliseconds, for a PDP response.
+ */
+ @Min(value = 0)
+ private long maxWaitMs;
+
+ /**
+ * Constructs the object.
+ */
+ public ParticipantUpdateParameters() {
+ super(ParticipantUpdateParameters.class.getSimpleName());
+ }
+}
+
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/ControlLoopAafFilter.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/ControlLoopAafFilter.java
new file mode 100644
index 000000000..f166de5d6
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/ControlLoopAafFilter.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.runtime.main.rest;
+
+import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter;
+import org.onap.policy.common.utils.resources.MessageConstants;
+
+/**
+ * Class to manage AAF filters for the control loop runtime component.
+ */
+public class ControlLoopAafFilter extends AafGranularAuthFilter {
+
+ public static final String AAF_NODETYPE = MessageConstants.POLICY_CLAMP;
+ public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE;
+
+ @Override
+ public String getPermissionTypeRoot() {
+ return AAF_ROOT_PERMISSION;
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java
new file mode 100644
index 000000000..dd3fa30fc
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java
@@ -0,0 +1,115 @@
+/*-
+ * ============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.runtime.main.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.BasicAuthDefinition;
+import io.swagger.annotations.Info;
+import io.swagger.annotations.SecurityDefinition;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
+import java.net.HttpURLConnection;
+import java.util.UUID;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.ResponseBuilder;
+
+/**
+ * Common superclass to provide REST endpoints for the control loop service.
+ */
+// @formatter:off
+@Path("/onap/controlloop/v2")
+@Api(value = "Control Loop API")
+@Produces({MediaType.APPLICATION_JSON, RestController.APPLICATION_YAML})
+@SwaggerDefinition(
+ info = @Info(description =
+ "Control Loop Service", version = "v1.0",
+ title = "Control Loop"),
+ consumes = {MediaType.APPLICATION_JSON, RestController.APPLICATION_YAML},
+ produces = {MediaType.APPLICATION_JSON, RestController.APPLICATION_YAML},
+ schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
+ tags = {@Tag(name = "controlloop", description = "Control Loop Service")},
+ securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
+// @formatter:on
+public class RestController {
+ public static final String APPLICATION_YAML = "application/yaml";
+
+ public static final String EXTENSION_NAME = "interface info";
+
+ public static final String API_VERSION_NAME = "api-version";
+ public static final String API_VERSION = "1.0.0";
+
+ public static final String LAST_MOD_NAME = "last-mod-release";
+ public static final String LAST_MOD_RELEASE = "Dublin";
+
+ public static final String VERSION_MINOR_NAME = "X-MinorVersion";
+ public static final String VERSION_MINOR_DESCRIPTION =
+ "Used to request or communicate a MINOR version back from the client"
+ + " to the server, and from the server back to the client";
+
+ public static final String VERSION_PATCH_NAME = "X-PatchVersion";
+ public static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for"
+ + " troubleshooting purposes only, and will not be provided by" + " the client on request";
+
+ public static final String VERSION_LATEST_NAME = "X-LatestVersion";
+ public static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version";
+
+ public static final String REQUEST_ID_NAME = "X-ONAP-RequestID";
+ public static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose";
+ public static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction";
+
+ public static final String AUTHORIZATION_TYPE = "basicAuth";
+
+ public static final int AUTHENTICATION_ERROR_CODE = HttpURLConnection.HTTP_UNAUTHORIZED;
+ public static final int AUTHORIZATION_ERROR_CODE = HttpURLConnection.HTTP_FORBIDDEN;
+ public static final int SERVER_ERROR_CODE = HttpURLConnection.HTTP_INTERNAL_ERROR;
+
+ public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error";
+ public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error";
+ public static final String SERVER_ERROR_MESSAGE = "Internal Server Error";
+
+ /**
+ * Adds version headers to the response.
+ *
+ * @param respBuilder response builder
+ * @return the response builder, with version headers
+ */
+ public ResponseBuilder addVersionControlHeaders(ResponseBuilder respBuilder) {
+ return respBuilder.header(VERSION_MINOR_NAME, "0").header(VERSION_PATCH_NAME, "0").header(VERSION_LATEST_NAME,
+ API_VERSION);
+ }
+
+ /**
+ * Adds logging headers to the response.
+ *
+ * @param respBuilder response builder
+ * @return the response builder, with version logging
+ */
+ public ResponseBuilder addLoggingHeaders(ResponseBuilder respBuilder, UUID requestId) {
+ if (requestId == null) {
+ // Generate a random uuid if client does not embed requestId in rest request
+ return respBuilder.header(REQUEST_ID_NAME, UUID.randomUUID());
+ }
+
+ return respBuilder.header(REQUEST_ID_NAME, requestId);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
new file mode 100644
index 000000000..a4238a9c4
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
@@ -0,0 +1,186 @@
+/*-
+ * ============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.runtime.main.startstop;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.ws.rs.core.Response.Status;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningHandler;
+import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationHandler;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.clamp.controlloop.runtime.main.rest.ControlLoopAafFilter;
+import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringHandler;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.TopicSource;
+import org.onap.policy.common.endpoints.http.server.RestServer;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.common.utils.services.ServiceManagerContainer;
+
+/**
+ * This class activates the control loop runtime component as a complete service together with all its controllers,
+ * listeners & handlers.
+ */
+public class ClRuntimeActivator extends ServiceManagerContainer {
+ // Name of the message type for messages on topics
+ private static final String[] MSG_TYPE_NAMES = {"messageType"};
+
+ private final ClRuntimeParameterGroup clRuntimeParameterGroup;
+
+ // Topics from which the application receives and to which the application sends messages
+ private List<TopicSink> topicSinks;
+ private List<TopicSource> topicSources;
+
+ /**
+ * Listens for messages on the topic, decodes them into a message, and then dispatches them.
+ */
+ private final MessageTypeDispatcher msgDispatcher;
+
+ /**
+ * Instantiate the activator for the control loop runtime as a complete service.
+ *
+ * @param clRuntimeParameterGroup the parameters for the control loop runtime service
+ */
+ public ClRuntimeActivator(final ClRuntimeParameterGroup clRuntimeParameterGroup) {
+
+ if (clRuntimeParameterGroup == null || !clRuntimeParameterGroup.isValid()) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR, "ParameterGroup not valid");
+ }
+
+ this.clRuntimeParameterGroup = clRuntimeParameterGroup;
+
+ topicSinks = TopicEndpointManager.getManager()
+ .addTopicSinks(clRuntimeParameterGroup.getTopicParameterGroup().getTopicSinks());
+
+ topicSources = TopicEndpointManager.getManager()
+ .addTopicSources(clRuntimeParameterGroup.getTopicParameterGroup().getTopicSources());
+
+ try {
+ msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES);
+ } catch (final RuntimeException e) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "topic message dispatcher failed to start", e);
+ }
+
+ final AtomicReference<ControlLoopHandler> commissioningHandler = new AtomicReference<>();
+ final AtomicReference<ControlLoopHandler> instantiationHandler = new AtomicReference<>();
+ final AtomicReference<ControlLoopHandler> supervisionHandler = new AtomicReference<>();
+ final AtomicReference<ControlLoopHandler> monitoringHandler = new AtomicReference<>();
+ final AtomicReference<RestServer> restServer = new AtomicReference<>();
+
+ // @formatter:off
+ addAction("Control loop runtime parameters",
+ () -> ParameterService.register(clRuntimeParameterGroup),
+ () -> ParameterService.deregister(clRuntimeParameterGroup.getName()));
+
+ addAction("Topic endpoint management",
+ () -> TopicEndpointManager.getManager().start(),
+ () -> TopicEndpointManager.getManager().shutdown());
+
+ addAction("Commissioning Handler",
+ () -> commissioningHandler.set(new CommissioningHandler(clRuntimeParameterGroup)),
+ () -> commissioningHandler.get().close());
+
+ addAction("Instantiation Handler",
+ () -> instantiationHandler.set(new InstantiationHandler(clRuntimeParameterGroup)),
+ () -> instantiationHandler.get().close());
+
+ addAction("Supervision Handler",
+ () -> supervisionHandler.set(new SupervisionHandler(clRuntimeParameterGroup)),
+ () -> supervisionHandler.get().close());
+
+ addAction("Monitoring Handler",
+ () -> monitoringHandler.set(new MonitoringHandler(clRuntimeParameterGroup)),
+ () -> monitoringHandler.get().close());
+
+ addHandlerActions("Commissioning", commissioningHandler);
+ addHandlerActions("Instantiation", instantiationHandler);
+ addHandlerActions("Supervision", supervisionHandler);
+ addHandlerActions("Monitoring", monitoringHandler);
+
+ addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher);
+
+ clRuntimeParameterGroup.getRestServerParameters().setName(clRuntimeParameterGroup.getName());
+
+ addAction("REST server",
+ () -> {
+ Set<Class<?>> providerClasses = new HashSet<>();
+ providerClasses.addAll(commissioningHandler.get().getProviderClasses());
+ providerClasses.addAll(instantiationHandler.get().getProviderClasses());
+ providerClasses.addAll(supervisionHandler.get().getProviderClasses());
+ providerClasses.addAll(monitoringHandler.get().getProviderClasses());
+
+ RestServer server = new RestServer(clRuntimeParameterGroup.getRestServerParameters(),
+ ControlLoopAafFilter.class,
+ providerClasses.toArray(new Class<?>[providerClasses.size()]));
+
+ restServer.set(server);
+ restServer.get().start();
+ },
+ () -> restServer.get().stop());
+ // @formatter:on
+ }
+
+ private void addHandlerActions(final String name, final AtomicReference<ControlLoopHandler> handler) {
+ addAction(name + " Providers",
+ () -> handler.get().startProviders(),
+ () -> handler.get().stopProviders());
+ addAction(name + " Listeners",
+ () -> handler.get().startAndRegisterListeners(msgDispatcher),
+ () -> handler.get().stopAndUnregisterListeners(msgDispatcher));
+ addAction(name + " Publishers",
+ () -> handler.get().startAndRegisterPublishers(topicSinks),
+ () -> handler.get().stopAndUnregisterPublishers());
+ }
+
+ /**
+ * Registers the dispatcher with the topic source(s).
+ */
+ private void registerMsgDispatcher() {
+ for (final TopicSource source : topicSources) {
+ source.register(msgDispatcher);
+ }
+ }
+
+ /**
+ * Unregisters the dispatcher from the topic source(s).
+ */
+ private void unregisterMsgDispatcher() {
+ for (final TopicSource source : topicSources) {
+ source.unregister(msgDispatcher);
+ }
+ }
+
+ /**
+ * Get the parameters used by the activator.
+ *
+ * @return the parameters of the activator
+ */
+ public ClRuntimeParameterGroup getParameterGroup() {
+ return clRuntimeParameterGroup;
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
new file mode 100644
index 000000000..f36bb858b
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
@@ -0,0 +1,151 @@
+/*-
+ * ============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.runtime.main.startstop;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Arrays;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.common.startstop.CommonCommandLineArguments;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+
+/**
+ * This class reads and handles command line parameters for the control loop runtime service.
+ */
+public class ClRuntimeCommandLineArguments {
+ private static final String FILE_MESSAGE_PREAMBLE = " file \"";
+ private static final int HELP_LINE_LENGTH = 120;
+
+ private final Options options;
+ private final CommonCommandLineArguments commonCommandLineArguments;
+
+ @Getter()
+ @Setter()
+ private String configurationFilePath = null;
+
+ /**
+ * Construct the options for the control loop runtime component.
+ */
+ public ClRuntimeCommandLineArguments() {
+ options = new Options();
+ commonCommandLineArguments = new CommonCommandLineArguments(options);
+ }
+
+ /**
+ * Construct the options for the CLI editor and parse in the given arguments.
+ *
+ * @param args The command line arguments
+ */
+ public ClRuntimeCommandLineArguments(final String[] args) {
+ // Set up the options with the default constructor
+ this();
+
+ // Parse the arguments
+ try {
+ parse(args);
+ } catch (final ControlLoopException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
+ "parse error on control loop runtime parameters", e);
+ }
+ }
+
+ /**
+ * Parse the command line options.
+ *
+ * @param args The command line arguments
+ * @return a string with a message for help and version, or null if there is no message
+ * @throws ControlLoopException on command argument errors
+ */
+ public String parse(final String[] args) throws ControlLoopException {
+ // Clear all our arguments
+ setConfigurationFilePath(null);
+ CommandLine commandLine = null;
+ try {
+ commandLine = new DefaultParser().parse(options, args);
+ } catch (final ParseException e) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ "invalid command line arguments specified : " + e.getMessage());
+ }
+
+ // Arguments left over after Commons CLI does its stuff
+ final String[] remainingArgs = commandLine.getArgs();
+
+ if (remainingArgs.length > 0) {
+ throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
+ "too many command line arguments specified : " + Arrays.toString(args));
+ }
+
+ if (commandLine.hasOption('h')) {
+ return commonCommandLineArguments.help(Main.class.getName(), options);
+ }
+
+ if (commandLine.hasOption('v')) {
+ return commonCommandLineArguments.version();
+ }
+
+ if (commandLine.hasOption('c')) {
+ setConfigurationFilePath(commandLine.getOptionValue('c'));
+ }
+
+ return null;
+ }
+
+ /**
+ * Validate the command line options.
+ *
+ * @throws ControlLoopException on command argument validation errors
+ */
+ public void validate() throws ControlLoopException {
+ commonCommandLineArguments.validate(configurationFilePath);
+ }
+
+ /**
+ * Gets the full expanded configuration file path.
+ *
+ * @return the configuration file path
+ */
+ public String getFullConfigurationFilePath() {
+ return ResourceUtils.getFilePath4Resource(getConfigurationFilePath());
+ }
+
+ /**
+ * Sets the configuration file path.
+ *
+ * @param configurationFilePath the configuration file path
+ */
+ public void setConfigurationFilePath(final String configurationFilePath) {
+ this.configurationFilePath = configurationFilePath;
+
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java
new file mode 100644
index 000000000..8e60d68cf
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java
@@ -0,0 +1,156 @@
+/*-
+ * ============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.runtime.main.startstop;
+
+import java.util.Arrays;
+import javax.ws.rs.core.Response;
+import org.onap.policy.clamp.controlloop.common.ControlLoopConstants;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterHandler;
+import org.onap.policy.common.utils.resources.MessageConstants;
+import org.onap.policy.common.utils.services.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class initiates ONAP Policy Framework Control Loop runtime component.
+ */
+public class Main {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
+
+ private ClRuntimeActivator activator;
+ private ClRuntimeParameterGroup parameterGroup;
+
+ /**
+ * Instantiates the control loop runtime service.
+ *
+ * @param args the command line arguments
+ */
+ public Main(final String[] args) {
+ final String argumentString = Arrays.toString(args);
+ LOGGER.info("Starting the control loop runtime service with arguments - {}", argumentString);
+
+ // Check the arguments
+ final ClRuntimeCommandLineArguments arguments = new ClRuntimeCommandLineArguments();
+ try {
+ // The arguments return a string if there is a message to print and we should exit
+ final String argumentMessage = arguments.parse(args);
+ if (argumentMessage != null) {
+ LOGGER.info(argumentMessage);
+ return;
+ }
+ // Validate that the arguments are sane
+ arguments.validate();
+
+ // Read the parameters
+ parameterGroup = new ClRuntimeParameterHandler().getParameters(arguments);
+
+ // Now, create the activator for the service
+ activator = new ClRuntimeActivator(parameterGroup);
+ Registry.register(ControlLoopConstants.REG_CLRUNTIME_ACTIVATOR, activator);
+
+ // Start the activator
+ activator.start();
+ } catch (Exception exp) {
+ if (null != activator) {
+ Registry.unregister(ControlLoopConstants.REG_CLRUNTIME_ACTIVATOR);
+ }
+ throw new ControlLoopRuntimeException(Response.Status.BAD_REQUEST,
+ String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP), exp);
+ }
+
+ // Add a shutdown hook to shut everything down in an orderly manner
+ Runtime.getRuntime().addShutdownHook(new ClRuntimeShutdownHookClass());
+ String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_CLAMP);
+ LOGGER.info(successMsg);
+ }
+
+ /**
+ * Check if main is running.
+ */
+ public boolean isRunning() {
+ return activator != null && activator.isAlive();
+ }
+
+ /**
+ * Get the parameters specified in JSON.
+ *
+ * @return the parameters
+ */
+ public ClRuntimeParameterGroup getParameters() {
+ return parameterGroup;
+ }
+
+ /**
+ * Shut down Execution.
+ *
+ * @throws ControlLoopException on shutdown errors
+ */
+ public void shutdown() throws ControlLoopException {
+ // clear the parameterGroup variable
+ parameterGroup = null;
+
+ // clear the cl runtime activator
+ if (activator != null) {
+ activator.stop();
+ }
+ }
+
+ /**
+ * The Class ClRuntimeShutdownHookClass terminates the control loop runtime service when its run method is called.
+ */
+ private class ClRuntimeShutdownHookClass extends Thread {
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ if (!activator.isAlive()) {
+ return;
+ }
+
+ try {
+ // Shutdown the control loop runtime service and wait for everything to stop
+ activator.stop();
+ } catch (final RuntimeException e) {
+ LOGGER.warn("error occured during shut down of the control loop runtime service", e);
+ }
+ }
+ }
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(final String[] args) { // NOSONAR
+ /*
+ * NOTE: arguments are validated by the constructor, thus sonar is disabled.
+ */
+
+ new Main(args);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
new file mode 100644
index 000000000..a7ad9180a
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.runtime.monitoring;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.clamp.controlloop.runtime.monitoring.rest.MonitoringQueryController;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.base.PfModelRuntimeException;
+
+/**
+ * This class handles monitoring of control loop definitions,
+ * so only one object of this type should be built at a time.
+ *
+ * <p/>
+ * It is effectively a singleton that is started at system start.
+ */
+public class MonitoringHandler extends ControlLoopHandler {
+
+ @Getter
+ private MonitoringProvider monitoringProvider;
+
+ /**
+ * Gets the Monitoring Handler.
+ *
+ * @return MonitoringHandler
+ */
+ public static MonitoringHandler getInstance() {
+ return Registry.get(MonitoringHandler.class.getName());
+ }
+
+ /**
+ * Create a handler.
+ *
+ * @param controlLoopParameters the parameters for access to the database
+ */
+ public MonitoringHandler(ClRuntimeParameterGroup controlLoopParameters) {
+ super(controlLoopParameters.getDatabaseProviderParameters());
+ }
+
+ @Override
+ public Set<Class<?>> getProviderClasses() {
+ return Set.of(MonitoringQueryController.class);
+ }
+
+ @Override
+ public void startProviders() {
+ monitoringProvider = new MonitoringProvider(getDatabaseProviderParameters());
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ monitoringProvider.close();
+ } catch (IOException e) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "Cannot stop provider", e);
+ }
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
new file mode 100644
index 000000000..193f8d557
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
@@ -0,0 +1,273 @@
+/*-
+ * ============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.runtime.monitoring;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import lombok.NonNull;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
+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.ParticipantStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ClElementStatisticsProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantStatisticsProvider;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * This class provides information about statistics data of CL elements and CL Participants in database to callers.
+ */
+public class MonitoringProvider implements Closeable {
+
+ private static final String DESC_ORDER = "DESC";
+ private final ParticipantStatisticsProvider participantStatisticsProvider;
+ private final ClElementStatisticsProvider clElementStatisticsProvider;
+ private final ControlLoopProvider controlLoopProvider;
+
+ /**
+ * Create a Monitoring provider.
+ *
+ */
+ public MonitoringProvider(PolicyModelsProviderParameters parameters) {
+
+ try {
+ participantStatisticsProvider = new ParticipantStatisticsProvider(parameters);
+ clElementStatisticsProvider = new ClElementStatisticsProvider(parameters);
+ controlLoopProvider = new ControlLoopProvider(parameters);
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ controlLoopProvider.close();
+ clElementStatisticsProvider.close();
+ participantStatisticsProvider.close();
+ }
+
+ /**
+ * Create participant statistics.
+ *
+ * @param participantStatistics the participant statistics
+ * @return the result of create operation
+ * @throws PfModelException on creation errors
+ */
+ public ParticipantStatisticsList createParticipantStatistics(List<ParticipantStatistics> participantStatistics)
+ throws PfModelException {
+ ParticipantStatisticsList participantStatisticsList = new ParticipantStatisticsList();
+ participantStatisticsList.setStatisticsList(participantStatisticsProvider
+ .createParticipantStatistics(participantStatistics));
+
+ return participantStatisticsList;
+ }
+
+ /**
+ * Create clElement statistics.
+ *
+ * @param clElementStatisticsList the clElement statistics
+ * @return the result of create operation
+ * @throws PfModelException on creation errors
+ */
+ public ClElementStatisticsList createClElementStatistics(List<ClElementStatistics> clElementStatisticsList)
+ throws PfModelException {
+ ClElementStatisticsList elementStatisticsList = new ClElementStatisticsList();
+ elementStatisticsList.setClElementStatistics(clElementStatisticsProvider
+ .createClElementStatistics(clElementStatisticsList));
+
+ return elementStatisticsList;
+ }
+
+ /**
+ * Get participant statistics based on specific filters.
+ *
+ * @param name the name of the participant statistics to get, null to get all statistics
+ * @param version the version of the participant statistics to get, null to get all statistics
+ * @param recordCount number of records to be fetched.
+ * @param startTime start of the timestamp, from statistics to be filtered
+ * @param endTime end of the timestamp up to which statistics to be filtered
+ * @return the participant found
+ */
+ public ParticipantStatisticsList fetchFilteredParticipantStatistics(@NonNull final String name,
+ final String version, int recordCount,
+ Instant startTime, Instant endTime) {
+ ParticipantStatisticsList participantStatisticsList = new ParticipantStatisticsList();
+
+ //Additional parameters can be added in filterMap for filtering data.
+ Map<String, Object> filterMap = null;
+ participantStatisticsList.setStatisticsList(participantStatisticsProvider.getFilteredParticipantStatistics(
+ name, version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
+
+ return participantStatisticsList;
+ }
+
+ /**
+ * Get all participant statistics records found for a specific control loop. *
+ *
+ * @param controlLoopName name of the control loop
+ * @param controlLoopVersion version of the control loop
+ * @return All the participant statistics found
+ * @throws PfModelException on errors getting participant statistics
+ */
+ public ParticipantStatisticsList fetchParticipantStatsPerControlLoop(@NonNull final String controlLoopName,
+ @NonNull final String controlLoopVersion)
+ throws PfModelException {
+ ParticipantStatisticsList statisticsList = new ParticipantStatisticsList();
+ List<ParticipantStatistics> participantStatistics = new ArrayList<>();
+ try {
+ //Fetch all participantIds for a specific control loop
+ List<ToscaConceptIdentifier> participantIds = getAllParticipantIdsPerControlLoop(controlLoopName,
+ controlLoopVersion);
+ for (ToscaConceptIdentifier id: participantIds) {
+ participantStatistics.addAll(participantStatisticsProvider.getFilteredParticipantStatistics(
+ id.getName(), id.getVersion(), null, null, null, DESC_ORDER, 0));
+ }
+ statisticsList.setStatisticsList(participantStatistics);
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(e);
+ }
+ return statisticsList;
+ }
+
+
+
+ /**
+ * Get clElement statistics based on specific filters.
+ *
+ * @param name the name of the clElement statistics to get, null to get all statistics
+ * @param version the version of the clElement statistics to get, null to get all statistics
+ * @param id UUID of the control loop element
+ * @param startTime start of the timestamp, from statistics to be filtered
+ * @param endTime end of the timestamp up to which statistics to be filtered
+ * @param recordCount number of records to be fetched.
+ * @return the participant found
+ * @throws PfModelException on errors getting control loop statistics
+ */
+ public ClElementStatisticsList fetchFilteredClElementStatistics(@NonNull final String name, final String version,
+ final String id, Instant startTime, Instant endTime,
+ int recordCount) throws PfModelException {
+ ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
+ Map<String, Object> filterMap = new HashMap<>();
+ //Adding UUID in filter if present
+ if (id != null) {
+ filterMap.put("localName", id);
+ }
+ clElementStatisticsList.setClElementStatistics(clElementStatisticsProvider.getFilteredClElementStatistics(
+ name, version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
+
+ return clElementStatisticsList;
+ }
+
+
+ /**
+ * Get clElement statistics per control loop.
+ *
+ * @param name the name of the control loop
+ * @param version the version of the control loop
+ * @return the clElement statistics found
+ * @throws PfModelException on errors getting control loop statistics
+ */
+ public ClElementStatisticsList fetchClElementStatsPerControlLoop(@NonNull final String name,
+ @NonNull final String version)
+ throws PfModelException {
+ ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
+ List<ClElementStatistics> clElementStats = new ArrayList<>();
+ try {
+ List<ControlLoopElement> clElements = new ArrayList<>();
+ //Fetch all control loop elements for the control loop
+ ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name,
+ version));
+ if (controlLoop != null) {
+ clElements.addAll(controlLoop.getElements().values());
+ //Collect control loop element statistics for each cl element.
+ for (ControlLoopElement clElement : clElements) {
+ clElementStats.addAll(fetchFilteredClElementStatistics(clElement.getParticipantId().getName(),
+ clElement.getParticipantId().getVersion(), clElement.getId().toString(), null,
+ null, 0).getClElementStatistics());
+ }
+ }
+ clElementStatisticsList.setClElementStatistics(clElementStats);
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(e);
+ }
+ return clElementStatisticsList;
+ }
+
+ /**
+ * If required, REST end point can be defined for this method to fetch associated participant Ids
+ * for a control loop.
+ *
+ * @param name the name of the control loop
+ * @param version the version of the control loop
+ * @return List of participant Id
+ * @throws PfModelException on errors
+ */
+ public List<ToscaConceptIdentifier> getAllParticipantIdsPerControlLoop(String name, String version)
+ throws PfModelException {
+ List<ToscaConceptIdentifier> participantIds = new ArrayList<>();
+ ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
+ if (controlLoop != null) {
+ for (ControlLoopElement clElement : controlLoop.getElements().values()) {
+ participantIds.add(clElement.getParticipantId());
+ }
+ }
+ return participantIds;
+ }
+
+ /**
+ * If required, REST end point can be defined for this method to fetch associated control loop element Ids
+ * for a control loop.
+ *
+ * @param name the name of the control loop
+ * @param version the version of the control loop
+ * @return Map of control loop Id and participant details
+ * @throws PfModelException on errors
+ */
+ public Map<String, ToscaConceptIdentifier> getAllClElementsIdPerControlLoop(String name, String version)
+ throws PfModelException {
+ Map<String, ToscaConceptIdentifier> clElementId = new HashMap<>();
+ ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
+ if (controlLoop != null) {
+ for (ControlLoopElement clElement : controlLoop.getElements().values()) {
+ clElementId.put(clElement.getId().toString(), clElement.getParticipantId());
+ }
+ }
+ return clElementId;
+ }
+
+ public void updateClElementStatistics(List<ClElementStatistics> clElementStatistics) {
+ // TODO Auto-generated method stub
+ }
+
+ public void updateParticipantStatistics(List<ParticipantStatistics> statisticsList) {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java
new file mode 100644
index 000000000..2e19ffe3a
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java
@@ -0,0 +1,371 @@
+/*-
+ * ============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.runtime.monitoring.rest;
+
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Authorization;
+import io.swagger.annotations.Extension;
+import io.swagger.annotations.ExtensionProperty;
+import io.swagger.annotations.ResponseHeader;
+import java.time.Instant;
+import java.util.UUID;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
+import org.onap.policy.clamp.controlloop.runtime.main.rest.RestController;
+import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringHandler;
+import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class handles REST endpoints for CL Statistics monitoring.
+ */
+public class MonitoringQueryController extends RestController {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringQueryController.class);
+ private final MonitoringProvider provider;
+
+ /**
+ * Create Monitoring Controller.
+ */
+ public MonitoringQueryController() {
+ this.provider = MonitoringHandler.getInstance().getMonitoringProvider();
+ }
+
+
+ /**
+ * Queries details of control loop participants statistics.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the participant to get, null for all participants statistics
+ * @param recordCount the record count to be fetched
+ * @return the participant statistics
+ */
+ // @formatter:off
+ @GET
+ @Path("/monitoring/participant")
+ @ApiOperation(value = "Query details of the requested participant stats",
+ notes = "Queries details of the requested participant stats, returning all participant stats",
+ response = ParticipantStatisticsList.class,
+ tags = {
+ "Clamp control loop Monitoring API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response queryParticipantStatistics(@HeaderParam(REQUEST_ID_NAME)
+ @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop participant name", required = true)
+ @QueryParam("name") final String name,
+ @ApiParam(value = "Control Loop participant version", required = true)
+ @QueryParam("version") final String version,
+ @ApiParam(value = "Record count", required = false) @DefaultValue("0")
+ @QueryParam("recordCount") final int recordCount,
+ @ApiParam(value = "start time", required = false)
+ @QueryParam("startTime") final String startTime,
+ @ApiParam(value = "end time", required = false)
+ @QueryParam("endTime") final String endTime) {
+
+ try {
+ Instant startTimestamp = null;
+ Instant endTimestamp = null;
+
+ if (startTime != null) {
+ startTimestamp = Instant.parse(startTime);
+ }
+ if (endTime != null) {
+ endTimestamp = Instant.parse(endTime);
+ }
+ ParticipantStatisticsList response = provider.fetchFilteredParticipantStatistics(name, version, recordCount,
+ startTimestamp, endTimestamp);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)
+ .entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException e) {
+ LOGGER.warn("Monitoring of participants statistics failed", e);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
+ requestId).build();
+ }
+
+ }
+
+ /**
+ * Queries details of all participant statistics per control loop.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the control loop
+ * @param version version of the control loop
+ * @return the control loop element statistics
+ */
+ // @formatter:off
+ @GET
+ @Path("/monitoring/participants/controlloop")
+ @ApiOperation(value = "Query details of all the participant stats in a control loop",
+ notes = "Queries details of the participant stats, returning all participant stats",
+ response = ClElementStatisticsList.class,
+ tags = {
+ "Clamp control loop Monitoring API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ })
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response queryParticipantStatisticsPerControlLoop(@HeaderParam(REQUEST_ID_NAME)
+ @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop name", required = true)
+ @QueryParam("name") final String name,
+ @ApiParam(value = "Control Loop version", required = true)
+ @QueryParam("version") final String version) {
+
+ try {
+ ParticipantStatisticsList response = provider.fetchParticipantStatsPerControlLoop(name, version);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)
+ .entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("Monitoring of Cl participant statistics failed", e);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
+ requestId).build();
+ }
+
+ }
+
+
+
+ /**
+ * Queries details of all control loop element statistics per control loop.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the control loop
+ * @param version version of the control loop
+ * @return the control loop element statistics
+ */
+ // @formatter:off
+ @GET
+ @Path("/monitoring/clelements/controlloop")
+ @ApiOperation(value = "Query details of the requested cl element stats in a control loop",
+ notes = "Queries details of the requested cl element stats, returning all clElement stats",
+ response = ClElementStatisticsList.class,
+ tags = {
+ "Clamp control loop Monitoring API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ })
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response queryElementStatisticsPerControlLoop(@HeaderParam(REQUEST_ID_NAME)
+ @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop name", required = true)
+ @QueryParam("name") final String name,
+ @ApiParam(value = "Control Loop version", required = true)
+ @QueryParam("version") final String version) {
+
+ try {
+ ClElementStatisticsList response = provider.fetchClElementStatsPerControlLoop(name, version);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)
+ .entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("Monitoring of Cl Element statistics failed", e);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
+ requestId).build();
+ }
+
+ }
+
+
+
+
+ /**
+ * Queries details of all control loop element statistics per control loop.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param name the name of the control loop
+ * @param version version of the control loop
+ * @param id Id of the control loop element
+ * @param recordCount the record count to be fetched
+ * @return the control loop element statistics
+ */
+ // @formatter:off
+ @GET
+ @Path("/monitoring/clelement")
+ @ApiOperation(value = "Query details of the requested cl element stats",
+ notes = "Queries details of the requested cl element stats, returning all clElement stats",
+ response = ClElementStatisticsList.class,
+ tags = {
+ "Clamp control loop Monitoring API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension(
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ })
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public Response queryElementStatistics(@HeaderParam(REQUEST_ID_NAME)
+ @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Participant name", required = true)
+ @QueryParam("name") final String name,
+ @ApiParam(value = "Participant version", required = true)
+ @QueryParam("version") final String version,
+ @ApiParam(value = "Record count", required = false)
+ @DefaultValue("0") @QueryParam("recordCount") final int recordCount,
+ @ApiParam(value = "Control Loop element id", required = false)
+ @QueryParam("id") final String id,
+ @ApiParam(value = "start time", required = false)
+ @QueryParam("startTime") final String startTime,
+ @ApiParam(value = "end time", required = false)
+ @QueryParam("endTime") final String endTime) {
+
+ try {
+ Instant startTimestamp = null;
+ Instant endTimestamp = null;
+
+ if (startTime != null) {
+ startTimestamp = Instant.parse(startTime);
+ }
+ if (endTime != null) {
+ endTimestamp = Instant.parse(endTime);
+ }
+ ClElementStatisticsList response = provider.fetchFilteredClElementStatistics(name, version, id,
+ startTimestamp, endTimestamp, recordCount);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)
+ .entity(response)
+ .build();
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("Monitoring of Cl Element statistics failed", e);
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
+ requestId).build();
+ }
+
+ }
+
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
new file mode 100644
index 000000000..63bff00fc
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
@@ -0,0 +1,450 @@
+/*-
+ * ============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.runtime.supervision;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.apache.commons.collections4.CollectionUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+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.ControlLoopState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningHandler;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringHandler;
+import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantControlLoopStateChangePublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantControlLoopUpdatePublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStateChangePublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusListener;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.common.utils.services.ServiceManager;
+import org.onap.policy.common.utils.services.ServiceManagerException;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class handles supervision of control loop instances, so only one object of this type should be built at a time.
+ *
+ * <p/> It is effectively a singleton that is started at system start.
+ */
+public class SupervisionHandler extends ControlLoopHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionHandler.class);
+
+ private static final String CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE = "Control loop can't transition from state ";
+ private static final String CONTROL_LOOP_IS_ALREADY_IN_STATE = "Control loop is already in state ";
+ private static final String TO_STATE = " to state ";
+ private static final String AND_TRANSITIONING_TO_STATE = " and transitioning to state ";
+
+ private ControlLoopProvider controlLoopProvider;
+ private ParticipantProvider participantProvider;
+ private CommissioningProvider commissioningProvider;
+ private MonitoringProvider monitoringProvider;
+
+ // Publishers for participant communication
+ private ParticipantStateChangePublisher stateChangePublisher;
+ private ParticipantControlLoopUpdatePublisher controlLoopUpdatePublisher;
+ private ParticipantControlLoopStateChangePublisher controlLoopStateChangePublisher;
+
+ // Database scanner
+ private SupervisionScanner scanner;
+
+ /**
+ * Used to manage the services.
+ */
+ private ServiceManager manager;
+ private ServiceManager publisherManager;
+
+ /**
+ * Gets the SupervisionHandler.
+ *
+ * @return SupervisionHandler
+ */
+ public static SupervisionHandler getInstance() {
+ return Registry.get(SupervisionHandler.class.getName());
+ }
+
+ /**
+ * Create a handler.
+ *
+ * @param clRuntimeParameterGroup the parameters for the control loop runtime
+ */
+ public SupervisionHandler(ClRuntimeParameterGroup clRuntimeParameterGroup) {
+ super(clRuntimeParameterGroup.getDatabaseProviderParameters());
+ // @formatter:off
+ this.manager = new ServiceManager()
+ .addAction("ControlLoop Provider",
+ () -> controlLoopProvider = new ControlLoopProvider(getDatabaseProviderParameters()),
+ () -> controlLoopProvider = null)
+ .addAction("Participant Provider",
+ () -> participantProvider = new ParticipantProvider(getDatabaseProviderParameters()),
+ () -> participantProvider = null);
+ // @formatter:on
+ }
+
+ /**
+ * Supervision trigger called when a command is issued on control loops.
+ *
+ * </p> Causes supervision to start or continue supervision on the control loops in question.
+ *
+ * @param controlLoopIdentifierList the control loops for which the supervision command has been issued
+ * @throws ControlLoopException on supervision triggering exceptions
+ */
+ public void triggerControlLoopSupervision(List<ToscaConceptIdentifier> controlLoopIdentifierList)
+ throws ControlLoopException {
+
+ LOGGER.debug("triggering control loop supervision on control loops {}", controlLoopIdentifierList);
+
+ if (CollectionUtils.isEmpty(controlLoopIdentifierList)) {
+ // This is just to force throwing of the exception in certain circumstances.
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ "The list of control loops for supervision is empty");
+ }
+
+ for (ToscaConceptIdentifier controlLoopId : controlLoopIdentifierList) {
+ try {
+ ControlLoop controlLoop = controlLoopProvider.getControlLoop(controlLoopId);
+
+ superviseControlLoop(controlLoop);
+
+ controlLoopProvider.updateControlLoop(controlLoop);
+ } catch (PfModelException pfme) {
+ throw new ControlLoopException(pfme.getErrorResponse().getResponseCode(), pfme.getMessage(), pfme);
+ }
+ }
+ }
+
+ @Override
+ public void startAndRegisterListeners(MessageTypeDispatcher msgDispatcher) {
+ msgDispatcher.register(ParticipantMessageType.PARTICIPANT_STATUS.name(), new ParticipantStatusListener());
+ }
+
+ @Override
+ public void startAndRegisterPublishers(List<TopicSink> topicSinks) {
+ // TODO: Use a parameter for the timeout
+ // @formatter:off
+ this.publisherManager = new ServiceManager()
+ .addAction("Supervision scanner",
+ () -> scanner = new SupervisionScanner(controlLoopProvider, 10000),
+ () -> scanner = null)
+ .addAction("ControlLoopUpdate publisher",
+ () -> controlLoopUpdatePublisher = new ParticipantControlLoopUpdatePublisher(topicSinks, -1),
+ () -> controlLoopUpdatePublisher.terminate())
+ .addAction("StateChange Publisher",
+ () -> stateChangePublisher = new ParticipantStateChangePublisher(topicSinks, 10000),
+ () -> stateChangePublisher.terminate())
+ .addAction("ControlLoopStateChange Publisher",
+ () -> controlLoopStateChangePublisher =
+ new ParticipantControlLoopStateChangePublisher(topicSinks, -1),
+ () -> controlLoopStateChangePublisher.terminate());
+ // @formatter:on
+ try {
+ publisherManager.start();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler start of publishers or scanner failed", exp);
+ }
+ }
+
+ @Override
+ public void stopAndUnregisterPublishers() {
+ try {
+ publisherManager.stop();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler stop of publishers or scanner failed", exp);
+ }
+ }
+
+ @Override
+ public void stopAndUnregisterListeners(MessageTypeDispatcher msgDispatcher) {
+ msgDispatcher.unregister(ParticipantMessageType.PARTICIPANT_STATUS.name());
+ }
+
+ /**
+ * Handle a ParticipantStatus message from a participant.
+ *
+ * @param participantStatusMessage the ParticipantStatus message received from a participant
+ */
+ public void handleParticipantStatusMessage(ParticipantStatus participantStatusMessage) {
+ LOGGER.debug("Participant Status received {}", participantStatusMessage);
+
+ try {
+ superviseParticipant(participantStatusMessage);
+ } catch (PfModelException | ControlLoopException svExc) {
+ LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc);
+ return;
+ }
+
+ try {
+ superviseControlLoops(participantStatusMessage);
+ } catch (PfModelException | ControlLoopException svExc) {
+ LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc);
+ }
+ }
+
+ /**
+ * Supervise a control loop, performing whatever actions need to be performed on the control loop.
+ *
+ * @param controlLoop the control loop to supervises
+ * @throws ControlLoopException on supervision errors
+ */
+ private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException {
+ switch (controlLoop.getOrderedState()) {
+ case UNINITIALISED:
+ superviseControlLoopUninitialization(controlLoop);
+ break;
+
+ case PASSIVE:
+ superviseControlLoopPassivation(controlLoop);
+ break;
+
+ case RUNNING:
+ superviseControlLoopActivation(controlLoop);
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ "A control loop cannot be commanded to go into state " + controlLoop.getOrderedState().name());
+ }
+ }
+
+ /**
+ * Supervise a control loop uninitialisation, performing whatever actions need to be performed on the control loop,
+ * control loop ordered state is UNINITIALIZED.
+ *
+ * @param controlLoop the control loop to supervises
+ * @throws ControlLoopException on supervision errors
+ */
+ private void superviseControlLoopUninitialization(ControlLoop controlLoop) throws ControlLoopException {
+ switch (controlLoop.getState()) {
+ case UNINITIALISED:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name());
+ break;
+
+ case UNINITIALISED2PASSIVE:
+ case PASSIVE:
+ controlLoop.setState(ControlLoopState.PASSIVE2UNINITIALISED);
+ sendControlLoopStateChange(controlLoop);
+ break;
+
+ case PASSIVE2UNINITIALISED:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE
+ + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState());
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
+ + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
+ break;
+ }
+ }
+
+ private void superviseControlLoopPassivation(ControlLoop controlLoop)
+ throws ControlLoopException, PfModelException {
+ switch (controlLoop.getState()) {
+ case PASSIVE:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name());
+ break;
+ case UNINITIALISED:
+ controlLoop.setState(ControlLoopState.UNINITIALISED2PASSIVE);
+ sendControlLoopUpdate(controlLoop);
+ break;
+
+ case UNINITIALISED2PASSIVE:
+ case RUNNING2PASSIVE:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE
+ + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState());
+ break;
+
+ case RUNNING:
+ controlLoop.setState(ControlLoopState.RUNNING2PASSIVE);
+ sendControlLoopStateChange(controlLoop);
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
+ + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
+ break;
+ }
+ }
+
+ private void superviseControlLoopActivation(ControlLoop controlLoop) throws ControlLoopException {
+ switch (controlLoop.getState()) {
+ case RUNNING:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name());
+ break;
+
+ case PASSIVE2RUNNING:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE
+ + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState());
+ break;
+
+ case PASSIVE:
+ controlLoop.setState(ControlLoopState.PASSIVE2RUNNING);
+ sendControlLoopStateChange(controlLoop);
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
+ + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
+ break;
+ }
+ }
+
+ private void sendControlLoopUpdate(ControlLoop controlLoop) throws PfModelException {
+ ParticipantControlLoopUpdate pclu = new ParticipantControlLoopUpdate();
+ pclu.setControlLoopId(controlLoop.getKey().asIdentifier());
+ pclu.setControlLoop(controlLoop);
+ // TODO: We should look up the correct TOSCA node template here for the control loop
+ // Tiny hack implemented to return the tosca service template entry from the database and be passed onto dmaap
+ commissioningProvider = CommissioningHandler.getInstance().getProvider();
+ pclu.setControlLoopDefinition(commissioningProvider.getToscaServiceTemplate(null, null));
+ controlLoopUpdatePublisher.send(pclu);
+ }
+
+ private void sendControlLoopStateChange(ControlLoop controlLoop) {
+ ParticipantControlLoopStateChange clsc = new ParticipantControlLoopStateChange();
+ clsc.setControlLoopId(controlLoop.getKey().asIdentifier());
+ clsc.setMessageId(UUID.randomUUID());
+ clsc.setOrderedState(controlLoop.getOrderedState());
+
+ controlLoopStateChangePublisher.send(clsc);
+ }
+
+ private void superviseParticipant(ParticipantStatus participantStatusMessage)
+ throws PfModelException, ControlLoopException {
+ if (participantStatusMessage.getParticipantId() == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "Participant ID on PARTICIPANT_STATUS message is null");
+ }
+
+ List<Participant> participantList =
+ participantProvider.getParticipants(participantStatusMessage.getParticipantId().getName(),
+ participantStatusMessage.getParticipantId().getVersion());
+
+ if (CollectionUtils.isEmpty(participantList)) {
+ Participant participant = new Participant();
+ participant.setName(participantStatusMessage.getParticipantId().getName());
+ participant.setVersion(participantStatusMessage.getParticipantId().getVersion());
+ participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
+ participant.setParticipantState(participantStatusMessage.getState());
+ participant.setHealthStatus(participantStatusMessage.getHealthStatus());
+
+ participantList.add(participant);
+ participantProvider.createParticipants(participantList);
+ } else {
+ for (Participant participant : participantList) {
+ participant.setParticipantState(participantStatusMessage.getState());
+ participant.setHealthStatus(participantStatusMessage.getHealthStatus());
+ }
+ participantProvider.updateParticipants(participantList);
+ }
+
+ monitoringProvider = MonitoringHandler.getInstance().getMonitoringProvider();
+ monitoringProvider.createParticipantStatistics(
+ List.of(participantStatusMessage.getParticipantStatistics()));
+ }
+
+ private void superviseControlLoops(ParticipantStatus participantStatusMessage)
+ throws PfModelException, ControlLoopException {
+ if (CollectionUtils.isEmpty(participantStatusMessage.getControlLoops().getControlLoopList())) {
+ return;
+ }
+
+ for (ControlLoop controlLoop : participantStatusMessage.getControlLoops().getControlLoopList()) {
+ if (controlLoop == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS message references unknown control loop: " + controlLoop);
+ }
+
+ ControlLoop dbControlLoop = controlLoopProvider
+ .getControlLoop(new ToscaConceptIdentifier(controlLoop.getName(), controlLoop.getVersion()));
+ if (dbControlLoop == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS control loop not found in database: " + controlLoop);
+ }
+
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ ControlLoopElement dbElement = dbControlLoop.getElements().get(element.getId());
+
+ if (dbElement == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS message references unknown control loop element: " + element);
+ }
+
+ // Replace element entry in the database
+ dbControlLoop.getElements().put(element.getId(), element);
+ }
+ controlLoopProvider.updateControlLoop(dbControlLoop);
+ }
+
+ monitoringProvider = MonitoringHandler.getInstance().getMonitoringProvider();
+ for (ControlLoop controlLoop : participantStatusMessage.getControlLoops().getControlLoopList()) {
+ monitoringProvider.createClElementStatistics(controlLoop.getControlLoopElementStatisticsList(controlLoop));
+ }
+ }
+
+ @Override
+ public void startProviders() {
+ try {
+ manager.start();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler start of providers failed", exp);
+ }
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ manager.stop();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler stop of providers failed", exp);
+ }
+ }
+
+ private void exceptionOccured(Response.Status status, String reason) throws ControlLoopException {
+ throw new ControlLoopException(status, reason);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
new file mode 100644
index 000000000..0ccfddff3
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
@@ -0,0 +1,116 @@
+/*-
+ * ============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.runtime.supervision;
+
+import java.io.Closeable;
+import java.util.Collection;
+import java.util.List;
+import java.util.TimerTask;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+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.persistence.provider.ControlLoopProvider;
+import org.onap.policy.models.base.PfModelException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to scan the control loops in the database and check if they are in the correct state.
+ */
+public class SupervisionScanner implements Runnable, Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class);
+
+ private ControlLoopProvider controlLoopProvider;
+ private ScheduledExecutorService timerPool;
+
+ /**
+ * Constructor for instantiating SupervisionScanner.
+ *
+ * @param controlLoopProvider the provider to use to read control loops from the database
+ * @param interval time interval to perform scans
+ */
+ public SupervisionScanner(final ControlLoopProvider controlLoopProvider, final long interval) {
+ this.controlLoopProvider = controlLoopProvider;
+
+ // Kick off the timer
+ timerPool = makeTimerPool();
+ timerPool.scheduleAtFixedRate(this, 0, interval, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void run() {
+ LOGGER.debug("Scanning control loops in the database . . .");
+
+ try {
+ for (ControlLoop controlLoop : controlLoopProvider.getControlLoops(null, null)) {
+ scanControlLoop(controlLoop);
+ }
+ } catch (PfModelException pfme) {
+ LOGGER.warn("error reading control loops from database", pfme);
+ }
+
+ LOGGER.debug("Control loop scan complete . . .");
+ }
+
+ @Override
+ public void close() {
+ timerPool.shutdown();
+ }
+
+ private void scanControlLoop(final ControlLoop controlLoop) throws PfModelException {
+ LOGGER.debug("scanning control loop {} . . .", controlLoop.getKey().asIdentifier());
+
+ if (controlLoop.getState().equals(controlLoop.getOrderedState().asState())) {
+ LOGGER.debug("control loop {} scanned, OK", controlLoop.getKey().asIdentifier());
+ return;
+ }
+
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ if (!element.getState().equals(element.getOrderedState().asState())) {
+ LOGGER.debug("control loop scan: transitioning from state {} to {}", controlLoop.getState(),
+ controlLoop.getOrderedState());
+ return;
+ }
+ }
+
+ LOGGER.debug("control loop scan: transition from state {} to {} completed", controlLoop.getState(),
+ controlLoop.getOrderedState());
+
+ controlLoop.setState(controlLoop.getOrderedState().asState());
+ controlLoopProvider.updateControlLoop(controlLoop);
+ }
+
+ /**
+ * Makes a new timer pool.
+ *
+ * @return a new timer pool
+ */
+ protected ScheduledExecutorService makeTimerPool() {
+ return Executors.newScheduledThreadPool(1);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java
new file mode 100644
index 000000000..c9c8ab851
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.runtime.supervision.comm;
+
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send ParticipantControlLoopStateChangePublisher messages to participants on DMaaP.
+ */
+public class ParticipantControlLoopStateChangePublisher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantControlLoopStateChangePublisher.class);
+
+ private TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantControlLoopStateChangePublisherPublisher.
+ *
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send ParticipantControlLoopStateChangePublisher messages
+ */
+ public ParticipantControlLoopStateChangePublisher(final List<TopicSink> topicSinks, final long interval) {
+ // TODO: Should not be dependent on the order of topic sinks in the config
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Terminates the current timer.
+ */
+ public void terminate() {
+ // This is a user initiated message and doesn't need a timer.
+ }
+
+ /**
+ * Get the current time interval used by the timer task.
+ *
+ * @return interval the current time interval
+ */
+ public long getInterval() {
+ // This is a user initiated message and doesn't need a timer.
+ return -1;
+ }
+
+ /**
+ * Method to send ParticipantControlLoopStateChangePublisher status message to participants on demand.
+ *
+ * @param controlLoopStateChange the ParticipantControlLoopStateChangePublisher message
+ */
+ public void send(final ParticipantControlLoopStateChange controlLoopStateChange) {
+ topicSinkClient.send(controlLoopStateChange);
+ LOGGER.debug("Sent ParticipantControlLoopStateChange to Participants - {}", controlLoopStateChange);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java
new file mode 100644
index 000000000..3c5d230c5
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.runtime.supervision.comm;
+
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send ParticipantControlLoopUpdate messages to participants on DMaaP.
+ */
+public class ParticipantControlLoopUpdatePublisher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantControlLoopUpdatePublisher.class);
+
+ private TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantUpdatePublisher.
+ *
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send ParticipantControlLoopUpdate messages
+ */
+ public ParticipantControlLoopUpdatePublisher(final List<TopicSink> topicSinks, final long interval) {
+ // TODO: Should not be dependent on the order of topic sinks in the config
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Terminates the current timer.
+ */
+ public void terminate() {
+ // This is a user initiated message and doesn't need a timer.
+ }
+
+ /**
+ * Get the current time interval used by the timer task.
+ *
+ * @return interval the current time interval
+ */
+ public long getInterval() {
+ // This is a user initiated message and doesn't need a timer.
+ return -1;
+ }
+
+ /**
+ * Method to send ParticipantControlLoopUpdate status message to participants on demand.
+ *
+ * @param participantControlLoopUpdate the ParticipantControlLoopUpdate message
+ */
+ public void send(final ParticipantControlLoopUpdate participantControlLoopUpdate) {
+ topicSinkClient.send(participantControlLoopUpdate);
+ LOGGER.debug("Sent ParticipantControlLoopUpdate to Participants - {}", participantControlLoopUpdate);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java
new file mode 100644
index 000000000..099039115
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java
@@ -0,0 +1,74 @@
+/*-
+ * ============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.runtime.supervision.comm;
+
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send ParticipantStateChange messages to participants on DMaaP.
+ */
+public class ParticipantStateChangePublisher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStateChangePublisher.class);
+
+ private TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantStateChangePublisher.
+ *
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send ParticipantStateChange messages
+ */
+ public ParticipantStateChangePublisher(final List<TopicSink> topicSinks, final long interval) {
+ // TODO: Should not be dependent on the order of topic sinks in the config
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Terminates the current timer.
+ */
+ public void terminate() {
+ // Nothing to terminate, this publisher does not have a timer
+ }
+
+ /**
+ * Get the current time interval used by the timer task.
+ *
+ * @return interval the current time interval
+ */
+ public long getInterval() {
+ return -1;
+ }
+
+ /**
+ * Method to send ParticipantStateChange status message to participants on demand.
+ *
+ * @param participantStateChange the ParticipantStateChange message
+ */
+ public void send(final ParticipantStateChange participantStateChange) {
+ topicSinkClient.send(participantStateChange);
+ LOGGER.debug("Sent ParticipantStateChange to Participants - {}", participantStateChange);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
new file mode 100644
index 000000000..a05f4aa20
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.runtime.supervision.comm;
+
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.onap.policy.common.utils.services.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Listener for ParticipantStatus messages sent by participants.
+ */
+public class ParticipantStatusListener extends ScoListener<ParticipantStatus> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusListener.class);
+
+ private final SupervisionHandler supervisionHandler = Registry.get(SupervisionHandler.class.getName());
+
+ /**
+ * Constructs the object.
+ */
+ public ParticipantStatusListener() {
+ super(ParticipantStatus.class);
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantStatus participantStatusMessage) {
+ LOGGER.debug("ParticipantStatus message received from participant - {}", participantStatusMessage);
+ supervisionHandler.handleParticipantStatusMessage(participantStatusMessage);
+ }
+}
diff --git a/runtime-controlloop/src/main/resources/META-INF/persistence.xml b/runtime-controlloop/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 000000000..e5d2cab11
--- /dev/null
+++ b/runtime-controlloop/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="CommissioningMariaDb" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+
+ <properties>
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+
+ <!-- property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL" /-->
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+
+ <persistence-unit name="ToscaConceptTest" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+
+ <!-- property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL" /-->
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+</persistence>
+
diff --git a/runtime-controlloop/src/main/resources/version.txt b/runtime-controlloop/src/main/resources/version.txt
new file mode 100644
index 000000000..e11449e5b
--- /dev/null
+++ b/runtime-controlloop/src/main/resources/version.txt
@@ -0,0 +1,4 @@
+ONAP Tosca defined control loop
+Version: ${project.version}
+Built (UTC): ${maven.build.timestamp}
+ONAP https://wiki.onap.org
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
new file mode 100644
index 000000000..956b5e911
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
@@ -0,0 +1,216 @@
+/*-
+ * ============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.runtime.commissioning;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+public class CommissioningProviderTest {
+ private static final String TOSCA_SERVICE_TEMPLATE_YAML =
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
+ private static final String TEMPLATE_IS_NULL = ".*serviceTemplate is marked non-null but is null";
+ private static final Coder CODER = new StandardCoder();
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+ private static int dbNum = 0;
+ private static final Object lockit = new Object();
+ private PolicyModelsProviderParameters databaseProviderParameters;
+
+ private static String getParameterGroupAsString() {
+ dbNum++;
+ return ResourceUtils.getResourceAsString("src/test/resources/parameters/TestParameters.json")
+ .replace("jdbc:h2:mem:testdb", "jdbc:h2:mem:commissioningdb" + dbNum);
+ }
+
+ /**
+ * Sets up db provider parameters before each test.
+ *
+ * @throws CoderException .
+ */
+ @Before
+ public void setupDbProviderParameters() throws CoderException {
+ synchronized (lockit) {
+ databaseProviderParameters = CODER.decode(getParameterGroupAsString(), ClRuntimeParameterGroup.class)
+ .getDatabaseProviderParameters();
+ }
+ }
+
+ /**
+ * Test the fetching of control loop definitions (ToscaServiceTemplates).
+ *
+ * @throws Exception .
+ */
+ @Test
+ public void testGetControlLoopDefinitions() throws Exception {
+ List<ToscaNodeTemplate> listOfTemplates;
+
+ try (CommissioningProvider provider = new CommissioningProvider(databaseProviderParameters)) {
+ ToscaServiceTemplate serviceTemplate = yamlTranslator
+ .fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML),
+ ToscaServiceTemplate.class);
+
+
+ listOfTemplates = provider.getControlLoopDefinitions(null, null);
+ assertThat(listOfTemplates).isEmpty();
+
+ provider.createControlLoopDefinitions(serviceTemplate);
+ listOfTemplates = provider.getControlLoopDefinitions(null, null);
+ assertThat(listOfTemplates).hasSize(2);
+
+ //Test Filtering
+ listOfTemplates = provider.getControlLoopDefinitions("org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "1.2.3");
+ assertThat(listOfTemplates).hasSize(1);
+ for (ToscaNodeTemplate template : listOfTemplates) {
+ //Other CL elements contain PMSD instead of PMSH in their name
+ assertFalse(template.getName().contains("PMSD"));
+ }
+
+ //Test Wrong Name
+ listOfTemplates = provider.getControlLoopDefinitions("WrongControlLoopName", "0.0.0");
+ assertThat(listOfTemplates).isEmpty();
+ }
+ }
+
+ /**
+ * Test the creation of control loop definitions (ToscaServiceTemplates).
+ *
+ * @throws Exception .
+ */
+ @Test
+ public void testCreateControlLoopDefinitions() throws Exception {
+ List<ToscaNodeTemplate> listOfTemplates;
+
+ try (CommissioningProvider provider = new CommissioningProvider(databaseProviderParameters)) {
+ //Test Service template is null
+ assertThatThrownBy(() -> provider.createControlLoopDefinitions(null)).hasMessageMatching(TEMPLATE_IS_NULL);
+ listOfTemplates = provider.getControlLoopDefinitions(null, null);
+ assertThat(listOfTemplates).isEmpty();
+
+ ToscaServiceTemplate serviceTemplate = yamlTranslator
+ .fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML),
+ ToscaServiceTemplate.class);
+
+ // Response should return the number of node templates present in the service template
+ List<ToscaConceptIdentifier> affectedDefinitions =
+ provider.createControlLoopDefinitions(serviceTemplate).getAffectedControlLoopDefinitions();
+ assertThat(affectedDefinitions).hasSize(13);
+ listOfTemplates = provider.getControlLoopDefinitions(null, null);
+ assertThat(listOfTemplates).hasSize(2);
+ }
+ }
+
+ /**
+ * Test the deletion of control loop definitions (ToscaServiceTemplate).
+ *
+ * @throws Exception .
+ */
+ @Test
+ public void testDeleteControlLoopDefinitions() throws Exception {
+ List<ToscaNodeTemplate> listOfTemplates;
+
+ try (CommissioningProvider provider = new CommissioningProvider(databaseProviderParameters)) {
+ ToscaServiceTemplate serviceTemplate = yamlTranslator
+ .fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML),
+ ToscaServiceTemplate.class);
+
+ listOfTemplates = provider.getControlLoopDefinitions(null, null);
+ assertThat(listOfTemplates).isEmpty();
+
+ provider.createControlLoopDefinitions(serviceTemplate);
+ listOfTemplates = provider.getControlLoopDefinitions(null, null);
+ assertThat(listOfTemplates).hasSize(2);
+
+ provider.deleteControlLoopDefinition(serviceTemplate.getName(), serviceTemplate.getVersion());
+ listOfTemplates = provider.getControlLoopDefinitions(null, null);
+ assertThat(listOfTemplates).isEmpty();
+ }
+ }
+
+ /**
+ * Test the fetching of control loop element definitions.
+ *
+ * @throws Exception .
+ */
+ @Test
+ public void testGetControlLoopElementDefinitions() throws Exception {
+ try (CommissioningProvider provider = new CommissioningProvider(databaseProviderParameters)) {
+ ToscaServiceTemplate serviceTemplate = yamlTranslator
+ .fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML),
+ ToscaServiceTemplate.class);
+
+ provider.getControlLoopDefinitions(null, null);
+
+ provider.createControlLoopDefinitions(serviceTemplate);
+ List<ToscaNodeTemplate> controlLoopDefinitionList = provider.getControlLoopDefinitions(
+ "org.onap.domain.pmsh.PMSHControlLoopDefinition", "1.2.3");
+
+ List<ToscaNodeTemplate> controlLoopElementNodeTemplates =
+ provider.getControlLoopElementDefinitions(controlLoopDefinitionList.get(0));
+
+ // 4 PMSH control loop elements definitions.
+ assertThat(controlLoopElementNodeTemplates).hasSize(4);
+
+ List<ToscaNodeType> derivedTypes = getDerivedNodeTypes(serviceTemplate);
+ for (ToscaNodeTemplate template : controlLoopElementNodeTemplates) {
+ assertTrue(checkNodeType(template, derivedTypes));
+ }
+ }
+ }
+
+ private boolean checkNodeType(ToscaNodeTemplate template, List<ToscaNodeType> derivedNodeTypes) {
+ String controlLoopElementType = "org.onap.policy.clamp.controlloop.ControlLoopElement";
+ for (ToscaNodeType derivedType : derivedNodeTypes) {
+ if (template.getType().equals(derivedType.getName()) || template.getType().equals(controlLoopElementType)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private List<ToscaNodeType> getDerivedNodeTypes(ToscaServiceTemplate serviceTemplate) {
+ String type = "org.onap.policy.clamp.controlloop.ControlLoopElement";
+ List<ToscaNodeType> nodeTypes = new ArrayList<>();
+ for (ToscaNodeType nodeType : serviceTemplate.getNodeTypes().values()) {
+ if (nodeType.getDerivedFrom().equals(type)) {
+ nodeTypes.add(nodeType);
+ }
+ }
+ return nodeTypes;
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java
new file mode 100644
index 000000000..4dbb3ea02
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java
@@ -0,0 +1,202 @@
+/*-
+ * ============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.runtime.commissioning.rest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.Response;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
+import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+public class CommissioningControllerTest extends CommonRestController {
+
+ private static final String TOSCA_SERVICE_TEMPLATE_YAML =
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+ private static final String COMMISSIONING_ENDPOINT = "commission";
+ private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
+
+ /**
+ * starts Main and inserts a commissioning template.
+ *
+ * @throws Exception if an error occurs
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ CommonRestController.setUpBeforeClass("CommissioningApi");
+
+ serviceTemplate = yamlTranslator.fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML),
+ ToscaServiceTemplate.class);
+ }
+
+ @AfterClass
+ public static void teardownAfterClass() {
+ CommonRestController.teardownAfterClass();
+ }
+
+ @Test
+ public void testSwagger() throws Exception {
+ super.testSwagger(COMMISSIONING_ENDPOINT);
+ }
+
+ @Test
+ public void testUnauthorizedCreate() throws Exception {
+ assertUnauthorizedPost(COMMISSIONING_ENDPOINT, Entity.json(serviceTemplate));
+ }
+
+ @Test
+ public void testUnauthorizedQuery() throws Exception {
+ assertUnauthorizedGet(COMMISSIONING_ENDPOINT);
+ }
+
+ @Test
+ public void testUnauthorizedQueryElements() throws Exception {
+ assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/elements");
+ }
+
+ @Test
+ public void testUnauthorizedDelete() throws Exception {
+ assertUnauthorizedDelete(COMMISSIONING_ENDPOINT);
+ }
+
+ @Test
+ public void testCreateBadRequest() throws Exception {
+ Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT);
+ Response resp = invocationBuilder.post(Entity.json("NotToscaServiceTempalte"));
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
+ CommissioningResponse commissioningResponse = resp.readEntity(CommissioningResponse.class);
+ assertNotNull(commissioningResponse.getErrorDetails());
+ assertNull(commissioningResponse.getAffectedControlLoopDefinitions());
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT);
+ Response resp = invocationBuilder.post(Entity.json(serviceTemplate));
+ assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
+ CommissioningResponse commissioningResponse = resp.readEntity(CommissioningResponse.class);
+
+ assertNotNull(commissioningResponse);
+ assertNull(commissioningResponse.getErrorDetails());
+ // Response should return the number of node templates present in the service template
+ assertThat(commissioningResponse.getAffectedControlLoopDefinitions()).hasSize(13);
+ for (String nodeTemplateName : serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().keySet()) {
+ assertTrue(commissioningResponse.getAffectedControlLoopDefinitions().stream()
+ .anyMatch(ac -> ac.getName().equals(nodeTemplateName)));
+ }
+ }
+
+ @Test
+ public void testQuery_NoResultWithThisName() throws Exception {
+ createEntryInDB();
+
+ Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "?name=noResultWithThisName");
+ Response rawresp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ List entityList = rawresp.readEntity(List.class);
+ assertThat(entityList).isEmpty();
+ }
+
+ @Test
+ public void testQuery() throws Exception {
+ createEntryInDB();
+
+ Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT);
+ Response rawresp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ List entityList = rawresp.readEntity(List.class);
+ assertNotNull(entityList);
+ assertThat(entityList).hasSize(2);
+ }
+
+ @Test
+ public void testQueryElementsBadRequest() throws Exception {
+ createEntryInDB();
+
+ //Call get elements with no info
+ Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "/elements");
+ Response resp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), resp.getStatus());
+ }
+
+ @Test
+ public void testQueryElements() throws Exception {
+ createEntryInDB();
+
+ Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "/elements"
+ + "?name=org.onap.domain.pmsh.PMSHControlLoopDefinition");
+ Response rawresp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ List entityList = rawresp.readEntity(List.class);
+ assertNotNull(entityList);
+ assertThat(entityList).hasSize(4);
+ }
+
+ @Test
+ public void testDeleteBadRequest() throws Exception {
+ createEntryInDB();
+
+ Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT);
+ //Call delete with no info
+ Response resp = invocationBuilder.delete();
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), resp.getStatus());
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ createEntryInDB();
+
+ Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "?name="
+ + serviceTemplate.getName() + "&version=" + serviceTemplate.getVersion());
+ //Call delete with no info
+ Response resp = invocationBuilder.delete();
+ assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
+
+ try (PolicyModelsProvider modelsProvider = new PolicyModelsProviderFactory()
+ .createPolicyModelsProvider(CommonRestController.getParameters())) {
+ List<ToscaServiceTemplate> templatesInDB = modelsProvider.getServiceTemplateList(null, null);
+ assertThat(templatesInDB).isEmpty();
+ }
+ }
+
+ private synchronized void createEntryInDB() throws Exception {
+ try (PolicyModelsProvider modelsProvider = new PolicyModelsProviderFactory()
+ .createPolicyModelsProvider(CommonRestController.getParameters())) {
+ modelsProvider.createServiceTemplate(serviceTemplate);
+ }
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
new file mode 100644
index 000000000..ccc54b93f
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
@@ -0,0 +1,370 @@
+/*-
+ * ============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.runtime.instantiation;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
+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.rest.instantiation.InstantiationCommand;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningHandler;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to perform unit test of {@link ControlLoopInstantiationProvider}}.
+ *
+ */
+public class ControlLoopInstantiationProviderTest {
+
+ private static final String CL_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/controlloops/ControlLoops.json";
+ private static final String CL_INSTANTIATION_UPDATE_JSON =
+ "src/test/resources/rest/controlloops/ControlLoopsUpdate.json";
+ private static final String CL_INSTANTIATION_CHANGE_STATE_JSON =
+ "src/test/resources/rest/controlloops/PassiveCommand.json";
+ private static final String CL_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON =
+ "src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json";
+ private static final String CL_INSTANTIATION_CONTROLLOOP_DEFINITION_NOT_FOUND_JSON =
+ "src/test/resources/rest/controlloops/ControlLoopsNotFound.json";
+ private static final String TOSCA_TEMPLATE_YAML =
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
+ private static final String CONTROL_LOOP_NOT_FOUND = "Control Loop not found";
+ private static final String DELETE_BAD_REQUEST = "Control Loop State is still %s";
+ private static final String ORDERED_STATE_INVALID = "ordered state invalid or not specified on command";
+ private static final String CONTROLLOOP_ELEMENT_NAME_NOT_FOUND =
+ "\"ControlLoops\" INVALID, item has status INVALID\n"
+ + " \"entry org.onap.domain.pmsh.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n"
+ + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not FOUND\n"
+ + " \"entry org.onap.domain.pmsh.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n"
+ + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not FOUND\n";
+
+ private static final String CONTROLLOOP_DEFINITION_NOT_FOUND = "\"ControlLoops\" INVALID, item has status INVALID\n"
+ + " \"entry org.onap.domain.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n"
+ + " item \"ControlLoop\" value \"org.onap.domain.PMSHControlLoopDefinition\" INVALID,"
+ + " Commissioned control loop definition not FOUND\n"
+ + " \"entry org.onap.domain.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n"
+ + " item \"ControlLoop\" value \"org.onap.domain.PMSHControlLoopDefinition\" INVALID,"
+ + " Commissioned control loop definition not FOUND\n";
+
+ private static PolicyModelsProviderParameters databaseProviderParameters;
+ private static SupervisionHandler supervisionHandler;
+ private static CommissioningHandler commissioningHandler;
+
+ /**
+ * setup Db Provider Parameters.
+ *
+ * @throws PfModelException if an error occurs
+ */
+ @BeforeClass
+ public static void setupDbProviderParameters() throws PfModelException {
+ databaseProviderParameters =
+ CommonTestData.geParameterGroup(0, "instantproviderdb").getDatabaseProviderParameters();
+ commissioningHandler = new CommissioningHandler(CommonTestData.geParameterGroup(0, "instantproviderdb"));
+ commissioningHandler.startProviders();
+ supervisionHandler = new SupervisionHandler(CommonTestData.geParameterGroup(0, "instantproviderdb"));
+ supervisionHandler.startProviders();
+ supervisionHandler.startAndRegisterPublishers(Collections.singletonList(Mockito.mock(TopicSink.class)));
+ }
+
+ @Test
+ public void testInstantiationCrud() throws Exception {
+ ControlLoops controlLoopsCreate =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Crud");
+ ControlLoops controlLoopsDb = getControlLoopsFromDb(controlLoopsCreate);
+ assertThat(controlLoopsDb.getControlLoopList()).isEmpty();
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+
+ // to validate control Loop, it needs to define ToscaServiceTemplate
+ InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
+
+ InstantiationResponse instantiationResponse = instantiationProvider.createControlLoops(controlLoopsCreate);
+ InstantiationUtils.assertInstantiationResponse(instantiationResponse, controlLoopsCreate);
+
+ controlLoopsDb = getControlLoopsFromDb(controlLoopsCreate);
+ assertThat(controlLoopsDb.getControlLoopList()).isNotEmpty();
+ Assert.assertEquals(controlLoopsCreate, controlLoopsDb);
+
+ for (ControlLoop controlLoop : controlLoopsCreate.getControlLoopList()) {
+ ControlLoops controlLoopsGet =
+ instantiationProvider.getControlLoops(controlLoop.getName(), controlLoop.getVersion());
+ assertThat(controlLoopsGet.getControlLoopList()).hasSize(1);
+ Assert.assertEquals(controlLoop, controlLoopsGet.getControlLoopList().get(0));
+ }
+
+ ControlLoops controlLoopsUpdate =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_UPDATE_JSON, "Crud");
+ Assert.assertNotEquals(controlLoopsUpdate, controlLoopsDb);
+
+ instantiationResponse = instantiationProvider.updateControlLoops(controlLoopsUpdate);
+ InstantiationUtils.assertInstantiationResponse(instantiationResponse, controlLoopsUpdate);
+
+ controlLoopsDb = getControlLoopsFromDb(controlLoopsCreate);
+ assertThat(controlLoopsDb.getControlLoopList()).isNotEmpty();
+ Assert.assertEquals(controlLoopsUpdate, controlLoopsDb);
+
+ InstantiationCommand instantiationCommand =
+ InstantiationUtils.getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, "Crud");
+ instantiationResponse = instantiationProvider.issueControlLoopCommand(instantiationCommand);
+ InstantiationUtils.assertInstantiationResponse(instantiationResponse, instantiationCommand);
+
+ for (ToscaConceptIdentifier toscaConceptIdentifier : instantiationCommand.getControlLoopIdentifierList()) {
+ ControlLoops controlLoopsGet = instantiationProvider.getControlLoops(toscaConceptIdentifier.getName(),
+ toscaConceptIdentifier.getVersion());
+ assertThat(controlLoopsGet.getControlLoopList()).hasSize(1);
+ Assert.assertEquals(instantiationCommand.getOrderedState(),
+ controlLoopsGet.getControlLoopList().get(0).getOrderedState());
+ }
+
+ // in order to delete a controlLoop the state must be UNINITIALISED
+ controlLoopsCreate.getControlLoopList().forEach(cl -> cl.setState(ControlLoopState.UNINITIALISED));
+ instantiationProvider.updateControlLoops(controlLoopsCreate);
+
+ for (ControlLoop controlLoop : controlLoopsCreate.getControlLoopList()) {
+ instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion());
+ }
+
+ controlLoopsDb = getControlLoopsFromDb(controlLoopsCreate);
+ assertThat(controlLoopsDb.getControlLoopList()).isEmpty();
+ }
+ }
+
+ private ControlLoops getControlLoopsFromDb(ControlLoops controlLoopsSource) throws Exception {
+ ControlLoops controlLoopsDb = new ControlLoops();
+ controlLoopsDb.setControlLoopList(new ArrayList<>());
+
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+
+ for (ControlLoop controlLoop : controlLoopsSource.getControlLoopList()) {
+ ControlLoops controlLoopsFromDb =
+ instantiationProvider.getControlLoops(controlLoop.getName(), controlLoop.getVersion());
+ controlLoopsDb.getControlLoopList().addAll(controlLoopsFromDb.getControlLoopList());
+ }
+ return controlLoopsDb;
+ }
+ }
+
+ @Test
+ public void testInstantiationDelete() throws Exception {
+ ControlLoops controlLoops =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Delete");
+ assertThat(getControlLoopsFromDb(controlLoops).getControlLoopList()).isEmpty();
+
+ ControlLoop controlLoop0 = controlLoops.getControlLoopList().get(0);
+
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+
+ // to validate control Loop, it needs to define ToscaServiceTemplate
+ InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
+
+ assertThatThrownBy(
+ () -> instantiationProvider.deleteControlLoop(controlLoop0.getName(), controlLoop0.getVersion()))
+ .hasMessageMatching(CONTROL_LOOP_NOT_FOUND);
+
+ InstantiationUtils.assertInstantiationResponse(instantiationProvider.createControlLoops(controlLoops),
+ controlLoops);
+
+ for (ControlLoopState state : ControlLoopState.values()) {
+ if (!ControlLoopState.UNINITIALISED.equals(state)) {
+ assertThatDeleteThrownBy(controlLoops, state);
+ }
+ }
+
+ controlLoop0.setState(ControlLoopState.UNINITIALISED);
+ instantiationProvider.updateControlLoops(controlLoops);
+
+ for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
+ instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion());
+ }
+
+ for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
+ ControlLoops controlLoopsGet =
+ instantiationProvider.getControlLoops(controlLoop.getName(), controlLoop.getVersion());
+ assertThat(controlLoopsGet.getControlLoopList()).isEmpty();
+ }
+ }
+ }
+
+ private void assertThatDeleteThrownBy(ControlLoops controlLoops, ControlLoopState state) throws Exception {
+ ControlLoop controlLoop = controlLoops.getControlLoopList().get(0);
+
+ controlLoop.setState(state);
+
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+
+ instantiationProvider.updateControlLoops(controlLoops);
+ assertThatThrownBy(
+ () -> instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion()))
+ .hasMessageMatching(String.format(DELETE_BAD_REQUEST, state));
+ }
+ }
+
+ @Test
+ public void testCreateControlLoops_NoDuplicates() throws Exception {
+ ControlLoops controlLoopsCreate =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "NoDuplicates");
+
+ ControlLoops controlLoopsDb = getControlLoopsFromDb(controlLoopsCreate);
+ assertThat(controlLoopsDb.getControlLoopList()).isEmpty();
+
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+
+ // to validate control Loop, it needs to define ToscaServiceTemplate
+ InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
+
+ InstantiationResponse instantiationResponse = instantiationProvider.createControlLoops(controlLoopsCreate);
+ InstantiationUtils.assertInstantiationResponse(instantiationResponse, controlLoopsCreate);
+
+ assertThatThrownBy(() -> instantiationProvider.createControlLoops(controlLoopsCreate)).hasMessageMatching(
+ controlLoopsCreate.getControlLoopList().get(0).getKey().asIdentifier() + " already defined");
+
+ for (ControlLoop controlLoop : controlLoopsCreate.getControlLoopList()) {
+ instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion());
+ }
+ }
+ }
+
+ @Test
+ public void testCreateControlLoops_CommissionedClElementNotFound() throws Exception {
+ ControlLoops controlLoops = InstantiationUtils
+ .getControlLoopsFromResource(CL_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON, "ClElementNotFound");
+
+ try (ControlLoopInstantiationProvider provider =
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+
+ // to validate control Loop, it needs to define ToscaServiceTemplate
+ InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
+
+ assertThat(getControlLoopsFromDb(controlLoops).getControlLoopList()).isEmpty();
+
+ assertThatThrownBy(() -> provider.createControlLoops(controlLoops))
+ .hasMessageMatching(CONTROLLOOP_ELEMENT_NAME_NOT_FOUND);
+ }
+ }
+
+ @Test
+ public void testCreateControlLoops_CommissionedClNotFound() throws Exception {
+ ControlLoops controlLoops = InstantiationUtils
+ .getControlLoopsFromResource(CL_INSTANTIATION_CONTROLLOOP_DEFINITION_NOT_FOUND_JSON, "ClNotFound");
+
+ assertThat(getControlLoopsFromDb(controlLoops).getControlLoopList()).isEmpty();
+
+ try (ControlLoopInstantiationProvider provider =
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ assertThatThrownBy(() -> provider.createControlLoops(controlLoops))
+ .hasMessageMatching(CONTROLLOOP_DEFINITION_NOT_FOUND);
+ }
+ }
+
+ @Test
+ public void testIssueControlLoopCommand_OrderedStateInvalid() throws ControlLoopRuntimeException, IOException {
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ assertThatThrownBy(() -> instantiationProvider.issueControlLoopCommand(new InstantiationCommand()))
+ .hasMessageMatching(ORDERED_STATE_INVALID);
+ }
+ }
+
+ @Test
+ public void testInstantiationVersions() throws Exception {
+
+ // create controlLoops V1
+ ControlLoops controlLoopsV1 =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "V1");
+ assertThat(getControlLoopsFromDb(controlLoopsV1).getControlLoopList()).isEmpty();
+
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+
+ // to validate control Loop, it needs to define ToscaServiceTemplate
+ InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
+
+ InstantiationUtils.assertInstantiationResponse(instantiationProvider.createControlLoops(controlLoopsV1),
+ controlLoopsV1);
+
+ // create controlLoops V2
+ ControlLoops controlLoopsV2 =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "V2");
+ assertThat(getControlLoopsFromDb(controlLoopsV2).getControlLoopList()).isEmpty();
+ InstantiationUtils.assertInstantiationResponse(instantiationProvider.createControlLoops(controlLoopsV2),
+ controlLoopsV2);
+
+ // GET controlLoops V2
+ for (ControlLoop controlLoop : controlLoopsV2.getControlLoopList()) {
+ ControlLoops controlLoopsGet =
+ instantiationProvider.getControlLoops(controlLoop.getName(), controlLoop.getVersion());
+ assertThat(controlLoopsGet.getControlLoopList()).hasSize(1);
+ Assert.assertEquals(controlLoop, controlLoopsGet.getControlLoopList().get(0));
+ }
+
+ // DELETE controlLoops V1
+ for (ControlLoop controlLoop : controlLoopsV1.getControlLoopList()) {
+ instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion());
+ }
+
+ // GET controlLoops V1 is not available
+ for (ControlLoop controlLoop : controlLoopsV1.getControlLoopList()) {
+ ControlLoops controlLoopsGet =
+ instantiationProvider.getControlLoops(controlLoop.getName(), controlLoop.getVersion());
+ assertThat(controlLoopsGet.getControlLoopList()).isEmpty();
+ }
+
+ // GET controlLoops V2 is still available
+ for (ControlLoop controlLoop : controlLoopsV2.getControlLoopList()) {
+ ControlLoops controlLoopsGet =
+ instantiationProvider.getControlLoops(controlLoop.getName(), controlLoop.getVersion());
+ assertThat(controlLoopsGet.getControlLoopList()).hasSize(1);
+ Assert.assertEquals(controlLoop, controlLoopsGet.getControlLoopList().get(0));
+ }
+
+ // DELETE controlLoops V2
+ for (ControlLoop controlLoop : controlLoopsV2.getControlLoopList()) {
+ instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion());
+ }
+
+ // GET controlLoops V2 is not available
+ for (ControlLoop controlLoop : controlLoopsV2.getControlLoopList()) {
+ ControlLoops controlLoopsGet =
+ instantiationProvider.getControlLoops(controlLoop.getName(), controlLoop.getVersion());
+ assertThat(controlLoopsGet.getControlLoopList()).isEmpty();
+ }
+ }
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java
new file mode 100644
index 000000000..958d91dff
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java
@@ -0,0 +1,149 @@
+/*-
+ * ============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.runtime.instantiation;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import org.junit.Assert;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+/**
+ * Utility methods supporting tests for Instantiation.
+ */
+public class InstantiationUtils {
+
+ private static final Coder CODER = new StandardCoder();
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+
+ /**
+ * Gets the ControlLoops from Resource.
+ *
+ * @param path path of the resource
+ * @param suffix suffix to add to all names in ControlLoops
+ * @return the ControlLoops from Resource
+ * @throws CoderException if an error occurs
+ */
+ public static ControlLoops getControlLoopsFromResource(final String path, final String suffix)
+ throws CoderException {
+ ControlLoops controlLoops = CODER.decode(new File(path), ControlLoops.class);
+
+ // add suffix to all names
+ controlLoops.getControlLoopList().forEach(controlLoop -> controlLoop.setName(controlLoop.getName() + suffix));
+ return controlLoops;
+ }
+
+ /**
+ * Gets InstantiationCommand from Resource.
+ *
+ * @param path path of the resource
+ * @param suffix suffix to add to all names in ControlLoops
+ * @return the InstantiationCommand
+ * @throws CoderException if an error occurs
+ */
+ public static InstantiationCommand getInstantiationCommandFromResource(final String path, final String suffix)
+ throws CoderException {
+ InstantiationCommand instantiationCommand = CODER.decode(new File(path), InstantiationCommand.class);
+
+ // add suffix to all names
+ instantiationCommand.getControlLoopIdentifierList().forEach(cl -> cl.setName(cl.getName() + suffix));
+ return instantiationCommand;
+ }
+
+ /**
+ * Assert that Instantiation Response contains proper ControlLoops.
+ *
+ * @param response InstantiationResponse
+ * @param controlLoops ControlLoops
+ */
+ public static void assertInstantiationResponse(InstantiationResponse response, ControlLoops controlLoops) {
+ assertNotNull(response);
+ Assert.assertNull(response.getErrorDetails());
+ assertEquals(response.getAffectedControlLoops().size(), controlLoops.getControlLoopList().size());
+ for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
+ assertTrue(response.getAffectedControlLoops().stream()
+ .filter(ac -> ac.equals(controlLoop.getKey().asIdentifier())).findAny().isPresent());
+ }
+ }
+
+ /**
+ * Assert that Instantiation Response contains proper ControlLoops.
+ *
+ * @param response InstantiationResponse
+ * @param command InstantiationCommand
+ */
+ public static void assertInstantiationResponse(InstantiationResponse response, InstantiationCommand command) {
+ assertNotNull(response);
+ assertEquals(response.getAffectedControlLoops().size(), command.getControlLoopIdentifierList().size());
+ for (ToscaConceptIdentifier toscaConceptIdentifier : command.getControlLoopIdentifierList()) {
+ assertTrue(response.getAffectedControlLoops().stream()
+ .filter(ac -> ac.compareTo(toscaConceptIdentifier) == 0).findAny().isPresent());
+ }
+ }
+
+ /**
+ * Assert that Instantiation Response contains ControlLoop equals to controlLoop.
+ *
+ * @param response InstantiationResponse
+ * @param controlLoop ControlLoop
+ */
+ public static void assertInstantiationResponse(InstantiationResponse response, ControlLoop controlLoop) {
+ assertNotNull(response);
+ Assert.assertNull(response.getErrorDetails());
+ assertEquals(1, response.getAffectedControlLoops().size());
+ assertEquals(0, response.getAffectedControlLoops().get(0).compareTo(controlLoop.getKey().asIdentifier()));
+ }
+
+ /**
+ * Store ToscaServiceTemplate from resource to DB.
+ *
+ * @param path path of the resource
+ * @param parameters The parameters for the implementation of the PolicyModelProvider
+ * @throws PfModelException if an error occurs
+ */
+ public static void storeToscaServiceTemplate(String path, PolicyModelsProviderParameters parameters)
+ throws PfModelException {
+
+ ToscaServiceTemplate template =
+ yamlTranslator.fromYaml(ResourceUtils.getResourceAsString(path), ToscaServiceTemplate.class);
+
+ try (PolicyModelsProvider modelsProvider =
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters)) {
+ modelsProvider.createServiceTemplate(template);
+ }
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java
new file mode 100644
index 000000000..71e762455
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java
@@ -0,0 +1,322 @@
+/*-
+ * ============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.runtime.instantiation.rest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.Response;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
+import org.onap.policy.clamp.controlloop.runtime.instantiation.ControlLoopInstantiationProvider;
+import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationUtils;
+import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to perform unit test of {@link InstantiationController}}.
+ *
+ */
+public class InstantiationControllerTest extends CommonRestController {
+
+ private static final String CL_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/controlloops/ControlLoops.json";
+
+ private static final String CL_INSTANTIATION_UPDATE_JSON =
+ "src/test/resources/rest/controlloops/ControlLoopsUpdate.json";
+
+ private static final String CL_INSTANTIATION_CHANGE_STATE_JSON =
+ "src/test/resources/rest/controlloops/PassiveCommand.json";
+
+ private static final String TOSCA_TEMPLATE_YAML =
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
+
+ private static final String INSTANTIATION_ENDPOINT = "instantiation";
+
+ private static final String INSTANTIATION_COMMAND_ENDPOINT = "instantiation/command";
+
+ /**
+ * starts Main and inserts a commissioning template.
+ *
+ * @throws Exception if an error occurs
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ CommonRestController.setUpBeforeClass("InstApi");
+
+ // to validate control Loop, it needs to define ToscaServiceTemplate
+ InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, getParameters());
+
+ ControlLoops controlLoops =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Command");
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(getParameters())) {
+ instantiationProvider.createControlLoops(controlLoops);
+ }
+ }
+
+ @AfterClass
+ public static void teardownAfterClass() {
+ CommonRestController.teardownAfterClass();
+ }
+
+ @Test
+ public void testSwagger() throws Exception {
+ super.testSwagger(INSTANTIATION_ENDPOINT);
+ }
+
+ @Test
+ public void testCreate_Unauthorized() throws Exception {
+ ControlLoops controlLoops =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Unauthorized");
+
+ assertUnauthorizedPost(INSTANTIATION_ENDPOINT, Entity.json(controlLoops));
+ }
+
+ @Test
+ public void testQuery_Unauthorized() throws Exception {
+ assertUnauthorizedGet(INSTANTIATION_ENDPOINT);
+ }
+
+ @Test
+ public void testUpdate_Unauthorized() throws Exception {
+ ControlLoops controlLoops =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_UPDATE_JSON, "Unauthorized");
+
+ assertUnauthorizedPut(INSTANTIATION_ENDPOINT, Entity.json(controlLoops));
+ }
+
+ @Test
+ public void testDelete_Unauthorized() throws Exception {
+ assertUnauthorizedDelete(INSTANTIATION_ENDPOINT);
+ }
+
+ @Test
+ public void testCommand_Unauthorized() throws Exception {
+ InstantiationCommand instantiationCommand = InstantiationUtils
+ .getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, "Unauthorized");
+
+ assertUnauthorizedPut(INSTANTIATION_COMMAND_ENDPOINT, Entity.json(instantiationCommand));
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ ControlLoops controlLoopsFromRsc =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Create");
+
+ Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT);
+ Response resp = invocationBuilder.post(Entity.json(controlLoopsFromRsc));
+ assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
+ InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class);
+ InstantiationUtils.assertInstantiationResponse(instResponse, controlLoopsFromRsc);
+
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(getParameters())) {
+ for (ControlLoop controlLoopFromRsc : controlLoopsFromRsc.getControlLoopList()) {
+ ControlLoops controlLoopsFromDb = instantiationProvider.getControlLoops(
+ controlLoopFromRsc.getKey().getName(), controlLoopFromRsc.getKey().getVersion());
+
+ assertNotNull(controlLoopsFromDb);
+ assertThat(controlLoopsFromDb.getControlLoopList()).hasSize(1);
+ assertEquals(controlLoopFromRsc, controlLoopsFromDb.getControlLoopList().get(0));
+ }
+ }
+ }
+
+ @Test
+ public void testCreateBadRequest() throws Exception {
+ ControlLoops controlLoopsFromRsc =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "CreateBadRequest");
+
+ Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT);
+ Response resp = invocationBuilder.post(Entity.json(controlLoopsFromRsc));
+ assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
+
+ // testing Bad Request: CL already defined
+ resp = invocationBuilder.post(Entity.json(controlLoopsFromRsc));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
+ InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class);
+ assertNotNull(instResponse.getErrorDetails());
+ assertNull(instResponse.getAffectedControlLoops());
+ }
+
+ @Test
+ public void testQuery_NoResultWithThisName() throws Exception {
+ Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName");
+ Response rawresp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ ControlLoops resp = rawresp.readEntity(ControlLoops.class);
+ assertThat(resp.getControlLoopList()).isEmpty();
+ }
+
+ @Test
+ public void testQuery() throws Exception {
+ // inserts a ControlLoops to DB
+ ControlLoops controlLoops =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Query");
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(getParameters())) {
+ instantiationProvider.createControlLoops(controlLoops);
+ }
+
+ for (ControlLoop controlLoopFromRsc : controlLoops.getControlLoopList()) {
+ Invocation.Builder invocationBuilder =
+ super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + controlLoopFromRsc.getKey().getName());
+ Response rawresp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ ControlLoops controlLoopsQuery = rawresp.readEntity(ControlLoops.class);
+ assertNotNull(controlLoopsQuery);
+ assertThat(controlLoopsQuery.getControlLoopList()).hasSize(1);
+ assertEquals(controlLoopFromRsc, controlLoopsQuery.getControlLoopList().get(0));
+ }
+ }
+
+ @Test
+ public void testUpdate() throws Exception {
+ ControlLoops controlLoopsCreate =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Update");
+
+ ControlLoops controlLoops =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_UPDATE_JSON, "Update");
+
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(getParameters())) {
+ instantiationProvider.createControlLoops(controlLoopsCreate);
+
+ Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT);
+ Response resp = invocationBuilder.put(Entity.json(controlLoops));
+ assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
+
+ InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class);
+ InstantiationUtils.assertInstantiationResponse(instResponse, controlLoops);
+
+ for (ControlLoop controlLoopUpdate : controlLoops.getControlLoopList()) {
+ ControlLoops controlLoopsFromDb = instantiationProvider
+ .getControlLoops(controlLoopUpdate.getKey().getName(), controlLoopUpdate.getKey().getVersion());
+
+ assertNotNull(controlLoopsFromDb);
+ assertThat(controlLoopsFromDb.getControlLoopList()).hasSize(1);
+ assertEquals(controlLoopUpdate, controlLoopsFromDb.getControlLoopList().get(0));
+ }
+ }
+ }
+
+ @Test
+ public void testDelete_NoResultWithThisName() throws Exception {
+ Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName");
+ Response resp = invocationBuilder.delete();
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus());
+ InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class);
+ assertNotNull(instResponse.getErrorDetails());
+ assertNull(instResponse.getAffectedControlLoops());
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ ControlLoops controlLoopsFromRsc =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Delete");
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(getParameters())) {
+ instantiationProvider.createControlLoops(controlLoopsFromRsc);
+
+ for (ControlLoop controlLoopFromRsc : controlLoopsFromRsc.getControlLoopList()) {
+ Invocation.Builder invocationBuilder =
+ super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + controlLoopFromRsc.getKey().getName()
+ + "&version=" + controlLoopFromRsc.getKey().getVersion());
+ Response resp = invocationBuilder.delete();
+ assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
+ InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class);
+ InstantiationUtils.assertInstantiationResponse(instResponse, controlLoopFromRsc);
+
+ ControlLoops controlLoopsFromDb = instantiationProvider.getControlLoops(
+ controlLoopFromRsc.getKey().getName(), controlLoopFromRsc.getKey().getVersion());
+ assertThat(controlLoopsFromDb.getControlLoopList()).isEmpty();
+ }
+ }
+ }
+
+ @Test
+ public void testDeleteBadRequest() throws Exception {
+ ControlLoops controlLoopsFromRsc =
+ InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "DelBadRequest");
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(getParameters())) {
+ instantiationProvider.createControlLoops(controlLoopsFromRsc);
+
+ for (ControlLoop controlLoopFromRsc : controlLoopsFromRsc.getControlLoopList()) {
+ Invocation.Builder invocationBuilder =
+ super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + controlLoopFromRsc.getKey().getName());
+ Response resp = invocationBuilder.delete();
+ // should be BAD_REQUEST
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), resp.getStatus());
+ }
+ }
+ }
+
+ @Test
+ public void testCommand_NotFound1() throws Exception {
+ Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT);
+ Response resp = invocationBuilder.put(Entity.json(new InstantiationCommand()));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
+ }
+
+ @Test
+ public void testCommand_NotFound2() throws Exception {
+ InstantiationCommand command =
+ InstantiationUtils.getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, "Command");
+ command.setOrderedState(null);
+
+ Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT);
+ Response resp = invocationBuilder.put(Entity.json(command));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
+ }
+
+ @Test
+ public void testCommand() throws Exception {
+ InstantiationCommand command =
+ InstantiationUtils.getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, "Command");
+
+ Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT);
+ Response resp = invocationBuilder.put(Entity.json(command));
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), resp.getStatus());
+ InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class);
+ InstantiationUtils.assertInstantiationResponse(instResponse, command);
+
+ // check passive state on DB
+ try (ControlLoopInstantiationProvider instantiationProvider =
+ new ControlLoopInstantiationProvider(getParameters())) {
+ for (ToscaConceptIdentifier toscaConceptIdentifier : command.getControlLoopIdentifierList()) {
+ ControlLoops controlLoopsGet = instantiationProvider.getControlLoops(toscaConceptIdentifier.getName(),
+ toscaConceptIdentifier.getVersion());
+ assertThat(controlLoopsGet.getControlLoopList()).hasSize(1);
+ assertEquals(command.getOrderedState(), controlLoopsGet.getControlLoopList().get(0).getOrderedState());
+ }
+ }
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestControllerTest.java
new file mode 100644
index 000000000..4f68b4f8c
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestControllerTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============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.runtime.main.rest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.UUID;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.junit.Test;
+
+/**
+ * Class to perform unit test of {@link RestController}}.
+ *
+ */
+public class RestControllerTest {
+
+ @Test
+ public void testProduces() {
+ Produces annotation = RestController.class.getAnnotation(Produces.class);
+ assertNotNull(annotation);
+ assertThat(annotation.value()).contains(MediaType.APPLICATION_JSON)
+ .contains(RestController.APPLICATION_YAML);
+ }
+
+ @Test
+ public void testAddVersionControlHeaders() {
+ RestController ctlr = new RestController();
+ Response resp = ctlr.addVersionControlHeaders(Response.status(Response.Status.OK)).build();
+ assertEquals("0", resp.getHeaderString(RestController.VERSION_MINOR_NAME));
+ assertEquals("0", resp.getHeaderString(RestController.VERSION_PATCH_NAME));
+ assertEquals("1.0.0", resp.getHeaderString(RestController.VERSION_LATEST_NAME));
+ }
+
+ @Test
+ public void testAddLoggingHeaders_Null() {
+ RestController ctlr = new RestController();
+ Response resp = ctlr.addLoggingHeaders(Response.status(Response.Status.OK), null).build();
+ assertNotNull(resp.getHeaderString(RestController.REQUEST_ID_NAME));
+ }
+
+ @Test
+ public void testAddLoggingHeaders_NonNull() {
+ UUID uuid = UUID.randomUUID();
+ RestController ctlr = new RestController();
+ Response resp = ctlr.addLoggingHeaders(Response.status(Response.Status.OK), uuid).build();
+ assertEquals(uuid.toString(), resp.getHeaderString(RestController.REQUEST_ID_NAME));
+ }
+
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivatorTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivatorTest.java
new file mode 100644
index 000000000..da71c239d
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivatorTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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.runtime.main.startstop;
+
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterHandler;
+import org.onap.policy.common.utils.services.Registry;
+
+/**
+ * Class to perform unit test of {@link ClRuntimeActivator}}.
+ *
+ */
+public class ClRuntimeActivatorTest {
+
+ @Test
+ public void testStartAndStop() throws Exception {
+ Registry.newRegistry();
+ final String[] configParameters = {"-c", "src/test/resources/parameters/TestParameters.json"};
+ final ClRuntimeCommandLineArguments arguments = new ClRuntimeCommandLineArguments();
+ arguments.parse(configParameters);
+ ClRuntimeParameterGroup parameterGroup = new ClRuntimeParameterHandler().getParameters(arguments);
+ ClRuntimeActivator activator = new ClRuntimeActivator(parameterGroup);
+ activator.isAlive();
+
+ assertFalse(activator.isAlive());
+ activator.start();
+ assertTrue(activator.isAlive());
+ assertTrue(activator.getParameterGroup().isValid());
+ assertEquals(activator.getParameterGroup().getName(),
+ activator.getParameterGroup().getRestServerParameters().getName());
+
+ // repeat start - should throw an exception
+ assertThatIllegalStateException().isThrownBy(() -> activator.start());
+ assertTrue(activator.isAlive());
+ assertTrue(activator.getParameterGroup().isValid());
+
+ activator.stop();
+ assertFalse(activator.isAlive());
+
+ // repeat stop - should throw an exception
+ assertThatIllegalStateException().isThrownBy(() -> activator.stop());
+ assertFalse(activator.isAlive());
+ }
+
+ @Test
+ public void testNull() {
+ assertThatExceptionOfType(ControlLoopRuntimeException.class).isThrownBy(() -> new ClRuntimeActivator(null));
+ }
+
+ @Test
+ public void testNotValid() {
+ ClRuntimeParameterGroup parameterGroup = new ClRuntimeParameterGroup("name");
+ assertThatExceptionOfType(ControlLoopRuntimeException.class)
+ .isThrownBy(() -> new ClRuntimeActivator(parameterGroup));
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/MainTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/MainTest.java
new file mode 100644
index 000000000..b06383c68
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/MainTest.java
@@ -0,0 +1,157 @@
+/*-
+ * ============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.runtime.main.startstop;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.common.ControlLoopConstants;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.common.utils.resources.MessageConstants;
+import org.onap.policy.common.utils.services.Registry;
+
+/**
+ * Class to perform unit test of {@link Main}}.
+ *
+ */
+public class MainTest {
+
+ public static final String POLICY_CLAMP_FAILURE_MSG =
+ String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_CLAMP);
+
+ /**
+ * Set up.
+ */
+ @BeforeClass
+ public static void setUp() {
+ Registry.newRegistry();
+ }
+
+ /**
+ * Shuts "main" down.
+ *
+ * @throws Exception if an error occurs
+ */
+ @AfterClass
+ public static void tearDown() throws Exception {
+ // shut down activator
+ final ClRuntimeActivator activator =
+ Registry.getOrDefault(ControlLoopConstants.REG_CLRUNTIME_ACTIVATOR, ClRuntimeActivator.class, null);
+ if (activator != null && activator.isAlive()) {
+ activator.shutdown();
+ }
+ }
+
+ @Test
+ public void testMain_Help() {
+ final String[] configParameters = {"-h"};
+ Main main = new Main(configParameters);
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_Version() {
+ final String[] configParameters = {"-v"};
+ Main main = new Main(configParameters);
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_Valid() {
+ final String[] configParameters = {"-c", "src/test/resources/parameters/TestParameters.json"};
+ Main main = new Main(configParameters);
+ assertTrue(main.isRunning());
+
+ // ensure items were added to the registry
+ assertNotNull(Registry.get(ControlLoopConstants.REG_CLRUNTIME_ACTIVATOR, ClRuntimeActivator.class));
+
+ assertThatCode(() -> main.shutdown()).doesNotThrowAnyException();
+
+ assertFalse(main.isRunning());
+ }
+
+ @Test
+ public void testMain_NoParameter() {
+ assertThatConfigParameterThrownException(new String[] {});
+ }
+
+ @Test
+ public void testMain_FilePathNotDefined() {
+ assertThatConfigParameterThrownException(new String[] {"-c"});
+ }
+
+ @Test
+ public void testMain_TooManyCommand() {
+ assertThatConfigParameterThrownException(new String[] {"-h", "d"});
+ }
+
+ @Test
+ public void testMain_WrongParameter() {
+ assertThatConfigParameterThrownException(new String[] {"-d"});
+ }
+
+ private void assertThatConfigParameterThrownException(final String[] configParameters) {
+ assertThatThrownBy(() -> Main.main(configParameters)).isInstanceOf(ControlLoopRuntimeException.class)
+ .hasMessage(POLICY_CLAMP_FAILURE_MSG);
+ }
+
+ @Test
+ public void testParticipant_NoFileWithThisName() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/NoFileWithThisName.json");
+ }
+
+ @Test
+ public void testParticipant_NotValidFile() {
+ assertThatConfigFileThrownException("src/test/resources/parameters");
+ }
+
+ @Test
+ public void testParticipant_FileEmpty() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/EmptyParameters.json");
+ }
+
+ @Test
+ public void testParticipant_NoParameters() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/NoParameters.json");
+ }
+
+ @Test
+ public void testParticipant_InvalidParameters() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/InvalidParameters.json");
+ }
+
+ @Test
+ public void testParticipant_WrongJsonFormat() {
+ assertThatConfigFileThrownException("src/test/resources/parameters/Unreadable.json");
+ }
+
+ private void assertThatConfigFileThrownException(final String configFilePath) {
+ final String[] configParameters = new String[] {"-c", configFilePath};
+ assertThatThrownBy(() -> new Main(configParameters)).isInstanceOf(ControlLoopRuntimeException.class)
+ .hasMessage(String.format(POLICY_CLAMP_FAILURE_MSG));
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
new file mode 100644
index 000000000..44096eecd
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
@@ -0,0 +1,264 @@
+/*-
+ * ============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.runtime.monitoring;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
+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.ParticipantStatisticsList;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+
+public class TestMonitoringProvider {
+
+ private static final String CL_PARTICIPANT_STATISTICS_JSON =
+ "src/test/resources/rest/monitoring/TestParticipantStatistics.json";
+ private static final String INVALID_PARTICIPANT_JSON_INPUT =
+ "src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json";
+ private static final String CL_ELEMENT_STATISTICS_JSON =
+ "src/test/resources/rest/monitoring/TestClElementStatistics.json";
+ private static final String INVALID_CL_ELEMENT_JSON_INPUT =
+ "src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json";
+ private static final Coder CODER = new StandardCoder();
+
+ private static final String CL_PROVIDER_FIELD = "controlLoopProvider";
+
+ private static final String LIST_IS_NULL = ".*StatisticsList is marked .*ull but is null";
+ private static ParticipantStatisticsList inputParticipantStatistics;
+ private static ParticipantStatisticsList invalidParticipantInput;
+ private static ClElementStatisticsList inputClElementStatistics;
+ private static ClElementStatisticsList invalidClElementInput;
+
+
+
+ @BeforeClass
+ public static void beforeSetupStatistics() throws CoderException {
+ // Reading input json for statistics data
+ inputParticipantStatistics =
+ CODER.decode(new File(CL_PARTICIPANT_STATISTICS_JSON), ParticipantStatisticsList.class);
+ invalidParticipantInput =
+ CODER.decode(new File(INVALID_PARTICIPANT_JSON_INPUT), ParticipantStatisticsList.class);
+ inputClElementStatistics = CODER.decode(new File(CL_ELEMENT_STATISTICS_JSON), ClElementStatisticsList.class);
+ invalidClElementInput = CODER.decode(new File(INVALID_CL_ELEMENT_JSON_INPUT), ClElementStatisticsList.class);
+ }
+
+
+ @Test
+ public void testCreateParticipantStatistics() throws Exception {
+ PolicyModelsProviderParameters parameters =
+ CommonTestData.geParameterGroup(0, "createparStat").getDatabaseProviderParameters();
+
+ try (MonitoringProvider provider = new MonitoringProvider(parameters)) {
+ // Creating statistics data in db with null input
+ assertThatThrownBy(() -> {
+ provider.createParticipantStatistics(null);
+ }).hasMessageMatching(LIST_IS_NULL);
+
+ assertThatThrownBy(() -> {
+ provider.createParticipantStatistics(invalidParticipantInput.getStatisticsList());
+ }).hasMessageMatching("participantStatisticsList is marked .*null but is null");
+
+ // Creating statistics data from input json
+ ParticipantStatisticsList createResponse =
+ provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
+
+ assertThat(createResponse.getStatisticsList()).hasSize(3);
+ assertEquals(createResponse.getStatisticsList().toString().replaceAll("\\s+", ""),
+ inputParticipantStatistics.getStatisticsList().toString().replaceAll("\\s+", ""));
+ }
+ }
+
+ @Test
+ public void testGetParticipantStatistics() throws Exception {
+ PolicyModelsProviderParameters parameters =
+ CommonTestData.geParameterGroup(0, "getparStat").getDatabaseProviderParameters();
+ try (MonitoringProvider provider = new MonitoringProvider(parameters)) {
+ ParticipantStatisticsList getResponse;
+
+ provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
+
+ assertThatThrownBy(() -> {
+ provider.fetchFilteredParticipantStatistics(null, null, 0, null, null);
+ }).hasMessageMatching("name is marked .*null but is null");
+
+ // Fetch specific statistics record with name, version and record count
+ getResponse = provider.fetchFilteredParticipantStatistics("name2", "1.001", 1,
+ null, null);
+ assertThat(getResponse.getStatisticsList()).hasSize(1);
+ assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""),
+ inputParticipantStatistics.getStatisticsList().get(2).toString().replaceAll("\\s+", ""));
+
+ // Fetch statistics using timestamp
+ getResponse = provider.fetchFilteredParticipantStatistics("name1", "1.001", 0,
+ null, Instant.parse("2021-01-10T15:00:00.000Z"));
+ assertThat(getResponse.getStatisticsList()).hasSize(1);
+
+ getResponse = provider.fetchFilteredParticipantStatistics("name1", "1.001", 0,
+ Instant.parse("2021-01-11T12:00:00.000Z"), Instant.parse("2021-01-11T16:00:00.000Z"));
+
+ assertThat(getResponse.getStatisticsList()).isEmpty();
+ }
+ }
+
+ @Test
+ public void testCreateClElementStatistics() throws Exception {
+ PolicyModelsProviderParameters parameters =
+ CommonTestData.geParameterGroup(0, "createelemstat").getDatabaseProviderParameters();
+ try (MonitoringProvider provider = new MonitoringProvider(parameters)) {
+ // Creating statistics data in db with null input
+ assertThatThrownBy(() -> {
+ provider.createClElementStatistics(null);
+ }).hasMessageMatching(LIST_IS_NULL);
+
+ assertThatThrownBy(() -> {
+ provider.createClElementStatistics(invalidClElementInput.getClElementStatistics());
+ }).hasMessageMatching("clElementStatisticsList is marked .*null but is null");
+
+ // Creating clElement statistics data from input json
+ ClElementStatisticsList createResponse =
+ provider.createClElementStatistics(inputClElementStatistics.getClElementStatistics());
+
+ assertThat(createResponse.getClElementStatistics()).hasSize(4);
+ assertEquals(createResponse.getClElementStatistics().toString().replaceAll("\\s+", ""),
+ inputClElementStatistics.getClElementStatistics().toString().replaceAll("\\s+", ""));
+ }
+ }
+
+ @Test
+ public void testGetClElementStatistics() throws Exception {
+ PolicyModelsProviderParameters parameters =
+ CommonTestData.geParameterGroup(0, "getelemstat").getDatabaseProviderParameters();
+ try (MonitoringProvider provider = new MonitoringProvider(parameters)) {
+ ClElementStatisticsList getResponse;
+
+ assertThatThrownBy(() -> {
+ provider.fetchFilteredClElementStatistics(null, null, null, null,
+ null, 0);
+ }).hasMessageMatching("name is marked .*null but is null");
+
+ ClElementStatisticsList lists = provider.createClElementStatistics(inputClElementStatistics
+ .getClElementStatistics());
+
+ getResponse = provider.fetchFilteredClElementStatistics("name1", null, null, null,
+ null, 0);
+
+ assertThat(getResponse.getClElementStatistics()).hasSize(2);
+ assertEquals(getResponse.getClElementStatistics().get(0).toString().replaceAll("\\s+", ""),
+ inputClElementStatistics.getClElementStatistics().get(0).toString().replaceAll("\\s+", ""));
+
+ // Fetch specific statistics record with name, id and record count
+ getResponse = provider.fetchFilteredClElementStatistics("name1", "1.001",
+ "709c62b3-8918-41b9-a747-d21eb79c6c20", null, null, 0);
+ assertThat(getResponse.getClElementStatistics()).hasSize(2);
+
+ // Fetch statistics using timestamp
+ getResponse = provider.fetchFilteredClElementStatistics("name1", "1.001", null,
+ Instant.parse("2021-01-10T13:45:00.000Z"), null, 0);
+ assertThat(getResponse.getClElementStatistics()).hasSize(2);
+ }
+ }
+
+ @Test
+ public void testGetParticipantStatsPerCL() throws Exception {
+ PolicyModelsProviderParameters parameters =
+ CommonTestData.geParameterGroup(0, "getparStatCL").getDatabaseProviderParameters();
+ try (MonitoringProvider provider = Mockito.spy(new MonitoringProvider(parameters))) {
+
+ provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
+ //Mock the response for fetching participant conceptIdentifiers per control loop
+ List<ToscaConceptIdentifier> conceptIdentifiers = new ArrayList<>();
+ conceptIdentifiers.add(new ToscaConceptIdentifier("name1", "1.001"));
+ when(provider.getAllParticipantIdsPerControlLoop("testName", "1.001"))
+ .thenReturn(conceptIdentifiers);
+ ParticipantStatisticsList getResponse;
+ getResponse = provider.fetchParticipantStatsPerControlLoop("testName", "1.001");
+ assertThat(getResponse.getStatisticsList()).hasSize(2);
+ assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""),
+ inputParticipantStatistics.getStatisticsList().get(0).toString().replaceAll("\\s+", ""));
+ assertThat(provider.fetchParticipantStatsPerControlLoop("invalidCLName", "1.002")
+ .getStatisticsList()).isEmpty();
+ }
+
+ }
+
+ @Test
+ public void testClElementStatsPerCL() throws Exception {
+ PolicyModelsProviderParameters parameters =
+ CommonTestData.geParameterGroup(0, "getelemstatPerCL").getDatabaseProviderParameters();
+ //Setup a dummy Control loop data
+ ControlLoopElement mockClElement = new ControlLoopElement();
+ mockClElement.setId(inputClElementStatistics.getClElementStatistics().get(0).getId());
+ mockClElement.setParticipantId(new ToscaConceptIdentifier(inputClElementStatistics.getClElementStatistics()
+ .get(0).getParticipantId().getName(), inputClElementStatistics.getClElementStatistics().get(0)
+ .getParticipantId().getVersion()));
+ ControlLoop mockCL = new ControlLoop();
+ mockCL.setElements(new LinkedHashMap<>());
+ mockCL.getElements().put(mockClElement.getId(), mockClElement);
+
+ //Mock controlloop data to be returned for the given CL Id
+ ControlLoopProvider mockClProvider = Mockito.mock(ControlLoopProvider.class);
+ when(mockClProvider.getControlLoop(new ToscaConceptIdentifier("testCLName", "1.001")))
+ .thenReturn(mockCL);
+
+ try (MonitoringProvider monitoringProvider = new MonitoringProvider(parameters)) {
+ monitoringProvider.createClElementStatistics(inputClElementStatistics.getClElementStatistics());
+ Field controlLoopProviderField = monitoringProvider.getClass().getDeclaredField(CL_PROVIDER_FIELD);
+ controlLoopProviderField.setAccessible(true);
+ controlLoopProviderField.set(monitoringProvider, mockClProvider);
+
+ ClElementStatisticsList getResponse;
+ getResponse = monitoringProvider.fetchClElementStatsPerControlLoop("testCLName", "1.001");
+
+ assertThat(getResponse.getClElementStatistics()).hasSize(2);
+ assertEquals(getResponse.getClElementStatistics().get(1).toString().replaceAll("\\s+", ""),
+ inputClElementStatistics.getClElementStatistics().get(1).toString().replaceAll("\\s+", ""));
+
+ assertThat(monitoringProvider.fetchClElementStatsPerControlLoop("invalidCLName", "1.002")
+ .getClElementStatistics()).isEmpty();
+
+ Map<String, ToscaConceptIdentifier> clElementIds = monitoringProvider
+ .getAllClElementsIdPerControlLoop("testCLName", "1.001");
+ assertThat(clElementIds).containsKey(inputClElementStatistics.getClElementStatistics().get(0).getId()
+ .toString());
+ }
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java
new file mode 100644
index 000000000..118199a2d
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java
@@ -0,0 +1,237 @@
+/*-
+ * ============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.runtime.monitoring.rest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.time.Instant;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.Response;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
+import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
+import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
+
+public class MonitoringQueryControllerTest extends CommonRestController {
+
+ private static final String CL_PARTICIPANT_STATISTICS_JSON =
+ "src/test/resources/rest/monitoring/TestParticipantStatistics.json";
+ private static final String CL_ELEMENT_STATISTICS_JSON =
+ "src/test/resources/rest/monitoring/TestClElementStatistics.json";
+
+ private static final Coder CODER = new StandardCoder();
+
+ private static ParticipantStatisticsList inputParticipantStatistics;
+ private static ClElementStatisticsList inputClElementStatistics;
+
+ private static ParticipantStatisticsList participantStatisticsList;
+ private static ClElementStatisticsList clElementStatisticsList;
+
+ private static final String CLELEMENT_STATS_ENDPOINT = "monitoring/clelement";
+ private static final String PARTICIPANT_STATS_ENDPOINT = "monitoring/participant";
+ private static final String PARTICIPANT_STATS_PER_CL_ENDPOINT = "monitoring/participants/controlloop";
+ private static final String CLELEMENT_STATS_PER_CL_ENDPOINT = "monitoring/clelements/controlloop";
+
+
+ /**
+ * starts Main.
+ *
+ * @throws Exception if an error occurs
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ CommonRestController.setUpBeforeClass("testStatisticsQuery");
+ inputParticipantStatistics = CODER.decode(new File(CL_PARTICIPANT_STATISTICS_JSON),
+ ParticipantStatisticsList.class);
+ inputClElementStatistics = CODER.decode(new File(CL_ELEMENT_STATISTICS_JSON),
+ ClElementStatisticsList.class);
+
+ try (MonitoringProvider monitoringProvider = new MonitoringProvider(getParameters())) {
+ // Insert Participant statistics to DB
+ participantStatisticsList = monitoringProvider.createParticipantStatistics(inputParticipantStatistics
+ .getStatisticsList());
+ // Insert CL Element statistics to DB
+ clElementStatisticsList = monitoringProvider.createClElementStatistics(inputClElementStatistics
+ .getClElementStatistics());
+ }
+ }
+
+ @AfterClass
+ public static void teardownAfterClass() {
+ CommonRestController.teardownAfterClass();
+ }
+
+ @Test
+ public void testQuery_Unauthorized_for_ClElementStats() throws Exception {
+ assertUnauthorizedGet(CLELEMENT_STATS_ENDPOINT);
+ }
+
+ @Test
+ public void testQuery_Unauthorized_for_ClParticipantStats() throws Exception {
+ assertUnauthorizedGet(PARTICIPANT_STATS_ENDPOINT);
+ }
+
+ @Test
+ public void testQuery_Unauthorized_for_ParticipantStatsPerCl() throws Exception {
+ assertUnauthorizedGet(PARTICIPANT_STATS_PER_CL_ENDPOINT);
+ }
+
+ @Test
+ public void testQuery_Unauthorized_for_ClElementStatsPerCl() throws Exception {
+ assertUnauthorizedGet(CLELEMENT_STATS_PER_CL_ENDPOINT);
+ }
+
+ @Test
+ public void testSwagger_ClStats() throws Exception {
+ super.testSwagger(CLELEMENT_STATS_ENDPOINT);
+ super.testSwagger(PARTICIPANT_STATS_ENDPOINT);
+ super.testSwagger(CLELEMENT_STATS_PER_CL_ENDPOINT);
+ super.testSwagger(PARTICIPANT_STATS_PER_CL_ENDPOINT);
+ }
+
+ @Test
+ public void testClElementStatisticsEndpoint() throws Exception {
+ // Filter statistics only based on participant Id and UUID
+ Invocation.Builder invokeRequest1 =
+ super.sendRequest(CLELEMENT_STATS_ENDPOINT + "?name=" + clElementStatisticsList
+ .getClElementStatistics().get(0).getParticipantId().getName() + "&version=" + clElementStatisticsList
+ .getClElementStatistics().get(0).getParticipantId().getVersion() + "&id=" + clElementStatisticsList
+ .getClElementStatistics().get(0).getId().toString());
+ Response response1 = invokeRequest1.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus());
+
+ ClElementStatisticsList result1 = response1.readEntity(ClElementStatisticsList.class);
+
+ assertNotNull(result1);
+ assertThat(result1.getClElementStatistics()).hasSize(2);
+ assertEquals(result1.getClElementStatistics().get(0), clElementStatisticsList
+ .getClElementStatistics().get(0));
+
+ // Filter statistics based on timestamp
+ Invocation.Builder invokeRequest2 =
+ super.sendRequest(CLELEMENT_STATS_ENDPOINT + "?name=" + clElementStatisticsList
+ .getClElementStatistics().get(1).getParticipantId().getName() + "&version=" + clElementStatisticsList
+ .getClElementStatistics().get(1).getParticipantId().getVersion() + "&startTime="
+ + Instant.parse("2021-01-10T13:00:00.000Z") + "&endTime=" + Instant.parse("2021-01-10T14:00:00.000Z"));
+ Response response2 = invokeRequest2.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), response2.getStatus());
+ ClElementStatisticsList result2 = response2.readEntity(ClElementStatisticsList.class);
+
+ assertNotNull(result2);
+ assertThat(result2.getClElementStatistics()).hasSize(1);
+ assertEquals(result1.getClElementStatistics().get(0), clElementStatisticsList
+ .getClElementStatistics().get(0));
+ }
+
+ @Test
+ public void testClElementStats_BadRequest() throws Exception {
+ Invocation.Builder invokeRequest1 =
+ super.sendRequest(CLELEMENT_STATS_ENDPOINT + "?version=1.0.0");
+ Response response1 = invokeRequest1.buildGet().invoke();
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
+ }
+
+ @Test
+ public void testParticipantStatisticsEndpoint() throws Exception {
+
+ // Filter statistics only based on participant Id
+ Invocation.Builder invokeRequest1 =
+ super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?name=" + participantStatisticsList
+ .getStatisticsList().get(0).getParticipantId().getName() + "&version=" + participantStatisticsList
+ .getStatisticsList().get(0).getParticipantId().getVersion());
+ Response response1 = invokeRequest1.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus());
+ ParticipantStatisticsList result1 = response1.readEntity(ParticipantStatisticsList.class);
+
+ assertNotNull(result1);
+ assertThat(result1.getStatisticsList()).hasSize(2);
+ assertEquals(result1.getStatisticsList().get(0), participantStatisticsList
+ .getStatisticsList().get(0));
+
+ // Filter statistics based on timestamp
+ Invocation.Builder invokeRequest2 =
+ super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?name=" + participantStatisticsList
+ .getStatisticsList().get(1).getParticipantId().getName() + "&version=" + participantStatisticsList
+ .getStatisticsList().get(1).getParticipantId().getVersion() + "&startTime="
+ + Instant.parse("2021-01-10T13:00:00.000Z") + "&endTime=" + Instant.parse("2021-01-10T14:00:00.000Z"));
+ Response response2 = invokeRequest2.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), response2.getStatus());
+ ParticipantStatisticsList result2 = response2.readEntity(ParticipantStatisticsList.class);
+
+ assertNotNull(result2);
+ assertThat(result2.getStatisticsList()).hasSize(1);
+ assertEquals(result1.getStatisticsList().get(0), participantStatisticsList
+ .getStatisticsList().get(0));
+ }
+
+ @Test
+ public void testParticipantStats_BadRequest() throws Exception {
+ Invocation.Builder invokeRequest1 =
+ super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?version=0.0");
+ Response response1 = invokeRequest1.buildGet().invoke();
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
+ }
+
+ @Test
+ public void testParticipantStatsPerClEndpoint() throws Exception {
+ Invocation.Builder invokeRequest1 =
+ super.sendRequest(PARTICIPANT_STATS_PER_CL_ENDPOINT + "?name=dummyName&version=1.001");
+ Response response1 = invokeRequest1.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus());
+ ParticipantStatisticsList result1 = response1.readEntity(ParticipantStatisticsList.class);
+ assertThat(result1.getStatisticsList()).isEmpty();
+ }
+
+ @Test
+ public void testParticipantStatsPerCl_BadRequest() throws Exception {
+ Invocation.Builder invokeRequest1 =
+ super.sendRequest(PARTICIPANT_STATS_PER_CL_ENDPOINT);
+ Response response1 = invokeRequest1.buildGet().invoke();
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
+ }
+
+ @Test
+ public void testClElementStatisticsPerClEndpoint() throws Exception {
+ Invocation.Builder invokeRequest1 =
+ super.sendRequest(CLELEMENT_STATS_PER_CL_ENDPOINT + "?name=dummyName&version=1.001");
+ Response response1 = invokeRequest1.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus());
+ ClElementStatisticsList result1 = response1.readEntity(ClElementStatisticsList.class);
+ assertThat(result1.getClElementStatistics()).isEmpty();
+ }
+
+ @Test
+ public void testClElementStatsPerCl_BadRequest() throws Exception {
+ Invocation.Builder invokeRequest1 =
+ super.sendRequest(CLELEMENT_STATS_PER_CL_ENDPOINT);
+ Response response1 = invokeRequest1.buildGet().invoke();
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
new file mode 100644
index 000000000..77f802d61
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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.runtime.util;
+
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+
+/**
+ * Class to hold/create all parameters for test cases.
+ *
+ */
+public class CommonTestData {
+ private static final Coder coder = new StandardCoder();
+
+ /**
+ * Gets the standard Control Loop parameters.
+ *
+ * @param port port to be inserted into the parameters
+ * @param dbName the database name
+ * @return the standard Control Loop parameters
+ */
+ public static ClRuntimeParameterGroup geParameterGroup(final int port, final String dbName) {
+ try {
+ return coder.decode(getParameterGroupAsString(port, dbName), ClRuntimeParameterGroup.class);
+
+ } catch (CoderException e) {
+ throw new RuntimeException("cannot read Control Loop parameters", e);
+ }
+ }
+
+ /**
+ * Gets the standard Control Loop parameters, as a String.
+ *
+ * @param port port to be inserted into the parameters
+ * @param dbName the database name
+ * @return the standard Control Loop parameters as string
+ */
+ public static String getParameterGroupAsString(final int port, final String dbName) {
+ return ResourceUtils.getResourceAsString("src/test/resources/parameters/InstantiationConfigParametersStd.json")
+ .replace("${port}", String.valueOf(port)).replace("${dbName}", "jdbc:h2:mem:" + dbName);
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java
new file mode 100644
index 000000000..0d668f139
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java
@@ -0,0 +1,263 @@
+/*-
+ * ============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.runtime.util.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.glassfish.jersey.client.ClientProperties;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.runtime.main.startstop.Main;
+import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
+import org.onap.policy.common.utils.network.NetworkUtil;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to perform Rest unit tests.
+ *
+ */
+public class CommonRestController {
+
+ private static final String CONFIG_FILE = "src/test/resources/parameters/RuntimeConfigParameters%d.json";
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CommonRestController.class);
+
+ public static final String SELF = NetworkUtil.getHostname();
+ public static final String ENDPOINT_PREFIX = "onap/controlloop/v2/";
+
+ private static int port;
+ private static String httpPrefix;
+ private static Main main;
+
+ /**
+ * Allocates a port for the server, writes a config file, and then starts Main.
+ *
+ * @param dbName database name
+ * @throws Exception if an error occurs
+ */
+ public static void setUpBeforeClass(final String dbName) throws Exception {
+ port = NetworkUtil.allocPort();
+
+ httpPrefix = "http://" + SELF + ":" + port + "/";
+
+ makeConfigFile(dbName);
+ startMain();
+ }
+
+ /**
+ * Stops Main.
+ */
+ public static void teardownAfterClass() {
+ try {
+ stopMain();
+ } catch (Exception ex) {
+ LOGGER.error("cannot stop main", ex);
+ }
+ }
+
+ protected static PolicyModelsProviderParameters getParameters() {
+ return main.getParameters().getDatabaseProviderParameters();
+ }
+
+ /**
+ * Verifies that an endpoint appears within the swagger response.
+ *
+ * @param endpoint the endpoint of interest
+ * @throws Exception if an error occurs
+ */
+ protected void testSwagger(final String endpoint) throws Exception {
+ final Invocation.Builder invocationBuilder = sendFqeRequest(httpPrefix + "swagger.yaml", true);
+ final String resp = invocationBuilder.get(String.class);
+
+ assertTrue(resp.contains(ENDPOINT_PREFIX + endpoint + ":"));
+ }
+
+ /**
+ * Makes a parameter configuration file.
+ *
+ * @param dbName database name
+ * @throws IOException if an error occurs writing the configuration file
+ * @throws FileNotFoundException if an error occurs writing the configuration file
+ */
+ private static void makeConfigFile(final String dbName) throws FileNotFoundException, IOException {
+ String json = CommonTestData.getParameterGroupAsString(port, dbName);
+
+ File file = new File(String.format(CONFIG_FILE, port));
+ file.deleteOnExit();
+
+ try (FileOutputStream output = new FileOutputStream(file)) {
+ output.write(json.getBytes(StandardCharsets.UTF_8));
+ }
+ }
+
+ /**
+ * Starts the "Main".
+ *
+ * @throws InterruptedException
+ *
+ * @throws Exception if an error occurs
+ */
+ protected static void startMain() throws InterruptedException {
+ Registry.newRegistry();
+
+ // make sure port is available
+ if (NetworkUtil.isTcpPortOpen(SELF, port, 1, 1L)) {
+ throw new IllegalStateException("port " + port + " is not available");
+ }
+
+ final String[] configParameters = {"-c", String.format(CONFIG_FILE, port)};
+
+ main = new Main(configParameters);
+
+ if (!NetworkUtil.isTcpPortOpen(SELF, port, 40, 250L)) {
+ throw new IllegalStateException("server is not listening on port " + port);
+ }
+ }
+
+ /**
+ * Stops the "Main".
+ *
+ * @throws ControlLoopException
+ *
+ * @throws Exception if an error occurs
+ */
+ private static void stopMain() throws Exception {
+ if (main != null) {
+ Main main2 = main;
+ main = null;
+
+ main2.shutdown();
+ }
+ // make sure port is close
+ if (NetworkUtil.isTcpPortOpen(SELF, port, 1, 1L)) {
+ throw new IllegalStateException("port " + port + " is still in use");
+ }
+ }
+
+ /**
+ * Sends a request to an endpoint.
+ *
+ * @param endpoint the target endpoint
+ * @return a request builder
+ * @throws Exception if an error occurs
+ */
+ protected Invocation.Builder sendRequest(final String endpoint) throws Exception {
+ return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, true);
+ }
+
+ /**
+ * Sends a request to an endpoint, without any authorization header.
+ *
+ * @param endpoint the target endpoint
+ * @return a request builder
+ * @throws Exception if an error occurs
+ */
+ protected Invocation.Builder sendNoAuthRequest(final String endpoint) throws Exception {
+ return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, false);
+ }
+
+ /**
+ * Sends a request to a fully qualified endpoint.
+ *
+ * @param fullyQualifiedEndpoint the fully qualified target endpoint
+ * @param includeAuth if authorization header should be included
+ * @return a request builder
+ * @throws Exception if an error occurs
+ */
+ protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth)
+ throws Exception {
+ final Client client = ClientBuilder.newBuilder().build();
+
+ client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
+ client.register(GsonMessageBodyHandler.class);
+
+ if (includeAuth) {
+ client.register(HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34"));
+ }
+
+ final WebTarget webTarget = client.target(fullyQualifiedEndpoint);
+
+ return webTarget.request(MediaType.APPLICATION_JSON);
+ }
+
+ /**
+ * Assert that POST call is Unauthorized.
+ *
+ * @param endPoint the endpoint
+ * @param entity the entity ofthe body
+ * @throws Exception if an error occurs
+ */
+ protected void assertUnauthorizedPost(final String endPoint, final Entity<?> entity) throws Exception {
+ Response rawresp = sendNoAuthRequest(endPoint).post(entity);
+ assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
+ }
+
+ /**
+ * Assert that PUT call is Unauthorized.
+ *
+ * @param endPoint the endpoint
+ * @param entity the entity ofthe body
+ * @throws Exception if an error occurs
+ */
+ protected void assertUnauthorizedPut(final String endPoint, final Entity<?> entity) throws Exception {
+ Response rawresp = sendNoAuthRequest(endPoint).put(entity);
+ assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
+ }
+
+ /**
+ * Assert that GET call is Unauthorized.
+ *
+ * @param endPoint the endpoint
+ * @throws Exception if an error occurs
+ */
+ protected void assertUnauthorizedGet(final String endPoint) throws Exception {
+ Response rawresp = sendNoAuthRequest(endPoint).buildGet().invoke();
+ assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
+ }
+
+ /**
+ * Assert that DELETE call is Unauthorized.
+ *
+ * @param endPoint the endpoint
+ * @throws Exception if an error occurs
+ */
+ protected void assertUnauthorizedDelete(final String endPoint) throws Exception {
+ Response rawresp = sendNoAuthRequest(endPoint).delete();
+ assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
+ }
+} \ No newline at end of file
diff --git a/runtime-controlloop/src/test/resources/META-INF/persistence.xml b/runtime-controlloop/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 000000000..6e31cca47
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="CommissioningMariaDb" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.base.PfConceptKey</class>
+ <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
+ <class>org.onap.policy.models.dao.converters.Uuid2String</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpStatistics</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+
+ <properties>
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+
+ <!-- property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL" /-->
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+
+ <persistence-unit name="ToscaConceptTest" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+
+ <properties>
+ <property name="eclipselink.target-database" value="MySQL" />
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+
+ <persistence-unit name="InstantiationTests" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+
+ <properties>
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+
+</persistence>
+
diff --git a/runtime-controlloop/src/test/resources/parameters/CommissioningConfig.json b/runtime-controlloop/src/test/resources/parameters/CommissioningConfig.json
new file mode 100644
index 000000000..bda9da6a1
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/CommissioningConfig.json
@@ -0,0 +1,20 @@
+{
+ "name": "CommissioningGroup",
+ "restServerParameters": {
+ "host": "127.0.0.1",
+ "port": 6969,
+ "userName": "admin",
+ "password": "password",
+ "https": false,
+ "aaf": false
+ },
+ "databaseProviderParameters": {
+ "name": "CommissioningProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "controlloop",
+ "databasePassword": "C0ntr0lL00p",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/EmptyParameters.json b/runtime-controlloop/src/test/resources/parameters/EmptyParameters.json
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/EmptyParameters.json
diff --git a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json
new file mode 100644
index 000000000..7682a1812
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json
@@ -0,0 +1,79 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": ${port},
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "${dbName}",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "InstantiationTests"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ },
+ "healthCheckRestClientParameters": [
+ {
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }
+ ]
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json
new file mode 100644
index 000000000..b0c322cb9
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json
@@ -0,0 +1,31 @@
+{
+ "name":" ",
+ "restServerParameters": {
+ "host": "127.0.0.1",
+ "port": 6969,
+ "userName": "admin",
+ "password": "password",
+ "https": false,
+ "aaf": false
+ },
+ "pdpParameters": {
+ "heartBeatMs": 1,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 1
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 1
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "PdpGroupTest"
+ }
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_sim.json b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_sim.json
new file mode 100644
index 000000000..0977da9ad
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_sim.json
@@ -0,0 +1,43 @@
+{
+ "name": "Instantiation",
+ "restServerParameters": {
+ "host": "127.0.0.1",
+ "port": 6969,
+ "userName": "admin",
+ "password": "password",
+ "https": false,
+ "aaf": false
+ },
+ "pdpParameters": {
+ "heartBeatMs": 10,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://localhost:3306/policyadmin",
+ "databaseUser": "policy",
+ "databasePassword": "UDAxaWNZ",
+ "persistenceUnit": "PolicyMariaDb"
+ },
+ "topicParameterGroup": {
+ "topicSources" : [{
+ "topic" : "INSTANTIATION",
+ "servers" : [ "localhost:6845" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "INSTANTIATION",
+ "servers" : [ "localhost:6845" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
+ }
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/InvalidParameters.json b/runtime-controlloop/src/test/resources/parameters/InvalidParameters.json
new file mode 100644
index 000000000..976ec2937
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/InvalidParameters.json
@@ -0,0 +1,3 @@
+{
+ "name": ""
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json b/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json
new file mode 100644
index 000000000..f784dcd16
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json
@@ -0,0 +1,59 @@
+{
+ "name":"PapGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
+ "pdpParameters": {
+ "heartBeatMs": 1,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 1
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 1
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "PdpGroupTest"
+ },
+ "topicParameterGroup": {
+ "topicSources" : [{
+ "topic" : "POLICY-PDP-PAP",
+ "servers" : [ "message-router" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "POLICY-PDP-PAP",
+ "servers" : [ "message-router" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
+ },
+ "healthCheckRestClientParameters":[{
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }]
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/NoParameters.json b/runtime-controlloop/src/test/resources/parameters/NoParameters.json
new file mode 100644
index 000000000..2c63c0851
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/NoParameters.json
@@ -0,0 +1,2 @@
+{
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/TestParameters.json b/runtime-controlloop/src/test/resources/parameters/TestParameters.json
new file mode 100644
index 000000000..c3be762d6
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/TestParameters.json
@@ -0,0 +1,79 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ },
+ "healthCheckRestClientParameters": [
+ {
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }
+ ]
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/TestParametersMariaDB.json b/runtime-controlloop/src/test/resources/parameters/TestParametersMariaDB.json
new file mode 100644
index 000000000..2c0127b16
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/TestParametersMariaDB.json
@@ -0,0 +1,79 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://localhost:3306/controlloop",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "CommissioningMariaDb"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ },
+ "healthCheckRestClientParameters": [
+ {
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }
+ ]
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/Unreadable.json b/runtime-controlloop/src/test/resources/parameters/Unreadable.json
new file mode 100644
index 000000000..3d117f416
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/Unreadable.json
@@ -0,0 +1,78 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "ToscaConceptTest"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ },
+ "healthCheckRestClientParameters": [
+ {
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }
+ ]
diff --git a/runtime-controlloop/src/test/resources/parameters/logback-test.xml b/runtime-controlloop/src/test/resources/parameters/logback-test.xml
new file mode 100644
index 000000000..e00c36baa
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/parameters/logback-test.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+
+<configuration>
+
+ <contextName>Apex</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/clamp_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.onap.policy.clamp.controlloop.runtime" level="trace" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>
diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json
new file mode 100644
index 000000000..faea7cd48
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json
@@ -0,0 +1,142 @@
+{
+ "controlLoopList": [
+ {
+ "name": "PMSHInstance0",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 0",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c20": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "definition": {
+ "name": "org.onap.domain.pmsh.DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 0 control loop"
+ }
+ }
+ },
+ {
+ "name": "PMSHInstance1",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 1",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
+ "definition": {
+ "name": "org.onap.domain.pmsh.DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 1 control loop"
+ }
+ }
+ }
+ ]
+}
diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json
new file mode 100644
index 000000000..13ea1bfc4
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json
@@ -0,0 +1,142 @@
+{
+ "controlLoopList": [
+ {
+ "name": "PMSHInstance0",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 0",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c20": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 0 control loop"
+ }
+ }
+ },
+ {
+ "name": "PMSHInstance1",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 1",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 1 control loop"
+ }
+ }
+ }
+ ]
+}
diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsNotFound.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsNotFound.json
new file mode 100644
index 000000000..9e9767472
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsNotFound.json
@@ -0,0 +1,142 @@
+{
+ "controlLoopList": [
+ {
+ "name": "PMSHInstance0",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 0",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c20": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 0 control loop"
+ }
+ }
+ },
+ {
+ "name": "PMSHInstance1",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 1",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 1 control loop"
+ }
+ }
+ }
+ ]
+}
diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsUpdate.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsUpdate.json
new file mode 100644
index 000000000..025e2a1fb
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsUpdate.json
@@ -0,0 +1,142 @@
+{
+ "controlLoopList": [
+ {
+ "name": "PMSHInstance0",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 1",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c24",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 0 control loop"
+ }
+ }
+ },
+ {
+ "name": "PMSHInstance1",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 1",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c28": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c28",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 1 control loop"
+ }
+ }
+ }
+ ]
+}
diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json
new file mode 100644
index 000000000..76131afc1
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json
@@ -0,0 +1,142 @@
+{
+ "controlLoopList": [
+ {
+ "name": "PMSHInstance0",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 0",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c20": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 0 control loop"
+ }
+ }
+ },
+ {
+ "name": "PMSHInstance1",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 1",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 1 control loop"
+ }
+ }
+ }
+ ]
+}
diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/PassiveCommand.json b/runtime-controlloop/src/test/resources/rest/controlloops/PassiveCommand.json
new file mode 100644
index 000000000..9c87e43b6
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/controlloops/PassiveCommand.json
@@ -0,0 +1,13 @@
+{
+ "orderedState": "PASSIVE",
+ "controlLoopIdentifierList": [
+ {
+ "name": "PMSHInstance0",
+ "version": "1.0.1"
+ },
+ {
+ "name": "PMSHInstance1",
+ "version": "1.0.1"
+ }
+ ]
+}
diff --git a/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics.json b/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics.json
new file mode 100644
index 000000000..21a048ff0
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics.json
@@ -0,0 +1,44 @@
+{
+ "clElementStatistics":[
+ {
+ "participantId":{
+ "name":"name1",
+ "version":"1.001"
+ },
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "timeStamp": "2021-01-10T13:45:00.000Z",
+ "controlLoopState": "UNINITIALISED",
+ "clElementUptime":250
+ },
+ {
+ "participantId":{
+ "name":"name1",
+ "version":"1.001"
+ },
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "timeStamp": "2021-01-10T15:45:00.000Z",
+ "controlLoopState": "UNINITIALISED",
+ "clElementUptime":450
+ },
+ {
+ "participantId":{
+ "name":"name2",
+ "version":"1.001"
+ },
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "timeStamp": "2021-01-10T14:25:00.000Z",
+ "controlLoopState": "UNINITIALISED",
+ "clElementUptime":330
+ },
+ {
+ "participantId":{
+ "name":"name2",
+ "version":"1.001"
+ },
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "timeStamp": "2021-01-10T16:35:00.000Z",
+ "controlLoopState": "UNINITIALISED",
+ "clElementUptime":650
+ }
+ ]
+} \ No newline at end of file
diff --git a/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json b/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json
new file mode 100644
index 000000000..2cf2619bf
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json
@@ -0,0 +1,13 @@
+{
+ "clElementStatisticsList":[
+ {
+ "participantId":{
+ "name":"name1",
+ "version":"1.001"
+ },
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "controlLoopState": "UNINITIALISED",
+ "clElementUptime":250
+ }
+ ]
+} \ No newline at end of file
diff --git a/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics.json b/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics.json
new file mode 100644
index 000000000..acd88e24b
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics.json
@@ -0,0 +1,46 @@
+{
+ "statisticsList":[
+ {
+ "participantId":{
+ "name":"name1",
+ "version":"1.001"
+ },
+ "timeStamp": "2021-01-10T13:45:00.000Z",
+ "state": "PASSIVE",
+ "healthStatus": "HEALTHY",
+ "eventCount":250,
+ "lastExecutionTime":100,
+ "averageExecutionTime":90,
+ "upTime":1000,
+ "lastStart":3000
+ },
+ {
+ "participantId":{
+ "name":"name1",
+ "version":"1.001"
+ },
+ "timeStamp": "2021-01-10T15:45:00.000Z",
+ "state": "PASSIVE",
+ "healthStatus": "HEALTHY",
+ "eventCount":262,
+ "lastExecutionTime":100,
+ "averageExecutionTime":90,
+ "upTime":2000,
+ "lastStart":3000
+ },
+ {
+ "participantId":{
+ "name":"name2",
+ "version":"1.001"
+ },
+ "timeStamp": "2021-01-27T14:25:00.000Z",
+ "state": "PASSIVE",
+ "healthStatus": "HEALTHY",
+ "eventCount":245,
+ "lastExecutionTime":1020,
+ "averageExecutionTime":85,
+ "upTime":1050,
+ "lastStart":3100
+ }
+ ]
+} \ No newline at end of file
diff --git a/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json b/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json
new file mode 100644
index 000000000..7281822f0
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json
@@ -0,0 +1,16 @@
+{
+ "participantStatisticsList":[
+ {
+ "participantId":{
+ "name":"name3",
+ "version":"1.001"
+ },
+ "state": "PASSIVE",
+ "eventCount":250,
+ "lastExecutionTime":100,
+ "averageExecutionTime":90,
+ "upTime":1000,
+ "lastStart":3000
+ }
+ ]
+} \ No newline at end of file
diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml
new file mode 100644
index 000000000..099e2e945
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml
@@ -0,0 +1,221 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+data_types:
+ onap.datatypes.ToscaConceptIdentifier:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ required: true
+ version:
+ type: string
+ required: true
+node_types:
+ org.onap.policy.clamp.controlloop.Participant:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ org.onap.policy.clamp.controlloop.ControlLoopElement:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ participant_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.ControlLoop:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ elements:
+ type: list
+ required: true
+ entry_schema:
+ type: onap.datatypes.ToscaConceptIdentifier
+ org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ dcae_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ policy_type_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.CDSControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ cds_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+topology_template:
+ node_templates:
+ org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant:
+ version: 2.3.4
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.policy.controlloop.PolicyControlLoopParticipant:
+ version: 2.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant:
+ version: 2.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.domain.pmsh.PMSH_DCAEMicroservice:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ dcae_blueprint_id:
+ name: org.onap.dcae.blueprints.PMSHBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.monitoring.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for CDS for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_Id:
+ name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
+ version: 3.2.1
+ cds_blueprint_id:
+ name: org.onap.ccsdk.cds.PMSHCdsBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSHControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ elements:
+ - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement
+ version: 1.2.3
+ org.onap.domain.pmsh.PMSD_DCAEMicroservice:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ dcae_blueprint_id:
+ name: org.onap.dcae.blueprints.PMSDBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.monitoring.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for CDS for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_Id:
+ name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
+ version: 3.2.1
+ cds_blueprint_id:
+ name: org.onap.ccsdk.cds.PMSDCdsBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSDControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ elements:
+ - name: org.onap.domain.pmsh.PMSD_DCAEMicroservice
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement
+ version: 1.2.3
diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml
new file mode 100644
index 000000000..01f825fc9
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml
@@ -0,0 +1,452 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+capability_types:
+ org.onap.EventProducer:
+ properties:
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ event_format:
+ type: string
+ required: true
+ event_format_version:
+ type: string
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+ org.onap.EventConsumer:
+ properties:
+ responding_capability:
+ type: string
+ required: false
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ - all valid values should be added here
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured,
+ etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+node_types:
+ org.onap.DynamicConfig:
+ properties:
+ application_name:
+ type: string
+ description: Value used to tie the config to an application ? should we be
+ using a relationship here instead?
+ required: true
+ application_version:
+ type: string
+ required: true
+ application_provider:
+ type: string
+ required: false
+ data_types:
+ type: object
+ required: false
+ schema:
+ type: object
+ required: false
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.APP:
+ properties:
+ application_name:
+ type: string
+ description: Human readable name for the application Product
+ required: false
+ provider:
+ type: string
+ description: Provider of the application and of the descriptor
+ required: true
+ application_version:
+ type: string
+ description: Software version of the application
+ required: true
+ blueprint_id:
+ type: string
+ description: A reference to the app blueprint
+ required: false
+ monitoring_policy:
+ type: string
+ description: A reference to the monitoring policy
+ required: false
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.EventRelay:
+ properties:
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: true
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key is relayed
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ supported_carrier_protocols:
+ type: map
+ description: 'A map describing supported carrier protocols and translations.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ supported_data_formats:
+ type: map
+ description: 'Is a map describing supported data formats and translation.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+relationship_types:
+ org.onap.PropagateEvent:
+ properties:
+ config_keys:
+ type: list
+ description: The relationship type used on requirements to org.onap.EventProducer
+ and org.onap.EventConsumer capabilities. Filters events by specific config_keys
+ to be transferred by this relationship. That is, any event with a specific
+ config_key found in the list is transferred. If list is not defined or is
+ empty, events with all config_keys are transferred.
+ required: false
+ entry_schema:
+ type: string
+ version: 0.0.1
+ derived_from: tosca.relationships.Root
+topology_template:
+ inputs:
+ pm_subscription_topic:
+ type: string
+ pm_subscription_response_topic:
+ type: string
+ pm_subscription_handler_blueprint_id:
+ type: string
+ pm_subscription_operational_policy_id:
+ type: string
+ pm_subscription_cds_blueprint_id:
+ type: string
+ enable_tls:
+ type: string
+ node_templates:
+ org.onap.PM_Subscription_Handler:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription Handler
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_handler_blueprint_id
+ description: Is this a reference to the DCAE Cloudify Blueprint that is
+ already stored(or will be stored before CL configuration & instatiation)
+ in DCAE Inventory?
+ artifact_config:
+ enable_tls:
+ get_input: enable_tls
+ pmsh_publish_topic_name:
+ get_input: pm_subscription_topic
+ capabilities:
+ pm-subscription-event-publisher:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-format
+ event_format_version: 1.0.0
+ attributes:
+ type: org.onap.EventProducer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ pm-subscription-event-receiver:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ relationships:
+ - type: tosca.relationships.DependsOn
+ - description: any ideas on a better realtionship ? or is it better to
+ just use the root realtionship ?
+ - target: org.onap.PM_Monitoring_Policy
+ attributes:
+ type: org.onap.EventConsumer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_Monitoring_Policy:
+ type: org.onap.DynamicConfig
+ properties:
+ application_name: PM Subscription Handler
+ application_version: 1.0.0
+ provider: Ericsson
+ data_types:
+ measurementType:
+ type: string
+ DN:
+ type: string
+ nfFilter:
+ properties:
+ nfNames:
+ type: list
+ entry_schema: string
+ modelInvariantIDs:
+ type: list
+ entry_schema:
+ type: string
+ modelVersionIDs:
+ type: list
+ entry_schema:
+ type: string
+ measurementGroup:
+ properties:
+ masurementTypes:
+ type: list
+ entry_schema:
+ type: measurementType
+ managedObjectDNsBasic:
+ type: list
+ entry_schema:
+ type: DN
+ schema:
+ subscription:
+ subscriptionName:
+ type: string
+ required: true
+ administrativeState:
+ type: string
+ required: true
+ filebasedGP:
+ type: integer
+ required: true
+ fileLocation:
+ type: string
+ required: true
+ nfFilter:
+ type: nfFilter
+ measurementGroups:
+ type: list
+ entry_schema:
+ type: measurementGroup
+ version: 0.0.0
+ description: Should I be showing a dependency between PM Subscription Handler
+ and the PM Monitoring Policy
+ org.onap.PM_Policy:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription Operational Policy
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_operational_policy_id
+ artifact_config: NOT_DEFINED
+ requirements:
+ - receive_0:
+ capability: pm-subscription-event-publisher
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_topic
+ version: 0.0.0
+ - send_0:
+ capability: cds-rest-receive
+ node: org.onap.CDS
+ version: 0.0.0
+ - receive_1:
+ capability: cds-rest-response
+ node: org.onap.CDS
+ version: 0.0.0
+ - send_1:
+ capability: pm-subscription-event-receiver
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_response_topic
+ version: 0.0.0
+ capabilities:
+ pm-subscription-response-event-publisher:
+ properties:
+ type: org.onap.EventProducer
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_CDS_Blueprint:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription CDS Blueprint
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_cds_blueprint_id
+ capabilities:
+ cds-rest-receive:
+ properties:
+ type: org.onap.EventConsumer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_format
+ event_format_version: 1.0.0
+ responding_capability: cds-rest-response
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ cds-rest-response:
+ properties:
+ type: org.onap.EventProducer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_response_format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.controlloop0:
+ type: org.onap.APP
+ properties:
+ application_name: Test Control Loop
+ provider: Ericsson
+ application_version: 1.0.0
+ status: NOT_DEPLOYED
+ version: 0.0.0
+version: 0.0.0
diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
new file mode 100644
index 000000000..099e2e945
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
@@ -0,0 +1,221 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+data_types:
+ onap.datatypes.ToscaConceptIdentifier:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ required: true
+ version:
+ type: string
+ required: true
+node_types:
+ org.onap.policy.clamp.controlloop.Participant:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ org.onap.policy.clamp.controlloop.ControlLoopElement:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ participant_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.ControlLoop:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ elements:
+ type: list
+ required: true
+ entry_schema:
+ type: onap.datatypes.ToscaConceptIdentifier
+ org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ dcae_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ policy_type_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.CDSControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ cds_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+topology_template:
+ node_templates:
+ org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant:
+ version: 2.3.4
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.policy.controlloop.PolicyControlLoopParticipant:
+ version: 2.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant:
+ version: 2.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.domain.pmsh.PMSH_DCAEMicroservice:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ dcae_blueprint_id:
+ name: org.onap.dcae.blueprints.PMSHBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.monitoring.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for CDS for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_Id:
+ name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
+ version: 3.2.1
+ cds_blueprint_id:
+ name: org.onap.ccsdk.cds.PMSHCdsBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSHControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ elements:
+ - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement
+ version: 1.2.3
+ org.onap.domain.pmsh.PMSD_DCAEMicroservice:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ dcae_blueprint_id:
+ name: org.onap.dcae.blueprints.PMSDBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.monitoring.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for CDS for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_Id:
+ name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
+ version: 3.2.1
+ cds_blueprint_id:
+ name: org.onap.ccsdk.cds.PMSDCdsBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSDControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ elements:
+ - name: org.onap.domain.pmsh.PMSD_DCAEMicroservice
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement
+ version: 1.2.3
diff --git a/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh b/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh
new file mode 100644
index 000000000..5e661777b
--- /dev/null
+++ b/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh
@@ -0,0 +1,31 @@
+#! /bin/bash
+# ============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=========================================================
+
+if [ $# -ne 1 ]
+then
+ echo invalid parameters $*, specify a single parameter as the topic to listen on
+ exit 1
+fi
+
+while true
+do
+ curl "http://localhost:3904/events/$1/TEST/1?timeout=60000"
+ echo ""
+done
+
diff --git a/runtime/pom.xml b/runtime/pom.xml
index 66d555ac7..f0277575e 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -647,7 +647,7 @@
</dependency>
</dependencies>
<configuration>
- <swaggerInput>${project.basedir}/docs/swagger/swagger.json</swaggerInput>
+ <swaggerInput>${project.basedir}/../docs/swagger/swagger.json</swaggerInput>
<outputDir>${project.build.directory}/asciidoc/generated</outputDir>
<config>
<swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>