1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
5 The CLAMP Automation Composition Runtime
6 ########################################
12 This article explains how CLAMP Automation Composition Runtime is implemented.
16 - Broadcast message: a message for all participants (participantId=null)
17 - Message to a participant: a message only for a participant (participantId properly filled)
18 - ThreadPoolExecutor: ThreadPoolExecutor executes the given task, into SupervisionAspect class is configured to execute tasks in ordered manner, one by one
19 - Spring Scheduling: into SupervisionAspect class, the @Scheduled annotation invokes "schedule()" method every "runtime.participantParameters.heartBeatMs" milliseconds with a fixed delay
20 - MessageIntercept: "@MessageIntercept" annotation is used into SupervisionHandler class to intercept "handleParticipantMessage" method calls using spring aspect oriented programming
21 - GUI: swagger-ui, Postman or policy-gui
22 - Message Broker: supported message Broker are DMaap and Strimzi-Kafka
27 Check CLAMP Runtime and Participants
28 ++++++++++++++++++++++++++++++++++++
29 - GUI calls GET "/onap/policy/clamp/acm/health" endpoint and receives the "UP" status as response
30 - GUI calls GET "/onap/policy/clamp/acm/v2/participants" endpoint and receives all participants registered with supported Element Types as response
32 Order an immediate Participant Report from all participants
33 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34 - GUI calls PUT "/onap/policy/clamp/acm/v2/participants" endpoint
35 - runtime-ACM receives the call by Rest-Api (CommissioningController)
36 - It triggers the execution to send a broadcast PARTICIPANT_STATUS_REQ message
38 Create of a Automation Composition Definition Type
39 ++++++++++++++++++++++++++++++++++++++++++++++++++
40 - GUI calls POST "/onap/policy/clamp/acm/v2/compositions" endpoint with a Automation Composition Type Definition (Tosca Service Template) as body
41 - runtime-ACM receives the call by Rest-Api (CommissioningController)
42 - It validates the Automation Composition Type Definition
43 - It saves to DB the Tosca Service Template using AcDefinitionProvider with new compositionId and COMMISSIONED status
44 - the Rest-Api call returns the compositionId generated and the list of Element Definition Type
46 Update of a Automation Composition Definition Type
47 ++++++++++++++++++++++++++++++++++++++++++++++++++
48 - GUI calls POST "/onap/policy/clamp/acm/v2/compositions" endpoint with a Automation Composition Type Definition (Tosca Service Template) as body. It have to contain the compositionId
49 - runtime-ACM receives the call by Rest-Api (CommissioningController)
50 - It checks that Automation Composition Type Definition is in COMMISSIONED status
51 - It validates the Automation Composition Type Definition
52 - It updates to DB the Tosca Service Template using AcDefinitionProvider using the compositionId
53 - the Rest-Api call returns the compositionId and the list of Element Definition Type
55 Priming of a Automation Composition Definition Type
56 +++++++++++++++++++++++++++++++++++++++++++++++++++
57 - GUI calls POST "/onap/policy/clamp/acm/v2/compositions/{compositionId}" endpoint with PRIME as primeOrder
58 - runtime-ACM receives the call by Rest-Api (CommissioningController)
59 - It checks that Automation Composition Type Definition is in COMMISSIONED status
60 - It validates and update the AC Element Type Definition with supported Element Types by participants
61 - It updates AC Definition to DB with PRIMING as status
62 - It triggers the execution to send a broadcast PARTICIPANT_PRIME message
63 - the message is built by ParticipantPrimePublisher using Tosca Service Template data
65 Create of a Automation Composition Instance
66 +++++++++++++++++++++++++++++++++++++++++++
67 - GUI calls POST "/onap/policy/clamp/acm/v2/compositions/{compositionId}/instances" endpoint with a Automation Composition Instance as body. It have to contain the compositionId
68 - runtime-ACM receives the call by Rest-Api (InstantiationController)
69 - It validates the AC Instance and checks that the related composition has COMMISSIONED as status
70 - It set the related participantId into the AC Element Instance using the participantId defined in AC Element Type Definition
71 - It saves the Automation Composition to DB with UNDEPLOYED deployState and NONE lockState
72 - the Rest-Api call returns the instanceId and the list of AC Element Instance
74 Update of a Automation Composition Instance
75 +++++++++++++++++++++++++++++++++++++++++++
76 - GUI calls POST "/onap/policy/clamp/acm/v2/compositions/{compositionId}/instances" endpoint with a Automation Composition Instance as body. It have to contain the compositionId and the instanceId
77 - runtime-ACM receives the call by Rest-Api (InstantiationController)
78 - It checks that AC Instance is in UNDEPLOYED deployState
79 - It updates the Automation Composition to DB
80 - the Rest-Api call returns the instanceId and the list of AC Element Instance
82 Issues AC instance to change status
83 +++++++++++++++++++++++++++++++++++
85 case **deployOrder: DEPLOY**
87 - GUI calls "/onap/policy/clamp/acm/v2/compositions/{compositionId}/instances/{instanceId}" endpoint with DEPLOY as deployOrder
88 - runtime-ACM receives the call by Rest-Api (InstantiationController)
89 - It validates the status order issued (related AC Instance has UNDEPLOYED as deployState)
90 - It updates the AC Instance to DB with DEPLOYING deployState
91 - It triggers the execution to send a broadcast AUTOMATION_COMPOSITION_DEPLOY message
92 - the message is built by AutomationCompositionDeployPublisher using Tosca Service Template data and Instance data. (with startPhase = first startPhase)
94 case **lockOrder: UNLOCK**
96 - GUI calls "/onap/policy/clamp/acm/v2/compositions/{compositionId}/instances/{instanceId}" endpoint with UNLOCK as lockOrder
97 - runtime-ACM receives the call by Rest-Api (InstantiationController)
98 - It validates the status order issued (related AC Instance has DEPLOYED as deployState and LOCK as lockOrder)
99 - It updates the AC Instance to DB with LOCKING lockOrder
100 - It triggers the execution to send a broadcast AUTOMATION_COMPOSITION_STATE_CHANGE message
101 - the message is built by AutomationCompositionStateChangePublisher using Instance data. (with startPhase = first startPhase)
103 case **lockOrder: LOCK**
105 - GUI calls "/onap/policy/clamp/acm/v2/compositions/{compositionId}/instances/{instanceId}" endpoint with LOCK as lockOrder
106 - runtime-ACM receives the call by Rest-Api (InstantiationController)
107 - It validates the status order issued (related AC Instance has DEPLOYED as deployState and UNLOCK as lockOrder)
108 - It updates the AC Instance to DB with UNLOCKING lockOrder
109 - It triggers the execution to send a broadcast AUTOMATION_COMPOSITION_STATE_CHANGE message
110 - the message is built by AutomationCompositionStateChangePublisher using Instance data. (with startPhase = last StartPhase)
112 case **deployOrder: UNDEPLOY**
114 - GUI calls "/onap/policy/clamp/acm/v2/compositions/{compositionId}/instances/{instanceId}" endpoint with UNDEPLOY as deployOrder
115 - runtime-ACM receives the call by Rest-Api (InstantiationController)
116 - It validates the status order issued (related AC Instance has DEPLOYED as deployState and LOCK as lockOrder)
117 - It updates the AC Instance to DB with UNDEPLOYING deployState
118 - It triggers the execution to send a broadcast AUTOMATION_COMPOSITION_STATE_CHANGE message
119 - the message is built by AutomationCompositionStateChangePublisher using Instance data. (with startPhase = last StartPhase)
121 Delete of a Automation Composition Instance
122 +++++++++++++++++++++++++++++++++++++++++++
123 - GUI calls DELETE "/onap/policy/clamp/acm/v2/compositions/{compositionId}/instances/{instanceId}" endpoint
124 - runtime-ACM receives the call by Rest-Api (InstantiationController)
125 - It checks that AC Instance is in UNDEPLOYED deployState
126 - It deletes the AC Instance from DB
128 Depriming of a Automation Composition Definition Type
129 +++++++++++++++++++++++++++++++++++++++++++++++++++++
130 - GUI calls POST "/onap/policy/clamp/acm/v2/compositions/{compositionId}" endpoint with DEPRIME as primeOrder
131 - runtime-ACM receives the call by Rest-Api (CommissioningController)
132 - It checks that Automation Composition Type Definition is in PRIMED status
133 - It updates AC Definition to DB with DEPRIMING as status
134 - It triggers the execution to send a broadcast PARTICIPANT_PRIME message
135 - the message is built by ParticipantPrimePublisher using Tosca Service Template data
137 Delete of a Automation Composition Definition Type
138 ++++++++++++++++++++++++++++++++++++++++++++++++++
139 - GUI calls DELETE "/onap/policy/clamp/acm/v2/compositions/{compositionId}" endpoint
140 - runtime-ACM receives the call by Rest-Api (CommissioningController)
141 - It checks that AC Definition Type is in COMMISSIONED status
142 - It deletes the Automation Composition Type from DB
146 The startPhase is particularly important in Automation Composition update and Automation Composition state changes because sometime the user wishes to control the order in which the state changes in Automation Composition Elements in a Automation Composition.
148 How to define StartPhase
149 ++++++++++++++++++++++++
150 StartPhase is defined as shown below in the Definition of TOSCA fundamental Automation Composition Types yaml file.
158 - greater-or-equal: 0
159 description: A value indicating the start phase in which this Automation Composition element will be started, the
160 first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped
161 in reverse start phase order. Automation Composition Elements with the same start phase are started and
162 stopped simultaneously
166 The "common: true" value in the metadata of the startPhase property identifies that property as being a common property.
167 This property will be set on the CLAMP GUI during Automation Composition commissioning.
168 Example where it could be used:
172 org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement:
173 # Consul http config for PMSH.
175 type: org.onap.policy.clamp.acm.HttpAutomationCompositionElement
177 description: Automation Composition element for the http requests of PMSH microservice
180 uninitializedToPassiveTimeout: 180
185 In state changes from UNDEPLOYED → DEPLOYED or LOCKED → UNLOCKED, Automation Composition elements are started in increasing order of their startPhase.
187 Example of DEPLOY order with Http_PMSHMicroserviceAutomationCompositionElement with startPhase to 1 and PMSH_K8SMicroserviceAutomationCompositionElement with startPhase to 0
189 - runtime-ACM sends a broadcast AUTOMATION_COMPOSITION_DEPLOY message to all participants with startPhase = 0
190 - participant receives the AUTOMATION_COMPOSITION_DEPLOY message and runs to DEPLOYED state (only AC elements defined as startPhase = 0)
191 - runtime-ACM receives AUTOMATION_COMPOSITION_DEPLOY_ACK messages from participants and set the state (from the AC element of the message) to DEPLOYED
192 - runtime-ACM calculates that all AC elements with startPhase = 0 are set to proper state and sends a broadcast AUTOMATION_COMPOSITION_DEPLOY message with startPhase = 1
193 - participant receives the AUTOMATION_COMPOSITION_DEPLOY message and runs to DEPLOYED state (only AC elements defined as startPhase = 1)
194 - runtime-ACM receives AUTOMATION_COMPOSITION_DEPLOY_ACK messages from participants and set the state (from the AC element of the message) to DEPLOYED
195 - runtime-ACM calculates that all AC elements are set to proper state and set AC to DEPLOYED
197 In that scenario the message AUTOMATION_COMPOSITION_DEPLOY has been sent two times.
199 Design of managing messages
200 ***************************
204 - A participant starts and send a PARTICIPANT_REGISTER message with participantId and supported Element Types
205 - runtime-ACM collects the message from Message Broker by ParticipantRegisterListener
206 - if not present, it saves participant reference with status ON_LINE to DB
208 PARTICIPANT_PRIME_ACK
209 ++++++++++++++++++++++
210 - A participant sends PARTICIPANT_PRIME_ACK message in response to a PARTICIPANT_PRIME message
211 - ParticipantPrimeAckListener collects the message from Message Broker
212 - It updates AC Definition to DB with PRIMED/DEPRIMED as status
216 - A participant sends a scheduled PARTICIPANT_STATUS message with participantId and supported Element Types
217 - runtime-ACM collects the message from Message Broker by ParticipantStatusListener
218 - if not present, it saves participant reference with status ON_LINE to DB
219 - MessageIntercept intercepts that event and adds a task to handle PARTICIPANT_STATUS in SupervisionScanner
220 - SupervisionScanner clears and starts the monitoring for participantStatus
222 AUTOMATION_COMPOSITION_DEPLOY_ACK
223 +++++++++++++++++++++++++++++++++
224 - A participant sends AUTOMATION_COMPOSITION_DEPLOY_ACK message in response to a AUTOMATION_COMPOSITION_DEPLOY message. It will send a AUTOMATION_COMPOSITION_DEPLOY_ACK - for each AC elements moved to the DEPLOYED state
225 - AutomationCompositionUpdateAckListener collects the message from Message Broker
226 - It checks the status of all Automation Composition elements and checks if the Automation Composition is fully DEPLOYED
227 - It updates the AC to DB
228 - MessageIntercept intercepts that event and adds a task to handle a monitoring execution in SupervisionScanner
230 AUTOMATION_COMPOSITION_STATECHANGE_ACK
231 ++++++++++++++++++++++++++++++++++++++
232 - A participant sends AUTOMATION_COMPOSITION_STATECHANGE_ACK message in response to a AUTOMATION_COMPOSITION_STATECHANGE message. It will send a AUTOMATION_COMPOSITION_DEPLOY_ACK - for each AC elements moved to the ordered state
233 - AutomationCompositionStateChangeAckListener collects the message from Message Broker
234 - It checks the status of all Automation Composition elements and checks if the transition process of the Automation Composition is terminated
235 - It updates the AC to DB
236 - MessageIntercept intercepts that event and adds a task to handle a monitoring execution in SupervisionScanner
238 Design of monitoring execution in SupervisionScanner
239 ****************************************************
240 Monitoring is designed to process the follow operations:
242 - to determine the next startPhase in a AUTOMATION_COMPOSITION_DEPLOY message
243 - to update AC deployState: in a scenario that "AutomationComposition.deployState" is in a kind of transitional state (example DEPLOYING), if all - AC elements are moved properly to the specific state, the "AutomationComposition.deployState" will be updated to that and saved to DB
244 - to update AC lockState: in a scenario that "AutomationComposition.lockState" is in a kind of transitional state (example LOCKING), if all - AC elements are moved properly to the specific state, the "AutomationComposition.lockState" will be updated to that and saved to DB
245 - to retry AUTOMATION_COMPOSITION_DEPLOY/AUTOMATION_COMPOSITION_STATE_CHANGE messages. if there is a AC Element not in the proper state, it will retry a broadcast message
247 The solution Design of retry, timeout, and reporting for all Participant message dialogues are implemented into the monitoring execution.
249 - Spring Scheduling inserts the task to monitor retry execution into ThreadPoolExecutor
250 - ThreadPoolExecutor executes the task
251 - a message will be retry if runtime-ACM do no receive Act message before MaxWaitMs milliseconds
253 Design of Exception handling
254 ****************************
255 GlobalControllerExceptionHandler
256 ++++++++++++++++++++++++++++++++
257 If error occurred during the Rest Api call, runtime-ACM responses with a proper status error code and a JSON message error.
258 This class is implemented to intercept and handle AutomationCompositionException, PfModelException and PfModelRuntimeException if they are thrown during the Rest Ali calls.
259 All of those classes must implement ErrorResponseInfo that contains message error and status response code.
260 So the Exception is converted in JSON message.
262 RuntimeErrorController
263 ++++++++++++++++++++++
264 If wrong end-point is called or an Exception not intercepted by GlobalControllerExceptionHandler, runtime-ACM responses with a proper status error code and a JSON message error.
265 This class is implemented to redirect the standard Web error page to a JSON message error.
266 Typically that happen when a wrong end-point is called, but also could be happen for not authorized call, or any other Exception not intercepted by GlobalControllerExceptionHandler.
268 Handle version and "X-ONAP-RequestID"
269 *************************************
270 RequestResponseLoggingFilter class handles version and "X-ONAP-RequestID" during a Rest-Api call; it works as a filter, so intercepts the Rest-Api and adds to the header those information.
274 runtime-ACM Rest Api supports **application/json**, **application/yaml** and **text/plain** Media Types. The configuration is implemented in CoderHttpMesageConverter.
278 JSON format is a standard for Rest Api. For the conversion from JSON to Object and vice-versa will be used **org.onap.policy.common.utils.coder.StandardCoder**.
282 YAML format is a standard for Automation Composition Type Definition. For the conversion from YAML to Object and vice-versa will be used **org.onap.policy.common.utils.coder.StandardYamlCoder**.
286 Text format is used by Prometheus. For the conversion from Object to String will be used **StringHttpMessageConverter**.