aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/src/main/resources/clamp/acm/acm-demo/toscaServiceTemplate.yaml1253
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java8
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java52
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java34
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java5
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java21
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java82
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java54
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java45
-rw-r--r--models/src/test/resources/providers/TestAcElementStatistics.json24
-rw-r--r--models/src/test/resources/providers/TestParticipant.json3
-rw-r--r--models/src/test/resources/providers/TestParticipantStatistics.json32
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java29
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java154
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java116
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java43
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java8
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java8
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java8
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java154
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java107
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java28
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java9
25 files changed, 1626 insertions, 663 deletions
diff --git a/examples/src/main/resources/clamp/acm/acm-demo/toscaServiceTemplate.yaml b/examples/src/main/resources/clamp/acm/acm-demo/toscaServiceTemplate.yaml
new file mode 100644
index 000000000..6a1ccfe85
--- /dev/null
+++ b/examples/src/main/resources/clamp/acm/acm-demo/toscaServiceTemplate.yaml
@@ -0,0 +1,1253 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2023 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
+ 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
+ org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest:
+ version: 1.0.0
+ derived_from: tosca.datatypes.Root
+ properties:
+ restRequestId:
+ type: onap.datatypes.ToscaConceptIdentifier
+ required: true
+ description: The name and version of a REST request to be sent to a REST endpoint
+ httpMethod:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - POST
+ - PUT
+ - GET
+ - DELETE
+ description: The REST method to use
+ path:
+ type: string
+ required: true
+ description: The path of the REST request relative to the base URL
+ body:
+ type: string
+ required: false
+ description: The body of the REST request for PUT and POST requests
+ expectedResponse:
+ type: integer
+ required: true
+ constraints: []
+ description: THe expected HTTP status code for the REST request
+ org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.ConfigurationEntity:
+ version: 1.0.0
+ derived_from: tosca.datatypes.Root
+ properties:
+ configurationEntityId:
+ type: onap.datatypes.ToscaConceptIdentifier
+ required: true
+ description: The name and version of a Configuration Entity to be handled
+ by the HTTP Automation Composition Element
+ restSequence:
+ type: list
+ entry_schema:
+ type: org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest
+ type_version: 1.0.0
+ description: A sequence of REST commands to send to the REST endpoint
+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
+node_types:
+ org.onap.policy.clamp.acm.Participant:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ required: false
+ org.onap.policy.clamp.acm.AutomationCompositionElement:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ required: false
+ metadata:
+ common: true
+ description: Specifies the organization that provides the automation composition element
+ participant_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ required: true
+ metadata:
+ common: true
+ participantType:
+ type: onap.datatypes.ToscaConceptIdentifier
+ required: true
+ metadata:
+ common: true
+ description: The identity of the participant type that hosts this type of Automation Composition Element
+ startPhase:
+ type: integer
+ required: false
+ constraints:
+ - greater_or_equal: 0
+ metadata:
+ common: true
+ description: A value indicating the start phase in which this automation composition element will be started, the
+ first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped
+ in reverse start phase order. Automation Composition Elements with the same start phase are started and
+ stopped simultaneously
+ uninitializedToPassiveTimeout:
+ type: integer
+ required: false
+ constraints:
+ - greater_or_equal: 0
+ default: 60
+ metadata:
+ common: true
+ description: The maximum time in seconds to wait for a state chage from uninitialized to passive
+ passiveToRunningTimeout:
+ type: integer
+ required: false
+ constraints:
+ - greater_or_equal: 0
+ default: 60
+ metadata:
+ common: true
+ description: The maximum time in seconds to wait for a state chage from passive to running
+ runningToPassiveTimeout:
+ type: integer
+ required: false
+ constraints:
+ - greater_or_equal: 0
+ default: 60
+ metadata:
+ common: true
+ description: The maximum time in seconds to wait for a state chage from running to passive
+ passiveToUninitializedTimeout:
+ type: integer
+ required: false
+ constraints:
+ - greater_or_equal: 0
+ default: 60
+ metadata:
+ common: true
+ description: The maximum time in seconds to wait for a state chage from passive to uninitialized
+ org.onap.policy.clamp.acm.AutomationComposition:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ required: false
+ metadata:
+ common: true
+ description: Specifies the organization that provides the automation composition element
+ elements:
+ type: list
+ required: true
+ metadata:
+ common: true
+ entry_schema:
+ type: onap.datatypes.ToscaConceptIdentifier
+ description: Specifies a list of automation composition element definitions that make up this automation composition definition
+ org.onap.policy.clamp.acm.PolicyAutomationCompositionElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
+ properties:
+ policy_type_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ required: true
+ policy_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ required: false
+ org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
+ properties:
+ chart:
+ type: string
+ required: true
+ configs:
+ type: list
+ required: false
+ requirements:
+ type: string
+ required: false
+ templates:
+ type: list
+ required: false
+ entry_schema:
+ values:
+ type: string
+ required: true
+ org.onap.policy.clamp.acm.HttpAutomationCompositionElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
+ properties:
+ baseUrl:
+ type: string
+ required: true
+ description: The base URL to be prepended to each path, identifies the host for the REST endpoints.
+ httpHeaders:
+ type: map
+ required: false
+ entry_schema:
+ type: string
+ description: HTTP headers to send on REST requests
+ configurationEntities:
+ type: map
+ required: true
+ entry_schema:
+ type: org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.ConfigurationEntity
+ type_version: 1.0.0
+ description: The connfiguration entities the Automation Composition Element is managing and their associated REST requests
+topology_template:
+ inputs:
+ acm_element_policy:
+ type: onap.datatypes.ToscaConceptIdentifier
+ description: The ID of the operational policy to use
+ default:
+ name: onap.policies.native.apex.ac.element
+ version: 1.0.0
+ node_templates:
+ org.onap.policy.clamp.acm.PolicyParticipant:
+ version: 2.3.1
+ type: org.onap.policy.clamp.acm.Participant
+ type_version: 1.0.1
+ description: Participant for Policy microservices
+ properties:
+ provider: ONAP
+ onap.policy.clamp.ac.element.Policy_AutomationCompositionElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement
+ type_version: 1.0.0
+ description: Automation composition element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.PM_Policy
+ version: 1.0.0
+ participantType:
+ name: org.onap.policy.clamp.acm.PolicyParticipant
+ version: 2.3.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ startPhase: 0
+ policy_id:
+ get_input: acm_element_policy
+ org.onap.k8s.acm.K8SAutomationCompositionParticipant:
+ version: 2.3.4
+ type: org.onap.policy.clamp.acm.Participant
+ type_version: 1.0.1
+ description: Participant for K8S
+ properties:
+ provider: ONAP
+ onap.policy.clamp.ac.element.K8S_StarterAutomationCompositionElement:
+ # Chart from any chart repository configured on helm client.
+ version: 1.2.3
+ type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
+ type_version: 1.0.1
+ description: Automation composition element for the K8S microservice for AC Element Starter
+ properties:
+ provider: ONAP
+ participant_id:
+ name: K8sParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.policy.clamp.acm.KubernetesParticipant
+ version: 2.3.4
+ startPhase: 0
+ uninitializedToPassiveTimeout: 300
+ podStatusCheckInterval: 30
+ chart:
+ chartId:
+ name: acelement
+ version: 0.1.0
+ namespace: onap
+ releaseName: acm-starter
+ podName: acm-starter
+ repository:
+ repoName: local
+ address: 'http://cluster-ip:8080'
+ overrideParams:
+ acelement.elementId.name: onap.policy.clamp.ac.starter
+ service.nodeport: 30800
+ onap.policy.clamp.ac.element.K8S_BridgeAutomationCompositionElement:
+ # Chart from any chart repository configured on helm client.
+ version: 1.2.3
+ type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
+ type_version: 1.0.1
+ description: Automation composition element for the K8S microservice for AC Element Bridge
+ properties:
+ provider: ONAP
+ participant_id:
+ name: K8sParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.policy.clamp.acm.KubernetesParticipant
+ version: 2.3.4
+ startPhase: 0
+ uninitializedToPassiveTimeout: 300
+ podStatusCheckInterval: 30
+ chart:
+ chartId:
+ name: acelement
+ version: 0.1.0
+ namespace: onap
+ releaseName: acm-bridge
+ podName: acm-bridge
+ repository:
+ repoName: local
+ address: 'http://cluster-ip:8080'
+ overrideParams:
+ acelement.elementId.name: onap.policy.clamp.ac.bridge
+ service.nodeport: 30801
+ onap.policy.clamp.ac.element.K8S_SinkAutomationCompositionElement:
+ # Chart from any chart repository configured on helm client.
+ version: 1.2.3
+ type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
+ type_version: 1.0.1
+ description: Automation composition element for the K8S microservice for AC Element Sink
+ properties:
+ provider: ONAP
+ participant_id:
+ name: K8sParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.policy.clamp.acm.KubernetesParticipant
+ version: 2.3.4
+ startPhase: 0
+ uninitializedToPassiveTimeout: 300
+ podStatusCheckInterval: 30
+ chart:
+ chartId:
+ name: acelement
+ version: 0.1.0
+ namespace: onap
+ releaseName: acm-sink
+ podName: acm-sink
+ repository:
+ repoName: local
+ address: 'http://cluster-ip:8080'
+ overrideParams:
+ acelement.elementId.name: onap.policy.clamp.ac.sink
+ service.nodeport: 30802
+ org.onap.policy.clamp.acm.HttpParticipant:
+ version: 2.3.4
+ type: org.onap.policy.clamp.acm.Participant
+ type_version: 1.0.1
+ description: Participant for Http requests
+ properties:
+ provider: ONAP
+ onap.policy.clamp.ac.element.Http_StarterAutomationCompositionElement:
+ # Http config for AC Element Starter.
+ version: 1.2.3
+ type: org.onap.policy.clamp.acm.HttpAutomationCompositionElement
+ type_version: 1.0.1
+ description: Automation composition element for the http requests of AC Element Starter microservice
+ properties:
+ provider: ONAP
+ participant_id:
+ name: HttpParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.policy.clamp.acm.HttpParticipant
+ version: 2.3.4
+ uninitializedToPassiveTimeout: 300
+ startPhase: 1
+ baseUrl: http://cluster-ip:30800
+ httpHeaders:
+ Content-Type: application/json
+ Authorization: Basic YWNtVXNlcjp6YiFYenRHMzQ=
+ configurationEntities:
+ - configurationEntityId:
+ name: onap.policy.clamp.ac.starter
+ version: 1.0.0
+ restSequence:
+ - restRequestId:
+ name: request1
+ version: 1.0.1
+ httpMethod: POST
+ path: /onap/policy/clamp/acelement/v2/activate
+ body: '{ "receiverId": { "name": "onap.policy.clamp.ac.startertobridge", "version": "1.0.0" }, "timerMs": 20000, "elementType": "STARTER", "topicParameterGroup": { "server": "acm-starter-ac-element-impl-dmaap", "listenerTopic": "POLICY_UPDATE_MSG", "publisherTopic": "AC_ELEMENT_MSG", "fetchTimeout": 15000, "topicCommInfrastructure": "dmaap" } }'
+ expectedResponse: 201
+ onap.policy.clamp.ac.element.Http_BridgeAutomationCompositionElement:
+ # Http config for AC Element Bridge.
+ version: 1.2.3
+ type: org.onap.policy.clamp.acm.HttpAutomationCompositionElement
+ type_version: 1.0.1
+ description: Automation composition element for the http requests of AC Element Bridge microservice
+ properties:
+ provider: ONAP
+ participant_id:
+ name: HttpParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.policy.clamp.acm.HttpParticipant
+ version: 2.3.4
+ uninitializedToPassiveTimeout: 300
+ startPhase: 1
+ baseUrl: http://cluster-ip:30801
+ httpHeaders:
+ Content-Type: application/json
+ Authorization: Basic YWNtVXNlcjp6YiFYenRHMzQ=
+ configurationEntities:
+ - configurationEntityId:
+ name: onap.policy.clamp.ac.bridge
+ version: 1.0.0
+ restSequence:
+ - restRequestId:
+ name: request2
+ version: 1.0.1
+ httpMethod: POST
+ path: /onap/policy/clamp/acelement/v2/activate
+ body: '{ "receiverId": { "name": "onap.policy.clamp.ac.bridgetosink", "version": "1.0.0" }, "timerMs": 20000, "elementType": "BRIDGE", "topicParameterGroup": { "server": "acm-starter-ac-element-impl-dmaap", "listenerTopic": "POLICY_UPDATE_MSG", "publisherTopic": "AC_ELEMENT_MSG", "fetchTimeout": 15000, "topicCommInfrastructure": "dmaap" } }'
+ expectedResponse: 201
+ onap.policy.clamp.ac.element.Http_SinkAutomationCompositionElement:
+ # Http config for AC Element Sink.
+ version: 1.2.3
+ type: org.onap.policy.clamp.acm.HttpAutomationCompositionElement
+ type_version: 1.0.1
+ description: Automation composition element for the http requests of AC Element Sink microservice
+ properties:
+ provider: ONAP
+ participant_id:
+ name: HttpParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.policy.clamp.acm.HttpParticipant
+ version: 2.3.4
+ uninitializedToPassiveTimeout: 300
+ startPhase: 1
+ baseUrl: http://cluster-ip:30802
+ httpHeaders:
+ Content-Type: application/json
+ Authorization: Basic YWNtVXNlcjp6YiFYenRHMzQ=
+ configurationEntities:
+ - configurationEntityId:
+ name: onap.policy.clamp.ac.sink
+ version: 1.0.0
+ restSequence:
+ - restRequestId:
+ name: request3
+ version: 1.0.1
+ httpMethod: POST
+ path: /onap/policy/clamp/acelement/v2/activate
+ body: '{ "receiverId": { "name": "onap.policy.clamp.ac.sink", "version": "1.0.0" }, "timerMs": 20000, "elementType": "SINK", "topicParameterGroup": { "server": "acm-starter-ac-element-impl-dmaap", "listenerTopic": "POLICY_UPDATE_MSG", "publisherTopic": "AC_ELEMENT_MSG", "fetchTimeout": 15000, "topicCommInfrastructure": "dmaap" } }'
+ expectedResponse: 201
+ onap.policy.clamp.ac.element.AutomationCompositionDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.acm.AutomationComposition
+ type_version: 1.0.1
+ description: Automation composition for Demo
+ properties:
+ provider: ONAP
+ elements:
+ - name: onap.policy.clamp.ac.element.Policy_AutomationCompositionElement
+ version: 1.2.3
+ - name: onap.policy.clamp.ac.element.K8S_StarterAutomationCompositionElement
+ version: 1.2.3
+ - name: onap.policy.clamp.ac.element.K8S_BridgeAutomationCompositionElement
+ version: 1.2.3
+ - name: onap.policy.clamp.ac.element.K8S_SinkAutomationCompositionElement
+ version: 1.2.3
+ - name: onap.policy.clamp.ac.element.Http_StarterAutomationCompositionElement
+ version: 1.2.3
+ - name: onap.policy.clamp.ac.element.Http_BridgeAutomationCompositionElement
+ version: 1.2.3
+ - name: onap.policy.clamp.ac.element.Http_SinkAutomationCompositionElement
+ version: 1.2.3
+ policies:
+ - onap.policies.native.apex.ac.element:
+ type: onap.policies.native.Apex
+ type_version: 1.0.0
+ properties:
+ engineServiceParameters:
+ name: MyApexEngine
+ version: 0.0.1
+ id: 45
+ instanceCount: 2
+ deploymentPort: 12561
+ engineParameters:
+ executorParameters:
+ JAVASCRIPT:
+ parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters
+ contextParameters:
+ parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters
+ schemaParameters:
+ Json:
+ parameterClassName: org.onap.policy.apex.plugins.context.schema.json.JsonSchemaHelperParameters
+ policy_type_impl:
+ policies:
+ key:
+ name: APEXacElementPolicy_Policies
+ version: 0.0.1
+ policyMap:
+ entry:
+ - key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ value:
+ policyKey:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ template: Freestyle
+ state:
+ entry:
+ - key: DecideForwardingState
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DecideForwardingState
+ trigger:
+ name: AcElementEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: CreateForwardPayload
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DecideForwardingState
+ localName: CreateForwardPayload
+ outgoingEvent:
+ name: DmaapResponseStatusEvent
+ version: 0.0.1
+ outgoingEventReference:
+ - name: DmaapResponseStatusEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference: []
+ taskSelectionLogic:
+ key:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DecideForwardingState
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DecideForwardingState
+ localName: CreateForwardPayload
+ firstState: DecideForwardingState
+ tasks:
+ key:
+ name: APEXacElementPolicy_Tasks
+ version: 0.0.1
+ taskMap:
+ entry:
+ - key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ inputEvent:
+ key:
+ name: AcElementEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: Dmaap
+ target: APEX
+ parameter:
+ entry:
+ - key: DmaapResponseEvent
+ value:
+ key:
+ parentKeyName: AcElementEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DmaapResponseEvent
+ fieldSchemaKey:
+ name: ACEventType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ENTRY
+ outputEvents:
+ entry:
+ - key: DmaapResponseStatusEvent
+ value:
+ key:
+ name: DmaapResponseStatusEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: APEX
+ target: Dmaap
+ parameter:
+ entry:
+ - key: DmaapResponseStatusEvent
+ value:
+ key:
+ parentKeyName: DmaapResponseStatusEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DmaapResponseStatusEvent
+ fieldSchemaKey:
+ name: ACEventType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ''
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: ACElementAlbum
+ version: 0.0.1
+ taskLogic:
+ key:
+ parentKeyName: ForwardPayloadTask
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: "/*\n * ============LICENSE_START=======================================================\n\
+ \ * Copyright (C) 2022 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);\nexecutor.logger.info(executor.inFields);\n\
+ \nvar msgResponse = executor.inFields.get('DmaapResponseEvent');\n\
+ executor.logger.info('Task in progress with mesages: ' + msgResponse);\n\
+ \nvar elementId = msgResponse.get('elementId').get('name');\n\
+ \nif (msgResponse.get('messageType') == 'STATUS' &&\n (elementId\
+ \ == 'onap.policy.clamp.ac.startertobridge'\n || elementId\
+ \ == 'onap.policy.clamp.ac.bridgetosink')) {\n\n var receiverId\
+ \ = '';\n if (elementId == 'onap.policy.clamp.ac.startertobridge')\
+ \ {\n receiverId = 'onap.policy.clamp.ac.bridge';\n\
+ \ } else {\n receiverId = 'onap.policy.clamp.ac.sink';\n\
+ \ }\n\n var elementIdResponse = new java.util.HashMap();\n\
+ \ elementIdResponse.put('name', receiverId);\n elementIdResponse.put('version',\
+ \ msgResponse.get('elementId').get('version'));\n\n var\
+ \ dmaapResponse = new java.util.HashMap();\n dmaapResponse.put('elementId',\
+ \ elementIdResponse);\n\n var message = msgResponse.get('message')\
+ \ + ' trace added from policy';\n dmaapResponse.put('message',\
+ \ message);\n dmaapResponse.put('messageType', 'STATUS');\n\
+ \ dmaapResponse.put('messageId', msgResponse.get('messageId'));\n\
+ \ dmaapResponse.put('timestamp', msgResponse.get('timestamp'));\n\
+ \n executor.logger.info('Sending forwarding Event to Ac\
+ \ element: ' + dmaapResponse);\n\n executor.outFields.put('DmaapResponseStatusEvent',\
+ \ dmaapResponse);\n}\n\ntrue;"
+ events:
+ key:
+ name: APEXacElementPolicy_Events
+ version: 0.0.1
+ eventMap:
+ entry:
+ - key:
+ name: AcElementEvent
+ version: 0.0.1
+ value:
+ key:
+ name: AcElementEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: Dmaap
+ target: APEX
+ parameter:
+ entry:
+ - key: DmaapResponseEvent
+ value:
+ key:
+ parentKeyName: AcElementEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DmaapResponseEvent
+ fieldSchemaKey:
+ name: ACEventType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ENTRY
+ - key:
+ name: DmaapResponseStatusEvent
+ version: 0.0.1
+ value:
+ key:
+ name: DmaapResponseStatusEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: APEX
+ target: Dmaap
+ parameter:
+ entry:
+ - key: DmaapResponseStatusEvent
+ value:
+ key:
+ parentKeyName: DmaapResponseStatusEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DmaapResponseStatusEvent
+ fieldSchemaKey:
+ name: ACEventType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ''
+ - key:
+ name: LogEvent
+ version: 0.0.1
+ value:
+ key:
+ name: LogEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: APEX
+ target: file
+ parameter:
+ entry:
+ - key: final_status
+ value:
+ key:
+ parentKeyName: LogEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: final_status
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: message
+ value:
+ key:
+ parentKeyName: LogEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: message
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ''
+ albums:
+ key:
+ name: APEXacElementPolicy_Albums
+ version: 0.0.1
+ albums:
+ entry:
+ - key:
+ name: ACElementAlbum
+ version: 0.0.1
+ value:
+ key:
+ name: ACElementAlbum
+ version: 0.0.1
+ scope: policy
+ isWritable: true
+ itemSchema:
+ name: ACEventType
+ version: 0.0.1
+ schemas:
+ key:
+ name: APEXacElementPolicy_Schemas
+ version: 0.0.1
+ schemas:
+ entry:
+ - key:
+ name: ACEventType
+ version: 0.0.1
+ value:
+ key:
+ name: ACEventType
+ version: 0.0.1
+ schemaFlavour: Json
+ schemaDefinition: "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\"\
+ ,\n \"type\": \"object\",\n \"properties\": {\n \
+ \ \"elementId\": {\n \"type\": \"object\",\n \
+ \ \"properties\": {\n \"name\": {\n \
+ \ \"type\": \"string\"\n },\n\
+ \ \"version\": {\n \"type\"\
+ : \"string\"\n }\n },\n \
+ \ \"required\": [\n \"name\",\n \
+ \ \"version\"\n ]\n },\n \"message\"\
+ : {\n \"type\": \"string\"\n },\n \"\
+ messageType\": {\n \"type\": \"string\"\n \
+ \ }\n },\n \"required\": [\n \"elementId\",\n \
+ \ \"message\",\n \"messageType\"\n ]\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: UUIDType
+ version: 0.0.1
+ value:
+ key:
+ name: UUIDType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.util.UUID
+ key:
+ name: APEXacElementPolicy
+ version: 0.0.1
+ keyInformation:
+ key:
+ name: APEXacElementPolicy_KeyInfo
+ version: 0.0.1
+ keyInfoMap:
+ entry:
+ - key:
+ name: ACElementAlbum
+ version: 0.0.1
+ value:
+ key:
+ name: ACElementAlbum
+ version: 0.0.1
+ UUID: 7cddfab8-6d3f-3f7f-8ac3-e2eb5979c900
+ description: Generated description for concept referred to by
+ key "ACElementAlbum:0.0.1"
+ - key:
+ name: ACEventType
+ version: 0.0.1
+ value:
+ key:
+ name: ACEventType
+ version: 0.0.1
+ UUID: dab78794-b666-3929-a75b-70d634b04fe5
+ description: Generated description for concept referred to by
+ key "ACEventType:0.0.1"
+ - key:
+ name: APEXacElementPolicy
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy
+ version: 0.0.1
+ UUID: da478611-7d77-3c46-b4be-be968769ba4e
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Albums
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Albums
+ version: 0.0.1
+ UUID: fa8dc15e-8c8d-3de3-a0f8-585b76511175
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Albums:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Events
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Events
+ version: 0.0.1
+ UUID: 8508cd65-8dd2-342d-a5c6-1570810dbe2b
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Events:0.0.1"
+ - key:
+ name: APEXacElementPolicy_KeyInfo
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_KeyInfo
+ version: 0.0.1
+ UUID: 09e6927d-c5ac-3779-919f-9333994eed22
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_KeyInfo:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Policies
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Policies
+ version: 0.0.1
+ UUID: cade3c9a-1600-3642-a6f4-315612187f46
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Policies:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Schemas
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Schemas
+ version: 0.0.1
+ UUID: 5bb4a8e9-35fa-37db-9a49-48ef036a7ba9
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Schemas:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Tasks
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Tasks
+ version: 0.0.1
+ UUID: 2527eeec-0d1f-3094-ad3f-212622b12836
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Tasks:0.0.1"
+ - key:
+ name: AcElementEvent
+ version: 0.0.1
+ value:
+ key:
+ name: AcElementEvent
+ version: 0.0.1
+ UUID: 32c013e2-2740-3986-a626-cbdf665b63e9
+ description: Generated description for concept referred to by
+ key "AcElementEvent:0.0.1"
+ - key:
+ name: DmaapResponseStatusEvent
+ version: 0.0.1
+ value:
+ key:
+ name: DmaapResponseStatusEvent
+ version: 0.0.1
+ UUID: 2715cb6c-2778-3461-8b69-871e79f95935
+ description: Generated description for concept referred to by
+ key "DmaapResponseStatusEvent:0.0.1"
+ - key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ UUID: 51defa03-1ecf-3314-bf34-2a652bce57fa
+ description: Generated description for concept referred to by
+ key "ForwardPayloadTask:0.0.1"
+ - key:
+ name: LogEvent
+ version: 0.0.1
+ value:
+ key:
+ name: LogEvent
+ version: 0.0.1
+ UUID: c540f048-96af-35e3-a36e-e9c29377cba7
+ description: Generated description for concept referred to by
+ key "LogEvent: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: 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: 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"
+ eventInputParameters:
+ DmaapConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTCLIENT
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters
+ parameters:
+ url: http://message-router:3904/events/AC_ELEMENT_MSG/APEX/1?timeout=30000
+ eventProtocolParameters:
+ eventProtocol: JSON
+ parameters:
+ pojoField: DmaapResponseEvent
+ eventName: AcElementEvent
+ eventNameFilter: AcElementEvent
+ eventOutputParameters:
+ logOutputter:
+ carrierTechnologyParameters:
+ carrierTechnology: FILE
+ parameters:
+ fileName: outputevents.log
+ eventProtocolParameters:
+ eventProtocol: JSON
+ DmaapReplyProducer:
+ carrierTechnologyParameters:
+ carrierTechnology: RESTCLIENT
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters
+ parameters:
+ url: http://message-router:3904/events/POLICY_UPDATE_MSG
+ eventProtocolParameters:
+ eventProtocol: JSON
+ parameters:
+ pojoField: DmaapResponseStatusEvent
+ eventNameFilter: (LogEvent|DmaapResponseStatusEvent)
+ name: onap.policies.native.apex.ac.element
+ version: 1.0.0
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
index 1a8fbc409..6a523fa75 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,10 +39,7 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
@NonNull
- private ParticipantState participantState = ParticipantState.UNKNOWN;
-
- @NonNull
- private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN;
+ private ParticipantState participantState = ParticipantState.ON_LINE;
@NonNull
private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier();
@@ -71,7 +68,6 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
super(otherParticipant);
this.definition = new ToscaConceptIdentifier(otherParticipant.definition);
this.participantState = otherParticipant.participantState;
- this.healthStatus = otherParticipant.healthStatus;
this.participantType = otherParticipant.participantType;
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java
deleted file mode 100644
index f8cc0a852..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.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,
-
- /**
- * The health status of the Participant is off line.
- */
- OFF_LINE
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java
index 4ab42c697..30dc69a06 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,36 +25,12 @@ package org.onap.policy.clamp.models.acm.concepts;
*/
public enum ParticipantState {
/**
- * Participant state is unknown.
+ * Participant state is online.
*/
- UNKNOWN,
+ ON_LINE,
/**
- * Participant is passive, automation composition element execution is always rejected.
+ * Participant is offline, automation composition element execution is always rejected.
*/
- PASSIVE,
-
- /**
- * Automation composition element 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,
-
- /**
- * Automation composition element 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,
-
- /**
- * Automation composition element execution is executed in the live environment by the participant.
- */
- ACTIVE,
-
- /**
- * Automation composition element execution has been terminated.
- */
- TERMINATED
+ OFF_LINE
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
index 1d57c24e8..31a42c548 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@ import lombok.Setter;
import lombok.ToString;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.models.base.PfUtils;
@@ -41,7 +40,6 @@ public class ParticipantStatus extends ParticipantMessage {
// State and health status of the participant
private ParticipantState state;
- private ParticipantHealthStatus healthStatus;
// A list of ParticipantDefinition updates, returned in response to ParticipantStatusReq only
private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
@@ -66,7 +64,6 @@ public class ParticipantStatus extends ParticipantMessage {
super(source);
this.state = source.state;
- this.healthStatus = source.healthStatus;
this.participantDefinitionUpdates =
PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new);
this.automationCompositionInfoList =
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
index 143499c0d..aec2d32d3 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,6 @@ import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.models.base.PfAuthorative;
@@ -80,10 +79,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
private ParticipantState participantState;
@Column
- @NotNull
- private ParticipantHealthStatus healthStatus;
-
- @Column
private String description;
/**
@@ -99,7 +94,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
* @param key the key
*/
public JpaParticipant(@NonNull final PfConceptKey key) {
- this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.UNKNOWN);
+ this(key, new PfConceptKey(), ParticipantState.ON_LINE);
}
/**
@@ -108,14 +103,12 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
* @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) {
+ @NonNull final ParticipantState participantState) {
this.key = key;
this.definition = definition;
this.participantState = participantState;
- this.healthStatus = healthStatus;
}
/**
@@ -128,7 +121,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
this.key = new PfConceptKey(copyConcept.key);
this.definition = new PfConceptKey(copyConcept.definition);
this.participantState = copyConcept.participantState;
- this.healthStatus = copyConcept.healthStatus;
this.description = copyConcept.description;
this.participantType = copyConcept.participantType;
}
@@ -150,7 +142,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
participant.setVersion(key.getVersion());
participant.setDefinition(new ToscaConceptIdentifier(definition));
participant.setParticipantState(participantState);
- participant.setHealthStatus(healthStatus);
participant.setDescription(description);
participant.setParticipantType(new ToscaConceptIdentifier(participantType));
@@ -165,7 +156,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
this.definition = participant.getDefinition().asConceptKey();
this.setParticipantState(participant.getParticipantState());
- this.setHealthStatus(participant.getHealthStatus());
this.setDescription(participant.getDescription());
this.participantType = participant.getParticipantType().asConceptKey();
}
@@ -216,11 +206,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
return result;
}
- result = ObjectUtils.compare(healthStatus, other.healthStatus);
- if (result != 0) {
- return result;
- }
-
result = ObjectUtils.compare(participantType, other.participantType);
if (result != 0) {
return result;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java
index 6e3b56d56..3f7e297a4 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,15 +23,13 @@ package org.onap.policy.clamp.models.acm.persistence.provider;
import java.util.List;
import java.util.Optional;
import javax.ws.rs.core.Response.Status;
-import lombok.AllArgsConstructor;
import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant;
import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantRepository;
-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.tosca.authorative.concepts.ToscaTypedEntityFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -40,10 +38,10 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Service
@Transactional
-@AllArgsConstructor
+@RequiredArgsConstructor
public class ParticipantProvider {
- private ParticipantRepository participantRepository;
+ private final ParticipantRepository participantRepository;
/**
* Get participants.
@@ -71,32 +69,12 @@ public class ParticipantProvider {
/**
* Get participant.
*
- * @param name the name of the participant to get
- * @param version the version of the participant to get
+ * @param participantId the Id of the participant to get
* @return the participant found
- * @throws PfModelException on errors getting participant
*/
@Transactional(readOnly = true)
- public Optional<Participant> findParticipant(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
- try {
- return participantRepository.findById(new PfConceptKey(name, version)).map(JpaParticipant::toAuthorative);
- } catch (IllegalArgumentException e) {
- throw new PfModelException(Status.BAD_REQUEST, "Error in find Participant", e);
- }
- }
-
- /**
- * Get filtered participants.
- *
- * @param filter the filter for the participants to get
- * @return the participants found
- */
- @Transactional(readOnly = true)
- public List<Participant> getFilteredParticipants(@NonNull final ToscaTypedEntityFilter<Participant> filter) {
-
- return filter.filter(ProviderUtils.asEntityList(
- participantRepository.getFiltered(JpaParticipant.class, filter.getName(), filter.getVersion())));
+ public Optional<Participant> findParticipant(@NonNull final ToscaConceptIdentifier participantId) {
+ return participantRepository.findById(participantId.asConceptKey()).map(JpaParticipant::toAuthorative);
}
/**
@@ -104,45 +82,31 @@ public class ParticipantProvider {
*
* @param participant participant to save
* @return the participant created
- * @throws PfModelException on errors creating participants
*/
- public Participant saveParticipant(@NonNull final Participant participant) throws PfModelException {
- try {
- var result = participantRepository
- .save(ProviderUtils.getJpaAndValidate(participant, JpaParticipant::new, "participant"));
+ public Participant saveParticipant(@NonNull final Participant participant) {
+ var result = participantRepository
+ .save(ProviderUtils.getJpaAndValidate(participant, JpaParticipant::new, "participant"));
- // Return the saved participant
- return result.toAuthorative();
- } catch (IllegalArgumentException e) {
- throw new PfModelException(Status.BAD_REQUEST, "Error in save Participant", e);
- }
+ // Return the saved participant
+ return result.toAuthorative();
}
/**
* Delete a participant.
*
- * @param name the name of the participant to delete
- * @param version the version of the participant to get
+ * @param participantId the Id of the participant to delete
* @return the participant deleted
- * @throws PfModelRuntimeException on errors deleting participants
*/
- public Participant deleteParticipant(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
- try {
- var participantKey = new PfConceptKey(name, version);
+ public Participant deleteParticipant(@NonNull final ToscaConceptIdentifier participantId) {
+ var jpaDeleteParticipantOpt = participantRepository.findById(participantId.asConceptKey());
- var jpaDeleteParticipantOpt = participantRepository.findById(participantKey);
-
- if (jpaDeleteParticipantOpt.isEmpty()) {
- String errorMessage =
- "delete of participant \"" + participantKey.getId() + "\" failed, participant does not exist";
- throw new PfModelRuntimeException(Status.BAD_REQUEST, errorMessage);
- }
- participantRepository.delete(jpaDeleteParticipantOpt.get());
-
- return jpaDeleteParticipantOpt.get().toAuthorative();
- } catch (IllegalArgumentException e) {
- throw new PfModelException(Status.BAD_REQUEST, "Error in delete Participant", e);
+ if (jpaDeleteParticipantOpt.isEmpty()) {
+ String errorMessage =
+ "delete of participant \"" + participantId + "\" failed, participant does not exist";
+ throw new PfModelRuntimeException(Status.BAD_REQUEST, errorMessage);
}
+ participantRepository.delete(jpaDeleteParticipantOpt.get());
+
+ return jpaDeleteParticipantOpt.get().toAuthorative();
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java
index f50bf36bc..f6eb3e0ff 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,9 +59,8 @@ class ParticipantTest {
p1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
p1.setDescription("Description");
- p1.setHealthStatus(ParticipantHealthStatus.HEALTHY);
p1.setName("Name");
- p1.setParticipantState(ParticipantState.ACTIVE);
+ p1.setParticipantState(ParticipantState.ON_LINE);
p1.setVersion("0.0.1");
assertThat(p1.toString()).contains("Participant(");
@@ -75,7 +74,6 @@ class ParticipantTest {
// @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
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
index 7bf439e3f..51331b4bb 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDef
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -59,8 +58,7 @@ class ParticipantStatusTest {
ToscaConceptIdentifier type = new ToscaConceptIdentifier("type", "2.3.4");
orig.setParticipantType(type);
orig.setMessageId(UUID.randomUUID());
- orig.setState(ParticipantState.ACTIVE);
- orig.setHealthStatus(ParticipantHealthStatus.HEALTHY);
+ orig.setState(ParticipantState.ON_LINE);
orig.setTimestamp(Instant.ofEpochMilli(3000));
var acInfo = getAutomationCompositionInfo(automationCompositionId);
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
index 3ff614918..9d1d7ff99 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -48,58 +47,52 @@ class JpaParticipantTest {
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)).hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, null, null, ParticipantHealthStatus.HEALTHY))
+ assertThatThrownBy(() -> new JpaParticipant(null, null, null))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, null, ParticipantState.ACTIVE, null))
+ assertThatThrownBy(() -> new JpaParticipant(null, null, ParticipantState.ON_LINE))
.hasMessageMatching(NULL_KEY_ERROR);
assertThatThrownBy(
- () -> new JpaParticipant(null, null, ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY))
+ () -> new JpaParticipant(null, null, ParticipantState.ON_LINE))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, null))
+ assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY))
+ assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE, null))
+ assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), ParticipantState.ON_LINE))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE,
- ParticipantHealthStatus.HEALTHY))
+ assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), ParticipantState.ON_LINE))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, null, null))
+ assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, null))
.hasMessageMatching("definition is marked .*ull but is null");
- assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, null, ParticipantHealthStatus.HEALTHY))
+ assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, null))
.hasMessageMatching("definition is marked .*ull but is null");
- assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, ParticipantState.ACTIVE, null))
+ assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, ParticipantState.ON_LINE))
.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(), null, ParticipantState.ON_LINE
+ )).hasMessageMatching("definition is marked .*ull but is null");
- assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, null))
+ assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null))
.hasMessageMatching("participantState is marked .*ull but is null");
assertThatThrownBy(
- () -> new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY))
+ () -> new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null))
.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));
+ assertNotNull(new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ON_LINE));
}
@Test
@@ -171,16 +164,10 @@ class JpaParticipantTest {
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);
+ testJpaParticipant.setParticipantState(ParticipantState.OFF_LINE);
assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
- testJpaParticipant.setHealthStatus(ParticipantHealthStatus.UNKNOWN);
+ testJpaParticipant.setParticipantState(ParticipantState.ON_LINE);
assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
-
assertEquals(testJpaParticipant, new JpaParticipant(testJpaParticipant));
}
@@ -199,9 +186,8 @@ class JpaParticipantTest {
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);
+ p1.setParticipantState(ParticipantState.ON_LINE);
assertThat(p1.toString()).contains("Participant(");
assertNotEquals(0, p1.hashCode());
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
index c7355f002..e11541988 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,13 +40,14 @@ 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.base.PfConceptKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
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 final ToscaConceptIdentifier INVALID_ID = new ToscaConceptIdentifier("invalid_name", "1.0.1");
private final List<Participant> inputParticipants = new ArrayList<>();
private List<JpaParticipant> jpaParticipantList;
@@ -67,18 +68,12 @@ class ParticipantProviderTest {
}
var participantProvider = new ParticipantProvider(participantRepository);
- assertThatThrownBy(() -> participantProvider.saveParticipant(null))
- .hasMessageMatching(LIST_IS_NULL);
+ assertThatThrownBy(() -> participantProvider.saveParticipant(null)).hasMessageMatching(LIST_IS_NULL);
when(participantRepository.save(any())).thenReturn(jpaParticipantList.get(0));
Participant savedParticipant = participantProvider.saveParticipant(inputParticipants.get(0));
assertEquals(savedParticipant, inputParticipants.get(0));
-
- when(participantRepository.save(any())).thenThrow(IllegalArgumentException.class);
-
- assertThatThrownBy(() -> participantProvider.saveParticipant(inputParticipants.get(0)))
- .hasMessageMatching("Error in save Participant");
}
@Test
@@ -98,26 +93,10 @@ class ParticipantProviderTest {
assertThat(participantProvider.getParticipants("invalid_name", "1.0.1")).isEmpty();
- assertThat(participantProvider.findParticipant("invalid_name", "1.0.1")).isEmpty();
+ assertThat(participantProvider.findParticipant(INVALID_ID)).isEmpty();
when(participantRepository.findAll()).thenReturn(jpaParticipantList);
assertThat(participantProvider.getParticipants()).hasSize(inputParticipants.size());
-
- when(participantRepository.findById(any())).thenThrow(IllegalArgumentException.class);
-
- assertThatThrownBy(() -> participantProvider.findParticipant("notValid", "notValid"))
- .hasMessageMatching("Error in find Participant");
-
- assertThatThrownBy(() -> participantProvider.getFilteredParticipants(null))
- .hasMessageMatching("filter is marked .*ull but is null");
-
- when(participantRepository.getFiltered((JpaParticipant.class), (null), (null)))
- .thenReturn(jpaParticipantList);
-
- final ToscaTypedEntityFilter<Participant> filter = ToscaTypedEntityFilter.<Participant>builder()
- .type("org.onap.domain.pmsh.PMSHAutomationCompositionDefinition").build();
- assertEquals(1, participantProvider.getFilteredParticipants(filter).size());
-
}
@Test
@@ -125,19 +104,13 @@ class ParticipantProviderTest {
var participantRepository = mock(ParticipantRepository.class);
var participantProvider = new ParticipantProvider(participantRepository);
- assertThatThrownBy(() -> participantProvider.deleteParticipant("Invalid_name", "1.0.1"))
- .hasMessageMatching(".*.failed, participant does not exist");
-
- String name = inputParticipants.get(0).getName();
- String version = inputParticipants.get(0).getVersion();
+ assertThatThrownBy(() -> participantProvider.deleteParticipant(INVALID_ID))
+ .hasMessageMatching(".*.failed, participant does not exist");
when(participantRepository.findById(any())).thenReturn(Optional.of(jpaParticipantList.get(0)));
- Participant deletedParticipant = participantProvider.deleteParticipant(name, version);
+ Participant deletedParticipant =
+ participantProvider.deleteParticipant(inputParticipants.get(0).getDefinition());
assertEquals(inputParticipants.get(0), deletedParticipant);
-
- when(participantRepository.findById(any())).thenThrow(IllegalArgumentException.class);
- assertThatThrownBy(() -> participantProvider.deleteParticipant(name, version))
- .hasMessageMatching("Error in delete Participant");
}
}
diff --git a/models/src/test/resources/providers/TestAcElementStatistics.json b/models/src/test/resources/providers/TestAcElementStatistics.json
deleted file mode 100644
index cceb91d14..000000000
--- a/models/src/test/resources/providers/TestAcElementStatistics.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "acElementStatistics":[
- {
- "participantId":{
- "name":"name1",
- "version":"1.001"
- },
- "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
- "timeStamp": "2021-01-10T13:45:00.000Z",
- "state": "UNINITIALISED",
- "acElementUptime":250
- },
- {
- "participantId":{
- "name":"name2",
- "version":"1.001"
- },
- "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
- "timeStamp": "2021-01-10T14:25:00.000Z",
- "state": "UNINITIALISED",
- "acElementUptime":330
- }
- ]
-}
diff --git a/models/src/test/resources/providers/TestParticipant.json b/models/src/test/resources/providers/TestParticipant.json
index 7e4f9540f..5d8a7ea09 100644
--- a/models/src/test/resources/providers/TestParticipant.json
+++ b/models/src/test/resources/providers/TestParticipant.json
@@ -5,8 +5,7 @@
"name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition",
"version": "1.0.0"
},
- "participantState": "PASSIVE",
- "healthStatus": "HEALTHY",
+ "participantState": "ON_LINE",
"description": "A dummy PMSH participant1",
"participantType":{
"name": "org.onap.domain.pmsh.PolicyAutomationCompositionDefinition",
diff --git a/models/src/test/resources/providers/TestParticipantStatistics.json b/models/src/test/resources/providers/TestParticipantStatistics.json
deleted file mode 100644
index 5cf626816..000000000
--- a/models/src/test/resources/providers/TestParticipantStatistics.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "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/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
index b442b9967..6edf1ffd4 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -29,13 +29,11 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import lombok.Getter;
-import lombok.Setter;
import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher;
import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
@@ -70,12 +68,6 @@ public class ParticipantHandler {
private final AutomationCompositionHandler automationCompositionHandler;
private final ParticipantMessagePublisher publisher;
- @Setter
- private ParticipantState state = ParticipantState.UNKNOWN;
-
- @Setter
- private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN;
-
private final Map<UUID, List<AutomationCompositionElementDefinition>> acElementDefsMap = new HashMap<>();
/**
@@ -169,21 +161,9 @@ public class ParticipantHandler {
public void handleParticipantRegisterAck(ParticipantRegisterAck participantRegisterAckMsg) {
LOGGER.debug("ParticipantRegisterAck message received as responseTo {}",
participantRegisterAckMsg.getResponseTo());
- statusToPassive();
publisher.sendParticipantStatus(makeHeartbeat(false));
}
- private void statusToPassive() {
- if (ParticipantHealthStatus.UNKNOWN.equals(this.healthStatus)) {
- this.healthStatus = ParticipantHealthStatus.HEALTHY;
- }
-
- if (ParticipantState.UNKNOWN.equals(this.state) || ParticipantState.TERMINATED.equals(this.state)) {
- this.state = ParticipantState.PASSIVE;
- }
-
- }
-
/**
* Method to send ParticipantDeregister message to automation composition runtime.
*/
@@ -218,7 +198,6 @@ public class ParticipantHandler {
acElementDefsMap.putIfAbsent(participantUpdateMsg.getCompositionId(), new ArrayList<>());
if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) {
- statusToPassive();
// This message is to commission the automation composition
for (var participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) {
if (participantDefinition.getParticipantType().equals(participantType)) {
@@ -230,7 +209,6 @@ public class ParticipantHandler {
} else {
// This message is to decommission the automation composition
acElementDefsMap.get(participantUpdateMsg.getCompositionId()).clear();
- this.state = ParticipantState.TERMINATED;
}
sendParticipantUpdateAck(participantUpdateMsg.getMessageId());
}
@@ -245,7 +223,7 @@ public class ParticipantHandler {
participantUpdateAck.setResult(true);
participantUpdateAck.setParticipantId(participantId);
participantUpdateAck.setParticipantType(participantType);
- participantUpdateAck.setState(state);
+ participantUpdateAck.setState(ParticipantState.ON_LINE);
publisher.sendParticipantUpdateAck(participantUpdateAck);
}
@@ -263,8 +241,7 @@ public class ParticipantHandler {
var heartbeat = new ParticipantStatus();
heartbeat.setParticipantId(participantId);
heartbeat.setParticipantType(participantType);
- heartbeat.setHealthStatus(healthStatus);
- heartbeat.setState(state);
+ heartbeat.setState(ParticipantState.ON_LINE);
heartbeat.setAutomationCompositionInfoList(getAutomationCompositionInfoList());
if (responseToParticipantStatusReq) {
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
index 9a80508e5..c27447405 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021,2022 Nordix Foundation.
+ * Copyright (C) 2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,28 +29,17 @@ import javax.ws.rs.core.Response;
import lombok.AllArgsConstructor;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher;
-import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
-import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
-import org.onap.policy.models.base.PfModelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -75,110 +64,14 @@ public class SupervisionHandler {
private static final String AND_TRANSITIONING_TO_STATE = " and transitioning to state ";
private final AutomationCompositionProvider automationCompositionProvider;
- private final ParticipantProvider participantProvider;
private final AcDefinitionProvider acDefinitionProvider;
// Publishers for participant communication
private final AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher;
private final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher;
- private final ParticipantRegisterAckPublisher participantRegisterAckPublisher;
- private final ParticipantDeregisterAckPublisher participantDeregisterAckPublisher;
private final ParticipantUpdatePublisher participantUpdatePublisher;
/**
- * Handle a ParticipantStatus message from a participant.
- *
- * @param participantStatusMessage the ParticipantStatus message received from a participant
- */
- @MessageIntercept
- @Timed(value = "listener.participant_status", description = "PARTICIPANT_STATUS messages received")
- public void handleParticipantMessage(ParticipantStatus participantStatusMessage) {
- LOGGER.debug("Participant Status received {}", participantStatusMessage);
- try {
- superviseParticipant(participantStatusMessage);
- } catch (PfModelException | AutomationCompositionException svExc) {
- LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc);
- }
- }
-
- /**
- * Handle a ParticipantRegister message from a participant.
- *
- * @param participantRegisterMessage the ParticipantRegister message received from a participant
- */
- @MessageIntercept
- @Timed(value = "listener.participant_register", description = "PARTICIPANT_REGISTER messages received")
- public void handleParticipantMessage(ParticipantRegister participantRegisterMessage) {
- LOGGER.debug("Participant Register received {}", participantRegisterMessage);
- try {
- checkParticipant(participantRegisterMessage, ParticipantState.UNKNOWN, ParticipantHealthStatus.UNKNOWN);
- } catch (PfModelException | AutomationCompositionException svExc) {
- LOGGER.warn("error saving participant {}", participantRegisterMessage.getParticipantId(), svExc);
- }
-
- participantUpdatePublisher.sendCommissioning(participantRegisterMessage.getParticipantId(),
- participantRegisterMessage.getParticipantType());
-
- participantRegisterAckPublisher.send(participantRegisterMessage.getMessageId(),
- participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType());
- }
-
- /**
- * Handle a ParticipantDeregister message from a participant.
- *
- * @param participantDeregisterMessage the ParticipantDeregister message received from a participant
- */
- @MessageIntercept
- @Timed(value = "listener.participant_deregister", description = "PARTICIPANT_DEREGISTER messages received")
- public void handleParticipantMessage(ParticipantDeregister participantDeregisterMessage) {
- LOGGER.debug("Participant Deregister received {}", participantDeregisterMessage);
- try {
- var participantOpt =
- participantProvider.findParticipant(participantDeregisterMessage.getParticipantId().getName(),
- participantDeregisterMessage.getParticipantId().getVersion());
-
- if (participantOpt.isPresent()) {
- var participant = participantOpt.get();
- participant.setParticipantState(ParticipantState.TERMINATED);
- participant.setHealthStatus(ParticipantHealthStatus.OFF_LINE);
- participantProvider.saveParticipant(participant);
- }
- } catch (PfModelException pfme) {
- LOGGER.warn("Model exception occured with participant id {}",
- participantDeregisterMessage.getParticipantId());
- }
-
- participantDeregisterAckPublisher.send(participantDeregisterMessage.getMessageId());
- }
-
- /**
- * Handle a ParticipantUpdateAck message from a participant.
- *
- * @param participantUpdateAckMessage the ParticipantUpdateAck message received from a participant
- */
- @MessageIntercept
- @Timed(value = "listener.participant_update_ack", description = "PARTICIPANT_UPDATE_ACK messages received")
- public void handleParticipantMessage(ParticipantUpdateAck participantUpdateAckMessage) {
- LOGGER.debug("Participant Update Ack received {}", participantUpdateAckMessage);
- try {
- var participantOpt =
- participantProvider.findParticipant(participantUpdateAckMessage.getParticipantId().getName(),
- participantUpdateAckMessage.getParticipantId().getVersion());
-
- if (participantOpt.isPresent()) {
- var participant = participantOpt.get();
- participant.setParticipantState(participantUpdateAckMessage.getState());
- participantProvider.saveParticipant(participant);
- } else {
- LOGGER.warn("Participant not found in database {}", participantUpdateAckMessage.getParticipantId());
- }
- } catch (PfModelException pfme) {
- LOGGER.warn("Model exception occured with participant id {}",
- participantUpdateAckMessage.getParticipantId());
- }
- }
-
- /**
* Send commissioning update message to dmaap.
*
* @param acmDefinition the AutomationComposition Definition
@@ -213,6 +106,17 @@ public class SupervisionHandler {
}
/**
+ * Handle a ParticipantUpdateAck message from a participant.
+ *
+ * @param participantUpdateAckMessage the ParticipantUpdateAck message received from a participant
+ */
+ @MessageIntercept
+ @Timed(value = "listener.participant_update_ack", description = "PARTICIPANT_UPDATE_ACK messages received")
+ public void handleParticipantMessage(ParticipantUpdateAck participantUpdateAckMessage) {
+ LOGGER.debug("Participant Update Ack message received {}", participantUpdateAckMessage);
+ }
+
+ /**
* Handle a AutomationComposition statechange acknowledge message from a participant.
*
* @param automationCompositionAckMessage the AutomationCompositionAck message received from a participant
@@ -405,40 +309,6 @@ public class SupervisionHandler {
return ParticipantUtils.getFirstStartPhase(automationComposition, toscaServiceTemplate);
}
- private void checkParticipant(ParticipantMessage participantMessage, ParticipantState participantState,
- ParticipantHealthStatus healthStatus) throws AutomationCompositionException, PfModelException {
- if (participantMessage.getParticipantId() == null) {
- exceptionOccured(Response.Status.NOT_FOUND, "Participant ID on PARTICIPANT_STATUS message is null");
- }
- var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId().getName(),
- participantMessage.getParticipantId().getVersion());
-
- if (participantOpt.isEmpty()) {
- var participant = new Participant();
- participant.setName(participantMessage.getParticipantId().getName());
- participant.setVersion(participantMessage.getParticipantId().getVersion());
- participant.setDefinition(participantMessage.getParticipantId());
- participant.setParticipantType(participantMessage.getParticipantType());
- participant.setParticipantState(participantState);
- participant.setHealthStatus(healthStatus);
-
- participantProvider.saveParticipant(participant);
- } else {
- var participant = participantOpt.get();
- participant.setParticipantState(participantState);
- participant.setHealthStatus(healthStatus);
-
- participantProvider.saveParticipant(participant);
- }
- }
-
- private void superviseParticipant(ParticipantStatus participantStatusMessage)
- throws PfModelException, AutomationCompositionException {
-
- checkParticipant(participantStatusMessage, participantStatusMessage.getState(),
- participantStatusMessage.getHealthStatus());
- }
-
private void exceptionOccured(Response.Status status, String reason) throws AutomationCompositionException {
throw new AutomationCompositionException(status, reason);
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
new file mode 100644
index 000000000..da9187d22
--- /dev/null
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.acm.runtime.supervision;
+
+import io.micrometer.core.annotation.Timed;
+import lombok.AllArgsConstructor;
+import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
+import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class handles supervision of participant status.
+ */
+@Component
+@AllArgsConstructor
+public class SupervisionParticipantHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionParticipantHandler.class);
+
+ private final ParticipantProvider participantProvider;
+ private final ParticipantRegisterAckPublisher participantRegisterAckPublisher;
+ private final ParticipantDeregisterAckPublisher participantDeregisterAckPublisher;
+
+ /**
+ * Handle a ParticipantRegister message from a participant.
+ *
+ * @param participantRegisterMsg the ParticipantRegister message received from a participant
+ */
+ @MessageIntercept
+ @Timed(value = "listener.participant_register", description = "PARTICIPANT_REGISTER messages received")
+ public void handleParticipantMessage(ParticipantRegister participantRegisterMsg) {
+ LOGGER.debug("Participant Register received {}", participantRegisterMsg);
+ saveParticipantStatus(participantRegisterMsg);
+
+ participantRegisterAckPublisher.send(participantRegisterMsg.getMessageId(),
+ participantRegisterMsg.getParticipantId(), participantRegisterMsg.getParticipantType());
+ }
+
+ /**
+ * Handle a ParticipantDeregister message from a participant.
+ *
+ * @param participantDeregisterMsg the ParticipantDeregister message received from a participant
+ */
+ @MessageIntercept
+ @Timed(value = "listener.participant_deregister", description = "PARTICIPANT_DEREGISTER messages received")
+ public void handleParticipantMessage(ParticipantDeregister participantDeregisterMsg) {
+ LOGGER.debug("Participant Deregister received {}", participantDeregisterMsg);
+ var participantOpt = participantProvider.findParticipant(participantDeregisterMsg.getParticipantId());
+
+ if (participantOpt.isPresent()) {
+ var participant = participantOpt.get();
+ participant.setParticipantState(ParticipantState.OFF_LINE);
+ participantProvider.saveParticipant(participant);
+ }
+
+ participantDeregisterAckPublisher.send(participantDeregisterMsg.getMessageId());
+ }
+
+ /**
+ * Handle a ParticipantStatus message from a participant.
+ *
+ * @param participantStatusMsg the ParticipantStatus message received from a participant
+ */
+ @MessageIntercept
+ @Timed(value = "listener.participant_status", description = "PARTICIPANT_STATUS messages received")
+ public void handleParticipantMessage(ParticipantStatus participantStatusMsg) {
+ LOGGER.debug("Participant Status received {}", participantStatusMsg);
+ saveParticipantStatus(participantStatusMsg);
+ }
+
+ private void saveParticipantStatus(ParticipantMessage participantMessage) {
+ var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId());
+
+ if (participantOpt.isEmpty()) {
+ var participant = new Participant();
+ participant.setName(participantMessage.getParticipantId().getName());
+ participant.setVersion(participantMessage.getParticipantId().getVersion());
+ participant.setDefinition(participantMessage.getParticipantId());
+ participant.setParticipantType(participantMessage.getParticipantType());
+ participant.setParticipantState(ParticipantState.ON_LINE);
+
+ participantProvider.saveParticipant(participant);
+ } else {
+ var participant = participantOpt.get();
+ participant.setParticipantState(ParticipantState.ON_LINE);
+
+ participantProvider.saveParticipant(participant);
+ }
+ }
+}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
index a71f49c10..e595f3bee 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -28,16 +28,14 @@ import java.util.UUID;
import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher;
-import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusReqPublisher;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
@@ -61,7 +59,6 @@ public class SupervisionScanner {
private final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher;
private final AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher;
private final ParticipantProvider participantProvider;
- private final ParticipantStatusReqPublisher participantStatusReqPublisher;
/**
* Constructor for instantiating SupervisionScanner.
@@ -71,21 +68,18 @@ public class SupervisionScanner {
* @param automationCompositionStateChangePublisher the AutomationComposition StateChange Publisher
* @param automationCompositionUpdatePublisher the AutomationCompositionUpdate Publisher
* @param participantProvider the Participant Provider
- * @param participantStatusReqPublisher the Participant StatusReq Publisher
* @param acRuntimeParameterGroup the parameters for the automation composition runtime
*/
public SupervisionScanner(final AutomationCompositionProvider automationCompositionProvider,
AcDefinitionProvider acDefinitionProvider,
final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher,
AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher,
- ParticipantProvider participantProvider, ParticipantStatusReqPublisher participantStatusReqPublisher,
- final AcRuntimeParameterGroup acRuntimeParameterGroup) {
+ ParticipantProvider participantProvider, final AcRuntimeParameterGroup acRuntimeParameterGroup) {
this.automationCompositionProvider = automationCompositionProvider;
this.acDefinitionProvider = acDefinitionProvider;
this.automationCompositionStateChangePublisher = automationCompositionStateChangePublisher;
this.automationCompositionUpdatePublisher = automationCompositionUpdatePublisher;
this.participantProvider = participantProvider;
- this.participantStatusReqPublisher = participantStatusReqPublisher;
automationCompositionCounter.setMaxRetryCount(
acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
@@ -106,13 +100,8 @@ public class SupervisionScanner {
LOGGER.debug("Scanning automation compositions in the database . . .");
if (counterCheck) {
- try {
- for (var participant : participantProvider.getParticipants()) {
- scanParticipantStatus(participant);
- }
- } catch (PfModelException pfme) {
- LOGGER.warn("error reading participant from database", pfme);
- return;
+ for (var participant : participantProvider.getParticipants()) {
+ scanParticipantStatus(participant);
}
}
@@ -127,22 +116,17 @@ public class SupervisionScanner {
LOGGER.debug("Automation composition scan complete . . .");
}
- private void scanParticipantStatus(Participant participant) throws PfModelException {
- ToscaConceptIdentifier id = participant.getKey().asIdentifier();
+ private void scanParticipantStatus(Participant participant) {
+ var id = participant.getKey().asIdentifier();
if (participantStatusCounter.isFault(id)) {
LOGGER.debug("report Participant fault");
return;
}
- if (participantStatusCounter.getDuration(id) > participantStatusCounter.getMaxWaitMs()) {
- if (participantStatusCounter.count(id)) {
- LOGGER.debug("retry message ParticipantStatusReq");
- participantStatusReqPublisher.send(id);
- participant.setHealthStatus(ParticipantHealthStatus.NOT_HEALTHY);
- } else {
- LOGGER.debug("report Participant fault");
- participantStatusCounter.setFault(id);
- participant.setHealthStatus(ParticipantHealthStatus.OFF_LINE);
- }
+ if (participantStatusCounter.getDuration(id) > participantStatusCounter.getMaxWaitMs()
+ && !participantStatusCounter.count(id)) {
+ LOGGER.debug("report Participant fault");
+ participantStatusCounter.setFault(id);
+ participant.setParticipantState(ParticipantState.OFF_LINE);
participantProvider.saveParticipant(participant);
}
}
@@ -209,8 +193,7 @@ public class SupervisionScanner {
? defaultMin
: defaultMax;
- if (nextSpNotCompleted != phaseMap.getOrDefault(automationComposition.getInstanceId(),
- firstStartPhase)) {
+ if (nextSpNotCompleted != phaseMap.getOrDefault(automationComposition.getInstanceId(), firstStartPhase)) {
phaseMap.put(automationComposition.getInstanceId(), nextSpNotCompleted);
sendAutomationCompositionMsg(automationComposition, nextSpNotCompleted);
} else if (counterCheck) {
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java
index eec21235f..62280a17c 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@
package org.onap.policy.clamp.acm.runtime.supervision.comm;
import org.onap.policy.clamp.acm.runtime.config.messaging.Listener;
-import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
+import org.onap.policy.clamp.acm.runtime.supervision.SupervisionParticipantHandler;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
@@ -40,12 +40,12 @@ public class ParticipantDeregisterListener extends ScoListener<ParticipantDeregi
implements Listener<ParticipantDeregister> {
private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantDeregisterListener.class);
- private final SupervisionHandler supervisionHandler;
+ private final SupervisionParticipantHandler supervisionHandler;
/**
* Constructs the object.
*/
- public ParticipantDeregisterListener(SupervisionHandler supervisionHandler) {
+ public ParticipantDeregisterListener(SupervisionParticipantHandler supervisionHandler) {
super(ParticipantDeregister.class);
this.supervisionHandler = supervisionHandler;
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java
index 852340000..b082e6f30 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@
package org.onap.policy.clamp.acm.runtime.supervision.comm;
import org.onap.policy.clamp.acm.runtime.config.messaging.Listener;
-import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
+import org.onap.policy.clamp.acm.runtime.supervision.SupervisionParticipantHandler;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
@@ -40,12 +40,12 @@ public class ParticipantRegisterListener extends ScoListener<ParticipantRegister
implements Listener<ParticipantRegister> {
private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRegisterListener.class);
- private final SupervisionHandler supervisionHandler;
+ private final SupervisionParticipantHandler supervisionHandler;
/**
* Constructs the object.
*/
- public ParticipantRegisterListener(SupervisionHandler supervisionHandler) {
+ public ParticipantRegisterListener(SupervisionParticipantHandler supervisionHandler) {
super(ParticipantRegister.class);
this.supervisionHandler = supervisionHandler;
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java
index 4ae1a1a2d..2118fe548 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@
package org.onap.policy.clamp.acm.runtime.supervision.comm;
import org.onap.policy.clamp.acm.runtime.config.messaging.Listener;
-import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
+import org.onap.policy.clamp.acm.runtime.supervision.SupervisionParticipantHandler;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
@@ -39,12 +39,12 @@ import org.springframework.stereotype.Component;
public class ParticipantStatusListener extends ScoListener<ParticipantStatus> implements Listener<ParticipantStatus> {
private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusListener.class);
- private final SupervisionHandler supervisionHandler;
+ private final SupervisionParticipantHandler supervisionHandler;
/**
* Constructs the object.
*/
- public ParticipantStatusListener(SupervisionHandler supervisionHandler) {
+ public ParticipantStatusListener(SupervisionParticipantHandler supervisionHandler) {
super(ParticipantStatus.class);
this.supervisionHandler = supervisionHandler;
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
index 2da869072..fd6c9a008 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,8 +38,6 @@ import org.mockito.Mockito;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher;
-import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
-import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
@@ -47,17 +45,12 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -109,10 +102,9 @@ class SupervisionHandlerTest {
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var handler = new SupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
- acDefinitionProvider, mock(AutomationCompositionUpdatePublisher.class),
- automationCompositionStateChangePublisher, mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), mock(ParticipantUpdatePublisher.class));
+ var handler = new SupervisionHandler(automationCompositionProvider, acDefinitionProvider,
+ mock(AutomationCompositionUpdatePublisher.class), automationCompositionStateChangePublisher,
+ mock(ParticipantUpdatePublisher.class));
handler.triggerAutomationCompositionSupervision(automationComposition);
@@ -160,10 +152,9 @@ class SupervisionHandlerTest {
void testAcRunningToPassive() throws AutomationCompositionException {
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class),
- mock(ParticipantProvider.class), mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- automationCompositionStateChangePublisher, mock(ParticipantUpdatePublisher.class),
- AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED);
+ mock(AutomationCompositionUpdatePublisher.class), automationCompositionStateChangePublisher,
+ mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud");
@@ -206,10 +197,9 @@ class SupervisionHandlerTest {
void testAcPassiveToRunning() throws AutomationCompositionException {
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class),
- mock(ParticipantProvider.class), mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- automationCompositionStateChangePublisher, mock(ParticipantUpdatePublisher.class),
- AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED);
+ mock(AutomationCompositionUpdatePublisher.class), automationCompositionStateChangePublisher,
+ mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud");
@@ -224,8 +214,7 @@ class SupervisionHandlerTest {
@Test
void testHandleAutomationCompositionStateChangeAckMessage() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
- var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
- mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class),
+ var handler = createSupervisionHandler(automationCompositionProvider,
mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -248,8 +237,7 @@ class SupervisionHandlerTest {
automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of());
automationCompositionAckMessage.setAutomationCompositionId(identifier);
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
- var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
- mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class),
+ var handler = createSupervisionHandler(automationCompositionProvider,
mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -260,112 +248,31 @@ class SupervisionHandlerTest {
}
@Test
- void testHandleParticipantDeregister() throws PfModelException {
- var participant = new Participant();
- participant.setName(participantId.getName());
- participant.setVersion(participantId.getVersion());
- participant.setParticipantType(participantType);
-
- var participantProvider = mock(ParticipantProvider.class);
- when(participantProvider.findParticipant(participantId.getName(), participantId.getVersion()))
- .thenReturn(Optional.of(participant));
-
- var participantDeregisterMessage = new ParticipantDeregister();
- participantDeregisterMessage.setMessageId(UUID.randomUUID());
- participantDeregisterMessage.setParticipantId(participantId);
- participantDeregisterMessage.setParticipantType(participantType);
- var participantDeregisterAckPublisher = mock(ParticipantDeregisterAckPublisher.class);
- var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
- mock(ParticipantRegisterAckPublisher.class), participantDeregisterAckPublisher,
- mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
- AutomationCompositionState.UNINITIALISED);
-
- handler.handleParticipantMessage(participantDeregisterMessage);
-
- verify(participantProvider).saveParticipant(any());
- verify(participantDeregisterAckPublisher).send(participantDeregisterMessage.getMessageId());
- }
-
- @Test
- void testHandleParticipantRegister() throws PfModelException {
- var participant = new Participant();
- participant.setName(participantId.getName());
- participant.setVersion(participantId.getVersion());
- participant.setParticipantType(participantType);
-
- var participantRegisterMessage = new ParticipantRegister();
- participantRegisterMessage.setMessageId(UUID.randomUUID());
- participantRegisterMessage.setParticipantId(participantId);
- participantRegisterMessage.setParticipantType(participantType);
- var participantProvider = mock(ParticipantProvider.class);
- var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class);
- var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
- participantRegisterAckPublisher, mock(ParticipantDeregisterAckPublisher.class),
- mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
- AutomationCompositionState.UNINITIALISED);
-
- handler.handleParticipantMessage(participantRegisterMessage);
-
- verify(participantProvider).saveParticipant(any());
- verify(participantRegisterAckPublisher).send(participantRegisterMessage.getMessageId(), participantId,
- participantType);
- }
-
- @Test
void testParticipantUpdateAck() throws PfModelException {
var participant = new Participant();
participant.setName(participantId.getName());
participant.setVersion(participantId.getVersion());
participant.setParticipantType(participantType);
- var participantProvider = mock(ParticipantProvider.class);
- when(participantProvider.findParticipant(participantId.getName(), participantId.getVersion()))
- .thenReturn(Optional.of(participant));
-
var participantUpdateAckMessage = new ParticipantUpdateAck();
participantUpdateAckMessage.setParticipantId(participantId);
participantUpdateAckMessage.setParticipantType(participantType);
- participantUpdateAckMessage.setState(ParticipantState.PASSIVE);
- var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
- mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class),
+ participantUpdateAckMessage.setState(ParticipantState.ON_LINE);
+ var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class),
mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
handler.handleParticipantMessage(participantUpdateAckMessage);
-
- verify(participantProvider).saveParticipant(any());
- }
-
- @Test
- void testHandleParticipantStatus() throws PfModelException {
- var participantStatusMessage = new ParticipantStatus();
- participantStatusMessage.setParticipantId(participantId);
- participantStatusMessage.setParticipantType(participantType);
- participantStatusMessage.setState(ParticipantState.PASSIVE);
- participantStatusMessage.setHealthStatus(ParticipantHealthStatus.HEALTHY);
-
- var participantProvider = mock(ParticipantProvider.class);
- var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
- mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class),
- mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
- AutomationCompositionState.UNINITIALISED);
- handler.handleParticipantMessage(participantStatusMessage);
-
- verify(participantProvider).saveParticipant(any());
}
@Test
void testHandleSendCommissionMessage() throws PfModelException {
var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class),
- mock(ParticipantProvider.class), mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- mock(AutomationCompositionStateChangePublisher.class), participantUpdatePublisher,
- AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED);
+ mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
+ participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
var acmDefinition = new AutomationCompositionDefinition();
handler.handleSendCommissionMessage(acmDefinition);
@@ -376,18 +283,15 @@ class SupervisionHandlerTest {
void testHandleSendDeCommissionMessage() throws PfModelException {
var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class),
- mock(ParticipantProvider.class), mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- mock(AutomationCompositionStateChangePublisher.class), participantUpdatePublisher,
- AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED);
+ mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
+ participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
handler.handleSendDeCommissionMessage(identifier);
verify(participantUpdatePublisher).sendDecomisioning(identifier);
}
private SupervisionHandler createSupervisionHandler(AutomationCompositionProvider automationCompositionProvider,
- ParticipantProvider participantProvider, ParticipantRegisterAckPublisher participantRegisterAckPublisher,
- ParticipantDeregisterAckPublisher participantDeregisterAckPublisher,
AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher,
AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher,
ParticipantUpdatePublisher participantUpdatePublisher, AutomationCompositionOrderedState orderedState,
@@ -406,24 +310,22 @@ class SupervisionHandlerTest {
when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()))
.thenReturn(InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML));
- return new SupervisionHandler(automationCompositionProvider, participantProvider, acDefinitionProvider,
+ return new SupervisionHandler(automationCompositionProvider, acDefinitionProvider,
automationCompositionUpdatePublisher, automationCompositionStateChangePublisher,
- participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher);
+ participantUpdatePublisher);
}
private SupervisionHandler createSupervisionHandlerForTrigger() {
- return new SupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
- mock(AcDefinitionProvider.class), mock(AutomationCompositionUpdatePublisher.class),
- mock(AutomationCompositionStateChangePublisher.class), mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), mock(ParticipantUpdatePublisher.class));
+ return new SupervisionHandler(mock(AutomationCompositionProvider.class), mock(AcDefinitionProvider.class),
+ mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
+ mock(ParticipantUpdatePublisher.class));
}
private SupervisionHandler createSupervisionHandlerForTrigger(
AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher) {
- return new SupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
- mock(AcDefinitionProvider.class), automationCompositionUpdatePublisher,
- mock(AutomationCompositionStateChangePublisher.class), mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), mock(ParticipantUpdatePublisher.class));
+ return new SupervisionHandler(mock(AutomationCompositionProvider.class), mock(AcDefinitionProvider.class),
+ automationCompositionUpdatePublisher, mock(AutomationCompositionStateChangePublisher.class),
+ mock(ParticipantUpdatePublisher.class));
}
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
new file mode 100644
index 000000000..9e35f2cf5
--- /dev/null
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.acm.runtime.supervision;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
+import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+class SupervisionParticipantHandlerTest {
+ private static final ToscaConceptIdentifier PARTICIPANT_ID = new ToscaConceptIdentifier("ParticipantId", "1.0.0");
+ private static final ToscaConceptIdentifier PARTICIPANT_TYPE =
+ new ToscaConceptIdentifier("ParticipantType", "1.0.0");
+
+ @Test
+ void testHandleParticipantDeregister() {
+ var participant = new Participant();
+ participant.setName(PARTICIPANT_ID.getName());
+ participant.setVersion(PARTICIPANT_ID.getVersion());
+ participant.setParticipantType(PARTICIPANT_TYPE);
+
+ var participantProvider = mock(ParticipantProvider.class);
+ when(participantProvider.findParticipant(PARTICIPANT_ID)).thenReturn(Optional.of(participant));
+
+ var participantDeregisterMessage = new ParticipantDeregister();
+ participantDeregisterMessage.setMessageId(UUID.randomUUID());
+ participantDeregisterMessage.setParticipantId(PARTICIPANT_ID);
+ participantDeregisterMessage.setParticipantType(PARTICIPANT_TYPE);
+ var participantDeregisterAckPublisher = mock(ParticipantDeregisterAckPublisher.class);
+ var handler = new SupervisionParticipantHandler(participantProvider,
+ mock(ParticipantRegisterAckPublisher.class), participantDeregisterAckPublisher);
+
+ handler.handleParticipantMessage(participantDeregisterMessage);
+
+ verify(participantProvider).saveParticipant(any());
+ verify(participantDeregisterAckPublisher).send(participantDeregisterMessage.getMessageId());
+ }
+
+ @Test
+ void testHandleParticipantRegister() {
+ var participant = new Participant();
+ participant.setName(PARTICIPANT_ID.getName());
+ participant.setVersion(PARTICIPANT_ID.getVersion());
+ participant.setParticipantType(PARTICIPANT_TYPE);
+
+ var participantRegisterMessage = new ParticipantRegister();
+ participantRegisterMessage.setMessageId(UUID.randomUUID());
+ participantRegisterMessage.setParticipantId(PARTICIPANT_ID);
+ participantRegisterMessage.setParticipantType(PARTICIPANT_TYPE);
+ var participantProvider = mock(ParticipantProvider.class);
+ var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class);
+ var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher,
+ mock(ParticipantDeregisterAckPublisher.class));
+
+ handler.handleParticipantMessage(participantRegisterMessage);
+
+ verify(participantProvider).saveParticipant(any());
+ verify(participantRegisterAckPublisher).send(participantRegisterMessage.getMessageId(), PARTICIPANT_ID,
+ PARTICIPANT_TYPE);
+ }
+
+ @Test
+ void testHandleParticipantStatus() {
+ var participantStatusMessage = new ParticipantStatus();
+ participantStatusMessage.setParticipantId(PARTICIPANT_ID);
+ participantStatusMessage.setParticipantType(PARTICIPANT_TYPE);
+ participantStatusMessage.setState(ParticipantState.ON_LINE);
+
+ var participantProvider = mock(ParticipantProvider.class);
+ var handler = new SupervisionParticipantHandler(participantProvider,
+ mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class));
+ handler.handleParticipantMessage(participantStatusMessage);
+
+ verify(participantProvider).saveParticipant(any());
+ }
+}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
index a6d4d3b0d..0142f294c 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,14 +36,12 @@ import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher;
-import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusReqPublisher;
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
@@ -81,7 +79,6 @@ class SupervisionScannerTest {
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
var participantProvider = mock(ParticipantProvider.class);
- var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud");
@@ -90,7 +87,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, acRuntimeParameterGroup);
+ acRuntimeParameterGroup);
supervisionScanner.run(false);
verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
@@ -108,12 +105,11 @@ class SupervisionScannerTest {
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var participantProvider = mock(ParticipantProvider.class);
- var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, acRuntimeParameterGroup);
+ acRuntimeParameterGroup);
supervisionScanner.run(false);
verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class));
@@ -133,18 +129,16 @@ class SupervisionScannerTest {
when(participantProvider.getParticipants(null, null)).thenReturn(List.of(participant));
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
- var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, acRuntimeParameterGroup);
+ acRuntimeParameterGroup);
supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
supervisionScanner.run(true);
verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
- verify(participantStatusReqPublisher, times(0)).send(any(ToscaConceptIdentifier.class));
}
@Test
@@ -169,13 +163,12 @@ class SupervisionScannerTest {
var participantProvider = mock(ParticipantProvider.class);
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
- var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, acRuntimeParameterGroup);
+ acRuntimeParameterGroup);
supervisionScanner.run(false);
@@ -196,27 +189,24 @@ class SupervisionScannerTest {
var participant = new Participant();
participant.setName(PARTICIPANT_NAME);
participant.setVersion(PARTICIPANT_VERSION);
- participant.setHealthStatus(ParticipantHealthStatus.HEALTHY);
- participant.setParticipantState(ParticipantState.ACTIVE);
+ participant.setParticipantState(ParticipantState.OFF_LINE);
participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
participant.setParticipantType(PARTICIPANT_TYPE);
var participantProvider = mock(ParticipantProvider.class);
when(participantProvider.getParticipants()).thenReturn(List.of(participant));
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
- var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, acRuntimeParameterGroup);
+ acRuntimeParameterGroup);
supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
supervisionScanner.run(true);
- verify(participantStatusReqPublisher).send(any(ToscaConceptIdentifier.class));
- verify(participantProvider).saveParticipant(any());
+ verify(participantProvider, times(0)).saveParticipant(any());
supervisionScanner.run(true);
- verify(participantProvider, times(2)).saveParticipant(any());
+ verify(participantProvider, times(1)).saveParticipant(any());
}
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
index b545fd957..b7d2d9303 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,6 +33,7 @@ import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
+import org.onap.policy.clamp.acm.runtime.supervision.SupervisionParticipantHandler;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
@@ -75,7 +76,7 @@ class SupervisionMessagesTest {
@Test
void testReceiveParticipantDeregister() {
final var participantDeregisterMsg = new ParticipantDeregister();
- var supervisionHandler = mock(SupervisionHandler.class);
+ var supervisionHandler = mock(SupervisionParticipantHandler.class);
var participantDeregisterListener = new ParticipantDeregisterListener(supervisionHandler);
participantDeregisterListener.onTopicEvent(INFRA, TOPIC, null, participantDeregisterMsg);
verify(supervisionHandler).handleParticipantMessage(participantDeregisterMsg);
@@ -192,7 +193,7 @@ class SupervisionMessagesTest {
@Test
void testParticipantRegisterListener() {
final var participantRegister = new ParticipantRegister();
- var supervisionHandler = mock(SupervisionHandler.class);
+ var supervisionHandler = mock(SupervisionParticipantHandler.class);
var participantRegisterListener = new ParticipantRegisterListener(supervisionHandler);
participantRegisterListener.onTopicEvent(INFRA, TOPIC, null, participantRegister);
verify(supervisionHandler).handleParticipantMessage(participantRegister);
@@ -201,7 +202,7 @@ class SupervisionMessagesTest {
@Test
void testParticipantStatusListener() {
final var participantStatus = new ParticipantStatus();
- var supervisionHandler = mock(SupervisionHandler.class);
+ var supervisionHandler = mock(SupervisionParticipantHandler.class);
var participantStatusListener = new ParticipantStatusListener(supervisionHandler);
participantStatusListener.onTopicEvent(INFRA, TOPIC, null, participantStatus);
verify(supervisionHandler).handleParticipantMessage(participantStatus);