From c9624f0e437db1d91b7076a1abdf71f74b5024dc Mon Sep 17 00:00:00 2001
From: liamfallon
Date: Fri, 21 May 2021 15:00:36 +0100
Subject: Move tosca-controlloop src directries to new modules
This is the second stage of the TOSCA Controlloop merge.
In this review, the src directories of the old tosca-controlloop modules
are moved to the new modules off the root of the clamp repo and the
pom.xml files are updated with dependencies to allow the build of the
moved modules to run.
So the changes are renaming of files and updates of POM files in the
modules to which src directories are added so that the build works, and
of course deletion of the tosca-controlloop directory and its sub-
modules
The third and final review will follow this, which will merge the
tosca-poc branch onto master, in effect merging this review to master.
The differences with the clamp master repo are shown here:
diff -qr clamp clamp-tp | diff_filter.sh
Files clamp/INFO.yaml and clamp-tp/INFO.yaml differ
Only in clamp-tp/common: src
Only in clamp-tp/models: src
Files clamp/participant/participant-impl/participant-impl-dcae/pom.xml and clamp-tp/participant/participant-impl/participant-impl-dcae/pom.xml differ
Only in clamp-tp/participant/participant-impl/participant-impl-dcae: src
Only in clamp-tp/participant/participant-impl/participant-impl-policy: src
Only in clamp-tp/participant/participant-impl/participant-impl-simulator: src
Files clamp/participant/participant-impl/pom.xml and clamp-tp/participant/participant-impl/pom.xml differ
Only in clamp-tp/participant/participant-intermediary: src
Files clamp/participant/pom.xml and clamp-tp/participant/pom.xml differ
Files clamp/pom.xml and clamp-tp/pom.xml differ
Only in clamp/releases: 6.0.1-container.yaml
Only in clamp/releases: 6.0.1.yaml
Only in clamp/releases: 6.0.2-container.yaml
Only in clamp/releases: 6.0.2.yaml
Only in clamp/releases: 6.1.0-container.yaml
Only in clamp/releases: 6.1.0.yaml
Only in clamp/releases: 6.1.1-container.yaml
Only in clamp/releases: 6.1.1.yaml
Files clamp/runtime/pom.xml and clamp-tp/runtime/pom.xml differ
Only in clamp-tp: runtime-controlloop
Issue-ID: POLICY-3215
Change-Id: I0e69e3c566ea387d61f77cfa118bb6d67b4f8253
Signed-off-by: liamfallon
---
.../commissioning/CommissioningHandler.java | 81 ++++
.../commissioning/CommissioningProvider.java | 208 ++++++++++
.../rest/CommissioningController.java | 360 +++++++++++++++++
.../ControlLoopInstantiationProvider.java | 276 +++++++++++++
.../instantiation/InstantiationHandler.java | 82 ++++
.../rest/InstantiationController.java | 416 +++++++++++++++++++
.../main/parameters/ClRuntimeParameterGroup.java | 55 +++
.../main/parameters/ClRuntimeParameterHandler.java | 77 ++++
.../main/parameters/ParticipantParameters.java | 59 +++
.../ParticipantStateChangeParameters.java | 53 +++
.../parameters/ParticipantUpdateParameters.java | 54 +++
.../runtime/main/rest/ControlLoopAafFilter.java | 38 ++
.../runtime/main/rest/RestController.java | 115 ++++++
.../runtime/main/startstop/ClRuntimeActivator.java | 186 +++++++++
.../startstop/ClRuntimeCommandLineArguments.java | 151 +++++++
.../controlloop/runtime/main/startstop/Main.java | 156 +++++++
.../runtime/monitoring/MonitoringHandler.java | 84 ++++
.../runtime/monitoring/MonitoringProvider.java | 273 +++++++++++++
.../monitoring/rest/MonitoringQueryController.java | 371 +++++++++++++++++
.../runtime/supervision/SupervisionHandler.java | 450 +++++++++++++++++++++
.../runtime/supervision/SupervisionScanner.java | 116 ++++++
...ParticipantControlLoopStateChangePublisher.java | 75 ++++
.../ParticipantControlLoopUpdatePublisher.java | 75 ++++
.../comm/ParticipantStateChangePublisher.java | 74 ++++
.../comm/ParticipantStatusListener.java | 53 +++
.../src/main/resources/META-INF/persistence.xml | 121 ++++++
runtime-controlloop/src/main/resources/version.txt | 4 +
27 files changed, 4063 insertions(+)
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/ControlLoopAafFilter.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java
create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
create mode 100644 runtime-controlloop/src/main/resources/META-INF/persistence.xml
create mode 100644 runtime-controlloop/src/main/resources/version.txt
(limited to 'runtime-controlloop/src/main')
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
new file mode 100644
index 000000000..88e8b1df9
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.commissioning;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+import javax.ws.rs.core.Response;
+import lombok.Getter;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.rest.CommissioningController;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.models.base.PfModelRuntimeException;
+
+/**
+ * This class handles commissioning of control loop definitions.
+ */
+public final class CommissioningHandler extends ControlLoopHandler {
+
+ @Getter
+ private CommissioningProvider provider;
+
+ /**
+ * Gets the CommissioningHandler.
+ *
+ * @return CommissioningHandler
+ */
+ public static CommissioningHandler getInstance() {
+ return Registry.get(CommissioningHandler.class.getName());
+ }
+
+ /**
+ * Create a handler.
+ *
+ * @param controlLoopParameters the parameters for access to the database
+ */
+ public CommissioningHandler(ClRuntimeParameterGroup controlLoopParameters) {
+ super(controlLoopParameters.getDatabaseProviderParameters());
+ }
+
+ @Override
+ public Set> getProviderClasses() {
+ return Set.of(CommissioningController.class);
+ }
+
+ @Override
+ public void startProviders() {
+ provider = new CommissioningProvider(getDatabaseProviderParameters());
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ provider.close();
+ } catch (IOException e) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
+ "an error has occured while stopping commissioning providers", e);
+ }
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
new file mode 100644
index 000000000..50f6787b9
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
@@ -0,0 +1,208 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.commissioning;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+
+/**
+ * This class provides the create, read and delete actions on Commissioning of Control Loop concepts in the database to
+ * the callers.
+ */
+public class CommissioningProvider implements Closeable {
+ public static final String CONTROL_LOOP_NODE_TYPE = "org.onap.policy.clamp.controlloop.ControlLoop";
+
+ private final PolicyModelsProvider modelsProvider;
+ private final ControlLoopProvider clProvider;
+
+ private static final Object lockit = new Object();
+
+ /**
+ * Create a commissioning provider.
+ *
+ * @throws ControlLoopRuntimeException on errors creating the provider
+ */
+ public CommissioningProvider(PolicyModelsProviderParameters databaseProviderParameters)
+ throws ControlLoopRuntimeException {
+ try {
+ modelsProvider = new PolicyModelsProviderFactory()
+ .createPolicyModelsProvider(databaseProviderParameters);
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(e);
+ }
+
+ try {
+ clProvider = new ControlLoopProvider(databaseProviderParameters);
+ } catch (PfModelException e) {
+ throw new PfModelRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ modelsProvider.close();
+ } catch (PfModelException e) {
+ throw new IOException("error closing modelsProvider", e);
+ }
+ }
+
+ /**
+ * Create control loops from a service template.
+ *
+ * @param serviceTemplate the service template
+ * @return the result of the commissioning operation
+ * @throws PfModelException on creation errors
+ */
+ public CommissioningResponse createControlLoopDefinitions(ToscaServiceTemplate serviceTemplate)
+ throws PfModelException {
+ synchronized (lockit) {
+ modelsProvider.createServiceTemplate(serviceTemplate);
+ }
+
+ CommissioningResponse response = new CommissioningResponse();
+ // @formatter:off
+ response.setAffectedControlLoopDefinitions(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates()
+ .values()
+ .stream()
+ .map(template -> template.getKey().asIdentifier())
+ .collect(Collectors.toList()));
+ // @formatter:on
+
+ return response;
+ }
+
+ /**
+ * Delete the control loop definition with the given name and version.
+ *
+ * @param name the name of the control loop definition to delete
+ * @param version the version of the control loop to delete
+ * @return the result of the deletion
+ * @throws PfModelException on deletion errors
+ */
+ public CommissioningResponse deleteControlLoopDefinition(String name, String version) throws PfModelException {
+ synchronized (lockit) {
+ modelsProvider.deleteServiceTemplate(name, version);
+ }
+
+ CommissioningResponse response = new CommissioningResponse();
+ response.setAffectedControlLoopDefinitions(
+ Collections.singletonList(new ToscaConceptIdentifier(name, version)));
+
+ return response;
+ }
+
+ /**
+ * Get control loop node templates.
+ *
+ * @param clName the name of the control loop, null for all
+ * @param clVersion the version of the control loop, null for all
+ * @return list of control loop node templates
+ * @throws PfModelException on errors getting control loop definitions
+ */
+ public List getControlLoopDefinitions(String clName, String clVersion) throws PfModelException {
+
+ // @formatter:off
+ ToscaTypedEntityFilter nodeTemplateFilter = ToscaTypedEntityFilter
+ .builder()
+ .name(clName)
+ .version(clVersion)
+ .type(CONTROL_LOOP_NODE_TYPE)
+ .build();
+ // @formatter:on
+
+ return clProvider.getFilteredNodeTemplates(nodeTemplateFilter);
+ }
+
+ /**
+ * Get the control loop elements from a control loop node template.
+ *
+ * @param controlLoopNodeTemplate the control loop node template
+ * @return a list of the control loop element node templates in a control loop node template
+ * @throws PfModelException on errors get control loop element node templates
+ */
+ public List getControlLoopElementDefinitions(ToscaNodeTemplate controlLoopNodeTemplate)
+ throws PfModelException {
+ if (!CONTROL_LOOP_NODE_TYPE.equals(controlLoopNodeTemplate.getType())) {
+ return Collections.emptyList();
+ }
+
+ if (MapUtils.isEmpty(controlLoopNodeTemplate.getProperties())) {
+ return Collections.emptyList();
+ }
+
+ @SuppressWarnings("unchecked")
+ List
Causes supervision to start or continue supervision on the control loops in question.
+ *
+ * @param controlLoopIdentifierList the control loops for which the supervision command has been issued
+ * @throws ControlLoopException on supervision triggering exceptions
+ */
+ public void triggerControlLoopSupervision(List controlLoopIdentifierList)
+ throws ControlLoopException {
+
+ LOGGER.debug("triggering control loop supervision on control loops {}", controlLoopIdentifierList);
+
+ if (CollectionUtils.isEmpty(controlLoopIdentifierList)) {
+ // This is just to force throwing of the exception in certain circumstances.
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ "The list of control loops for supervision is empty");
+ }
+
+ for (ToscaConceptIdentifier controlLoopId : controlLoopIdentifierList) {
+ try {
+ ControlLoop controlLoop = controlLoopProvider.getControlLoop(controlLoopId);
+
+ superviseControlLoop(controlLoop);
+
+ controlLoopProvider.updateControlLoop(controlLoop);
+ } catch (PfModelException pfme) {
+ throw new ControlLoopException(pfme.getErrorResponse().getResponseCode(), pfme.getMessage(), pfme);
+ }
+ }
+ }
+
+ @Override
+ public void startAndRegisterListeners(MessageTypeDispatcher msgDispatcher) {
+ msgDispatcher.register(ParticipantMessageType.PARTICIPANT_STATUS.name(), new ParticipantStatusListener());
+ }
+
+ @Override
+ public void startAndRegisterPublishers(List topicSinks) {
+ // TODO: Use a parameter for the timeout
+ // @formatter:off
+ this.publisherManager = new ServiceManager()
+ .addAction("Supervision scanner",
+ () -> scanner = new SupervisionScanner(controlLoopProvider, 10000),
+ () -> scanner = null)
+ .addAction("ControlLoopUpdate publisher",
+ () -> controlLoopUpdatePublisher = new ParticipantControlLoopUpdatePublisher(topicSinks, -1),
+ () -> controlLoopUpdatePublisher.terminate())
+ .addAction("StateChange Publisher",
+ () -> stateChangePublisher = new ParticipantStateChangePublisher(topicSinks, 10000),
+ () -> stateChangePublisher.terminate())
+ .addAction("ControlLoopStateChange Publisher",
+ () -> controlLoopStateChangePublisher =
+ new ParticipantControlLoopStateChangePublisher(topicSinks, -1),
+ () -> controlLoopStateChangePublisher.terminate());
+ // @formatter:on
+ try {
+ publisherManager.start();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler start of publishers or scanner failed", exp);
+ }
+ }
+
+ @Override
+ public void stopAndUnregisterPublishers() {
+ try {
+ publisherManager.stop();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler stop of publishers or scanner failed", exp);
+ }
+ }
+
+ @Override
+ public void stopAndUnregisterListeners(MessageTypeDispatcher msgDispatcher) {
+ msgDispatcher.unregister(ParticipantMessageType.PARTICIPANT_STATUS.name());
+ }
+
+ /**
+ * Handle a ParticipantStatus message from a participant.
+ *
+ * @param participantStatusMessage the ParticipantStatus message received from a participant
+ */
+ public void handleParticipantStatusMessage(ParticipantStatus participantStatusMessage) {
+ LOGGER.debug("Participant Status received {}", participantStatusMessage);
+
+ try {
+ superviseParticipant(participantStatusMessage);
+ } catch (PfModelException | ControlLoopException svExc) {
+ LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc);
+ return;
+ }
+
+ try {
+ superviseControlLoops(participantStatusMessage);
+ } catch (PfModelException | ControlLoopException svExc) {
+ LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc);
+ }
+ }
+
+ /**
+ * Supervise a control loop, performing whatever actions need to be performed on the control loop.
+ *
+ * @param controlLoop the control loop to supervises
+ * @throws ControlLoopException on supervision errors
+ */
+ private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException {
+ switch (controlLoop.getOrderedState()) {
+ case UNINITIALISED:
+ superviseControlLoopUninitialization(controlLoop);
+ break;
+
+ case PASSIVE:
+ superviseControlLoopPassivation(controlLoop);
+ break;
+
+ case RUNNING:
+ superviseControlLoopActivation(controlLoop);
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ "A control loop cannot be commanded to go into state " + controlLoop.getOrderedState().name());
+ }
+ }
+
+ /**
+ * Supervise a control loop uninitialisation, performing whatever actions need to be performed on the control loop,
+ * control loop ordered state is UNINITIALIZED.
+ *
+ * @param controlLoop the control loop to supervises
+ * @throws ControlLoopException on supervision errors
+ */
+ private void superviseControlLoopUninitialization(ControlLoop controlLoop) throws ControlLoopException {
+ switch (controlLoop.getState()) {
+ case UNINITIALISED:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name());
+ break;
+
+ case UNINITIALISED2PASSIVE:
+ case PASSIVE:
+ controlLoop.setState(ControlLoopState.PASSIVE2UNINITIALISED);
+ sendControlLoopStateChange(controlLoop);
+ break;
+
+ case PASSIVE2UNINITIALISED:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE
+ + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState());
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
+ + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
+ break;
+ }
+ }
+
+ private void superviseControlLoopPassivation(ControlLoop controlLoop)
+ throws ControlLoopException, PfModelException {
+ switch (controlLoop.getState()) {
+ case PASSIVE:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name());
+ break;
+ case UNINITIALISED:
+ controlLoop.setState(ControlLoopState.UNINITIALISED2PASSIVE);
+ sendControlLoopUpdate(controlLoop);
+ break;
+
+ case UNINITIALISED2PASSIVE:
+ case RUNNING2PASSIVE:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE
+ + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState());
+ break;
+
+ case RUNNING:
+ controlLoop.setState(ControlLoopState.RUNNING2PASSIVE);
+ sendControlLoopStateChange(controlLoop);
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
+ + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
+ break;
+ }
+ }
+
+ private void superviseControlLoopActivation(ControlLoop controlLoop) throws ControlLoopException {
+ switch (controlLoop.getState()) {
+ case RUNNING:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name());
+ break;
+
+ case PASSIVE2RUNNING:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE
+ + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState());
+ break;
+
+ case PASSIVE:
+ controlLoop.setState(ControlLoopState.PASSIVE2RUNNING);
+ sendControlLoopStateChange(controlLoop);
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
+ + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
+ break;
+ }
+ }
+
+ private void sendControlLoopUpdate(ControlLoop controlLoop) throws PfModelException {
+ ParticipantControlLoopUpdate pclu = new ParticipantControlLoopUpdate();
+ pclu.setControlLoopId(controlLoop.getKey().asIdentifier());
+ pclu.setControlLoop(controlLoop);
+ // TODO: We should look up the correct TOSCA node template here for the control loop
+ // Tiny hack implemented to return the tosca service template entry from the database and be passed onto dmaap
+ commissioningProvider = CommissioningHandler.getInstance().getProvider();
+ pclu.setControlLoopDefinition(commissioningProvider.getToscaServiceTemplate(null, null));
+ controlLoopUpdatePublisher.send(pclu);
+ }
+
+ private void sendControlLoopStateChange(ControlLoop controlLoop) {
+ ParticipantControlLoopStateChange clsc = new ParticipantControlLoopStateChange();
+ clsc.setControlLoopId(controlLoop.getKey().asIdentifier());
+ clsc.setMessageId(UUID.randomUUID());
+ clsc.setOrderedState(controlLoop.getOrderedState());
+
+ controlLoopStateChangePublisher.send(clsc);
+ }
+
+ private void superviseParticipant(ParticipantStatus participantStatusMessage)
+ throws PfModelException, ControlLoopException {
+ if (participantStatusMessage.getParticipantId() == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "Participant ID on PARTICIPANT_STATUS message is null");
+ }
+
+ List participantList =
+ participantProvider.getParticipants(participantStatusMessage.getParticipantId().getName(),
+ participantStatusMessage.getParticipantId().getVersion());
+
+ if (CollectionUtils.isEmpty(participantList)) {
+ Participant participant = new Participant();
+ participant.setName(participantStatusMessage.getParticipantId().getName());
+ participant.setVersion(participantStatusMessage.getParticipantId().getVersion());
+ participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
+ participant.setParticipantState(participantStatusMessage.getState());
+ participant.setHealthStatus(participantStatusMessage.getHealthStatus());
+
+ participantList.add(participant);
+ participantProvider.createParticipants(participantList);
+ } else {
+ for (Participant participant : participantList) {
+ participant.setParticipantState(participantStatusMessage.getState());
+ participant.setHealthStatus(participantStatusMessage.getHealthStatus());
+ }
+ participantProvider.updateParticipants(participantList);
+ }
+
+ monitoringProvider = MonitoringHandler.getInstance().getMonitoringProvider();
+ monitoringProvider.createParticipantStatistics(
+ List.of(participantStatusMessage.getParticipantStatistics()));
+ }
+
+ private void superviseControlLoops(ParticipantStatus participantStatusMessage)
+ throws PfModelException, ControlLoopException {
+ if (CollectionUtils.isEmpty(participantStatusMessage.getControlLoops().getControlLoopList())) {
+ return;
+ }
+
+ for (ControlLoop controlLoop : participantStatusMessage.getControlLoops().getControlLoopList()) {
+ if (controlLoop == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS message references unknown control loop: " + controlLoop);
+ }
+
+ ControlLoop dbControlLoop = controlLoopProvider
+ .getControlLoop(new ToscaConceptIdentifier(controlLoop.getName(), controlLoop.getVersion()));
+ if (dbControlLoop == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS control loop not found in database: " + controlLoop);
+ }
+
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ ControlLoopElement dbElement = dbControlLoop.getElements().get(element.getId());
+
+ if (dbElement == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS message references unknown control loop element: " + element);
+ }
+
+ // Replace element entry in the database
+ dbControlLoop.getElements().put(element.getId(), element);
+ }
+ controlLoopProvider.updateControlLoop(dbControlLoop);
+ }
+
+ monitoringProvider = MonitoringHandler.getInstance().getMonitoringProvider();
+ for (ControlLoop controlLoop : participantStatusMessage.getControlLoops().getControlLoopList()) {
+ monitoringProvider.createClElementStatistics(controlLoop.getControlLoopElementStatisticsList(controlLoop));
+ }
+ }
+
+ @Override
+ public void startProviders() {
+ try {
+ manager.start();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler start of providers failed", exp);
+ }
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ manager.stop();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler stop of providers failed", exp);
+ }
+ }
+
+ private void exceptionOccured(Response.Status status, String reason) throws ControlLoopException {
+ throw new ControlLoopException(status, reason);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
new file mode 100644
index 000000000..0ccfddff3
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision;
+
+import java.io.Closeable;
+import java.util.Collection;
+import java.util.List;
+import java.util.TimerTask;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.models.base.PfModelException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to scan the control loops in the database and check if they are in the correct state.
+ */
+public class SupervisionScanner implements Runnable, Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class);
+
+ private ControlLoopProvider controlLoopProvider;
+ private ScheduledExecutorService timerPool;
+
+ /**
+ * Constructor for instantiating SupervisionScanner.
+ *
+ * @param controlLoopProvider the provider to use to read control loops from the database
+ * @param interval time interval to perform scans
+ */
+ public SupervisionScanner(final ControlLoopProvider controlLoopProvider, final long interval) {
+ this.controlLoopProvider = controlLoopProvider;
+
+ // Kick off the timer
+ timerPool = makeTimerPool();
+ timerPool.scheduleAtFixedRate(this, 0, interval, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void run() {
+ LOGGER.debug("Scanning control loops in the database . . .");
+
+ try {
+ for (ControlLoop controlLoop : controlLoopProvider.getControlLoops(null, null)) {
+ scanControlLoop(controlLoop);
+ }
+ } catch (PfModelException pfme) {
+ LOGGER.warn("error reading control loops from database", pfme);
+ }
+
+ LOGGER.debug("Control loop scan complete . . .");
+ }
+
+ @Override
+ public void close() {
+ timerPool.shutdown();
+ }
+
+ private void scanControlLoop(final ControlLoop controlLoop) throws PfModelException {
+ LOGGER.debug("scanning control loop {} . . .", controlLoop.getKey().asIdentifier());
+
+ if (controlLoop.getState().equals(controlLoop.getOrderedState().asState())) {
+ LOGGER.debug("control loop {} scanned, OK", controlLoop.getKey().asIdentifier());
+ return;
+ }
+
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ if (!element.getState().equals(element.getOrderedState().asState())) {
+ LOGGER.debug("control loop scan: transitioning from state {} to {}", controlLoop.getState(),
+ controlLoop.getOrderedState());
+ return;
+ }
+ }
+
+ LOGGER.debug("control loop scan: transition from state {} to {} completed", controlLoop.getState(),
+ controlLoop.getOrderedState());
+
+ controlLoop.setState(controlLoop.getOrderedState().asState());
+ controlLoopProvider.updateControlLoop(controlLoop);
+ }
+
+ /**
+ * Makes a new timer pool.
+ *
+ * @return a new timer pool
+ */
+ protected ScheduledExecutorService makeTimerPool() {
+ return Executors.newScheduledThreadPool(1);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java
new file mode 100644
index 000000000..c9c8ab851
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send ParticipantControlLoopStateChangePublisher messages to participants on DMaaP.
+ */
+public class ParticipantControlLoopStateChangePublisher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantControlLoopStateChangePublisher.class);
+
+ private TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantControlLoopStateChangePublisherPublisher.
+ *
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send ParticipantControlLoopStateChangePublisher messages
+ */
+ public ParticipantControlLoopStateChangePublisher(final List topicSinks, final long interval) {
+ // TODO: Should not be dependent on the order of topic sinks in the config
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Terminates the current timer.
+ */
+ public void terminate() {
+ // This is a user initiated message and doesn't need a timer.
+ }
+
+ /**
+ * Get the current time interval used by the timer task.
+ *
+ * @return interval the current time interval
+ */
+ public long getInterval() {
+ // This is a user initiated message and doesn't need a timer.
+ return -1;
+ }
+
+ /**
+ * Method to send ParticipantControlLoopStateChangePublisher status message to participants on demand.
+ *
+ * @param controlLoopStateChange the ParticipantControlLoopStateChangePublisher message
+ */
+ public void send(final ParticipantControlLoopStateChange controlLoopStateChange) {
+ topicSinkClient.send(controlLoopStateChange);
+ LOGGER.debug("Sent ParticipantControlLoopStateChange to Participants - {}", controlLoopStateChange);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java
new file mode 100644
index 000000000..3c5d230c5
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send ParticipantControlLoopUpdate messages to participants on DMaaP.
+ */
+public class ParticipantControlLoopUpdatePublisher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantControlLoopUpdatePublisher.class);
+
+ private TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantUpdatePublisher.
+ *
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send ParticipantControlLoopUpdate messages
+ */
+ public ParticipantControlLoopUpdatePublisher(final List topicSinks, final long interval) {
+ // TODO: Should not be dependent on the order of topic sinks in the config
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Terminates the current timer.
+ */
+ public void terminate() {
+ // This is a user initiated message and doesn't need a timer.
+ }
+
+ /**
+ * Get the current time interval used by the timer task.
+ *
+ * @return interval the current time interval
+ */
+ public long getInterval() {
+ // This is a user initiated message and doesn't need a timer.
+ return -1;
+ }
+
+ /**
+ * Method to send ParticipantControlLoopUpdate status message to participants on demand.
+ *
+ * @param participantControlLoopUpdate the ParticipantControlLoopUpdate message
+ */
+ public void send(final ParticipantControlLoopUpdate participantControlLoopUpdate) {
+ topicSinkClient.send(participantControlLoopUpdate);
+ LOGGER.debug("Sent ParticipantControlLoopUpdate to Participants - {}", participantControlLoopUpdate);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java
new file mode 100644
index 000000000..099039115
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send ParticipantStateChange messages to participants on DMaaP.
+ */
+public class ParticipantStateChangePublisher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStateChangePublisher.class);
+
+ private TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantStateChangePublisher.
+ *
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send ParticipantStateChange messages
+ */
+ public ParticipantStateChangePublisher(final List topicSinks, final long interval) {
+ // TODO: Should not be dependent on the order of topic sinks in the config
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Terminates the current timer.
+ */
+ public void terminate() {
+ // Nothing to terminate, this publisher does not have a timer
+ }
+
+ /**
+ * Get the current time interval used by the timer task.
+ *
+ * @return interval the current time interval
+ */
+ public long getInterval() {
+ return -1;
+ }
+
+ /**
+ * Method to send ParticipantStateChange status message to participants on demand.
+ *
+ * @param participantStateChange the ParticipantStateChange message
+ */
+ public void send(final ParticipantStateChange participantStateChange) {
+ topicSinkClient.send(participantStateChange);
+ LOGGER.debug("Sent ParticipantStateChange to Participants - {}", participantStateChange);
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
new file mode 100644
index 000000000..a05f4aa20
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.onap.policy.common.utils.services.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Listener for ParticipantStatus messages sent by participants.
+ */
+public class ParticipantStatusListener extends ScoListener {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusListener.class);
+
+ private final SupervisionHandler supervisionHandler = Registry.get(SupervisionHandler.class.getName());
+
+ /**
+ * Constructs the object.
+ */
+ public ParticipantStatusListener() {
+ super(ParticipantStatus.class);
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantStatus participantStatusMessage) {
+ LOGGER.debug("ParticipantStatus message received from participant - {}", participantStatusMessage);
+ supervisionHandler.handleParticipantStatusMessage(participantStatusMessage);
+ }
+}
diff --git a/runtime-controlloop/src/main/resources/META-INF/persistence.xml b/runtime-controlloop/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 000000000..e5d2cab11
--- /dev/null
+++ b/runtime-controlloop/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,121 @@
+
+
+
+
+ org.eclipse.persistence.jpa.PersistenceProvider
+
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics
+
+
+
+
+
+
+
+
+ NONE
+
+
+
+ org.eclipse.persistence.jpa.PersistenceProvider
+
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate
+ org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics
+ org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics
+
+
+
+
+
+
+
+ NONE
+
+
+
diff --git a/runtime-controlloop/src/main/resources/version.txt b/runtime-controlloop/src/main/resources/version.txt
new file mode 100644
index 000000000..e11449e5b
--- /dev/null
+++ b/runtime-controlloop/src/main/resources/version.txt
@@ -0,0 +1,4 @@
+ONAP Tosca defined control loop
+Version: ${project.version}
+Built (UTC): ${maven.build.timestamp}
+ONAP https://wiki.onap.org
--
cgit 1.2.3-korg