summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src/main/java/org
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-01-25 19:55:43 +0000
committerliamfallon <liam.fallon@est.tech>2022-02-18 15:54:40 +0000
commit43098043c4ef31d9d5dead66568d7d9482a6b165 (patch)
tree6f6ea4812ff93d65e7c64e12a3ec6ab4462a64e2 /participant/participant-intermediary/src/main/java/org
parentf401b5099bcb64f3e21de608d0207dd69d8043cd (diff)
Rename TOSCA Control Loop to ACM
This commit renames the TOSCA Control Loop functionality in CLAMP to Automation Composition Management. This review is a direct renaming review and, as everything is renamed together it is large. Issue-ID: POLICY-3939 Change-Id: I28f0a6dd889bf3570a4c1365ae9e71fc58db6d6c Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/main/java/org')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java65
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java130
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java140
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionStateChangeListener.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java)18
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionUpdateListener.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java)19
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/MessageSender.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java)6
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantAckListener.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java)8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantDeregisterAckListener.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantDeregisterAckListener.java)8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantListener.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java)8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java)38
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantRegisterAckListener.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantRegisterAckListener.java)8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantStatusReqListener.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusReqListener.java)8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantUpdateListener.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantUpdateListener.java)8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java476
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivator.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java)17
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Listener.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java)2
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java)177
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Publisher.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Publisher.java)2
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java)6
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantParameters.java (renamed from participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantParameters.java)2
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java63
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java129
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java137
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java454
24 files changed, 979 insertions, 950 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
new file mode 100644
index 000000000..9affd5751
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.intermediary.api;
+
+import java.util.UUID;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+
+/**
+ * This interface is implemented by participant implementations to receive updates on automation composition elements.
+ */
+public interface AutomationCompositionElementListener {
+ /**
+ * Handle a automation composition element state change.
+ *
+ * @param automationCompositionElementId the ID of the automation composition element
+ * @param currentState the current state of the automation composition element
+ * @param newState the state to which the automation composition element is changing to
+ * @throws PfModelException in case of a model exception
+ */
+ public void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId,
+ UUID automationCompositionElementId, AutomationCompositionState currentState,
+ AutomationCompositionOrderedState newState) throws PfModelException;
+
+ /**
+ * Handle an update on a automation composition element.
+ *
+ * @param element the information on the automation composition element
+ * @param automationCompositionElementDefinition toscaNodeTemplate
+ * @throws PfModelException from Policy framework
+ */
+ public void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId,
+ AutomationCompositionElement element, ToscaNodeTemplate automationCompositionElementDefinition)
+ throws PfModelException;
+
+ /**
+ * Handle automationCompositionElement statistics.
+ *
+ * @param automationCompositionElementId automationCompositionElement id
+ * @throws PfModelException in case of a model exception
+ */
+ public void handleStatistics(UUID automationCompositionElementId) throws PfModelException;
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
new file mode 100644
index 000000000..79f5259bf
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.intermediary.api;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+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.AutomationCompositions;
+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.concepts.ParticipantStatistics;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
+
+/**
+ * This interface is used by participant implementations to use the participant intermediary.
+ */
+public interface ParticipantIntermediaryApi {
+
+ /**
+ * Register a listener for automation composition elements that are mediated by the intermediary.
+ *
+ * @param automationCompositionElementListener The automation composition element listener to register
+ */
+ void registerAutomationCompositionElementListener(
+ AutomationCompositionElementListener automationCompositionElementListener);
+
+ /**
+ * Get participants loops from the intermediary API.
+ *
+ * @param name the participant name, null for all
+ * @param version the participant version, null for all
+ * @return the participants
+ */
+ List<Participant> getParticipants(String name, String version);
+
+ /**
+ * Get common properties of a automation composition element.
+ *
+ * @param acElementDef the automation composition element definition
+ * @return the common properties
+ */
+ Map<String, ToscaProperty> getAcElementDefinitionCommonProperties(ToscaConceptIdentifier acElementDef);
+
+ /**
+ * Update the state of a participant.
+ *
+ * @param definition the definition of the participant to update the state on
+ * @param state the state of the participant
+ * @return the participant
+ */
+ Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state);
+
+ /**
+ * Update the statistics of a participant.
+ *
+ * @param participantStatistics the statistics of the participant
+ */
+ void updateParticipantStatistics(ParticipantStatistics participantStatistics);
+
+ /**
+ * Get automation compositions from the intermediary API.
+ *
+ * @param name the automation composition element name, null for all
+ * @param version the automation composition element version, null for all
+ * @return the automation composition elements
+ */
+ AutomationCompositions getAutomationCompositions(String name, String version);
+
+ /**
+ * Get automation composition elements from the intermediary API.
+ *
+ * @param name the automation composition element name, null for all
+ * @param version the automation composition element version, null for all
+ * @return the automation composition elements
+ */
+ Map<UUID, AutomationCompositionElement> getAutomationCompositionElements(String name, String version);
+
+ /**
+ * Get automation composition element from the intermediary API.
+ *
+ * @param id automation composition element ID
+ * @return the automation composition element
+ */
+ AutomationCompositionElement getAutomationCompositionElement(UUID id);
+
+ /**
+ * Update the state of a automation composition element.
+ *
+ * @param id the ID of the automation composition element to update the state on
+ * @param currentState the state of the automation composition element
+ * @param newState the state of the automation composition element
+ * @return AutomationCompositionElement updated automation composition element
+ */
+ AutomationCompositionElement updateAutomationCompositionElementState(ToscaConceptIdentifier automationCompositionId,
+ UUID id, AutomationCompositionOrderedState currentState, AutomationCompositionState newState,
+ ParticipantMessageType messageType);
+
+ /**
+ * Update the automation composition element statistics.
+ *
+ * @param id the ID of the automation composition element to update the state on
+ * @param elementStatistics the updated statistics
+ */
+ void updateAutomationCompositionElementStatistics(UUID id, AcElementStatistics elementStatistics);
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
new file mode 100644
index 000000000..1a1f8500f
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
@@ -0,0 +1,140 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.intermediary.api.impl;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
+import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+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.AutomationCompositions;
+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.concepts.ParticipantStatistics;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is api implementation used by participant intermediary.
+ */
+@Component
+public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryApi {
+
+ // The handler for the participant intermediary
+ private final ParticipantHandler participantHandler;
+
+ // The handler for the automationComposition intermediary
+ private final AutomationCompositionHandler automationCompositionHandler;
+
+ /**
+ * Constructor.
+ *
+ * @param participantHandler ParticipantHandler
+ * @param automationCompositionHandler AutomationCompositionHandler
+ */
+ public ParticipantIntermediaryApiImpl(ParticipantHandler participantHandler,
+ AutomationCompositionHandler automationCompositionHandler) {
+ this.participantHandler = participantHandler;
+ this.automationCompositionHandler = automationCompositionHandler;
+ }
+
+ @Override
+ public void registerAutomationCompositionElementListener(
+ AutomationCompositionElementListener automationCompositionElementListener) {
+ automationCompositionHandler.registerAutomationCompositionElementListener(automationCompositionElementListener);
+ }
+
+ @Override
+ public List<Participant> getParticipants(String name, String version) {
+ return List.of(participantHandler.getParticipant(name, version));
+ }
+
+ @Override
+ public Map<String, ToscaProperty> getAcElementDefinitionCommonProperties(ToscaConceptIdentifier acElementDef) {
+ return participantHandler.getAcElementDefinitionCommonProperties(acElementDef);
+ }
+
+ @Override
+ public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state) {
+ return participantHandler.updateParticipantState(definition, state);
+ }
+
+ @Override
+ public void updateParticipantStatistics(ParticipantStatistics participantStatistics) {
+ participantHandler.updateParticipantStatistics(participantStatistics);
+ }
+
+ @Override
+ public AutomationCompositions getAutomationCompositions(String name, String version) {
+ return automationCompositionHandler.getAutomationCompositions();
+ }
+
+ @Override
+ public Map<UUID, AutomationCompositionElement> getAutomationCompositionElements(String name, String version) {
+ List<AutomationComposition> automationCompositions =
+ automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList();
+
+ for (AutomationComposition automationComposition : automationCompositions) {
+ if (name.equals(automationComposition.getDefinition().getName())) {
+ return automationComposition.getElements();
+ }
+ }
+ return new LinkedHashMap<>();
+ }
+
+ @Override
+ public AutomationCompositionElement getAutomationCompositionElement(UUID id) {
+ List<AutomationComposition> automationCompositions =
+ automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList();
+
+ for (AutomationComposition automationComposition : automationCompositions) {
+ AutomationCompositionElement acElement = automationComposition.getElements().get(id);
+ if (acElement != null) {
+ return acElement;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public AutomationCompositionElement updateAutomationCompositionElementState(
+ ToscaConceptIdentifier automationCompositionId, UUID id, AutomationCompositionOrderedState currentState,
+ AutomationCompositionState newState, ParticipantMessageType messageType) {
+ return automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id,
+ currentState, newState);
+ }
+
+ @Override
+ public void updateAutomationCompositionElementStatistics(UUID id, AcElementStatistics elementStatistics) {
+ automationCompositionHandler.updateAutomationCompositionElementStatistics(id, elementStatistics);
+ }
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionStateChangeListener.java
index d24f32f2f..b9ec6a6a0 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionStateChangeListener.java
@@ -18,31 +18,31 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
import org.springframework.stereotype.Component;
/**
* Listener for Participant State Change messages sent by CLAMP.
*/
@Component
-public class ControlLoopStateChangeListener extends ParticipantListener<ControlLoopStateChange> {
+public class AutomationCompositionStateChangeListener extends ParticipantListener<AutomationCompositionStateChange> {
/**
* Constructs the object.
*
* @param participantHandler the handler for managing the state of the participant
*/
- public ControlLoopStateChangeListener(final ParticipantHandler participantHandler) {
- super(ControlLoopStateChange.class, participantHandler,
- participantHandler::handleControlLoopStateChange);
+ public AutomationCompositionStateChangeListener(final ParticipantHandler participantHandler) {
+ super(AutomationCompositionStateChange.class, participantHandler,
+ participantHandler::handleAutomationCompositionStateChange);
}
@Override
public String getType() {
- return ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE.name();
+ return ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE.name();
}
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionUpdateListener.java
index f9dec1863..6c5dc127d 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionUpdateListener.java
@@ -18,30 +18,31 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
import org.springframework.stereotype.Component;
/**
- * Listener for Control Loop Update messages sent by CLAMP.
+ * Listener for Automation Composition Update messages sent by ACM.
*/
@Component
-public class ControlLoopUpdateListener extends ParticipantListener<ControlLoopUpdate> {
+public class AutomationCompositionUpdateListener extends ParticipantListener<AutomationCompositionUpdate> {
/**
* Constructs the object.
*
* @param participantHandler the handler for managing the state of the participant
*/
- public ControlLoopUpdateListener(final ParticipantHandler participantHandler) {
- super(ControlLoopUpdate.class, participantHandler, participantHandler::handleControlLoopUpdate);
+ public AutomationCompositionUpdateListener(final ParticipantHandler participantHandler) {
+ super(AutomationCompositionUpdate.class, participantHandler,
+ participantHandler::handleAutomationCompositionUpdate);
}
@Override
public String getType() {
- return ParticipantMessageType.CONTROL_LOOP_UPDATE.name();
+ return ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE.name();
}
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/MessageSender.java
index e11c883b4..0810a8a8a 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/MessageSender.java
@@ -18,15 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
import java.io.Closeable;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantAckListener.java
index 95bbb2940..c5427db6b 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantAckListener.java
@@ -21,12 +21,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
import java.util.function.Consumer;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.Listener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.Listener;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.listeners.ScoListener;
import org.onap.policy.common.utils.coder.StandardCoderObject;
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantDeregisterAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantDeregisterAckListener.java
index 5440e005b..51a2d2f9d 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantDeregisterAckListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantDeregisterAckListener.java
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
import org.springframework.stereotype.Component;
/**
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantListener.java
index 5326ccddc..0eaf25cca 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantListener.java
@@ -19,12 +19,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
import java.util.function.Consumer;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.Listener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.Listener;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.listeners.ScoListener;
import org.onap.policy.common.utils.coder.StandardCoderObject;
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java
index 79d62623c..67814a4e6 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java
@@ -19,17 +19,17 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
import java.util.List;
import javax.ws.rs.core.Response.Status;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.Publisher;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.Publisher;
+import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
+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.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.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
import org.slf4j.Logger;
@@ -69,7 +69,7 @@ public class ParticipantMessagePublisher implements Publisher {
*/
public void sendParticipantStatus(final ParticipantStatus participantStatus) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
+ throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantStatus);
LOGGER.debug("Sent Participant Status message to CLAMP - {}", participantStatus);
@@ -82,7 +82,7 @@ public class ParticipantMessagePublisher implements Publisher {
*/
public void sendParticipantRegister(final ParticipantRegister participantRegister) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
+ throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantRegister);
LOGGER.debug("Sent Participant Register message to CLAMP - {}", participantRegister);
@@ -95,7 +95,7 @@ public class ParticipantMessagePublisher implements Publisher {
*/
public void sendParticipantDeregister(final ParticipantDeregister participantDeregister) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
+ throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantDeregister);
LOGGER.debug("Sent Participant Deregister message to CLAMP - {}", participantDeregister);
@@ -108,23 +108,23 @@ public class ParticipantMessagePublisher implements Publisher {
*/
public void sendParticipantUpdateAck(final ParticipantUpdateAck participantUpdateAck) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
+ throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantUpdateAck);
LOGGER.debug("Sent Participant Update Ack message to CLAMP - {}", participantUpdateAck);
}
/**
- * Method to send ControlLoop Update/StateChange Ack message to runtime.
+ * Method to send AutomationComposition Update/StateChange Ack message to runtime.
*
- * @param controlLoopAck ControlLoop Update/StateChange Ack
+ * @param automationCompositionAck AutomationComposition Update/StateChange Ack
*/
- public void sendControlLoopAck(final ControlLoopAck controlLoopAck) {
+ public void sendAutomationCompositionAck(final AutomationCompositionAck automationCompositionAck) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
+ throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
- topicSinkClient.send(controlLoopAck);
- LOGGER.debug("Sent ControlLoop Update/StateChange Ack to runtime - {}", controlLoopAck);
+ topicSinkClient.send(automationCompositionAck);
+ LOGGER.debug("Sent AutomationComposition Update/StateChange Ack to runtime - {}", automationCompositionAck);
}
/**
@@ -134,7 +134,7 @@ public class ParticipantMessagePublisher implements Publisher {
*/
public void sendHeartbeat(final ParticipantStatus participantStatus) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
+ throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantStatus);
LOGGER.debug("Sent Participant heartbeat to CLAMP - {}", participantStatus);
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantRegisterAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantRegisterAckListener.java
index 7be460815..e29fa6f96 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantRegisterAckListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantRegisterAckListener.java
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck;
import org.springframework.stereotype.Component;
/**
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusReqListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantStatusReqListener.java
index 9e978fe75..7af3678d7 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusReqListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantStatusReqListener.java
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatusReq;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq;
import org.springframework.stereotype.Component;
/**
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantUpdateListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantUpdateListener.java
index da45501e7..19eb5fb30 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantUpdateListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantUpdateListener.java
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.springframework.stereotype.Component;
/**
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
new file mode 100644
index 000000000..7e1fb5443
--- /dev/null
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
@@ -0,0 +1,476 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.intermediary.handler;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import lombok.Getter;
+import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
+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.AcElementStatistics;
+import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
+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.AutomationCompositions;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates;
+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.AutomationCompositionStateChange;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/*
+ * This class is responsible for managing the state of all automation compositions in the participant.
+ */
+@Component
+public class AutomationCompositionHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionHandler.class);
+
+ private final ToscaConceptIdentifier participantType;
+ private final ToscaConceptIdentifier participantId;
+ private final ParticipantMessagePublisher publisher;
+
+ @Getter
+ private final Map<ToscaConceptIdentifier, AutomationComposition> automationCompositionMap = new LinkedHashMap<>();
+
+ @Getter
+ private final Map<UUID, AutomationCompositionElement> elementsOnThisParticipant = new LinkedHashMap<>();
+
+ @Getter
+ private List<AutomationCompositionElementListener> listeners = new ArrayList<>();
+
+ /**
+ * Constructor, set the participant ID and messageSender.
+ *
+ * @param parameters the parameters of the participant
+ * @param publisher the ParticipantMessage Publisher
+ */
+ public AutomationCompositionHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher) {
+ this.participantType = parameters.getIntermediaryParameters().getParticipantType();
+ this.participantId = parameters.getIntermediaryParameters().getParticipantId();
+ this.publisher = publisher;
+ }
+
+ public void registerAutomationCompositionElementListener(AutomationCompositionElementListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Handle a automation composition element state change message.
+ *
+ * @param automationCompositionId the automationComposition Id
+ * @param id the automationComposition UUID
+ * @param orderedState the current state
+ * @param newState the ordered state
+ * @return automationCompositionElement the updated automation composition element
+ */
+ public AutomationCompositionElement updateAutomationCompositionElementState(
+ ToscaConceptIdentifier automationCompositionId, UUID id, AutomationCompositionOrderedState orderedState,
+ AutomationCompositionState newState) {
+
+ if (id == null) {
+ LOGGER.warn("Cannot update Automation composition element state, id is null");
+ return null;
+ }
+
+ // Update states of AutomationCompositionElement in automationCompositionMap
+ for (var automationComposition : automationCompositionMap.values()) {
+ var element = automationComposition.getElements().get(id);
+ if (element != null) {
+ element.setOrderedState(orderedState);
+ element.setState(newState);
+ }
+ var checkOpt = automationComposition.getElements().values().stream()
+ .filter(acElement -> !newState.equals(acElement.getState())).findAny();
+ if (checkOpt.isEmpty()) {
+ automationComposition.setState(newState);
+ automationComposition.setOrderedState(orderedState);
+ }
+ }
+
+ // Update states of AutomationCompositionElement in elementsOnThisParticipant
+ var acElement = elementsOnThisParticipant.get(id);
+ if (acElement != null) {
+ var automationCompositionStateChangeAck =
+ new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
+ automationCompositionStateChangeAck.setParticipantId(participantId);
+ automationCompositionStateChangeAck.setParticipantType(participantType);
+ automationCompositionStateChangeAck.setAutomationCompositionId(automationCompositionId);
+ acElement.setOrderedState(orderedState);
+ acElement.setState(newState);
+ automationCompositionStateChangeAck.getAutomationCompositionResultMap().put(acElement.getId(),
+ new AutomationCompositionElementAck(newState, true,
+ "Automation composition element {} state changed to {}\", id, newState)"));
+ LOGGER.debug("Automation composition element {} state changed to {}", id, newState);
+ automationCompositionStateChangeAck
+ .setMessage("AutomationCompositionElement state changed to {} " + newState);
+ automationCompositionStateChangeAck.setResult(true);
+ publisher.sendAutomationCompositionAck(automationCompositionStateChangeAck);
+ return acElement;
+ }
+ return null;
+ }
+
+ /**
+ * Handle a automation composition element statistics.
+ *
+ * @param id automation composition element id
+ * @param elementStatistics automation composition element Statistics
+ */
+ public void updateAutomationCompositionElementStatistics(UUID id, AcElementStatistics elementStatistics) {
+ var acElement = elementsOnThisParticipant.get(id);
+ if (acElement != null) {
+ elementStatistics.setParticipantId(participantId);
+ elementStatistics.setId(id);
+ acElement.setAcElementStatistics(elementStatistics);
+ }
+ }
+
+ /**
+ * Handle a automation composition state change message.
+ *
+ * @param stateChangeMsg the state change message
+ * @param acElementDefinitions the list of AutomationCompositionElementDefinition
+ */
+ public void handleAutomationCompositionStateChange(AutomationCompositionStateChange stateChangeMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ if (stateChangeMsg.getAutomationCompositionId() == null) {
+ return;
+ }
+
+ var automationComposition = automationCompositionMap.get(stateChangeMsg.getAutomationCompositionId());
+
+ if (automationComposition == null) {
+ var automationCompositionAck =
+ new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
+ automationCompositionAck.setParticipantId(participantId);
+ automationCompositionAck.setParticipantType(participantType);
+ automationCompositionAck.setMessage("Automation composition " + stateChangeMsg.getAutomationCompositionId()
+ + " does not use this participant " + participantId);
+ automationCompositionAck.setResult(false);
+ automationCompositionAck.setResponseTo(stateChangeMsg.getMessageId());
+ automationCompositionAck.setAutomationCompositionId(stateChangeMsg.getAutomationCompositionId());
+ publisher.sendAutomationCompositionAck(automationCompositionAck);
+ LOGGER.debug("Automation composition {} does not use this participant",
+ stateChangeMsg.getAutomationCompositionId());
+ return;
+ }
+
+ handleState(automationComposition, stateChangeMsg.getOrderedState(), stateChangeMsg.getStartPhase(),
+ acElementDefinitions);
+ }
+
+ /**
+ * Method to handle state changes.
+ *
+ * @param automationComposition participant response
+ * @param orderedState automation composition ordered state
+ * @param startPhaseMsg startPhase from message
+ * @param acElementDefinitions the list of AutomationCompositionElementDefinition
+ */
+ private void handleState(final AutomationComposition automationComposition,
+ AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ switch (orderedState) {
+ case UNINITIALISED:
+ handleUninitialisedState(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
+ break;
+ case PASSIVE:
+ handlePassiveState(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
+ break;
+ case RUNNING:
+ handleRunningState(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
+ break;
+ default:
+ LOGGER.debug("StateChange message has no state, state is null {}",
+ automationComposition.getDefinition());
+ break;
+ }
+ }
+
+ /**
+ * Handle a automation composition update message.
+ *
+ * @param updateMsg the update message
+ * @param acElementDefinitions the list of AutomationCompositionElementDefinition
+ */
+ public void handleAutomationCompositionUpdate(AutomationCompositionUpdate updateMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+
+ if (!updateMsg.appliesTo(participantType, participantId)) {
+ return;
+ }
+
+ if (0 == updateMsg.getStartPhase()) {
+ handleAcUpdatePhase0(updateMsg, acElementDefinitions);
+ } else {
+ handleAcUpdatePhaseN(updateMsg, acElementDefinitions);
+ }
+ }
+
+ private void handleAcUpdatePhase0(AutomationCompositionUpdate updateMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ var automationComposition = automationCompositionMap.get(updateMsg.getAutomationCompositionId());
+
+ // TODO: Updates to existing AutomationCompositions are not supported yet (Addition/Removal of
+ // AutomationComposition
+ // elements to existing AutomationComposition has to be supported).
+ if (automationComposition != null) {
+ var automationCompositionUpdateAck =
+ new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK);
+ automationCompositionUpdateAck.setParticipantId(participantId);
+ automationCompositionUpdateAck.setParticipantType(participantType);
+
+ automationCompositionUpdateAck.setMessage("Automation composition " + updateMsg.getAutomationCompositionId()
+ + " already defined on participant " + participantId);
+ automationCompositionUpdateAck.setResult(false);
+ automationCompositionUpdateAck.setResponseTo(updateMsg.getMessageId());
+ automationCompositionUpdateAck.setAutomationCompositionId(updateMsg.getAutomationCompositionId());
+ publisher.sendAutomationCompositionAck(automationCompositionUpdateAck);
+ return;
+ }
+
+ if (updateMsg.getParticipantUpdatesList().isEmpty()) {
+ LOGGER.warn("No AutomationCompositionElement updates in message {}",
+ updateMsg.getAutomationCompositionId());
+ return;
+ }
+
+ var acElements = storeElementsOnThisParticipant(updateMsg.getParticipantUpdatesList());
+
+ var acElementMap = prepareAcElementMap(acElements);
+ automationComposition = new AutomationComposition();
+ automationComposition.setDefinition(updateMsg.getAutomationCompositionId());
+ automationComposition.setElements(acElementMap);
+ automationCompositionMap.put(updateMsg.getAutomationCompositionId(), automationComposition);
+
+ handleAutomationCompositionElementUpdate(acElements, acElementDefinitions, updateMsg.getStartPhase(),
+ updateMsg.getAutomationCompositionId());
+ }
+
+ private void handleAcUpdatePhaseN(AutomationCompositionUpdate updateMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+
+ var acElementList = updateMsg.getParticipantUpdatesList().stream()
+ .flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream())
+ .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
+
+ handleAutomationCompositionElementUpdate(acElementList, acElementDefinitions, updateMsg.getStartPhase(),
+ updateMsg.getAutomationCompositionId());
+ }
+
+ private void handleAutomationCompositionElementUpdate(List<AutomationCompositionElement> acElements,
+ List<AutomationCompositionElementDefinition> acElementDefinitions, Integer startPhaseMsg,
+ ToscaConceptIdentifier automationCompositionId) {
+ try {
+ for (var element : acElements) {
+ var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, element.getDefinition());
+ if (acElementNodeTemplate != null) {
+ int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties());
+ if (startPhaseMsg.equals(startPhase)) {
+ for (var acElementListener : listeners) {
+ acElementListener.automationCompositionElementUpdate(automationCompositionId, element,
+ acElementNodeTemplate);
+ }
+ }
+ }
+ }
+ } catch (PfModelException e) {
+ LOGGER.debug("Automation composition element update failed {}", automationCompositionId);
+ }
+
+ }
+
+ private ToscaNodeTemplate getAcElementNodeTemplate(
+ List<AutomationCompositionElementDefinition> acElementDefinitions, ToscaConceptIdentifier acElementDefId) {
+
+ for (var acElementDefinition : acElementDefinitions) {
+ if (acElementDefId.getName().contains(acElementDefinition.getAcElementDefinitionId().getName())) {
+ return acElementDefinition.getAutomationCompositionElementToscaNodeTemplate();
+ }
+ }
+ return null;
+ }
+
+ private List<AutomationCompositionElement> storeElementsOnThisParticipant(
+ List<ParticipantUpdates> participantUpdates) {
+ var acElementList = participantUpdates.stream()
+ .flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream())
+ .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
+
+ for (var element : acElementList) {
+ elementsOnThisParticipant.put(element.getId(), element);
+ }
+ return acElementList;
+ }
+
+ private Map<UUID, AutomationCompositionElement> prepareAcElementMap(List<AutomationCompositionElement> acElements) {
+ Map<UUID, AutomationCompositionElement> acElementMap = new LinkedHashMap<>();
+ for (var element : acElements) {
+ acElementMap.put(element.getId(), element);
+ }
+ return acElementMap;
+ }
+
+ /**
+ * Method to handle when the new state from participant is UNINITIALISED state.
+ *
+ * @param automationComposition participant response
+ * @param orderedState orderedState
+ * @param startPhaseMsg startPhase from message
+ * @param acElementDefinitions the list of AutomationCompositionElementDefinition
+ */
+ private void handleUninitialisedState(final AutomationComposition automationComposition,
+ final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ handleStateChange(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
+ boolean isAllUninitialised = automationComposition.getElements().values().stream()
+ .filter(element -> !AutomationCompositionState.UNINITIALISED.equals(element.getState())).findAny()
+ .isEmpty();
+ if (isAllUninitialised) {
+ automationCompositionMap.remove(automationComposition.getDefinition());
+ automationComposition.getElements().values()
+ .forEach(element -> elementsOnThisParticipant.remove(element.getId()));
+ }
+ }
+
+ /**
+ * Method to handle when the new state from participant is PASSIVE state.
+ *
+ * @param automationComposition participant response
+ * @param orderedState orderedState
+ * @param startPhaseMsg startPhase from message
+ * @param acElementDefinitions the list of AutomationCompositionElementDefinition
+ */
+ private void handlePassiveState(final AutomationComposition automationComposition,
+ final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ handleStateChange(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
+ }
+
+ /**
+ * Method to handle when the new state from participant is RUNNING state.
+ *
+ * @param automationComposition participant response
+ * @param orderedState orderedState
+ * @param startPhaseMsg startPhase from message
+ * @param acElementDefinitions the list of AutomationCompositionElementDefinition
+ */
+ private void handleRunningState(final AutomationComposition automationComposition,
+ final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ handleStateChange(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
+ }
+
+ /**
+ * Method to update the state of automation composition elements.
+ *
+ * @param automationComposition participant status in memory
+ * @param orderedState orderedState the new ordered state the participant should have
+ * @param startPhaseMsg startPhase from message
+ * @param acElementDefinitions the list of AutomationCompositionElementDefinition
+ */
+ private void handleStateChange(AutomationComposition automationComposition,
+ final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+
+ if (orderedState.equals(automationComposition.getOrderedState())) {
+ var automationCompositionAck =
+ new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
+ automationCompositionAck.setParticipantId(participantId);
+ automationCompositionAck.setParticipantType(participantType);
+ automationCompositionAck.setMessage("Automation composition is already in state " + orderedState);
+ automationCompositionAck.setResult(false);
+ automationCompositionAck.setAutomationCompositionId(automationComposition.getDefinition());
+ publisher.sendAutomationCompositionAck(automationCompositionAck);
+ return;
+ }
+
+ automationComposition.getElements().values().stream()
+ .forEach(acElement -> automationCompositionElementStateChange(automationComposition, orderedState,
+ acElement, startPhaseMsg, acElementDefinitions));
+ }
+
+ private void automationCompositionElementStateChange(AutomationComposition automationComposition,
+ AutomationCompositionOrderedState orderedState, AutomationCompositionElement acElement, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, acElement.getDefinition());
+ if (acElementNodeTemplate != null) {
+ int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties());
+ if (startPhaseMsg.equals(startPhase)) {
+ for (var acElementListener : listeners) {
+ try {
+ acElementListener.automationCompositionElementStateChange(automationComposition.getDefinition(),
+ acElement.getId(), acElement.getState(), orderedState);
+ } catch (PfModelException e) {
+ LOGGER.debug("Automation composition element update failed {}",
+ automationComposition.getDefinition());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Get automation compositions as a {@link ConrolLoops} class.
+ *
+ * @return the automation compositions
+ */
+ public AutomationCompositions getAutomationCompositions() {
+ var automationCompositions = new AutomationCompositions();
+ automationCompositions.setAutomationCompositionList(new ArrayList<>(automationCompositionMap.values()));
+ return automationCompositions;
+ }
+
+ /**
+ * Get properties of a automation composition element.
+ *
+ * @param id the automation composition element id
+ * @return the instance properties
+ */
+ public Map<String, ToscaProperty> getAcElementInstanceProperties(UUID id) {
+ Map<String, ToscaProperty> propertiesMap = new HashMap<>();
+ for (var automationComposition : automationCompositionMap.values()) {
+ var element = automationComposition.getElements().get(id);
+ if (element != null) {
+ propertiesMap.putAll(element.getPropertiesMap());
+ }
+ }
+ return propertiesMap;
+ }
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivator.java
index e42fac46e..0144f669c 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivator.java
@@ -19,13 +19,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
+package org.onap.policy.clamp.acm.participant.intermediary.handler;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import lombok.Getter;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
@@ -61,16 +61,15 @@ public class IntermediaryActivator extends ServiceManagerContainer implements Cl
* @param publishers list of Publishers
* @param listeners list of Listeners
*/
- public <T> IntermediaryActivator(final ParticipantParameters parameters,
- ParticipantHandler participantHandler, List<Publisher> publishers,
- List<Listener<T>> listeners) {
+ public <T> IntermediaryActivator(final ParticipantParameters parameters, ParticipantHandler participantHandler,
+ List<Publisher> publishers, List<Listener<T>> listeners) {
this.participantHandler = participantHandler;
- topicSinks = TopicEndpointManager.getManager()
- .addTopicSinks(parameters.getIntermediaryParameters().getClampControlLoopTopics().getTopicSinks());
+ topicSinks = TopicEndpointManager.getManager().addTopicSinks(
+ parameters.getIntermediaryParameters().getClampAutomationCompositionTopics().getTopicSinks());
- topicSources = TopicEndpointManager.getManager()
- .addTopicSources(parameters.getIntermediaryParameters().getClampControlLoopTopics().getTopicSources());
+ topicSources = TopicEndpointManager.getManager().addTopicSources(
+ parameters.getIntermediaryParameters().getClampAutomationCompositionTopics().getTopicSources());
msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES);
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Listener.java
index 19bad9a67..56ed55441 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Listener.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
+package org.onap.policy.clamp.acm.participant.intermediary.handler;
import org.onap.policy.common.endpoints.listeners.ScoListener;
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
index 89a13a84b..fa02f3dcf 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
@@ -20,7 +20,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
+package org.onap.policy.clamp.acm.participant.intermediary.handler;
import java.time.Instant;
import java.util.ArrayList;
@@ -32,33 +32,33 @@ import java.util.UUID;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.Setter;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatusReq;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
+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.AcElementStatisticsList;
+import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+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.AutomationCompositionStatistics;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+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.concepts.ParticipantStatistics;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck;
+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.ParticipantRegisterAck;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
@@ -79,7 +79,7 @@ public class ParticipantHandler {
@Getter
private final ToscaConceptIdentifier participantId;
- private final ControlLoopHandler controlLoopHandler;
+ private final AutomationCompositionHandler automationCompositionHandler;
private final ParticipantStatistics participantStatistics;
private final ParticipantMessagePublisher publisher;
@@ -89,7 +89,7 @@ public class ParticipantHandler {
@Setter
private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN;
- private final List<ControlLoopElementDefinition> clElementDefsOnThisParticipant = new ArrayList<>();
+ private final List<AutomationCompositionElementDefinition> acElementDefsOnThisParticipant = new ArrayList<>();
/**
* Constructor, set the participant ID and sender.
@@ -98,11 +98,11 @@ public class ParticipantHandler {
* @param publisher the publisher for sending responses to messages
*/
public ParticipantHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher,
- ControlLoopHandler controlLoopHandler) {
+ AutomationCompositionHandler automationCompositionHandler) {
this.participantType = parameters.getIntermediaryParameters().getParticipantType();
this.participantId = parameters.getIntermediaryParameters().getParticipantId();
this.publisher = publisher;
- this.controlLoopHandler = controlLoopHandler;
+ this.automationCompositionHandler = automationCompositionHandler;
this.participantStatistics = new ParticipantStatistics();
this.participantStatistics.setParticipantId(participantId);
this.participantStatistics.setState(state);
@@ -121,42 +121,45 @@ public class ParticipantHandler {
}
/**
- * Update ControlLoopElement statistics. The control loop elements listening will be
- * notified to retrieve statistics from respective controlloop elements, and controlloopelements
+ * Update AutomationCompositionElement statistics. The automation composition elements listening will be
+ * notified to retrieve statistics from respective automation composition elements, and automation
+ * compositionelements
* data on the handler will be updated.
*
- * @param controlLoops the control loops
- * @param clElementListener control loop element listener
+ * @param automationCompositions the automation compositions
+ * @param acElementListener automation composition element listener
*/
- private void updateClElementStatistics(ControlLoops controlLoops, ControlLoopElementListener clElementListener) {
- for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- for (ControlLoopElement element : controlLoop.getElements().values()) {
+ private void updateAcElementStatistics(AutomationCompositions automationCompositions,
+ AutomationCompositionElementListener acElementListener) {
+ for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) {
+ for (AutomationCompositionElement element : automationComposition.getElements().values()) {
try {
- clElementListener.handleStatistics(element.getId());
+ acElementListener.handleStatistics(element.getId());
} catch (PfModelException e) {
- LOGGER.debug("Getting statistics for Control loop element failed for element ID {}",
- element.getId(), e);
+ LOGGER.debug("Getting statistics for automation composition element failed for element ID {}",
+ element.getId(), e);
}
}
}
}
/**
- * Handle a control loop update message.
+ * Handle a automation composition update message.
*
* @param updateMsg the update message
*/
- public void handleControlLoopUpdate(ControlLoopUpdate updateMsg) {
- controlLoopHandler.handleControlLoopUpdate(updateMsg, clElementDefsOnThisParticipant);
+ public void handleAutomationCompositionUpdate(AutomationCompositionUpdate updateMsg) {
+ automationCompositionHandler.handleAutomationCompositionUpdate(updateMsg, acElementDefsOnThisParticipant);
}
/**
- * Handle a control loop state change message.
+ * Handle a automation composition state change message.
*
* @param stateChangeMsg the state change message
*/
- public void handleControlLoopStateChange(ControlLoopStateChange stateChangeMsg) {
- controlLoopHandler.handleControlLoopStateChange(stateChangeMsg, clElementDefsOnThisParticipant);
+ public void handleAutomationCompositionStateChange(AutomationCompositionStateChange stateChangeMsg) {
+ automationCompositionHandler.handleAutomationCompositionStateChange(stateChangeMsg,
+ acElementDefsOnThisParticipant);
}
private void handleStateChange(ParticipantState newParticipantState, ParticipantUpdateAck response) {
@@ -221,15 +224,15 @@ public class ParticipantHandler {
}
/**
- * Get common properties of a controlloopelement.
+ * Get common properties of a automation composition element.
*
- * @param clElementDef the control loop element definition
+ * @param acElementDef the automation composition element definition
* @return the common properties
*/
- public Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef) {
+ public Map<String, ToscaProperty> getAcElementDefinitionCommonProperties(ToscaConceptIdentifier acElementDef) {
Map<String, ToscaProperty> commonPropertiesMap = new HashMap<>();
- clElementDefsOnThisParticipant.stream().forEach(definition -> {
- if (definition.getClElementDefinitionId().equals(clElementDef)) {
+ acElementDefsOnThisParticipant.stream().forEach(definition -> {
+ if (definition.getAcElementDefinitionId().equals(acElementDef)) {
commonPropertiesMap.putAll(definition.getCommonPropertiesMap());
}
});
@@ -257,7 +260,7 @@ public class ParticipantHandler {
}
/**
- * Method to send ParticipantRegister message to controlloop runtime.
+ * Method to send ParticipantRegister message to automation composition runtime.
*/
public void sendParticipantRegister() {
var participantRegister = new ParticipantRegister();
@@ -274,7 +277,7 @@ public class ParticipantHandler {
*/
public void handleParticipantRegisterAck(ParticipantRegisterAck participantRegisterAckMsg) {
LOGGER.debug("ParticipantRegisterAck message received as responseTo {}",
- participantRegisterAckMsg.getResponseTo());
+ participantRegisterAckMsg.getResponseTo());
statusToPassive();
publisher.sendParticipantStatus(makeHeartbeat(false));
}
@@ -291,7 +294,7 @@ public class ParticipantHandler {
}
/**
- * Method to send ParticipantDeregister message to controlloop runtime.
+ * Method to send ParticipantDeregister message to automation composition runtime.
*/
public void sendParticipantDeregister() {
var participantDeregister = new ParticipantDeregister();
@@ -308,7 +311,7 @@ public class ParticipantHandler {
*/
public void handleParticipantDeregisterAck(ParticipantDeregisterAck participantDeregisterAckMsg) {
LOGGER.debug("ParticipantDeregisterAck message received as responseTo {}",
- participantDeregisterAckMsg.getResponseTo());
+ participantDeregisterAckMsg.getResponseTo());
}
/**
@@ -318,27 +321,28 @@ public class ParticipantHandler {
*/
public void handleParticipantUpdate(ParticipantUpdate participantUpdateMsg) {
LOGGER.debug("ParticipantUpdate message received for participantId {}",
- participantUpdateMsg.getParticipantId());
+ participantUpdateMsg.getParticipantId());
if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) {
statusToPassive();
- // This message is to commission the controlloop
+ // This message is to commission the automation composition
for (ParticipantDefinition participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) {
if (participantDefinition.getParticipantType().equals(participantType)) {
- clElementDefsOnThisParticipant.addAll(participantDefinition.getControlLoopElementDefinitionList());
+ acElementDefsOnThisParticipant
+ .addAll(participantDefinition.getAutomationCompositionElementDefinitionList());
break;
}
}
} else {
- // This message is to decommission the controlloop
- clElementDefsOnThisParticipant.clear();
+ // This message is to decommission the automation composition
+ acElementDefsOnThisParticipant.clear();
this.state = ParticipantState.TERMINATED;
}
sendParticipantUpdateAck(participantUpdateMsg.getMessageId());
}
/**
- * Method to send ParticipantUpdateAck message to controlloop runtime.
+ * Method to send ParticipantUpdateAck message to automation composition runtime.
*/
public void sendParticipantUpdateAck(UUID messageId) {
var participantUpdateAck = new ParticipantUpdateAck();
@@ -359,13 +363,13 @@ public class ParticipantHandler {
}
/**
- * Method to send heartbeat to controlloop runtime.
+ * Method to send heartbeat to automation composition runtime.
*/
public ParticipantStatus makeHeartbeat(boolean responseToParticipantStatusReq) {
if (!responseToParticipantStatusReq) {
- var controlLoops = controlLoopHandler.getControlLoops();
- for (var clElementListener : controlLoopHandler.getListeners()) {
- updateClElementStatistics(controlLoops, clElementListener);
+ var automationCompositions = automationCompositionHandler.getAutomationCompositions();
+ for (var acElementListener : automationCompositionHandler.getListeners()) {
+ updateAcElementStatistics(automationCompositions, acElementListener);
}
}
this.participantStatistics.setState(state);
@@ -378,38 +382,35 @@ public class ParticipantHandler {
heartbeat.setParticipantType(participantType);
heartbeat.setHealthStatus(healthStatus);
heartbeat.setState(state);
- heartbeat.setControlLoopInfoList(getControlLoopInfoList());
+ heartbeat.setAutomationCompositionInfoList(getAutomationCompositionInfoList());
if (responseToParticipantStatusReq) {
ParticipantDefinition participantDefinition = new ParticipantDefinition();
participantDefinition.setParticipantId(participantId);
participantDefinition.setParticipantType(participantType);
- participantDefinition.setControlLoopElementDefinitionList(clElementDefsOnThisParticipant);
+ participantDefinition.setAutomationCompositionElementDefinitionList(acElementDefsOnThisParticipant);
heartbeat.setParticipantDefinitionUpdates(List.of(participantDefinition));
}
return heartbeat;
}
- private List<ControlLoopInfo> getControlLoopInfoList() {
- List<ControlLoopInfo> controlLoopInfoList = new ArrayList<>();
- for (var entry : controlLoopHandler.getControlLoopMap().entrySet()) {
- var clInfo = new ControlLoopInfo();
- clInfo.setControlLoopId(entry.getKey());
- var clStatitistics = new ControlLoopStatistics();
- clStatitistics.setControlLoopId(entry.getKey());
- var clElementStatisticsList = new ClElementStatisticsList();
- clElementStatisticsList
- .setClElementStatistics(entry.getValue().getElements().values()
- .stream()
- .map(ControlLoopElement::getClElementStatistics)
- .filter(Objects::nonNull)
- .collect(Collectors.toList()));
- clStatitistics.setClElementStatisticsList(clElementStatisticsList);
- clInfo.setControlLoopStatistics(clStatitistics);
- clInfo.setState(entry.getValue().getState());
- controlLoopInfoList.add(clInfo);
+ private List<AutomationCompositionInfo> getAutomationCompositionInfoList() {
+ List<AutomationCompositionInfo> automationCompositionInfoList = new ArrayList<>();
+ for (var entry : automationCompositionHandler.getAutomationCompositionMap().entrySet()) {
+ var acInfo = new AutomationCompositionInfo();
+ acInfo.setAutomationCompositionId(entry.getKey());
+ var acStatitistics = new AutomationCompositionStatistics();
+ acStatitistics.setAutomationCompositionId(entry.getKey());
+ var acElementStatisticsList = new AcElementStatisticsList();
+ acElementStatisticsList.setAcElementStatistics(entry.getValue().getElements().values().stream()
+ .map(AutomationCompositionElement::getAcElementStatistics).filter(Objects::nonNull)
+ .collect(Collectors.toList()));
+ acStatitistics.setAcElementStatisticsList(acElementStatisticsList);
+ acInfo.setAutomationCompositionStatistics(acStatitistics);
+ acInfo.setState(entry.getValue().getState());
+ automationCompositionInfoList.add(acInfo);
}
- return controlLoopInfoList;
+ return automationCompositionInfoList;
}
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Publisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Publisher.java
index 287d7c055..72aa645fd 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Publisher.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Publisher.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
+package org.onap.policy.clamp.acm.participant.intermediary.handler;
import java.util.List;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
index fdc451e6b..dcbfd1b2e 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.parameters;
+package org.onap.policy.clamp.acm.participant.intermediary.parameters;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
@@ -50,12 +50,12 @@ public class ParticipantIntermediaryParameters {
@Valid
private ToscaConceptIdentifier participantType;
- // The time interval for periodic reporting of status to the CLAMP control loop server
+ // The time interval for periodic reporting of status to the CLAMP ACM server
@Valid
@Positive
private long reportingTimeIntervalMs;
@NotNull
@ParameterGroupConstraint
- private TopicParameterGroup clampControlLoopTopics;
+ private TopicParameterGroup clampAutomationCompositionTopics;
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantParameters.java
index c350b1b95..ca9c56607 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantParameters.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantParameters.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.parameters;
+package org.onap.policy.clamp.acm.participant.intermediary.parameters;
public interface ParticipantParameters {
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java
deleted file mode 100644
index 58378fa41..000000000
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.intermediary.api;
-
-import java.util.UUID;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-
-/**
- * This interface is implemented by participant implementations to receive updates on control loop elements.
- */
-public interface ControlLoopElementListener {
- /**
- * Handle a control loop element state change.
- *
- * @param controlLoopElementId the ID of the control loop element
- * @param currentState the current state of the control loop element
- * @param newState the state to which the control loop element is changing to
- * @throws PfModelException in case of a model exception
- */
- public void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId, UUID controlLoopElementId,
- ControlLoopState currentState, ControlLoopOrderedState newState) throws PfModelException;
-
- /**
- * Handle an update on a control loop element.
- *
- * @param element the information on the control loop element
- * @param controlLoopElementDefinition toscaNodeTemplate
- * @throws PfModelException from Policy framework
- */
- public void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, ControlLoopElement element,
- ToscaNodeTemplate controlLoopElementDefinition) throws PfModelException;
-
- /**
- * Handle controlLoopElement statistics.
- *
- * @param controlLoopElementId controlLoopElement id
- * @throws PfModelException in case of a model exception
- */
- public void handleStatistics(UUID controlLoopElementId) throws PfModelException;
-}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
deleted file mode 100644
index 0cb4963ec..000000000
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.intermediary.api;
-
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
-
-/**
- * This interface is used by participant implementations to use the participant intermediary.
- */
-public interface ParticipantIntermediaryApi {
-
- /**
- * Register a listener for control loop elements that are mediated by the intermediary.
- *
- * @param controlLoopElementListener The control loop element listener to register
- */
- void registerControlLoopElementListener(ControlLoopElementListener controlLoopElementListener);
-
- /**
- * Get participants loops from the intermediary API.
- *
- * @param name the participant name, null for all
- * @param version the participant version, null for all
- * @return the participants
- */
- List<Participant> getParticipants(String name, String version);
-
- /**
- * Get common properties of a controlloopelement.
- *
- * @param clElementDef the control loop element definition
- * @return the common properties
- */
- Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef);
-
- /**
- * Update the state of a participant.
- *
- * @param definition the definition of the participant to update the state on
- * @param state the state of the participant
- * @return the participant
- */
- Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state);
-
- /**
- * Update the statistics of a participant.
- *
- * @param participantStatistics the statistics of the participant
- */
- void updateParticipantStatistics(ParticipantStatistics participantStatistics);
-
- /**
- * Get control loops from the intermediary API.
- *
- * @param name the control loop element name, null for all
- * @param version the control loop element version, null for all
- * @return the control loop elements
- */
- ControlLoops getControlLoops(String name, String version);
-
- /**
- * Get control loop elements from the intermediary API.
- *
- * @param name the control loop element name, null for all
- * @param version the control loop element version, null for all
- * @return the control loop elements
- */
- Map<UUID, ControlLoopElement> getControlLoopElements(String name, String version);
-
- /**
- * Get control loop element from the intermediary API.
- *
- * @param id control loop element ID
- * @return the control loop element
- */
- ControlLoopElement getControlLoopElement(UUID id);
-
- /**
- * Update the state of a control loop element.
- *
- * @param id the ID of the control loop element to update the state on
- * @param currentState the state of the control loop element
- * @param newState the state of the control loop element
- * @return ControlLoopElement updated control loop element
- */
- ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId,
- UUID id, ControlLoopOrderedState currentState,
- ControlLoopState newState, ParticipantMessageType messageType);
-
- /**
- * Update the control loop element statistics.
- *
- * @param id the ID of the control loop element to update the state on
- * @param elementStatistics the updated statistics
- */
- void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics);
-}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
deleted file mode 100644
index bbafc4678..000000000
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.intermediary.api.impl;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ControlLoopHandler;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
-import org.springframework.stereotype.Component;
-
-/**
- * This class is api implementation used by participant intermediary.
- */
-@Component
-public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryApi {
-
- // The handler for the participant intermediary
- private final ParticipantHandler participantHandler;
-
- // The handler for the controlLoop intermediary
- private final ControlLoopHandler controlLoopHandler;
-
- /**
- * Constructor.
- *
- * @param participantHandler ParticipantHandler
- * @param controlLoopHandler ControlLoopHandler
- */
- public ParticipantIntermediaryApiImpl(ParticipantHandler participantHandler,
- ControlLoopHandler controlLoopHandler) {
- this.participantHandler = participantHandler;
- this.controlLoopHandler = controlLoopHandler;
- }
-
- @Override
- public void registerControlLoopElementListener(ControlLoopElementListener controlLoopElementListener) {
- controlLoopHandler.registerControlLoopElementListener(controlLoopElementListener);
- }
-
- @Override
- public List<Participant> getParticipants(String name, String version) {
- return List.of(participantHandler.getParticipant(name, version));
- }
-
- @Override
- public Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef) {
- return participantHandler.getClElementDefinitionCommonProperties(clElementDef);
- }
-
- @Override
- public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state) {
- return participantHandler.updateParticipantState(definition, state);
- }
-
- @Override
- public void updateParticipantStatistics(ParticipantStatistics participantStatistics) {
- participantHandler.updateParticipantStatistics(participantStatistics);
- }
-
- @Override
- public ControlLoops getControlLoops(String name, String version) {
- return controlLoopHandler.getControlLoops();
- }
-
- @Override
- public Map<UUID, ControlLoopElement> getControlLoopElements(String name, String version) {
- List<ControlLoop> controlLoops = controlLoopHandler.getControlLoops().getControlLoopList();
-
- for (ControlLoop controlLoop : controlLoops) {
- if (name.equals(controlLoop.getDefinition().getName())) {
- return controlLoop.getElements();
- }
- }
- return new LinkedHashMap<>();
- }
-
- @Override
- public ControlLoopElement getControlLoopElement(UUID id) {
- List<ControlLoop> controlLoops = controlLoopHandler.getControlLoops().getControlLoopList();
-
- for (ControlLoop controlLoop : controlLoops) {
- ControlLoopElement clElement = controlLoop.getElements().get(id);
- if (clElement != null) {
- return clElement;
- }
- }
- return null;
- }
-
- @Override
- public ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId,
- UUID id, ControlLoopOrderedState currentState,
- ControlLoopState newState, ParticipantMessageType messageType) {
- return controlLoopHandler.updateControlLoopElementState(controlLoopId,
- id, currentState, newState);
- }
-
- @Override
- public void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics) {
- controlLoopHandler.updateControlLoopElementStatistics(id, elementStatistics);
- }
-}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
deleted file mode 100644
index 5a0f4989f..000000000
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.stream.Collectors;
-import lombok.Getter;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementAck;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/*
- * This class is responsible for managing the state of all control loops in the participant.
- */
-@Component
-public class ControlLoopHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopHandler.class);
-
- private final ToscaConceptIdentifier participantType;
- private final ToscaConceptIdentifier participantId;
- private final ParticipantMessagePublisher publisher;
-
- @Getter
- private final Map<ToscaConceptIdentifier, ControlLoop> controlLoopMap = new LinkedHashMap<>();
-
- @Getter
- private final Map<UUID, ControlLoopElement> elementsOnThisParticipant = new LinkedHashMap<>();
-
- @Getter
- private List<ControlLoopElementListener> listeners = new ArrayList<>();
-
- /**
- * Constructor, set the participant ID and messageSender.
- *
- * @param parameters the parameters of the participant
- * @param publisher the ParticipantMessage Publisher
- */
- public ControlLoopHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher) {
- this.participantType = parameters.getIntermediaryParameters().getParticipantType();
- this.participantId = parameters.getIntermediaryParameters().getParticipantId();
- this.publisher = publisher;
- }
-
- public void registerControlLoopElementListener(ControlLoopElementListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Handle a control loop element state change message.
- *
- * @param controlLoopId the controlLoop Id
- * @param id the controlLoop UUID
- * @param orderedState the current state
- * @param newState the ordered state
- * @return controlLoopElement the updated controlloop element
- */
- public ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId, UUID id,
- ControlLoopOrderedState orderedState, ControlLoopState newState) {
-
- if (id == null) {
- LOGGER.warn("Cannot update Control loop element state, id is null");
- return null;
- }
-
- // Update states of ControlLoopElement in controlLoopMap
- for (var controlLoop : controlLoopMap.values()) {
- var element = controlLoop.getElements().get(id);
- if (element != null) {
- element.setOrderedState(orderedState);
- element.setState(newState);
- }
- var checkOpt = controlLoop.getElements().values().stream()
- .filter(clElement -> !newState.equals(clElement.getState())).findAny();
- if (checkOpt.isEmpty()) {
- controlLoop.setState(newState);
- controlLoop.setOrderedState(orderedState);
- }
- }
-
- // Update states of ControlLoopElement in elementsOnThisParticipant
- var clElement = elementsOnThisParticipant.get(id);
- if (clElement != null) {
- var controlLoopStateChangeAck = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK);
- controlLoopStateChangeAck.setParticipantId(participantId);
- controlLoopStateChangeAck.setParticipantType(participantType);
- controlLoopStateChangeAck.setControlLoopId(controlLoopId);
- clElement.setOrderedState(orderedState);
- clElement.setState(newState);
- controlLoopStateChangeAck.getControlLoopResultMap().put(clElement.getId(), new ControlLoopElementAck(
- newState, true, "Control loop element {} state changed to {}\", id, newState)"));
- LOGGER.debug("Control loop element {} state changed to {}", id, newState);
- controlLoopStateChangeAck.setMessage("ControlLoopElement state changed to {} " + newState);
- controlLoopStateChangeAck.setResult(true);
- publisher.sendControlLoopAck(controlLoopStateChangeAck);
- return clElement;
- }
- return null;
- }
-
- /**
- * Handle a control loop element statistics.
- *
- * @param id controlloop element id
- * @param elementStatistics control loop element Statistics
- */
- public void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics) {
- var clElement = elementsOnThisParticipant.get(id);
- if (clElement != null) {
- elementStatistics.setParticipantId(participantId);
- elementStatistics.setId(id);
- clElement.setClElementStatistics(elementStatistics);
- }
- }
-
- /**
- * Handle a control loop state change message.
- *
- * @param stateChangeMsg the state change message
- * @param clElementDefinitions the list of ControlLoopElementDefinition
- */
- public void handleControlLoopStateChange(ControlLoopStateChange stateChangeMsg,
- List<ControlLoopElementDefinition> clElementDefinitions) {
- if (stateChangeMsg.getControlLoopId() == null) {
- return;
- }
-
- var controlLoop = controlLoopMap.get(stateChangeMsg.getControlLoopId());
-
- if (controlLoop == null) {
- var controlLoopAck = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK);
- controlLoopAck.setParticipantId(participantId);
- controlLoopAck.setParticipantType(participantType);
- controlLoopAck.setMessage("Control loop " + stateChangeMsg.getControlLoopId()
- + " does not use this participant " + participantId);
- controlLoopAck.setResult(false);
- controlLoopAck.setResponseTo(stateChangeMsg.getMessageId());
- controlLoopAck.setControlLoopId(stateChangeMsg.getControlLoopId());
- publisher.sendControlLoopAck(controlLoopAck);
- LOGGER.debug("Control loop {} does not use this participant", stateChangeMsg.getControlLoopId());
- return;
- }
-
- handleState(controlLoop, stateChangeMsg.getOrderedState(), stateChangeMsg.getStartPhase(),
- clElementDefinitions);
- }
-
- /**
- * Method to handle state changes.
- *
- * @param controlLoop participant response
- * @param orderedState controlloop ordered state
- * @param startPhaseMsg startPhase from message
- * @param clElementDefinitions the list of ControlLoopElementDefinition
- */
- private void handleState(final ControlLoop controlLoop, ControlLoopOrderedState orderedState, Integer startPhaseMsg,
- List<ControlLoopElementDefinition> clElementDefinitions) {
- switch (orderedState) {
- case UNINITIALISED:
- handleUninitialisedState(controlLoop, orderedState, startPhaseMsg, clElementDefinitions);
- break;
- case PASSIVE:
- handlePassiveState(controlLoop, orderedState, startPhaseMsg, clElementDefinitions);
- break;
- case RUNNING:
- handleRunningState(controlLoop, orderedState, startPhaseMsg, clElementDefinitions);
- break;
- default:
- LOGGER.debug("StateChange message has no state, state is null {}", controlLoop.getDefinition());
- break;
- }
- }
-
- /**
- * Handle a control loop update message.
- *
- * @param updateMsg the update message
- * @param clElementDefinitions the list of ControlLoopElementDefinition
- */
- public void handleControlLoopUpdate(ControlLoopUpdate updateMsg,
- List<ControlLoopElementDefinition> clElementDefinitions) {
-
- if (!updateMsg.appliesTo(participantType, participantId)) {
- return;
- }
-
- if (0 == updateMsg.getStartPhase()) {
- handleClUpdatePhase0(updateMsg, clElementDefinitions);
- } else {
- handleClUpdatePhaseN(updateMsg, clElementDefinitions);
- }
- }
-
- private void handleClUpdatePhase0(ControlLoopUpdate updateMsg,
- List<ControlLoopElementDefinition> clElementDefinitions) {
- var controlLoop = controlLoopMap.get(updateMsg.getControlLoopId());
-
- // TODO: Updates to existing ControlLoops are not supported yet (Addition/Removal of ControlLoop
- // elements to existing ControlLoop has to be supported).
- if (controlLoop != null) {
- var controlLoopUpdateAck = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_UPDATE_ACK);
- controlLoopUpdateAck.setParticipantId(participantId);
- controlLoopUpdateAck.setParticipantType(participantType);
-
- controlLoopUpdateAck.setMessage("Control loop " + updateMsg.getControlLoopId()
- + " already defined on participant " + participantId);
- controlLoopUpdateAck.setResult(false);
- controlLoopUpdateAck.setResponseTo(updateMsg.getMessageId());
- controlLoopUpdateAck.setControlLoopId(updateMsg.getControlLoopId());
- publisher.sendControlLoopAck(controlLoopUpdateAck);
- return;
- }
-
- if (updateMsg.getParticipantUpdatesList().isEmpty()) {
- LOGGER.warn("No ControlLoopElement updates in message {}", updateMsg.getControlLoopId());
- return;
- }
-
- var clElements = storeElementsOnThisParticipant(updateMsg.getParticipantUpdatesList());
-
- var clElementMap = prepareClElementMap(clElements);
- controlLoop = new ControlLoop();
- controlLoop.setDefinition(updateMsg.getControlLoopId());
- controlLoop.setElements(clElementMap);
- controlLoopMap.put(updateMsg.getControlLoopId(), controlLoop);
-
- handleControlLoopElementUpdate(clElements, clElementDefinitions, updateMsg.getStartPhase(),
- updateMsg.getControlLoopId());
- }
-
- private void handleClUpdatePhaseN(ControlLoopUpdate updateMsg,
- List<ControlLoopElementDefinition> clElementDefinitions) {
-
- var clElementList = updateMsg.getParticipantUpdatesList().stream()
- .flatMap(participantUpdate -> participantUpdate.getControlLoopElementList().stream())
- .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
-
- handleControlLoopElementUpdate(clElementList, clElementDefinitions, updateMsg.getStartPhase(),
- updateMsg.getControlLoopId());
- }
-
- private void handleControlLoopElementUpdate(List<ControlLoopElement> clElements,
- List<ControlLoopElementDefinition> clElementDefinitions, Integer startPhaseMsg,
- ToscaConceptIdentifier controlLoopId) {
- try {
- for (var element : clElements) {
- var clElementNodeTemplate = getClElementNodeTemplate(clElementDefinitions, element.getDefinition());
- if (clElementNodeTemplate != null) {
- int startPhase = ParticipantUtils.findStartPhase(clElementNodeTemplate.getProperties());
- if (startPhaseMsg.equals(startPhase)) {
- for (var clElementListener : listeners) {
- clElementListener.controlLoopElementUpdate(controlLoopId, element, clElementNodeTemplate);
- }
- }
- }
- }
- } catch (PfModelException e) {
- LOGGER.debug("Control loop element update failed {}", controlLoopId);
- }
-
- }
-
- private ToscaNodeTemplate getClElementNodeTemplate(List<ControlLoopElementDefinition> clElementDefinitions,
- ToscaConceptIdentifier clElementDefId) {
-
- for (var clElementDefinition : clElementDefinitions) {
- if (clElementDefId.getName().contains(clElementDefinition.getClElementDefinitionId().getName())) {
- return clElementDefinition.getControlLoopElementToscaNodeTemplate();
- }
- }
- return null;
- }
-
- private List<ControlLoopElement> storeElementsOnThisParticipant(List<ParticipantUpdates> participantUpdates) {
- var clElementList = participantUpdates.stream()
- .flatMap(participantUpdate -> participantUpdate.getControlLoopElementList().stream())
- .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
-
- for (var element : clElementList) {
- elementsOnThisParticipant.put(element.getId(), element);
- }
- return clElementList;
- }
-
- private Map<UUID, ControlLoopElement> prepareClElementMap(List<ControlLoopElement> clElements) {
- Map<UUID, ControlLoopElement> clElementMap = new LinkedHashMap<>();
- for (var element : clElements) {
- clElementMap.put(element.getId(), element);
- }
- return clElementMap;
- }
-
- /**
- * Method to handle when the new state from participant is UNINITIALISED state.
- *
- * @param controlLoop participant response
- * @param orderedState orderedState
- * @param startPhaseMsg startPhase from message
- * @param clElementDefinitions the list of ControlLoopElementDefinition
- */
- private void handleUninitialisedState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- Integer startPhaseMsg, List<ControlLoopElementDefinition> clElementDefinitions) {
- handleStateChange(controlLoop, orderedState, startPhaseMsg, clElementDefinitions);
- boolean isAllUninitialised = controlLoop.getElements().values().stream()
- .filter(element -> !ControlLoopState.UNINITIALISED.equals(element.getState())).findAny().isEmpty();
- if (isAllUninitialised) {
- controlLoopMap.remove(controlLoop.getDefinition());
- controlLoop.getElements().values().forEach(element -> elementsOnThisParticipant.remove(element.getId()));
- }
- }
-
- /**
- * Method to handle when the new state from participant is PASSIVE state.
- *
- * @param controlLoop participant response
- * @param orderedState orderedState
- * @param startPhaseMsg startPhase from message
- * @param clElementDefinitions the list of ControlLoopElementDefinition
- */
- private void handlePassiveState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- Integer startPhaseMsg, List<ControlLoopElementDefinition> clElementDefinitions) {
- handleStateChange(controlLoop, orderedState, startPhaseMsg, clElementDefinitions);
- }
-
- /**
- * Method to handle when the new state from participant is RUNNING state.
- *
- * @param controlLoop participant response
- * @param orderedState orderedState
- * @param startPhaseMsg startPhase from message
- * @param clElementDefinitions the list of ControlLoopElementDefinition
- */
- private void handleRunningState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- Integer startPhaseMsg, List<ControlLoopElementDefinition> clElementDefinitions) {
- handleStateChange(controlLoop, orderedState, startPhaseMsg, clElementDefinitions);
- }
-
- /**
- * Method to update the state of control loop elements.
- *
- * @param controlLoop participant status in memory
- * @param orderedState orderedState the new ordered state the participant should have
- * @param startPhaseMsg startPhase from message
- * @param clElementDefinitions the list of ControlLoopElementDefinition
- */
- private void handleStateChange(ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- Integer startPhaseMsg, List<ControlLoopElementDefinition> clElementDefinitions) {
-
- if (orderedState.equals(controlLoop.getOrderedState())) {
- var controlLoopAck = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK);
- controlLoopAck.setParticipantId(participantId);
- controlLoopAck.setParticipantType(participantType);
- controlLoopAck.setMessage("Control loop is already in state " + orderedState);
- controlLoopAck.setResult(false);
- controlLoopAck.setControlLoopId(controlLoop.getDefinition());
- publisher.sendControlLoopAck(controlLoopAck);
- return;
- }
-
- controlLoop.getElements().values().stream().forEach(clElement -> controlLoopElementStateChange(controlLoop,
- orderedState, clElement, startPhaseMsg, clElementDefinitions));
- }
-
- private void controlLoopElementStateChange(ControlLoop controlLoop, ControlLoopOrderedState orderedState,
- ControlLoopElement clElement, Integer startPhaseMsg,
- List<ControlLoopElementDefinition> clElementDefinitions) {
- var clElementNodeTemplate = getClElementNodeTemplate(clElementDefinitions, clElement.getDefinition());
- if (clElementNodeTemplate != null) {
- int startPhase = ParticipantUtils.findStartPhase(clElementNodeTemplate.getProperties());
- if (startPhaseMsg.equals(startPhase)) {
- for (var clElementListener : listeners) {
- try {
- clElementListener.controlLoopElementStateChange(controlLoop.getDefinition(), clElement.getId(),
- clElement.getState(), orderedState);
- } catch (PfModelException e) {
- LOGGER.debug("Control loop element update failed {}", controlLoop.getDefinition());
- }
- }
- }
- }
- }
-
- /**
- * Get control loops as a {@link ConrolLoops} class.
- *
- * @return the control loops
- */
- public ControlLoops getControlLoops() {
- var controlLoops = new ControlLoops();
- controlLoops.setControlLoopList(new ArrayList<>(controlLoopMap.values()));
- return controlLoops;
- }
-
- /**
- * Get properties of a controlloopelement.
- *
- * @param id the control loop element id
- * @return the instance properties
- */
- public Map<String, ToscaProperty> getClElementInstanceProperties(UUID id) {
- Map<String, ToscaProperty> propertiesMap = new HashMap<>();
- for (var controlLoop : controlLoopMap.values()) {
- var element = controlLoop.getElements().get(id);
- if (element != null) {
- propertiesMap.putAll(element.getPropertiesMap());
- }
- }
- return propertiesMap;
- }
-}