summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src/main
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 /runtime-controlloop/src/main
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 'runtime-controlloop/src/main')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java45
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java378
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/AafConfiguration.java46
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/ConverterConfiguration.java44
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/FilterConfig.java45
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SecurityConfig.java47
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SpringFoxConfig.java45
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java41
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java137
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Publisher.java34
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java619
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java49
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java45
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java46
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java515
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java637
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/MonitoringQueryController.java341
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/AbstractRestController.java91
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/ControlLoopAafFilter.java38
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java67
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RuntimeErrorController.java104
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java243
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounter.java106
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/MessageIntercept.java32
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspect.java105
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java491
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java301
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java62
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantPublisher.java62
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java68
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangePublisher.java50
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java68
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java91
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java45
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java69
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java50
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java69
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java68
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusReqPublisher.java48
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java69
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java127
-rw-r--r--runtime-controlloop/src/main/resources/application.yaml67
-rw-r--r--runtime-controlloop/src/main/resources/version.txt4
43 files changed, 0 insertions, 5709 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java
deleted file mode 100644
index 44a661e55..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java
+++ /dev/null
@@ -1,45 +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.runtime;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.scheduling.annotation.EnableScheduling;
-
-@EnableScheduling
-@SpringBootApplication
-@EnableJpaRepositories({"org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository"})
-@ComponentScan({"org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider",
- "org.onap.policy.clamp.controlloop.runtime",
- "org.onap.policy.clamp.controlloop.common.rest"})
-@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.runtime.main.parameters")
-@EntityScan({"org.onap.policy.models.tosca.simple.concepts",
- "org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts"})
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-}
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
deleted file mode 100644
index 382823b19..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
+++ /dev/null
@@ -1,378 +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.runtime.commissioning;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.PropertyNamingStrategies;
-import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import javax.ws.rs.core.Response.Status;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.MapUtils;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider;
-import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
-import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaRelationshipType;
-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.ToscaTopologyTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * This class provides the create, read and delete actions on Commissioning of Control Loop concepts in the database to
- * the callers.
- */
-@Service
-@Transactional
-public class CommissioningProvider {
- public static final String CONTROL_LOOP_NODE_TYPE = "org.onap.policy.clamp.controlloop.ControlLoop";
- private static final String INSTANCE_TEXT = "_Instance";
-
- private final ServiceTemplateProvider serviceTemplateProvider;
- private final ControlLoopProvider clProvider;
- private final ObjectMapper mapper = new ObjectMapper();
- private final ParticipantProvider participantProvider;
- private final SupervisionHandler supervisionHandler;
-
- /**
- * Create a commissioning provider.
- *
- * @param serviceTemplateProvider the ServiceTemplate Provider
- * @param clProvider the ControlLoop Provider
- * @param supervisionHandler the Supervision Handler
- * @param participantProvider the Participant Provider
- */
- public CommissioningProvider(ServiceTemplateProvider serviceTemplateProvider, ControlLoopProvider clProvider,
- SupervisionHandler supervisionHandler, ParticipantProvider participantProvider) {
- this.serviceTemplateProvider = serviceTemplateProvider;
- this.clProvider = clProvider;
- this.supervisionHandler = supervisionHandler;
- this.participantProvider = participantProvider;
- mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
- }
-
- /**
- * 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 {
-
- if (verifyIfInstancePropertiesExists()) {
- throw new PfModelException(Status.BAD_REQUEST, "Delete instances, to commission control loop definitions");
- }
- serviceTemplate = serviceTemplateProvider.createServiceTemplate(serviceTemplate);
- List<Participant> participantList = participantProvider.getParticipants();
- if (!participantList.isEmpty()) {
- supervisionHandler.handleSendCommissionMessage(serviceTemplate.getName(), serviceTemplate.getVersion());
- }
- var 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 {
-
- if (verifyIfInstancePropertiesExists()) {
- throw new PfModelException(Status.BAD_REQUEST, "Delete instances, to commission control loop definitions");
- }
- List<Participant> participantList = participantProvider.getParticipants();
- if (!participantList.isEmpty()) {
- supervisionHandler.handleSendDeCommissionMessage();
- }
- serviceTemplateProvider.deleteServiceTemplate(name, version);
- var response = new CommissioningResponse();
- response.setAffectedControlLoopDefinitions(List.of(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
- */
- @Transactional(readOnly = true)
- public List<ToscaNodeTemplate> getControlLoopDefinitions(String clName, String clVersion) throws PfModelException {
-
- // @formatter:off
- ToscaTypedEntityFilter<ToscaNodeTemplate> nodeTemplateFilter = ToscaTypedEntityFilter
- .<ToscaNodeTemplate>builder()
- .name(clName)
- .version(clVersion)
- .type(CONTROL_LOOP_NODE_TYPE)
- .build();
- // @formatter:on
-
- return clProvider.getFilteredNodeTemplates(nodeTemplateFilter);
- }
-
- /**
- * Get the control loop elements from a control loop node template.
- *
- * @param controlLoopNodeTemplate the control loop node template
- * @return a list of the control loop element node templates in a control loop node template
- * @throws PfModelException on errors get control loop element node templates
- */
- @Transactional(readOnly = true)
- public List<ToscaNodeTemplate> getControlLoopElementDefinitions(ToscaNodeTemplate controlLoopNodeTemplate)
- throws PfModelException {
- if (!CONTROL_LOOP_NODE_TYPE.equals(controlLoopNodeTemplate.getType())) {
- return Collections.emptyList();
- }
-
- if (MapUtils.isEmpty(controlLoopNodeTemplate.getProperties())) {
- return Collections.emptyList();
- }
-
- @SuppressWarnings("unchecked")
- List<Map<String, String>> controlLoopElements =
- (List<Map<String, String>>) controlLoopNodeTemplate.getProperties().get("elements");
-
- if (CollectionUtils.isEmpty(controlLoopElements)) {
- return Collections.emptyList();
- }
-
- List<ToscaNodeTemplate> controlLoopElementList = new ArrayList<>();
- // @formatter:off
- controlLoopElementList.addAll(
- controlLoopElements
- .stream()
- .map(elementMap -> clProvider.getNodeTemplates(elementMap.get("name"),
- elementMap.get("version")))
- .flatMap(List::stream)
- .collect(Collectors.toList())
- );
- // @formatter:on
-
- return controlLoopElementList;
- }
-
- /**
- * Get node templates with common properties added.
- *
- * @param common boolean indicating common or instance properties to be used
- * @param name the name of the definition to use, null for all definitions
- * @param version the version of the definition to use, null for all definitions
- * @return the nodes templates with common or instance properties
- * @throws PfModelException on errors getting common or instance properties from node_templates
- */
- @Transactional(readOnly = true)
- public Map<String, ToscaNodeTemplate> getNodeTemplatesWithCommonOrInstanceProperties(boolean common, String name,
- String version) throws PfModelException {
-
- if (common && verifyIfInstancePropertiesExists()) {
- throw new PfModelException(Status.BAD_REQUEST,
- "Cannot create or edit common properties, delete all the instantiations first");
- }
-
- var serviceTemplateList = serviceTemplateProvider.getServiceTemplateList(name, version);
- var commonOrInstanceNodeTypeProps =
- serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(common, serviceTemplateList.get(0));
-
- var serviceTemplates = new ToscaServiceTemplates();
- serviceTemplates.setServiceTemplates(filterToscaNodeTemplateInstance(serviceTemplateList));
-
- return serviceTemplateProvider.getDerivedCommonOrInstanceNodeTemplates(
- serviceTemplates.getServiceTemplates().get(0).getToscaTopologyTemplate().getNodeTemplates(),
- commonOrInstanceNodeTypeProps);
- }
-
- /**
- * Get the requested control loop definitions.
- *
- * @param name the name of the definition to get, null for all definitions
- * @param version the version of the definition to get, null for all definitions
- * @return the control loop definitions
- * @throws PfModelException on errors getting control loop definitions
- */
- @Transactional(readOnly = true)
- public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException {
- return serviceTemplateProvider.getToscaServiceTemplate(name, version);
- }
-
- /**
- * Get All the requested control loop definitions.
- *
- * @return the control loop definitions
- * @throws PfModelException on errors getting control loop definitions
- */
- @Transactional(readOnly = true)
- public List<ToscaServiceTemplate> getAllToscaServiceTemplate() throws PfModelException {
- return serviceTemplateProvider.getAllServiceTemplates();
- }
-
- /**
- * Get the tosca service template with only required sections.
- *
- * @param name the name of the template to get, null for all definitions
- * @param version the version of the template to get, null for all definitions
- * @return the tosca service template
- * @throws PfModelException on errors getting tosca service template
- */
- @Transactional(readOnly = true)
- public String getToscaServiceTemplateReduced(String name, String version) throws PfModelException {
- var serviceTemplateList = serviceTemplateProvider.getServiceTemplateList(name, version);
-
- List<ToscaServiceTemplate> filteredServiceTemplateList = filterToscaNodeTemplateInstance(serviceTemplateList);
-
- if (filteredServiceTemplateList.isEmpty()) {
- throw new PfModelException(Status.BAD_REQUEST, "Invalid Service Template");
- }
-
- ToscaServiceTemplate fullTemplate = filteredServiceTemplateList.get(0);
-
- var template = new HashMap<String, Object>();
- template.put("tosca_definitions_version", fullTemplate.getToscaDefinitionsVersion());
- template.put("data_types", fullTemplate.getDataTypes());
- template.put("policy_types", fullTemplate.getPolicyTypes());
- template.put("node_types", fullTemplate.getNodeTypes());
- template.put("topology_template", fullTemplate.getToscaTopologyTemplate());
-
- try {
- return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(template);
-
- } catch (JsonProcessingException e) {
- throw new PfModelException(Status.BAD_REQUEST, "Converion to Json Schema failed", e);
- }
- }
-
- /**
- * Get the requested json schema.
- *
- * @param section section of the tosca service template to get schema for
- * @return the specified tosca service template or section Json Schema
- * @throws PfModelException on errors with retrieving the classes
- */
- @Transactional(readOnly = true)
- public String getToscaServiceTemplateSchema(String section) throws PfModelException {
- var visitor = new SchemaFactoryWrapper();
-
- try {
- switch (section) {
- case "data_types":
- mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaDataType.class), visitor);
- break;
- case "capability_types":
- mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaCapabilityType.class), visitor);
- break;
- case "node_types":
- mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaNodeType.class), visitor);
- break;
- case "relationship_types":
- mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaRelationshipType.class), visitor);
- break;
- case "policy_types":
- mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaPolicyType.class), visitor);
- break;
- case "topology_template":
- mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaTopologyTemplate.class), visitor);
- break;
- case "node_templates":
- mapper.acceptJsonFormatVisitor(
- mapper.getTypeFactory().constructCollectionType(List.class, ToscaNodeTemplate.class),
- visitor);
- break;
- default:
- mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaServiceTemplate.class), visitor);
- }
-
- var jsonSchema = visitor.finalSchema();
- return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonSchema);
- } catch (JsonProcessingException e) {
- throw new PfModelException(Status.BAD_REQUEST, "Converion to Json Schema failed", e);
- }
- }
-
- private List<ToscaServiceTemplate> filterToscaNodeTemplateInstance(List<ToscaServiceTemplate> serviceTemplates) {
-
- List<ToscaServiceTemplate> toscaServiceTemplates = new ArrayList<>();
-
- serviceTemplates.stream().forEach(serviceTemplate -> {
-
- Map<String, ToscaNodeTemplate> toscaNodeTemplates = new HashMap<>();
-
- serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, nodeTemplate) -> {
- if (!nodeTemplate.getName().contains(INSTANCE_TEXT)) {
- toscaNodeTemplates.put(key, nodeTemplate);
- }
- });
-
- serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().clear();
- serviceTemplate.getToscaTopologyTemplate().setNodeTemplates(toscaNodeTemplates);
-
- toscaServiceTemplates.add(serviceTemplate);
- });
-
- return toscaServiceTemplates;
- }
-
- /**
- * Validates to see if there is any instance properties saved.
- *
- * @return true if exists instance properties
- */
- private boolean verifyIfInstancePropertiesExists() {
- return clProvider.getAllNodeTemplates().stream()
- .anyMatch(nodeTemplate -> nodeTemplate.getKey().getName().contains(INSTANCE_TEXT));
-
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/AafConfiguration.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/AafConfiguration.java
deleted file mode 100644
index 4483fbd1b..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/AafConfiguration.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.policy.clamp.controlloop.runtime.config;
-
-import javax.servlet.Filter;
-import org.onap.policy.clamp.controlloop.runtime.main.web.ControlLoopAafFilter;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-
-@Configuration
-@Profile("clamp-aaf-authentication")
-public class AafConfiguration {
-
- /**
- * Method to return Aaf filter.
- *
- * @return Filter
- */
- @Bean
- public Filter aafFilter() {
- return new ControlLoopAafFilter();
- }
-
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/ConverterConfiguration.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/ConverterConfiguration.java
deleted file mode 100644
index d67d2e75d..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/ConverterConfiguration.java
+++ /dev/null
@@ -1,44 +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.runtime.config;
-
-import java.util.Arrays;
-import java.util.List;
-import org.onap.policy.clamp.controlloop.common.rest.CoderHttpMesageConverter;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.StringHttpMessageConverter;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-@Configuration
-public class ConverterConfiguration implements WebMvcConfigurer {
-
- @Override
- public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
- converters.add(new CoderHttpMesageConverter<>("yaml"));
- converters.add(new CoderHttpMesageConverter<>("json"));
-
- StringHttpMessageConverter converter = new StringHttpMessageConverter();
- converter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN));
- converters.add(converter);
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/FilterConfig.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/FilterConfig.java
deleted file mode 100644
index 57bfc2e7c..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/FilterConfig.java
+++ /dev/null
@@ -1,45 +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.runtime.config;
-
-import org.onap.policy.clamp.controlloop.common.rest.RequestResponseLoggingFilter;
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class FilterConfig {
-
- /**
- * Logging Filter configuration.
- *
- * @return FilterRegistrationBean
- */
- @Bean
- public FilterRegistrationBean<RequestResponseLoggingFilter> loggingFilter() {
- FilterRegistrationBean<RequestResponseLoggingFilter> registrationBean = new FilterRegistrationBean<>();
-
- registrationBean.setFilter(new RequestResponseLoggingFilter());
- registrationBean.addUrlPatterns("/onap/controlloop/v2/*");
-
- return registrationBean;
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SecurityConfig.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SecurityConfig.java
deleted file mode 100644
index 846944ea2..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SecurityConfig.java
+++ /dev/null
@@ -1,47 +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.runtime.config;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-
-@Configuration
-public class SecurityConfig extends WebSecurityConfigurerAdapter {
-
- @Value("${security.enable-csrf:true}")
- private boolean csrfEnabled = true;
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- // @formatter:off
- http.authorizeRequests()
- .antMatchers().authenticated()
- .anyRequest().authenticated()
- .and().httpBasic();
- // @formatter:on
-
- if (!csrfEnabled) {
- http.csrf().disable();
- }
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SpringFoxConfig.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SpringFoxConfig.java
deleted file mode 100644
index d8c703397..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SpringFoxConfig.java
+++ /dev/null
@@ -1,45 +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.runtime.config;
-
-import org.onap.policy.clamp.controlloop.runtime.main.rest.MonitoringQueryController;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-
-@Configuration
-public class SpringFoxConfig {
-
- /**
- * Docket Spring Fox Config.
- *
- * @return Docket
- */
- @Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2).select()
- .apis(RequestHandlerSelectors.basePackage(MonitoringQueryController.class.getPackageName()))
- .paths(PathSelectors.any()).build();
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java
deleted file mode 100644
index 0afbf1c4c..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java
+++ /dev/null
@@ -1,41 +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.runtime.config.messaging;
-
-import org.onap.policy.common.endpoints.listeners.ScoListener;
-
-public interface Listener<T> {
-
- /**
- * Get the type of message of interest to the listener.
- *
- * @return type of message of interest to the listener
- */
- String getType();
-
- /**
- * Get listener to register.
- *
- * @return listener to register
- */
- ScoListener<T> getScoListener();
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java
deleted file mode 100644
index 284094bc4..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.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.runtime.config.messaging;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.List;
-import lombok.Getter;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
-import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.event.comm.TopicSource;
-import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
-import org.onap.policy.common.utils.services.ServiceManagerContainer;
-import org.springframework.context.event.ContextClosedEvent;
-import org.springframework.context.event.ContextRefreshedEvent;
-import org.springframework.context.event.EventListener;
-import org.springframework.stereotype.Component;
-
-@Component
-public class MessageDispatcherActivator extends ServiceManagerContainer implements Closeable {
-
- private static final String[] MSG_TYPE_NAMES = {"messageType"};
-
- // Topics from which the application receives and to which the application sends messages
- private List<TopicSink> topicSinks;
- private List<TopicSource> topicSources;
-
- @Getter
- private final MessageTypeDispatcher msgDispatcher;
-
- /**
- * Constructor.
- *
- * @param clRuntimeParameterGroup the parameters for the control loop runtime service
- * @param publishers list of Publishers
- * @param listeners list of Listeners
- * @throws ControlLoopRuntimeException if the activator does not start
- */
- public <T> MessageDispatcherActivator(final ClRuntimeParameterGroup clRuntimeParameterGroup,
- List<Publisher> publishers, List<Listener<T>> listeners) {
- topicSinks = TopicEndpointManager.getManager()
- .addTopicSinks(clRuntimeParameterGroup.getTopicParameterGroup().getTopicSinks());
-
- topicSources = TopicEndpointManager.getManager()
- .addTopicSources(clRuntimeParameterGroup.getTopicParameterGroup().getTopicSources());
-
- msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES);
-
- // @formatter:off
- addAction("Topic endpoint management",
- () -> TopicEndpointManager.getManager().start(),
- () -> TopicEndpointManager.getManager().shutdown());
-
- publishers.forEach(publisher ->
- addAction("Publisher " + publisher.getClass().getSimpleName(),
- () -> publisher.active(topicSinks),
- publisher::stop));
-
- listeners.forEach(listener ->
- addAction("Listener " + listener.getClass().getSimpleName(),
- () -> msgDispatcher.register(listener.getType(), listener.getScoListener()),
- () -> msgDispatcher.unregister(listener.getType())));
-
- addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher);
- // @formatter:on
- }
-
- /**
- * Registers the dispatcher with the topic source(s).
- */
- private void registerMsgDispatcher() {
- for (final TopicSource source : topicSources) {
- source.register(msgDispatcher);
- }
- }
-
- /**
- * Unregisters the dispatcher from the topic source(s).
- */
- private void unregisterMsgDispatcher() {
- for (final TopicSource source : topicSources) {
- source.unregister(msgDispatcher);
- }
- }
-
- /**
- * Start Manager after the application is Started.
- *
- * @param cre Refreshed Event
- */
- @EventListener
- public void handleContextStart(ContextRefreshedEvent cre) {
- if (!isAlive()) {
- start();
- }
- }
-
- /**
- * Handle ContextClosedEvent.
- *
- * @param ctxClosedEvent ContextClosedEvent
- */
- @EventListener
- public void handleContextClosedEvent(ContextClosedEvent ctxClosedEvent) {
- if (isAlive()) {
- stop();
- }
- }
-
- @Override
- public void close() throws IOException {
- if (isAlive()) {
- super.shutdown();
- }
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Publisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Publisher.java
deleted file mode 100644
index 3cd4dff85..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Publisher.java
+++ /dev/null
@@ -1,34 +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.runtime.config.messaging;
-
-import java.util.List;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-
-/**
- * Publisher.
- */
-public interface Publisher {
-
- void active(List<TopicSink> topicSinks);
-
- void stop();
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
deleted file mode 100644
index 1bff2d747..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
+++ /dev/null
@@ -1,619 +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.runtime.instantiation;
-
-import com.google.gson.Gson;
-import com.google.gson.internal.LinkedTreeMap;
-import com.google.gson.reflect.TypeToken;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.function.Function;
-import java.util.function.UnaryOperator;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import lombok.AllArgsConstructor;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.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.persistence.provider.ControlLoopProvider;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
-import org.onap.policy.clamp.controlloop.models.messages.rest.GenericNameVersion;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopOrderStateResponse;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopPrimed;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopPrimedResponse;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstancePropertiesResponse;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
-import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
-import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ObjectValidationResult;
-import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.common.parameters.ValidationStatus;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNameVersion;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * This class is dedicated to the Instantiation of Commissioned control loop.
- */
-@Service
-@Transactional
-@AllArgsConstructor
-public class ControlLoopInstantiationProvider {
- private static final String CONTROL_LOOP_NODE_TYPE = "org.onap.policy.clamp.controlloop.ControlLoop";
- private static final String CONTROL_LOOP_NODE_ELEMENT_TYPE = "ControlLoopElement";
- private static final String PARTICIPANT_ID_PROPERTY_KEY = "participant_id";
- private static final String PARTICIPANT_TYPE_PROPERTY_KEY = "participantType";
- private static final String CL_ELEMENT_NAME = "name";
- private static final String CL_ELEMENT_VERSION = "version";
- private static final String INSTANCE_TEXT = "_Instance";
-
- private static final Gson GSON = new Gson();
-
- private final ControlLoopProvider controlLoopProvider;
- private final CommissioningProvider commissioningProvider;
- private final SupervisionHandler supervisionHandler;
- private final ParticipantProvider participantProvider;
- private static final String ENTRY = "entry ";
-
- /**
- * Creates Instance Properties and Control Loop.
- *
- * @param serviceTemplate the service template
- * @return the result of the instantiation operation
- * @throws PfModelException on creation errors
- */
- public InstancePropertiesResponse createInstanceProperties(ToscaServiceTemplate serviceTemplate)
- throws PfModelException {
-
- String instanceName = generateSequentialInstanceName();
- ControlLoop controlLoop = new ControlLoop();
- Map<UUID, ControlLoopElement> controlLoopElements = new HashMap<>();
-
- ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0);
-
- Map<String, ToscaNodeTemplate> persistedNodeTemplateMap =
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
-
- Map<String, ToscaNodeTemplate> nodeTemplates = deepCloneNodeTemplate(serviceTemplate);
-
- nodeTemplates.forEach((key, template) -> {
- ToscaNodeTemplate newNodeTemplate = new ToscaNodeTemplate();
- String name = key + instanceName;
- String version = template.getVersion();
- String description = template.getDescription() + instanceName;
- newNodeTemplate.setName(name);
- newNodeTemplate.setVersion(version);
- newNodeTemplate.setDescription(description);
- newNodeTemplate.setProperties(new HashMap<>(template.getProperties()));
- newNodeTemplate.setType(template.getType());
- newNodeTemplate.setTypeVersion(template.getTypeVersion());
- newNodeTemplate.setMetadata(template.getMetadata());
-
- crateNewControlLoopInstance(instanceName, controlLoop, controlLoopElements, template, newNodeTemplate);
-
- persistedNodeTemplateMap.put(name, newNodeTemplate);
- });
-
- ControlLoops controlLoops = new ControlLoops();
-
- serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().putAll(persistedNodeTemplateMap);
-
- controlLoop.setElements(controlLoopElements);
- controlLoops.getControlLoopList().add(controlLoop);
-
- return saveInstancePropertiesAndControlLoop(serviceTemplate, controlLoops);
- }
-
- /**
- * Deletes Instance Properties.
- *
- * @param name the name of the control loop to delete
- * @param version the version of the control loop to delete
- * @return the result of the deletion
- * @throws PfModelException on deletion errors
- */
- public InstantiationResponse deleteInstanceProperties(String name, String version) throws PfModelException {
-
- String instanceName = getInstancePropertyName(name, version);
-
- Map<String, ToscaNodeTemplate> filteredToscaNodeTemplateMap = new HashMap<>();
-
- ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0);
-
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, nodeTemplate) -> {
- if (!nodeTemplate.getName().contains(instanceName)) {
- filteredToscaNodeTemplateMap.put(key, nodeTemplate);
- }
- });
-
- List<ToscaNodeTemplate> filteredToscaNodeTemplateList = toscaServiceTemplate.getToscaTopologyTemplate()
- .getNodeTemplates().values().stream()
- .filter(nodeTemplate -> nodeTemplate.getName().contains(instanceName)).collect(Collectors.toList());
-
- InstantiationResponse response = this.deleteControlLoop(name, version);
-
- controlLoopProvider.deleteInstanceProperties(filteredToscaNodeTemplateMap, filteredToscaNodeTemplateList);
-
- return response;
- }
-
- /**
- * Create control loops.
- *
- * @param controlLoops the control loop
- * @return the result of the instantiation operation
- * @throws PfModelException on creation errors
- */
- public InstantiationResponse createControlLoops(ControlLoops controlLoops) throws PfModelException {
- for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- var checkControlLoopOpt = controlLoopProvider.findControlLoop(controlLoop.getKey().asIdentifier());
- if (checkControlLoopOpt.isPresent()) {
- throw new PfModelException(Response.Status.BAD_REQUEST,
- controlLoop.getKey().asIdentifier() + " already defined");
- }
- }
- BeanValidationResult validationResult = validateControlLoops(controlLoops);
- if (!validationResult.isValid()) {
- throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult());
- }
- controlLoopProvider.saveControlLoops(controlLoops.getControlLoopList());
-
- var response = new InstantiationResponse();
- response.setAffectedControlLoops(controlLoops.getControlLoopList().stream()
- .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
-
- return response;
- }
-
- /**
- * Update control loops.
- *
- * @param controlLoops the control loop
- * @return the result of the instantiation operation
- * @throws PfModelException on update errors
- */
- public InstantiationResponse updateControlLoops(ControlLoops controlLoops) throws PfModelException {
- BeanValidationResult validationResult = validateControlLoops(controlLoops);
- if (!validationResult.isValid()) {
- throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult());
- }
- controlLoopProvider.saveControlLoops(controlLoops.getControlLoopList());
-
- var response = new InstantiationResponse();
- response.setAffectedControlLoops(controlLoops.getControlLoopList().stream()
- .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
-
- return response;
- }
-
- /**
- * Validate ControlLoops.
- *
- * @param controlLoops ControlLoops to validate
- * @return the result of validation
- * @throws PfModelException if controlLoops is not valid
- */
- private BeanValidationResult validateControlLoops(ControlLoops controlLoops) throws PfModelException {
-
- var result = new BeanValidationResult("ControlLoops", controlLoops);
-
- for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- var subResult = new BeanValidationResult(ENTRY + controlLoop.getDefinition().getName(), controlLoop);
-
- List<ToscaNodeTemplate> toscaNodeTemplates = commissioningProvider.getControlLoopDefinitions(
- controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
-
- if (toscaNodeTemplates.isEmpty()) {
- subResult.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
- ValidationStatus.INVALID, "Commissioned control loop definition not FOUND"));
- } else if (toscaNodeTemplates.size() > 1) {
- subResult.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
- ValidationStatus.INVALID, "Commissioned control loop definition not VALID"));
- } else {
-
- List<ToscaNodeTemplate> clElementDefinitions =
- commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplates.get(0));
-
- // @formatter:off
- Map<String, ToscaConceptIdentifier> definitions = clElementDefinitions
- .stream()
- .map(nodeTemplate -> nodeTemplate.getKey().asIdentifier())
- .collect(Collectors.toMap(ToscaConceptIdentifier::getName, UnaryOperator.identity()));
- // @formatter:on
-
- for (ControlLoopElement element : controlLoop.getElements().values()) {
- subResult.addResult(validateDefinition(definitions, element.getDefinition()));
- }
- }
- result.addResult(subResult);
- }
- return result;
- }
-
- /**
- * Validate ToscaConceptIdentifier, checking if exist in ToscaConceptIdentifiers map.
- *
- * @param definitions map of all ToscaConceptIdentifiers
- * @param definition ToscaConceptIdentifier to validate
- * @return the validation result
- */
- private ValidationResult validateDefinition(Map<String, ToscaConceptIdentifier> definitions,
- ToscaConceptIdentifier definition) {
- var result = new BeanValidationResult(ENTRY + definition.getName(), definition);
- ToscaConceptIdentifier identifier = definitions.get(definition.getName());
- if (identifier == null) {
- result.setResult(ValidationStatus.INVALID, "Not FOUND");
- } else if (!identifier.equals(definition)) {
- result.setResult(ValidationStatus.INVALID, "Version not matching");
- }
- return (result.isClean() ? null : result);
- }
-
- /**
- * Delete the control loop with the given name and version.
- *
- * @param name the name of the control loop to delete
- * @param version the version of the control loop to delete
- * @return the result of the deletion
- * @throws PfModelException on deletion errors
- */
- public InstantiationResponse deleteControlLoop(String name, String version) throws PfModelException {
- var controlLoopOpt = controlLoopProvider.findControlLoop(name, version);
- if (controlLoopOpt.isEmpty()) {
- throw new PfModelException(Response.Status.NOT_FOUND, "Control Loop not found");
- }
- var controlLoop = controlLoopOpt.get();
- if (!ControlLoopState.UNINITIALISED.equals(controlLoop.getState())) {
- throw new PfModelException(Response.Status.BAD_REQUEST,
- "Control Loop State is still " + controlLoop.getState());
- }
- var response = new InstantiationResponse();
- response.setAffectedControlLoops(
- List.of(controlLoopProvider.deleteControlLoop(name, version).getKey().asIdentifier()));
- return response;
- }
-
- /**
- * Get the requested control loops.
- *
- * @param name the name of the control loop to get, null for all control loops
- * @param version the version of the control loop to get, null for all control loops
- * @return the control loops
- * @throws PfModelException on errors getting control loops
- */
- @Transactional(readOnly = true)
- public ControlLoops getControlLoops(String name, String version) throws PfModelException {
- var controlLoops = new ControlLoops();
- controlLoops.setControlLoopList(controlLoopProvider.getControlLoops(name, version));
-
- return controlLoops;
- }
-
- /**
- * Issue a command to control loops, setting their ordered state.
- *
- * @param command the command to issue to control loops
- * @return the result of the initiation command
- * @throws PfModelException on errors setting the ordered state on the control loops
- * @throws ControlLoopException on ordered state invalid
- */
- public InstantiationResponse issueControlLoopCommand(InstantiationCommand command)
- throws ControlLoopException, PfModelException {
-
- if (command.getOrderedState() == null) {
- throw new ControlLoopException(Status.BAD_REQUEST, "ordered state invalid or not specified on command");
- }
-
- var participants = participantProvider.getParticipants();
- if (participants.isEmpty()) {
- throw new ControlLoopException(Status.BAD_REQUEST, "No participants registered");
- }
- var validationResult = new BeanValidationResult("InstantiationCommand", command);
- List<ControlLoop> controlLoops = new ArrayList<>(command.getControlLoopIdentifierList().size());
- for (ToscaConceptIdentifier id : command.getControlLoopIdentifierList()) {
- var controlLoopOpt = controlLoopProvider.findControlLoop(id);
- if (controlLoopOpt.isEmpty()) {
- validationResult.addResult("ToscaConceptIdentifier", id, ValidationStatus.INVALID,
- "ControlLoop with id " + id + " not found");
- } else {
- var controlLoop = controlLoopOpt.get();
- controlLoop.setCascadedOrderedState(command.getOrderedState());
- controlLoops.add(controlLoop);
- }
- }
- if (validationResult.isValid()) {
- validationResult = validateIssueControlLoops(controlLoops, participants);
- }
- if (!validationResult.isValid()) {
- throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult());
- }
- controlLoopProvider.saveControlLoops(controlLoops);
-
- supervisionHandler.triggerControlLoopSupervision(command.getControlLoopIdentifierList());
- var response = new InstantiationResponse();
- response.setAffectedControlLoops(command.getControlLoopIdentifierList());
-
- return response;
- }
-
- private BeanValidationResult validateIssueControlLoops(List<ControlLoop> controlLoops,
- List<Participant> participants) {
- var result = new BeanValidationResult("ControlLoops", controlLoops);
-
- Map<ToscaConceptIdentifier, Participant> participantMap = participants.stream()
- .collect(Collectors.toMap(participant -> participant.getKey().asIdentifier(), Function.identity()));
-
- for (ControlLoop controlLoop : controlLoops) {
-
- for (var element : controlLoop.getElements().values()) {
-
- var subResult = new BeanValidationResult(ENTRY + element.getDefinition().getName(), element);
- Participant p = participantMap.get(element.getParticipantId());
- if (p == null) {
- subResult.addResult(new ObjectValidationResult(CONTROL_LOOP_NODE_ELEMENT_TYPE,
- element.getDefinition().getName(), ValidationStatus.INVALID,
- "Participant with ID " + element.getParticipantId() + " is not registered"));
- } else if (!p.getParticipantType().equals(element.getParticipantType())) {
- subResult.addResult(new ObjectValidationResult(CONTROL_LOOP_NODE_ELEMENT_TYPE,
- element.getDefinition().getName(), ValidationStatus.INVALID,
- "Participant with ID " + element.getParticipantType() + " - " + element.getParticipantId()
- + " is not registered"));
- }
- result.addResult(subResult);
- }
-
- }
-
- return result;
- }
-
- /**
- * Gets a list of control loops with it's ordered state.
- *
- * @param name the name of the control loop to get, null for all control loops
- * @param version the version of the control loop to get, null for all control loops
- * @return a list of Instantiation Command
- * @throws PfModelException on errors getting control loops
- */
- @Transactional(readOnly = true)
- public ControlLoopOrderStateResponse getInstantiationOrderState(String name, String version)
- throws PfModelException {
-
- List<ControlLoop> controlLoops = controlLoopProvider.getControlLoops(name, version);
-
- var response = new ControlLoopOrderStateResponse();
-
- controlLoops.forEach(controlLoop -> {
- var genericNameVersion = new GenericNameVersion();
- genericNameVersion.setName(controlLoop.getName());
- genericNameVersion.setVersion(controlLoop.getVersion());
- response.getControlLoopIdentifierList().add(genericNameVersion);
- });
-
- return response;
- }
-
- /**
- * Saves Instance Properties and Control Loop.
- * Gets a list of control loops which are primed or de-primed.
- *
- * @param name the name of the control loop to get, null for all control loops
- * @param version the version of the control loop to get, null for all control loops
- * @return a list of Instantiation Command
- * @throws PfModelException on errors getting control loops
- */
- @Transactional(readOnly = true)
- public ControlLoopPrimedResponse getControlLoopPriming(String name, String version) throws PfModelException {
-
- List<ControlLoop> controlLoops = controlLoopProvider.getControlLoops(name, version);
-
- var response = new ControlLoopPrimedResponse();
-
- controlLoops.forEach(controlLoop -> {
- var primed = new ControlLoopPrimed();
- primed.setName(controlLoop.getName());
- primed.setVersion(controlLoop.getVersion());
- primed.setPrimed(controlLoop.getPrimed());
- response.getPrimedControlLoopsList().add(primed);
- });
-
- return response;
- }
-
- /**
- * Creates instance element name.
- *
- * @param serviceTemplate the service template
- * @param controlLoops a list of control loops
- * @return the result of the instance properties and instantiation operation
- * @throws PfModelException on creation errors
- */
- private InstancePropertiesResponse saveInstancePropertiesAndControlLoop(ToscaServiceTemplate serviceTemplate,
- ControlLoops controlLoops) throws PfModelException {
-
- for (var controlLoop : controlLoops.getControlLoopList()) {
- var checkControlLoopOpt = controlLoopProvider.findControlLoop(controlLoop.getKey().asIdentifier());
- if (checkControlLoopOpt.isPresent()) {
- throw new PfModelException(Response.Status.BAD_REQUEST,
- "Control loop with id " + controlLoop.getKey().asIdentifier() + " already defined");
- }
- }
- Map<String, ToscaNodeTemplate> toscaSavedNodeTemplate =
- controlLoopProvider.saveInstanceProperties(serviceTemplate);
- controlLoopProvider.saveControlLoops(controlLoops.getControlLoopList());
- List<ToscaConceptIdentifier> affectedControlLoops = controlLoops.getControlLoopList().stream()
- .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList());
-
- List<ToscaConceptIdentifier> toscaAffectedProperties = toscaSavedNodeTemplate.values().stream()
- .map(template -> template.getKey().asIdentifier()).collect(Collectors.toList());
-
- var response = new InstancePropertiesResponse();
- response.setAffectedInstanceProperties(Stream.of(affectedControlLoops, toscaAffectedProperties)
- .flatMap(Collection::stream).collect(Collectors.toList()));
-
- return response;
- }
-
- /**
- * Crates a new Control Loop instance.
- *
- * @param instanceName Control Loop Instance name
- * @param controlLoop empty Control Loop
- * @param controlLoopElements new Control Loop Element map
- * @param template original Cloned Tosca Node Template
- * @param newNodeTemplate new Tosca Node Template
- */
- private void crateNewControlLoopInstance(String instanceName, ControlLoop controlLoop,
- Map<UUID, ControlLoopElement> controlLoopElements, ToscaNodeTemplate template,
- ToscaNodeTemplate newNodeTemplate) {
- if (template.getType().equals(CONTROL_LOOP_NODE_TYPE)) {
- controlLoop.setDefinition(getControlLoopDefinition(newNodeTemplate));
- }
-
- if (template.getType().contains(CONTROL_LOOP_NODE_ELEMENT_TYPE)) {
- ControlLoopElement controlLoopElement = getControlLoopElement(newNodeTemplate);
- controlLoopElements.put(controlLoopElement.getId(), controlLoopElement);
- }
-
- controlLoop.setName("PMSH" + instanceName);
- controlLoop.setVersion(template.getVersion());
- controlLoop.setDescription("PMSH control loop " + instanceName);
- controlLoop.setState(ControlLoopState.UNINITIALISED);
- controlLoop.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- }
-
- /**
- * Get's the instance property name of the control loop.
- *
- * @param name the name of the control loop to get, null for all control loops
- * @param version the version of the control loop to get, null for all control loops
- * @return the instance name of the control loop instance properties
- * @throws PfModelException on errors getting control loops
- */
- private String getInstancePropertyName(String name, String version) throws PfModelException {
- List<String> toscaDefinitionsNames = controlLoopProvider.getControlLoops(name, version).stream()
- .map(ControlLoop::getDefinition).map(ToscaNameVersion::getName).collect(Collectors.toList());
-
- return toscaDefinitionsNames.stream().reduce("", (s1, s2) -> {
-
- if (s2.contains(INSTANCE_TEXT)) {
- String[] instances = s2.split(INSTANCE_TEXT);
-
- return INSTANCE_TEXT + instances[1];
- }
-
- return s1;
- });
- }
-
- /**
- * Generates Instance Name in sequential order and return it to append to the Node Template Name.
- *
- * @return instanceName
- */
- private String generateSequentialInstanceName() {
- List<ToscaNodeTemplate> nodeTemplates = controlLoopProvider.getAllNodeTemplates();
-
- int instanceNumber = nodeTemplates.stream().map(ToscaNodeTemplate::getName)
- .filter(name -> name.contains(INSTANCE_TEXT)).map(n -> {
- String[] defNameArr = n.split(INSTANCE_TEXT);
-
- return Integer.parseInt(defNameArr[1]);
- }).reduce(0, Math::max);
-
- return INSTANCE_TEXT + (instanceNumber + 1);
- }
-
- /**
- * Retrieves Control Loop Definition.
- *
- * @param template tosca node template
- * @return control loop definition
- */
- private ToscaConceptIdentifier getControlLoopDefinition(ToscaNodeTemplate template) {
- ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
- definition.setName(template.getName());
- definition.setVersion(template.getVersion());
- return definition;
- }
-
- /**
- * Retrieves Control Loop Element.
- *
- * @param template tosca node template
- * @return a control loop element
- */
- @SuppressWarnings("unchecked")
- private ControlLoopElement getControlLoopElement(ToscaNodeTemplate template) {
- ControlLoopElement controlLoopElement = new ControlLoopElement();
- ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
- definition.setName(template.getName());
- definition.setVersion(template.getVersion());
- controlLoopElement.setDefinition(definition);
- LinkedTreeMap<String, Object> participantId =
- (LinkedTreeMap<String, Object>) template.getProperties().get(PARTICIPANT_ID_PROPERTY_KEY);
- if (participantId != null) {
- ToscaConceptIdentifier participantIdProperty = new ToscaConceptIdentifier();
- participantIdProperty.setName(String.valueOf(participantId.get(CL_ELEMENT_NAME)));
- participantIdProperty.setVersion(String.valueOf(participantId.get(CL_ELEMENT_VERSION)));
- controlLoopElement.setParticipantId(participantIdProperty);
- }
- LinkedTreeMap<String, Object> participantType =
- (LinkedTreeMap<String, Object>) template.getProperties().get(PARTICIPANT_TYPE_PROPERTY_KEY);
- if (participantType != null) {
- ToscaConceptIdentifier participantTypeProperty = new ToscaConceptIdentifier();
- participantTypeProperty.setName(String.valueOf(participantType.get(CL_ELEMENT_NAME)));
- participantTypeProperty.setVersion(participantType.get(CL_ELEMENT_VERSION).toString());
- controlLoopElement.setParticipantType(participantTypeProperty);
- }
- return controlLoopElement;
- }
-
- /**
- * Deep clones ToscaNodeTemplate.
- *
- * @param serviceTemplate ToscaServiceTemplate
- * @return a cloned Hash Map of ToscaNodeTemplate
- */
- private Map<String, ToscaNodeTemplate> deepCloneNodeTemplate(ToscaServiceTemplate serviceTemplate) {
- String jsonString = GSON.toJson(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates());
- Type type = new TypeToken<HashMap<String, ToscaNodeTemplate>>() {}.getType();
- return GSON.fromJson(jsonString, type);
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
deleted file mode 100644
index 047bca2b1..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
+++ /dev/null
@@ -1,49 +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.runtime.main.parameters;
-
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-import lombok.Getter;
-import lombok.Setter;
-import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.parameters.validation.ParameterGroupConstraint;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.validation.annotation.Validated;
-
-/**
- * Class to hold all parameters needed for the Control Loop runtime component.
- *
- */
-@Validated
-@Getter
-@Setter
-@ConfigurationProperties(prefix = "runtime")
-public class ClRuntimeParameterGroup {
-
- @Valid
- @NotNull
- private ParticipantParameters participantParameters;
-
- @NotNull
- @ParameterGroupConstraint
- private TopicParameterGroup topicParameterGroup;
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java
deleted file mode 100644
index e3e34878f..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java
+++ /dev/null
@@ -1,45 +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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.runtime.main.parameters;
-
-import javax.validation.Valid;
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.validation.annotation.Validated;
-
-/**
- * Parameters for communicating with participants.
- */
-@Getter
-@Setter
-@Validated
-public class ParticipantParameters {
-
- @Min(100)
- private long heartBeatMs;
-
- @Min(100)
- private long maxStatusWaitMs;
-
- @Valid
- @NotNull
- private ParticipantUpdateParameters updateParameters;
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
deleted file mode 100644
index c0b0480de..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
+++ /dev/null
@@ -1,46 +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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.runtime.main.parameters;
-
-import javax.validation.constraints.Min;
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.validation.annotation.Validated;
-
-/**
- * Parameters for Participant UPDATE requests.
- */
-@Getter
-@Setter
-@Validated
-public class ParticipantUpdateParameters {
-
- /**
- * Maximum number of times to re-send a request to a PDP.
- */
- @Min(value = 1)
- private int maxRetryCount;
-
- /**
- * Maximum time to wait, in milliseconds, for a PDP response.
- */
- @Min(value = 100)
- private long maxWaitMs;
-
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
deleted file mode 100644
index fcb5aed97..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
+++ /dev/null
@@ -1,515 +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.runtime.main.rest;
-
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Authorization;
-import io.swagger.annotations.Extension;
-import io.swagger.annotations.ExtensionProperty;
-import io.swagger.annotations.ResponseHeader;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import javax.ws.rs.core.Response.Status;
-import lombok.RequiredArgsConstructor;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
-import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
-import org.onap.policy.clamp.controlloop.runtime.main.web.AbstractRestController;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Class to provide REST end points for creating, deleting, querying commissioned control loops.
- */
-@RestController
-@RequiredArgsConstructor
-public class CommissioningController extends AbstractRestController {
-
- private static final String TAGS = "Clamp Control Loop Commissioning API";
-
- private final CommissioningProvider provider;
-
- /**
- * Creates a control loop definition.
- *
- * @param requestId request ID used in ONAP logging
- * @param body the body of control loop following TOSCA definition
- * @return a response
- * @throws PfModelException on errors creating a control loop definition
- */
- // @formatter:off
- @PostMapping(value = "/commission",
- consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(
- value = "Commissions control loop definitions",
- notes = "Commissions control loop definitions, returning the commissioned control loop definition IDs",
- response = CommissioningResponse.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<CommissioningResponse> create(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ToscaServiceTemplate body)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.createControlLoopDefinitions(body));
- }
-
- /**
- * Deletes a control loop definition.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop definition to delete
- * @param version the version of the control loop definition to delete
- * @return a response
- * @throws PfModelException on errors deleting a control loop definition
- */
- // @formatter:off
- @DeleteMapping(value = "/commission",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Delete a commissioned control loop",
- notes = "Deletes a Commissioned Control Loop, returning optional error details",
- response = CommissioningResponse.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<CommissioningResponse> delete(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true) @RequestParam(
- value = "name") String name,
- @ApiParam(
- value = "Control Loop definition version",
- required = true) @RequestParam("version") String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.deleteControlLoopDefinition(name, version));
- }
-
- /**
- * Queries details of all or specific control loop definitions.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop definition to get, null for all definitions
- * @param version the version of the control loop definition to get, null for all definitions
- * @return the control loop definitions
- * @throws PfModelException on errors getting details of all or specific control loop definitions
- */
- // @formatter:off
- @GetMapping(value = "/commission",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested commissioned control loop definitions",
- notes = "Queries details of the requested commissioned control loop definitions, "
- + "returning all control loop details",
- response = ToscaNodeTemplate.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<List<ToscaNodeTemplate>> query(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Control Loop definition version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.getControlLoopDefinitions(name, version));
- }
-
- /**
- * Retrieves the Tosca Service Template.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the tosca service template to retrieve
- * @param version the version of the tosca service template to get
- * @return the specified tosca service template
- * @throws PfModelException on errors getting the Tosca Service Template
- */
- // @formatter:off
- @GetMapping(value = "/commission/toscaservicetemplate",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested tosca service templates",
- notes = "Queries details of the requested commissioned tosca service template, "
- + "returning all tosca service template details",
- response = ToscaServiceTemplate.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<String> queryToscaServiceTemplate(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Tosca service template name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Tosca service template version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.getToscaServiceTemplateReduced(name, version));
- }
-
- /**
- * Retrieves the Json Schema for the specified Tosca Service Template.
- *
- * @param requestId request ID used in ONAP logging
- * @param section section of the tosca service template to get schema for
- * @return the specified tosca service template or section Json Schema
- * @throws PfModelException on errros getting the Json Schema for the specified Tosca Service Template
- */
- // @formatter:off
- @GetMapping(value = "/commission/toscaServiceTemplateSchema",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested tosca service template json schema",
- notes = "Queries details of the requested commissioned tosca service template json schema, "
- + "returning all tosca service template json schema details",
- response = ToscaServiceTemplate.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<String> queryToscaServiceTemplateJsonSchema(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Section of Template schema is desired for", required = false) @RequestParam(
- value = "section",
- required = false,
- defaultValue = "all") String section)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.getToscaServiceTemplateSchema(section));
- }
-
- /**
- * Retrieves the Common or Instance Properties for the specified Tosca Service Template.
- *
- * @param requestId request ID used in ONAP logging
- * @param common a flag, true to get common properties, false to get instance properties
- * @param name the name of the tosca service template to retrieve
- * @param version the version of the tosca service template to get
- * @return the specified tosca service template or section Json Schema
- * @throws PfModelException on errors getting the Common or Instance Properties
- * @throws ControlLoopException on error getting the Common or Instance Properties
- */
- // @formatter:off
- @GetMapping(value = "/commission/getCommonOrInstanceProperties",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested tosca service template common or instance properties",
- notes = "Queries details of the requested commissioned tosca service template json common"
- + "or instance properties, returning all tosca service template common or instance property details",
- response = ToscaServiceTemplate.class,
- tags = {"Clamp Control Loop Commissioning API"},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<Map<String, ToscaNodeTemplate>> queryToscaServiceCommonOrInstanceProperties(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Flag, true for common properties, false for instance", required = false) @RequestParam(
- value = "common",
- defaultValue = "false",
- required = false) boolean common,
- @ApiParam(value = "Tosca service template name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Tosca service template version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.getNodeTemplatesWithCommonOrInstanceProperties(common, name, version));
- }
-
- /**
- * Queries the elements of a specific control loop.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop definition to get
- * @param version the version of the control loop definition to get
- * @return the control loop element definitions
- * @throws PfModelException on errors getting the elements of a specific control loop
- */
- // @formatter:off
- @GetMapping(value = "/commission/elements",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested commissioned control loop element definitions",
- notes = "Queries details of the requested commissioned control loop element definitions, "
- + "returning all control loop elements' details",
- response = ToscaNodeTemplate.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<List<ToscaNodeTemplate>> queryElements(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Control Loop definition version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- List<ToscaNodeTemplate> nodeTemplate = provider.getControlLoopDefinitions(name, version);
- // Prevent ambiguous queries with multiple returns
- if (nodeTemplate.size() > 1) {
- throw new PfModelException(Status.NOT_ACCEPTABLE, "Multiple ControlLoops are not supported");
- }
-
- List<ToscaNodeTemplate> response = provider.getControlLoopElementDefinitions(nodeTemplate.get(0));
- return ResponseEntity.ok().body(response);
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java
deleted file mode 100644
index d229e68cb..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java
+++ /dev/null
@@ -1,637 +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.runtime.main.rest;
-
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Authorization;
-import io.swagger.annotations.Extension;
-import io.swagger.annotations.ExtensionProperty;
-import io.swagger.annotations.ResponseHeader;
-import java.util.UUID;
-import lombok.RequiredArgsConstructor;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopOrderStateResponse;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopPrimedResponse;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstancePropertiesResponse;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
-import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
-import org.onap.policy.clamp.controlloop.runtime.instantiation.ControlLoopInstantiationProvider;
-import org.onap.policy.clamp.controlloop.runtime.main.web.AbstractRestController;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Class to provide REST end points for creating, deleting, query and commanding a control loop definition.
- */
-@RestController
-@RequiredArgsConstructor
-public class InstantiationController extends AbstractRestController {
-
- private static final String TAGS = "Clamp Control Loop Instantiation API";
-
- // The CL provider for instantiation requests
- private final ControlLoopInstantiationProvider provider;
-
- /**
- * Creates a control loop.
- *
- * @param requestId request ID used in ONAP logging
- * @param controlLoops the control loops
- * @return a response
- * @throws PfModelException on errors creating a control loop
- */
- // @formatter:off
- @PostMapping(value = "/instantiation",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
- consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(
- value = "Commissions control loop definitions",
- notes = "Commissions control loop definitions, returning the control loop IDs",
- response = InstantiationResponse.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<InstantiationResponse> create(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ControlLoops controlLoops)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.createControlLoops(controlLoops));
- }
-
- /**
- * Saves instance properties.
- *
- * @param requestId request ID used in ONAP logging
- * @param body the body of control loop following TOSCA definition
- * @return a response
- */
- // @formatter:off
- @PostMapping(value = "/instanceProperties",
- consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(
- value = "Saves instance properties",
- notes = "Saves instance properties, returning the saved instances properties and it's version",
- response = InstancePropertiesResponse.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<InstancePropertiesResponse> createInstanceProperties(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.createInstanceProperties(body));
- }
-
- /**
- * Deletes a control loop definition and instance properties.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop to delete
- * @param version the version of the control loop to delete
- * @return a response
- * @throws PfModelException on errors deleting of control loop and instance properties
- */
- // @formatter:off
- @DeleteMapping(value = "/instanceProperties",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Delete a control loop and instance properties",
- notes = "Deletes a control loop and instance properties, returning optional error details",
- response = InstantiationResponse.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
-
- public ResponseEntity<InstantiationResponse> deleteInstanceProperties(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true) @RequestParam("name") String name,
- @ApiParam(value = "Control Loop definition version") @RequestParam(
- value = "version",
- required = true) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.deleteInstanceProperties(name, version));
- }
-
- /**
- * Queries details of all control loops.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop to get, null for all control loops
- * @param version the version of the control loop to get, null for all control loops
- * @return the control loops
- * @throws PfModelException on errors getting commissioning of control loop
- */
- // @formatter:off
- @GetMapping(value = "/instantiation",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested control loops",
- notes = "Queries details of the requested control loops, returning all control loop details",
- response = ControlLoops.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ControlLoops> query(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Control Loop definition version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.getControlLoops(name, version));
- }
-
- /**
- * Updates a control loop.
- *
- * @param requestId request ID used in ONAP logging
- * @param controlLoops the control loops
- * @return a response
- * @throws PfModelException on errors updating of control loops
- */
- // @formatter:off
- @PutMapping(value = "/instantiation",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
- consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(
- value = "Updates control loop definitions",
- notes = "Updates control loop definitions, returning the updated control loop definition IDs",
- response = InstantiationResponse.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<InstantiationResponse> update(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ControlLoops controlLoops)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.updateControlLoops(controlLoops));
- }
-
- /**
- * Deletes a control loop definition.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop to delete
- * @param version the version of the control loop to delete
- * @return a response
- * @throws PfModelException on errors deleting of control loop
- */
- // @formatter:off
- @DeleteMapping(value = "/instantiation",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Delete a control loop",
- notes = "Deletes a control loop, returning optional error details",
- response = InstantiationResponse.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
-
- public ResponseEntity<InstantiationResponse> delete(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true) @RequestParam("name") String name,
- @ApiParam(value = "Control Loop definition version") @RequestParam(
- value = "version",
- required = true) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.deleteControlLoop(name, version));
- }
-
- /**
- * Issues control loop commands to control loops.
- *
- * @param requestId request ID used in ONAP logging
- * @param command the command to issue to control loops
- * @return the control loop definitions
- * @throws PfModelException on errors issuing a command
- * @throws ControlLoopException on errors issuing a command
- */
- // @formatter:off
- @PutMapping(value = "/instantiation/command",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
- consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Issue a command to the requested control loops",
- notes = "Issues a command to a control loop, ordering a state change on the control loop",
- response = InstantiationResponse.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<InstantiationResponse> issueControlLoopCommand(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(
- value = "Entity Body of control loop command",
- required = true) @RequestBody InstantiationCommand command)
- throws ControlLoopException, PfModelException {
-
- return ResponseEntity.accepted().body(provider.issueControlLoopCommand(command));
- }
-
- /**
- * Queries details of all control loops.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop to get, null for all control loops
- * @param version the version of the control loop to get, null for all control loops
- * @return the control loops
- * @throws PfModelException on errors getting commissioning of control loop
- */
- // @formatter:off
- @GetMapping(value = "/instantiationState",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested control loops",
- notes = "Queries details of the requested control loops, returning all control loop details",
- response = ControlLoops.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ControlLoopOrderStateResponse> getInstantiationOrderState(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Control Loop version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.getInstantiationOrderState(name, version));
- }
-
- /**
- * Queries Primed/De-Primed status of a control loop.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop to get, null for all control loops
- * @param version the version of the control loop to get, null for all control loops
- * @return the control loops
- * @throws PfModelException on errors getting priming of control loop
- */
- // @formatter:off
- @GetMapping(value = "/controlLoopPriming",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query priming details of the requested control loops",
- notes = "Queries priming details of the requested control loops, returning primed/deprimed control loops",
- response = ControlLoopPrimedResponse.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ControlLoopPrimedResponse> getControlLoopPriming(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Control Loop definition version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.getControlLoopPriming(name, version));
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/MonitoringQueryController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/MonitoringQueryController.java
deleted file mode 100644
index c4ce5bb05..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/MonitoringQueryController.java
+++ /dev/null
@@ -1,341 +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.runtime.main.rest;
-
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Authorization;
-import io.swagger.annotations.Extension;
-import io.swagger.annotations.ExtensionProperty;
-import io.swagger.annotations.ResponseHeader;
-import java.time.Instant;
-import java.util.UUID;
-import lombok.RequiredArgsConstructor;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
-import org.onap.policy.clamp.controlloop.runtime.main.web.AbstractRestController;
-import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
-import org.onap.policy.models.base.PfModelException;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * This class handles REST endpoints for CL Statistics monitoring.
- */
-@RestController
-@RequiredArgsConstructor
-public class MonitoringQueryController extends AbstractRestController {
-
- private static final String TAGS = "Clamp Control Loop Monitoring API";
- private final MonitoringProvider provider;
-
- /**
- * Queries details of control loop participants statistics.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the participant to get, null for all participants statistics
- * @param version the version of the participant to get, null for all participants with the given name
- * @param recordCount the record count to be fetched
- * @param startTime the time from which to get statistics
- * @param endTime the time to which to get statistics
- * @return the participant statistics
- */
- // @formatter:off
- @GetMapping(value = "/monitoring/participant",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested participant stats",
- notes = "Queries details of the requested participant stats, returning all participant stats",
- response = ParticipantStatisticsList.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ParticipantStatisticsList> queryParticipantStatistics(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop participant name") @RequestParam(
- value = "name",
- required = false) final String name,
- @ApiParam(value = "Control Loop participant version", required = false) @RequestParam(
- value = "version",
- required = false) final String version,
- @ApiParam(value = "Record count", required = false) @RequestParam(
- value = "recordCount",
- required = false,
- defaultValue = "0") final int recordCount,
- @ApiParam(value = "start time", required = false) @RequestParam(
- value = "startTime",
- required = false) final String startTime,
- @ApiParam(value = "end time", required = false) @RequestParam(
- value = "endTime",
- required = false) final String endTime) {
-
- Instant startTimestamp = null;
- Instant endTimestamp = null;
-
- if (startTime != null) {
- startTimestamp = Instant.parse(startTime);
- }
- if (endTime != null) {
- endTimestamp = Instant.parse(endTime);
- }
- return ResponseEntity.ok().body(
- provider.fetchFilteredParticipantStatistics(name, version, recordCount, startTimestamp, endTimestamp));
- }
-
- /**
- * Queries details of all participant statistics per control loop.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop
- * @param version version of the control loop
- * @return the control loop element statistics
- */
- // @formatter:off
- @GetMapping(value = "/monitoring/participants/controlloop",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of all the participant stats in a control loop",
- notes = "Queries details of the participant stats, returning all participant stats",
- response = ClElementStatisticsList.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- })
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ParticipantStatisticsList> queryParticipantStatisticsPerControlLoop(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop name", required = true) @RequestParam(
- value = "name",
- required = false) final String name,
- @ApiParam(value = "Control Loop version", required = true) @RequestParam(
- value = "version",
- required = false) final String version) {
-
- return ResponseEntity.ok().body(provider.fetchParticipantStatsPerControlLoop(name, version));
- }
-
- /**
- * Queries details of all control loop element statistics per control loop.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop
- * @param version version of the control loop
- * @return the control loop element statistics
- */
- // @formatter:off
- @GetMapping(value = "/monitoring/clelements/controlloop",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested cl element stats in a control loop",
- notes = "Queries details of the requested cl element stats, returning all clElement stats",
- response = ClElementStatisticsList.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- })
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ClElementStatisticsList> queryElementStatisticsPerControlLoop(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop name", required = true) @RequestParam(
- value = "name",
- required = false) final String name,
- @ApiParam(value = "Control Loop version", required = true) @RequestParam(
- value = "version",
- required = false) final String version) {
-
- return ResponseEntity.ok().body(provider.fetchClElementStatsPerControlLoop(name, version));
- }
-
- /**
- * Queries details of all control loop element statistics per control loop.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the control loop
- * @param version version of the control loop
- * @param id Id of the control loop element
- * @param recordCount the record count to be fetched
- * @param startTime the time from which to get statistics
- * @param endTime the time to which to get statistics
- * @return the control loop element statistics
- * @throws PfModelException on errors getting details of all control loop element statistics per control loop
- */
- // @formatter:off
- @GetMapping(value = "/monitoring/clelement",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested cl element stats",
- notes = "Queries details of the requested cl element stats, returning all clElement stats",
- response = ClElementStatisticsList.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- })
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ClElementStatisticsList> queryElementStatistics(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Participant name", required = true) @RequestParam(
- value = "name",
- required = false) final String name,
- @ApiParam(value = "Participant version", required = true) @RequestParam(
- value = "version",
- required = false) final String version,
- @ApiParam(value = "Record count", required = false) @RequestParam(
- value = "recordCount",
- required = false,
- defaultValue = "0") final int recordCount,
- @ApiParam(value = "Control Loop element id", required = false) @RequestParam(
- value = "id",
- required = false) final String id,
- @ApiParam(value = "start time", required = false) @RequestParam(
- value = "startTime",
- required = false) final String startTime,
- @ApiParam(value = "end time", required = false) @RequestParam(
- value = "endTime",
- required = false) final String endTime)
- throws PfModelException {
-
- Instant startTimestamp = null;
- Instant endTimestamp = null;
-
- if (startTime != null) {
- startTimestamp = Instant.parse(startTime);
- }
- if (endTime != null) {
- endTimestamp = Instant.parse(endTime);
- }
- return ResponseEntity.ok().body(provider.fetchFilteredClElementStatistics(name, version, id, startTimestamp,
- endTimestamp, recordCount));
- }
-
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/AbstractRestController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/AbstractRestController.java
deleted file mode 100644
index 7d279ba67..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/AbstractRestController.java
+++ /dev/null
@@ -1,91 +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.runtime.main.web;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.BasicAuthDefinition;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.SecurityDefinition;
-import io.swagger.annotations.SwaggerDefinition;
-import io.swagger.annotations.Tag;
-import java.net.HttpURLConnection;
-import javax.ws.rs.core.MediaType;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-/**
- * Common superclass to provide REST endpoints for the participant simulator.
- */
-// @formatter:off
-@RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML})
-@Api(value = "Control Loop Commissioning API")
-@SwaggerDefinition(
- info = @Info(description =
- "Control Loop Service", version = "v1.0",
- title = "Control Loop"),
- consumes = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML},
- produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML},
- schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
- tags = {@Tag(name = "controlloop", description = "Control Loop Service")},
- securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
-// @formatter:on
-public abstract class AbstractRestController {
- public static final String APPLICATION_YAML = "application/yaml";
-
- public static final String EXTENSION_NAME = "interface info";
-
- public static final String API_VERSION_NAME = "api-version";
- public static final String API_VERSION = "1.0.0";
-
- public static final String LAST_MOD_NAME = "last-mod-release";
- public static final String LAST_MOD_RELEASE = "Dublin";
-
- public static final String VERSION_MINOR_NAME = "X-MinorVersion";
- public static final String VERSION_MINOR_DESCRIPTION =
- "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client";
-
- public static final String VERSION_PATCH_NAME = "X-PatchVersion";
- public static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request";
-
- public static final String VERSION_LATEST_NAME = "X-LatestVersion";
- public static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version";
-
- public static final String REQUEST_ID_NAME = "X-ONAP-RequestID";
- public static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose";
- public static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction";
-
- public static final String AUTHORIZATION_TYPE = "basicAuth";
-
- public static final int AUTHENTICATION_ERROR_CODE = HttpURLConnection.HTTP_UNAUTHORIZED;
- public static final int AUTHORIZATION_ERROR_CODE = HttpURLConnection.HTTP_FORBIDDEN;
- public static final int SERVER_ERROR_CODE = HttpURLConnection.HTTP_INTERNAL_ERROR;
-
- public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error";
- public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error";
- public static final String SERVER_ERROR_MESSAGE = "Internal Server Error";
-
- /**
- * Constructor.
- */
- protected AbstractRestController() {
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/ControlLoopAafFilter.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/ControlLoopAafFilter.java
deleted file mode 100644
index 739a691c9..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/ControlLoopAafFilter.java
+++ /dev/null
@@ -1,38 +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.runtime.main.web;
-
-import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter;
-import org.onap.policy.common.utils.resources.MessageConstants;
-
-/**
- * Class to manage AAF filters for the control loop runtime component.
- */
-public class ControlLoopAafFilter extends AafGranularAuthFilter {
-
- public static final String AAF_NODETYPE = MessageConstants.POLICY_CLAMP;
- public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE;
-
- @Override
- public String getPermissionTypeRoot() {
- return AAF_ROOT_PERMISSION;
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java
deleted file mode 100644
index fd493fd89..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java
+++ /dev/null
@@ -1,67 +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.runtime.main.web;
-
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse;
-import org.onap.policy.clamp.controlloop.models.rest.RestUtils;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.RestControllerAdvice;
-
-@RestControllerAdvice
-public class GlobalControllerExceptionHandler {
-
- /**
- * Handle ControlLoopException.
- *
- * @param ex ControlLoopException
- * @return ResponseEntity
- */
- @ExceptionHandler(ControlLoopException.class)
- public ResponseEntity<SimpleResponse> handleBadRequest(ControlLoopException ex) {
- return RestUtils.toSimpleResponse(ex);
- }
-
- /**
- * Handle PfModelRuntimeException.
- *
- * @param ex PfModelRuntimeException
- * @return ResponseEntity
- */
- @ExceptionHandler(PfModelRuntimeException.class)
- public ResponseEntity<SimpleResponse> handleBadRequest(PfModelRuntimeException ex) {
- return RestUtils.toSimpleResponse(ex);
- }
-
- /**
- * Handle PfModelException.
- *
- * @param ex PfModelException
- * @return ResponseEntity
- */
- @ExceptionHandler(PfModelException.class)
- public ResponseEntity<SimpleResponse> handleBadRequest(PfModelException ex) {
- return RestUtils.toSimpleResponse(ex);
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RuntimeErrorController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RuntimeErrorController.java
deleted file mode 100644
index ac2dba355..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RuntimeErrorController.java
+++ /dev/null
@@ -1,104 +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.runtime.main.web;
-
-import io.swagger.v3.oas.annotations.Hidden;
-import java.util.Map;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.http.HttpServletRequest;
-import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse;
-import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.web.error.ErrorAttributeOptions;
-import org.springframework.boot.web.servlet.error.ErrorAttributes;
-import org.springframework.boot.web.servlet.error.ErrorController;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.context.request.ServletWebRequest;
-
-@Controller
-@Hidden
-public class RuntimeErrorController implements ErrorController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(RuntimeErrorController.class);
-
- private final ErrorAttributes errorAttributes;
-
- @Value("${server.error.path}")
- private String path;
-
- /**
- * Constructor.
- *
- * @param errorAttributes ErrorAttributes
- */
- public RuntimeErrorController(ErrorAttributes errorAttributes) {
- this.errorAttributes = errorAttributes;
- }
-
- protected HttpStatus getStatus(HttpServletRequest request) {
- Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
- if (statusCode == null) {
- return HttpStatus.INTERNAL_SERVER_ERROR;
- }
- try {
- return HttpStatus.valueOf(statusCode);
- } catch (Exception ex) {
- LOGGER.error("statusCode {} Not Valid", statusCode, ex);
- return HttpStatus.INTERNAL_SERVER_ERROR;
- }
- }
-
- /**
- * Handle Errors not handled to GlobalControllerExceptionHandler.
- *
- * @param request HttpServletRequest
- * @return ResponseEntity
- */
- @RequestMapping(value = "${server.error.path}", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<TypedSimpleResponse<SimpleResponse>> handleError(HttpServletRequest request) {
- Map<String, Object> map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request),
- ErrorAttributeOptions.defaults());
-
- var sb = new StringBuilder();
- final Object error = map.get("error");
- if (error != null) {
- sb.append(error.toString()).append(" ");
- }
- final Object message = map.get("message");
- if (message != null) {
- sb.append(message.toString());
- }
-
- TypedSimpleResponse<SimpleResponse> resp = new TypedSimpleResponse<>();
- resp.setErrorDetails(sb.toString());
-
- return ResponseEntity.status(getStatus(request)).body(resp);
-
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
deleted file mode 100644
index 2ec438bea..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
+++ /dev/null
@@ -1,243 +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.runtime.monitoring;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import lombok.AllArgsConstructor;
-import lombok.NonNull;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ClElementStatisticsProvider;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantStatisticsProvider;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * This class provides information about statistics data of CL elements and CL Participants in database to callers.
- */
-@Service
-@Transactional
-@AllArgsConstructor
-public class MonitoringProvider {
-
- private static final String DESC_ORDER = "DESC";
- private final ParticipantStatisticsProvider participantStatisticsProvider;
- private final ClElementStatisticsProvider clElementStatisticsProvider;
- private final ControlLoopProvider controlLoopProvider;
-
- /**
- * Create participant statistics.
- *
- * @param participantStatistics the participant statistics
- * @return the result of create operation
- * @throws PfModelException on creation errors
- */
- public ParticipantStatisticsList createParticipantStatistics(List<ParticipantStatistics> participantStatistics)
- throws PfModelException {
- var participantStatisticsList = new ParticipantStatisticsList();
- participantStatisticsList
- .setStatisticsList(participantStatisticsProvider.createParticipantStatistics(participantStatistics));
-
- return participantStatisticsList;
- }
-
- /**
- * Create clElement statistics.
- *
- * @param clElementStatisticsList the clElement statistics
- * @return the result of create operation
- * @throws PfModelException on creation errors
- */
- public ClElementStatisticsList createClElementStatistics(List<ClElementStatistics> clElementStatisticsList)
- throws PfModelException {
- var elementStatisticsList = new ClElementStatisticsList();
- elementStatisticsList
- .setClElementStatistics(clElementStatisticsProvider.createClElementStatistics(clElementStatisticsList));
-
- return elementStatisticsList;
- }
-
- /**
- * Get participant statistics based on specific filters.
- *
- * @param name the name of the participant statistics to get, null to get all statistics
- * @param version the version of the participant statistics to get, null to get all statistics
- * @param recordCount number of records to be fetched.
- * @param startTime start of the timestamp, from statistics to be filtered
- * @param endTime end of the timestamp up to which statistics to be filtered
- * @return the participant found
- */
- @Transactional(readOnly = true)
- public ParticipantStatisticsList fetchFilteredParticipantStatistics(@NonNull final String name,
- final String version, int recordCount, Instant startTime, Instant endTime) {
- var participantStatisticsList = new ParticipantStatisticsList();
-
- // Additional parameters can be added in filterMap for filtering data.
- Map<String, Object> filterMap = null;
- participantStatisticsList.setStatisticsList(participantStatisticsProvider.getFilteredParticipantStatistics(name,
- version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
-
- return participantStatisticsList;
- }
-
- /**
- * Get all participant statistics records found for a specific control loop. *
- *
- * @param controlLoopName name of the control loop
- * @param controlLoopVersion version of the control loop
- * @return All the participant statistics found
- * @throws PfModelRuntimeException on errors getting participant statistics
- */
- @Transactional(readOnly = true)
- public ParticipantStatisticsList fetchParticipantStatsPerControlLoop(@NonNull final String controlLoopName,
- @NonNull final String controlLoopVersion) {
- var statisticsList = new ParticipantStatisticsList();
- List<ParticipantStatistics> participantStatistics = new ArrayList<>();
- try {
- // Fetch all participantIds for a specific control loop
- List<ToscaConceptIdentifier> participantIds =
- getAllParticipantIdsPerControlLoop(controlLoopName, controlLoopVersion);
- for (ToscaConceptIdentifier id : participantIds) {
- participantStatistics.addAll(participantStatisticsProvider.getFilteredParticipantStatistics(
- id.getName(), id.getVersion(), null, null, null, DESC_ORDER, 0));
- }
- statisticsList.setStatisticsList(participantStatistics);
- } catch (PfModelException e) {
- throw new PfModelRuntimeException(e);
- }
- return statisticsList;
- }
-
- /**
- * Get clElement statistics based on specific filters.
- *
- * @param name the name of the clElement statistics to get, null to get all statistics
- * @param version the version of the clElement statistics to get, null to get all statistics
- * @param id UUID of the control loop element
- * @param startTime start of the timestamp, from statistics to be filtered
- * @param endTime end of the timestamp up to which statistics to be filtered
- * @param recordCount number of records to be fetched.
- * @return the participant found
- * @throws PfModelException on errors getting control loop statistics
- */
- @Transactional(readOnly = true)
- public ClElementStatisticsList fetchFilteredClElementStatistics(@NonNull final String name, final String version,
- final String id, Instant startTime, Instant endTime, int recordCount) throws PfModelException {
- var clElementStatisticsList = new ClElementStatisticsList();
- Map<String, Object> filterMap = new HashMap<>();
- // Adding UUID in filter if present
- if (id != null) {
- filterMap.put("localName", id);
- }
- clElementStatisticsList.setClElementStatistics(clElementStatisticsProvider.getFilteredClElementStatistics(name,
- version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
-
- return clElementStatisticsList;
- }
-
- /**
- * Get clElement statistics per control loop.
- *
- * @param name the name of the control loop
- * @param version the version of the control loop
- * @return the clElement statistics found
- * @throws PfModelRuntimeException on errors getting control loop statistics
- */
- @Transactional(readOnly = true)
- public ClElementStatisticsList fetchClElementStatsPerControlLoop(@NonNull final String name,
- @NonNull final String version) {
- var clElementStatisticsList = new ClElementStatisticsList();
- List<ClElementStatistics> clElementStats = new ArrayList<>();
- try {
- List<ControlLoopElement> clElements = new ArrayList<>();
- // Fetch all control loop elements for the control loop
- var controlLoopOpt = controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(name, version));
- if (controlLoopOpt.isPresent()) {
- clElements.addAll(controlLoopOpt.get().getElements().values());
- // Collect control loop element statistics for each cl element.
- for (ControlLoopElement clElement : clElements) {
- clElementStats.addAll(fetchFilteredClElementStatistics(clElement.getParticipantId().getName(),
- clElement.getParticipantId().getVersion(), clElement.getId().toString(), null, null, 0)
- .getClElementStatistics());
- }
- }
- clElementStatisticsList.setClElementStatistics(clElementStats);
- } catch (PfModelException e) {
- throw new PfModelRuntimeException(e);
- }
- return clElementStatisticsList;
- }
-
- /**
- * If required, REST end point can be defined for this method to fetch associated participant Ids
- * for a control loop.
- *
- * @param name the name of the control loop
- * @param version the version of the control loop
- * @return List of participant Id
- * @throws PfModelException on errors
- */
- @Transactional(readOnly = true)
- public List<ToscaConceptIdentifier> getAllParticipantIdsPerControlLoop(String name, String version)
- throws PfModelException {
- List<ToscaConceptIdentifier> participantIds = new ArrayList<>();
- var controlLoopOpt = controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(name, version));
- if (controlLoopOpt.isPresent()) {
- for (ControlLoopElement clElement : controlLoopOpt.get().getElements().values()) {
- participantIds.add(clElement.getParticipantId());
- }
- }
- return participantIds;
- }
-
- /**
- * If required, REST end point can be defined for this method to fetch associated control loop element Ids
- * for a control loop.
- *
- * @param name the name of the control loop
- * @param version the version of the control loop
- * @return Map of control loop Id and participant details
- * @throws PfModelException on errors
- */
- @Transactional(readOnly = true)
- public Map<String, ToscaConceptIdentifier> getAllClElementsIdPerControlLoop(String name, String version)
- throws PfModelException {
- Map<String, ToscaConceptIdentifier> clElementId = new HashMap<>();
- var controlLoopOpt = controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(name, version));
- if (controlLoopOpt.isPresent()) {
- for (ControlLoopElement clElement : controlLoopOpt.get().getElements().values()) {
- clElementId.put(clElement.getId().toString(), clElement.getParticipantId());
- }
- }
- return clElementId;
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounter.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounter.java
deleted file mode 100644
index 7e070d700..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounter.java
+++ /dev/null
@@ -1,106 +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.runtime.supervision;
-
-import java.time.Instant;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import lombok.Getter;
-import lombok.Setter;
-
-public class HandleCounter<K> {
- @Getter
- @Setter
- private long maxWaitMs;
-
- @Getter
- @Setter
- private int maxRetryCount;
-
- private Map<K, Integer> mapCounter = new HashMap<>();
- private Set<K> mapFault = new HashSet<>();
- private Map<K, Long> mapTimer = new HashMap<>();
-
- public long getDuration(K id) {
- mapTimer.putIfAbsent(id, getEpochMilli());
- return getEpochMilli() - mapTimer.get(id);
- }
-
- /**
- * Reset timer and clear counter and fault by id.
- *
- * @param id the id
- */
- public void clear(K id) {
- mapFault.remove(id);
- mapCounter.put(id, 0);
- mapTimer.put(id, getEpochMilli());
- }
-
- /**
- * Remove counter, timer and fault by id.
- *
- * @param id the id
- */
- public void remove(K id) {
- mapFault.remove(id);
- mapCounter.remove(id);
- mapTimer.remove(id);
- }
-
- public void setFault(K id) {
- mapCounter.put(id, 0);
- mapFault.add(id);
- }
-
- /**
- * Increment RetryCount by id e return true if minor or equal of maxRetryCount.
- *
- * @param id the identifier
- * @return false if count is major of maxRetryCount
- */
- public boolean count(K id) {
- int counter = mapCounter.getOrDefault(id, 0) + 1;
- if (counter <= maxRetryCount) {
- mapCounter.put(id, counter);
- return true;
- }
- return false;
- }
-
- public boolean isFault(K id) {
- return mapFault.contains(id);
- }
-
- public int getCounter(K id) {
- return mapCounter.getOrDefault(id, 0);
- }
-
- protected long getEpochMilli() {
- return Instant.now().toEpochMilli();
- }
-
- public Set<K> keySet() {
- return mapCounter.keySet();
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/MessageIntercept.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/MessageIntercept.java
deleted file mode 100644
index c23ed833d..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/MessageIntercept.java
+++ /dev/null
@@ -1,32 +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.runtime.supervision;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface MessageIntercept {
-
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspect.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspect.java
deleted file mode 100644
index d975ec6bc..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspect.java
+++ /dev/null
@@ -1,105 +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.runtime.supervision;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import lombok.RequiredArgsConstructor;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.aspectj.lang.annotation.After;
-import org.aspectj.lang.annotation.AfterReturning;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-@Aspect
-@Component
-@RequiredArgsConstructor
-public class SupervisionAspect implements Closeable {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionAspect.class);
-
- private final SupervisionScanner supervisionScanner;
-
- private ThreadPoolExecutor executor =
- new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
-
- @Scheduled(
- fixedRateString = "${runtime.participantParameters.heartBeatMs}",
- initialDelayString = "${runtime.participantParameters.heartBeatMs}")
- public void schedule() {
- LOGGER.info("Add scheduled scanning");
- executor.execute(() -> supervisionScanner.run(true));
- }
-
- /**
- * Intercept Messages from participant and run Supervision Scan.
- */
- @After("@annotation(MessageIntercept)")
- public void doCheck() {
- if (executor.getQueue().size() < 2) {
- LOGGER.debug("Add scanning Message");
- executor.execute(() -> supervisionScanner.run(false));
- }
- }
-
- @Before("@annotation(MessageIntercept) && args(participantStatusMessage,..)")
- public void handleParticipantStatus(ParticipantStatus participantStatusMessage) {
- executor.execute(() -> supervisionScanner.handleParticipantStatus(participantStatusMessage.getParticipantId()));
- }
-
- /**
- * Intercepts participant Register Message
- * if there is a Commissioning starts an execution of handleParticipantRegister.
- *
- * @param participantRegisterMessage the ParticipantRegister message
- * @param isCommissioning is Commissioning
- */
- @AfterReturning(
- value = "@annotation(MessageIntercept) && args(participantRegisterMessage,..)",
- returning = "isCommissioning")
- public void handleParticipantRegister(ParticipantRegister participantRegisterMessage, boolean isCommissioning) {
- if (isCommissioning) {
- executor.execute(() -> supervisionScanner.handleParticipantRegister(new ImmutablePair<>(
- participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType())));
- }
- }
-
- @Before("@annotation(MessageIntercept) && args(participantUpdateAckMessage,..)")
- public void handleParticipantUpdateAck(ParticipantUpdateAck participantUpdateAckMessage) {
- executor.execute(() -> supervisionScanner.handleParticipantUpdateAck(new ImmutablePair<>(
- participantUpdateAckMessage.getParticipantId(), participantUpdateAckMessage.getParticipantType())));
- }
-
- @Override
- public void close() throws IOException {
- executor.shutdown();
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
deleted file mode 100644
index 6af2788e6..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
+++ /dev/null
@@ -1,491 +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.runtime.supervision;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import lombok.AllArgsConstructor;
-import org.apache.commons.collections4.CollectionUtils;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementAck;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider;
-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.ParticipantMessage;
-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.runtime.monitoring.MonitoringProvider;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopStateChangePublisher;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopUpdatePublisher;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantRegisterAckPublisher;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * This class handles supervision of control loop instances, so only one object of this type should be built at a time.
- *
- * <p/>
- * It is effectively a singleton that is started at system start.
- */
-@Component
-@AllArgsConstructor
-public class SupervisionHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionHandler.class);
-
- private static final String CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE = "Control loop can't transition from state ";
- private static final String CONTROL_LOOP_IS_ALREADY_IN_STATE = "Control loop is already in state ";
- private static final String TO_STATE = " to state ";
- private static final String AND_TRANSITIONING_TO_STATE = " and transitioning to state ";
-
- private final ControlLoopProvider controlLoopProvider;
- private final ParticipantProvider participantProvider;
- private final MonitoringProvider monitoringProvider;
- private final ServiceTemplateProvider serviceTemplateProvider;
-
- // Publishers for participant communication
- private final ControlLoopUpdatePublisher controlLoopUpdatePublisher;
- private final ControlLoopStateChangePublisher controlLoopStateChangePublisher;
- private final ParticipantRegisterAckPublisher participantRegisterAckPublisher;
- private final ParticipantDeregisterAckPublisher participantDeregisterAckPublisher;
- private final ParticipantUpdatePublisher participantUpdatePublisher;
-
- /**
- * Supervision trigger called when a command is issued on control loops.
- *
- * <p/>
- * Causes supervision to start or continue supervision on the control loops in question.
- *
- * @param controlLoopIdentifierList the control loops for which the supervision command has been issued
- * @throws ControlLoopException on supervision triggering exceptions
- */
- public void triggerControlLoopSupervision(List<ToscaConceptIdentifier> controlLoopIdentifierList)
- throws ControlLoopException {
-
- LOGGER.debug("triggering control loop supervision on control loops {}", controlLoopIdentifierList);
-
- if (CollectionUtils.isEmpty(controlLoopIdentifierList)) {
- // This is just to force throwing of the exception in certain circumstances.
- exceptionOccured(Response.Status.NOT_ACCEPTABLE, "The list of control loops for supervision is empty");
- }
-
- for (ToscaConceptIdentifier controlLoopId : controlLoopIdentifierList) {
- try {
- var controlLoop = controlLoopProvider.getControlLoop(controlLoopId);
-
- superviseControlLoop(controlLoop);
-
- controlLoopProvider.saveControlLoop(controlLoop);
- } catch (PfModelException pfme) {
- throw new ControlLoopException(pfme.getErrorResponse().getResponseCode(), pfme.getMessage(), pfme);
- }
- }
- }
-
- /**
- * Handle a ParticipantStatus message from a participant.
- *
- * @param participantStatusMessage the ParticipantStatus message received from a participant
- */
- @MessageIntercept
- public void handleParticipantMessage(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);
- }
- }
-
- /**
- * Handle a ParticipantRegister message from a participant.
- *
- * @param participantRegisterMessage the ParticipantRegister message received from a participant
- */
- @MessageIntercept
- public boolean handleParticipantMessage(ParticipantRegister participantRegisterMessage) {
- LOGGER.debug("Participant Register received {}", participantRegisterMessage);
- try {
- checkParticipant(participantRegisterMessage, ParticipantState.UNKNOWN, ParticipantHealthStatus.UNKNOWN);
- } catch (PfModelException | ControlLoopException svExc) {
- LOGGER.warn("error saving participant {}", participantRegisterMessage.getParticipantId(), svExc);
- }
-
- var isCommissioning = participantUpdatePublisher.sendCommissioning(null, null,
- participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType());
-
- participantRegisterAckPublisher.send(participantRegisterMessage.getMessageId(),
- participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType());
- return isCommissioning;
- }
-
- /**
- * Handle a ParticipantDeregister message from a participant.
- *
- * @param participantDeregisterMessage the ParticipantDeregister message received from a participant
- */
- @MessageIntercept
- public void handleParticipantMessage(ParticipantDeregister participantDeregisterMessage) {
- LOGGER.debug("Participant Deregister received {}", participantDeregisterMessage);
- try {
- var participantOpt =
- participantProvider.findParticipant(participantDeregisterMessage.getParticipantId().getName(),
- participantDeregisterMessage.getParticipantId().getVersion());
-
- if (participantOpt.isPresent()) {
- var participant = participantOpt.get();
- participant.setParticipantState(ParticipantState.TERMINATED);
- participant.setHealthStatus(ParticipantHealthStatus.OFF_LINE);
- participantProvider.saveParticipant(participant);
- }
- } catch (PfModelException pfme) {
- LOGGER.warn("Model exception occured with participant id {}",
- participantDeregisterMessage.getParticipantId());
- }
-
- participantDeregisterAckPublisher.send(participantDeregisterMessage.getMessageId());
- }
-
- /**
- * Handle a ParticipantUpdateAck message from a participant.
- *
- * @param participantUpdateAckMessage the ParticipantUpdateAck message received from a participant
- */
- @MessageIntercept
- public void handleParticipantMessage(ParticipantUpdateAck participantUpdateAckMessage) {
- LOGGER.debug("Participant Update Ack received {}", participantUpdateAckMessage);
- try {
- var participantOpt =
- participantProvider.findParticipant(participantUpdateAckMessage.getParticipantId().getName(),
- participantUpdateAckMessage.getParticipantId().getVersion());
-
- if (participantOpt.isPresent()) {
- var participant = participantOpt.get();
- participant.setParticipantState(participantUpdateAckMessage.getState());
- participantProvider.saveParticipant(participant);
- } else {
- LOGGER.warn("Participant not found in database {}", participantUpdateAckMessage.getParticipantId());
- }
- } catch (PfModelException pfme) {
- LOGGER.warn("Model exception occured with participant id {}",
- participantUpdateAckMessage.getParticipantId());
- }
- }
-
- /**
- * Send commissioning update message to dmaap.
- *
- * @param name the ToscaServiceTemplate name
- * @param version the ToscaServiceTemplate version
- */
- public void handleSendCommissionMessage(String name, String version) {
- LOGGER.debug("Participant update message with serviveTemplate {} {} being sent to all participants", name,
- version);
- participantUpdatePublisher.sendComissioningBroadcast(name, version);
- }
-
- /**
- * Send decommissioning update message to dmaap.
- *
- */
- public void handleSendDeCommissionMessage() {
- LOGGER.debug("Participant update message being sent");
- participantUpdatePublisher.sendDecomisioning();
- }
-
- /**
- * Handle a ControlLoop update acknowledge message from a participant.
- *
- * @param controlLoopAckMessage the ControlLoopAck message received from a participant
- */
- @MessageIntercept
- public void handleControlLoopUpdateAckMessage(ControlLoopAck controlLoopAckMessage) {
- LOGGER.debug("ControlLoop Update Ack message received {}", controlLoopAckMessage);
- setClElementStateInDb(controlLoopAckMessage);
- }
-
- /**
- * Handle a ControlLoop statechange acknowledge message from a participant.
- *
- * @param controlLoopAckMessage the ControlLoopAck message received from a participant
- */
- @MessageIntercept
- public void handleControlLoopStateChangeAckMessage(ControlLoopAck controlLoopAckMessage) {
- LOGGER.debug("ControlLoop StateChange Ack message received {}", controlLoopAckMessage);
- setClElementStateInDb(controlLoopAckMessage);
- }
-
- private void setClElementStateInDb(ControlLoopAck controlLoopAckMessage) {
- if (controlLoopAckMessage.getControlLoopResultMap() != null) {
- try {
- var controlLoop = controlLoopProvider.getControlLoop(controlLoopAckMessage.getControlLoopId());
- if (controlLoop != null) {
- var updated = updateState(controlLoop, controlLoopAckMessage.getControlLoopResultMap().entrySet());
- updated |= setPrimed(controlLoop);
- if (updated) {
- controlLoopProvider.saveControlLoop(controlLoop);
- }
- } else {
- LOGGER.warn("ControlLoop not found in database {}", controlLoopAckMessage.getControlLoopId());
- }
- } catch (PfModelException pfme) {
- LOGGER.warn("Model exception occured with ControlLoop Id {}", controlLoopAckMessage.getControlLoopId());
- }
- }
- }
-
- private boolean updateState(ControlLoop controlLoop,
- Set<Map.Entry<UUID, ControlLoopElementAck>> controlLoopResultSet) {
- var updated = false;
- for (var clElementAck : controlLoopResultSet) {
- var element = controlLoop.getElements().get(clElementAck.getKey());
- if (element != null) {
- element.setState(clElementAck.getValue().getState());
- updated = true;
- }
- }
- return updated;
- }
-
- private boolean setPrimed(ControlLoop controlLoop) {
- var clElements = controlLoop.getElements().values();
- if (clElements != null) {
- Boolean primedFlag = true;
- var checkOpt = controlLoop.getElements().values().stream()
- .filter(clElement -> (!clElement.getState().equals(ControlLoopState.PASSIVE)
- || !clElement.getState().equals(ControlLoopState.RUNNING)))
- .findAny();
- if (checkOpt.isEmpty()) {
- primedFlag = false;
- }
- controlLoop.setPrimed(primedFlag);
- return true;
- }
-
- return false;
- }
-
- /**
- * 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 {
- 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);
- controlLoopStateChangePublisher.send(controlLoop, getFirstStartPhase(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 {
- 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);
- controlLoopUpdatePublisher.send(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);
- controlLoopStateChangePublisher.send(controlLoop, getFirstStartPhase(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);
- controlLoopStateChangePublisher.send(controlLoop, getFirstStartPhase(controlLoop));
- break;
-
- default:
- exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
- + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
- break;
- }
- }
-
- private int getFirstStartPhase(ControlLoop controlLoop) {
- ToscaServiceTemplate toscaServiceTemplate = null;
- try {
- toscaServiceTemplate = serviceTemplateProvider.getAllServiceTemplates().get(0);
- } catch (PfModelException e) {
- throw new PfModelRuntimeException(Status.BAD_REQUEST, "Canont load ToscaServiceTemplate from DB", e);
- }
- return ParticipantUtils.getFirstStartPhase(controlLoop, toscaServiceTemplate);
- }
-
- private void checkParticipant(ParticipantMessage participantMessage, ParticipantState participantState,
- ParticipantHealthStatus healthStatus) throws ControlLoopException, PfModelException {
- if (participantMessage.getParticipantId() == null) {
- exceptionOccured(Response.Status.NOT_FOUND, "Participant ID on PARTICIPANT_STATUS message is null");
- }
- var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId().getName(),
- participantMessage.getParticipantId().getVersion());
-
- if (participantOpt.isEmpty()) {
- var participant = new Participant();
- participant.setName(participantMessage.getParticipantId().getName());
- participant.setVersion(participantMessage.getParticipantId().getVersion());
- participant.setDefinition(participantMessage.getParticipantId());
- participant.setParticipantType(participantMessage.getParticipantType());
- participant.setParticipantState(participantState);
- participant.setHealthStatus(healthStatus);
-
- participantProvider.saveParticipant(participant);
- } else {
- var participant = participantOpt.get();
- participant.setParticipantState(participantState);
- participant.setHealthStatus(healthStatus);
-
- participantProvider.saveParticipant(participant);
- }
- }
-
- private void superviseParticipant(ParticipantStatus participantStatusMessage)
- throws PfModelException, ControlLoopException {
-
- checkParticipant(participantStatusMessage, participantStatusMessage.getState(),
- participantStatusMessage.getHealthStatus());
-
- monitoringProvider.createParticipantStatistics(List.of(participantStatusMessage.getParticipantStatistics()));
- }
-
- private void superviseControlLoops(ParticipantStatus participantStatusMessage)
- throws PfModelException, ControlLoopException {
- if (participantStatusMessage.getControlLoopInfoList() != null) {
- for (ControlLoopInfo clEntry : participantStatusMessage.getControlLoopInfoList()) {
- var dbControlLoop =
- controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(clEntry.getControlLoopId()));
- if (dbControlLoop == null) {
- exceptionOccured(Response.Status.NOT_FOUND,
- "PARTICIPANT_STATUS control loop not found in database: " + clEntry.getControlLoopId());
- }
- dbControlLoop.setState(clEntry.getState());
- monitoringProvider.createClElementStatistics(
- clEntry.getControlLoopStatistics().getClElementStatisticsList().getClElementStatistics());
- }
- }
- }
-
- 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
deleted file mode 100644
index 01e035b87..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
+++ /dev/null
@@ -1,301 +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.runtime.supervision;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.commons.lang3.tuple.Pair;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider;
-import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopStateChangePublisher;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopUpdatePublisher;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusReqPublisher;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
-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.ToscaServiceTemplate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * This class is used to scan the control loops in the database and check if they are in the correct state.
- */
-@Component
-public class SupervisionScanner {
- private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class);
-
- private final HandleCounter<ToscaConceptIdentifier> controlLoopCounter = new HandleCounter<>();
- private final HandleCounter<ToscaConceptIdentifier> participantStatusCounter = new HandleCounter<>();
- private final HandleCounter<Pair<ToscaConceptIdentifier, ToscaConceptIdentifier>> participantUpdateCounter =
- new HandleCounter<>();
-
- private final Map<ToscaConceptIdentifier, Integer> phaseMap = new HashMap<>();
-
- private final ControlLoopProvider controlLoopProvider;
- private final ServiceTemplateProvider serviceTemplateProvider;
- private final ControlLoopStateChangePublisher controlLoopStateChangePublisher;
- private final ControlLoopUpdatePublisher controlLoopUpdatePublisher;
- private final ParticipantProvider participantProvider;
- private final ParticipantStatusReqPublisher participantStatusReqPublisher;
- private final ParticipantUpdatePublisher participantUpdatePublisher;
-
- /**
- * Constructor for instantiating SupervisionScanner.
- *
- * @param controlLoopProvider the provider to use to read control loops from the database
- * @param serviceTemplateProvider the Policy Models Provider
- * @param controlLoopStateChangePublisher the ControlLoop StateChange Publisher
- * @param controlLoopUpdatePublisher the ControlLoopUpdate Publisher
- * @param participantProvider the Participant Provider
- * @param participantStatusReqPublisher the Participant StatusReq Publisher
- * @param participantUpdatePublisher the Participant Update Publisher
- * @param clRuntimeParameterGroup the parameters for the control loop runtime
- */
- public SupervisionScanner(final ControlLoopProvider controlLoopProvider,
- ServiceTemplateProvider serviceTemplateProvider,
- final ControlLoopStateChangePublisher controlLoopStateChangePublisher,
- ControlLoopUpdatePublisher controlLoopUpdatePublisher, ParticipantProvider participantProvider,
- ParticipantStatusReqPublisher participantStatusReqPublisher,
- ParticipantUpdatePublisher participantUpdatePublisher,
- final ClRuntimeParameterGroup clRuntimeParameterGroup) {
- this.controlLoopProvider = controlLoopProvider;
- this.serviceTemplateProvider = serviceTemplateProvider;
- this.controlLoopStateChangePublisher = controlLoopStateChangePublisher;
- this.controlLoopUpdatePublisher = controlLoopUpdatePublisher;
- this.participantProvider = participantProvider;
- this.participantStatusReqPublisher = participantStatusReqPublisher;
- this.participantUpdatePublisher = participantUpdatePublisher;
-
- controlLoopCounter.setMaxRetryCount(
- clRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
- controlLoopCounter.setMaxWaitMs(clRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
-
- participantUpdateCounter.setMaxRetryCount(
- clRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
- participantUpdateCounter
- .setMaxWaitMs(clRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxWaitMs());
-
- participantStatusCounter.setMaxRetryCount(
- clRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
- participantStatusCounter.setMaxWaitMs(clRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
- }
-
- /**
- * Run Scanning.
- *
- * @param counterCheck if true activate counter and retry
- */
- public void run(boolean counterCheck) {
- LOGGER.debug("Scanning control loops in the database . . .");
-
- if (counterCheck) {
- try {
- for (var participant : participantProvider.getParticipants()) {
- scanParticipantStatus(participant);
- }
- } catch (PfModelException pfme) {
- LOGGER.warn("error reading participant from database", pfme);
- return;
- }
- }
-
- try {
- var list = serviceTemplateProvider.getAllServiceTemplates();
- if (list != null && !list.isEmpty()) {
- ToscaServiceTemplate toscaServiceTemplate = list.get(0);
-
- for (ControlLoop controlLoop : controlLoopProvider.getControlLoops()) {
- scanControlLoop(controlLoop, toscaServiceTemplate, counterCheck);
- }
- }
- } catch (PfModelException pfme) {
- LOGGER.warn("error reading control loops from database", pfme);
- }
-
- if (counterCheck) {
- scanParticipantUpdate();
- }
-
- LOGGER.debug("Control loop scan complete . . .");
- }
-
- private void scanParticipantUpdate() {
- LOGGER.debug("Scanning participants to update . . .");
-
- for (var id : participantUpdateCounter.keySet()) {
- if (participantUpdateCounter.isFault(id)) {
- LOGGER.debug("report Participant Update fault");
-
- } else if (participantUpdateCounter.getDuration(id) > participantUpdateCounter.getMaxWaitMs()) {
-
- if (participantUpdateCounter.count(id)) {
- LOGGER.debug("retry message ParticipantUpdate");
- participantUpdatePublisher.sendCommissioning(null, null, id.getLeft(), id.getRight());
- } else {
- LOGGER.debug("report Participant Update fault");
- participantUpdateCounter.setFault(id);
- }
- }
- }
-
- LOGGER.debug("Participants to update scan complete . . .");
- }
-
- private void scanParticipantStatus(Participant participant) throws PfModelException {
- ToscaConceptIdentifier id = participant.getKey().asIdentifier();
- if (participantStatusCounter.isFault(id)) {
- LOGGER.debug("report Participant fault");
- return;
- }
- if (participantStatusCounter.getDuration(id) > participantStatusCounter.getMaxWaitMs()) {
- if (participantStatusCounter.count(id)) {
- LOGGER.debug("retry message ParticipantStatusReq");
- participantStatusReqPublisher.send(id);
- participant.setHealthStatus(ParticipantHealthStatus.NOT_HEALTHY);
- } else {
- LOGGER.debug("report Participant fault");
- participantStatusCounter.setFault(id);
- participant.setHealthStatus(ParticipantHealthStatus.OFF_LINE);
- }
- participantProvider.saveParticipant(participant);
- }
- }
-
- /**
- * handle participant Status message.
- */
- public void handleParticipantStatus(ToscaConceptIdentifier id) {
- participantStatusCounter.clear(id);
- }
-
- public void handleParticipantRegister(Pair<ToscaConceptIdentifier, ToscaConceptIdentifier> id) {
- participantUpdateCounter.clear(id);
- }
-
- public void handleParticipantUpdateAck(Pair<ToscaConceptIdentifier, ToscaConceptIdentifier> id) {
- participantUpdateCounter.remove(id);
- }
-
- private void scanControlLoop(final ControlLoop controlLoop, ToscaServiceTemplate toscaServiceTemplate,
- boolean counterCheck) 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());
-
- // Clear missed report counter on Control Loop
- clearFaultAndCounter(controlLoop);
- return;
- }
-
- var completed = true;
- var minSpNotCompleted = 1000; // min startPhase not completed
- var maxSpNotCompleted = 0; // max startPhase not completed
- var defaultMin = 1000; // min startPhase
- var defaultMax = 0; // max startPhase
- for (ControlLoopElement element : controlLoop.getElements().values()) {
- ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()
- .get(element.getDefinition().getName());
- int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties());
- defaultMin = Math.min(defaultMin, startPhase);
- defaultMax = Math.max(defaultMax, startPhase);
- if (!element.getState().equals(element.getOrderedState().asState())) {
- completed = false;
- minSpNotCompleted = Math.min(minSpNotCompleted, startPhase);
- maxSpNotCompleted = Math.max(maxSpNotCompleted, startPhase);
- }
- }
-
- if (completed) {
- LOGGER.debug("control loop scan: transition from state {} to {} completed", controlLoop.getState(),
- controlLoop.getOrderedState());
-
- controlLoop.setState(controlLoop.getOrderedState().asState());
- controlLoopProvider.saveControlLoop(controlLoop);
-
- // Clear missed report counter on Control Loop
- clearFaultAndCounter(controlLoop);
- } else {
- LOGGER.debug("control loop scan: transition from state {} to {} not completed", controlLoop.getState(),
- controlLoop.getOrderedState());
-
- var nextSpNotCompleted = ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())
- || ControlLoopState.PASSIVE2RUNNING.equals(controlLoop.getState()) ? minSpNotCompleted
- : maxSpNotCompleted;
-
- var firstStartPhase = ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())
- || ControlLoopState.PASSIVE2RUNNING.equals(controlLoop.getState()) ? defaultMin : defaultMax;
-
- if (nextSpNotCompleted != phaseMap.getOrDefault(controlLoop.getKey().asIdentifier(), firstStartPhase)) {
- phaseMap.put(controlLoop.getKey().asIdentifier(), nextSpNotCompleted);
- sendControlLoopMsg(controlLoop, nextSpNotCompleted);
- } else if (counterCheck) {
- phaseMap.put(controlLoop.getKey().asIdentifier(), nextSpNotCompleted);
- handleCounter(controlLoop, nextSpNotCompleted);
- }
- }
- }
-
- private void clearFaultAndCounter(ControlLoop controlLoop) {
- controlLoopCounter.clear(controlLoop.getKey().asIdentifier());
- phaseMap.clear();
- }
-
- private void handleCounter(ControlLoop controlLoop, int startPhase) {
- ToscaConceptIdentifier id = controlLoop.getKey().asIdentifier();
- if (controlLoopCounter.isFault(id)) {
- LOGGER.debug("report ControlLoop fault");
- return;
- }
-
- if (controlLoopCounter.getDuration(id) > controlLoopCounter.getMaxWaitMs()) {
- if (controlLoopCounter.count(id)) {
- phaseMap.put(id, startPhase);
- sendControlLoopMsg(controlLoop, startPhase);
- } else {
- LOGGER.debug("report ControlLoop fault");
- controlLoopCounter.setFault(id);
- }
- }
- }
-
- private void sendControlLoopMsg(ControlLoop controlLoop, int startPhase) {
- if (ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())) {
- LOGGER.debug("retry message ControlLoopUpdate");
- controlLoopUpdatePublisher.send(controlLoop, startPhase);
- } else {
- LOGGER.debug("retry message ControlLoopStateChange");
- controlLoopStateChangePublisher.send(controlLoop, startPhase);
- }
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java
deleted file mode 100644
index 4b4ca9915..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java
+++ /dev/null
@@ -1,62 +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.runtime.supervision.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.ParticipantAckMessage;
-import org.onap.policy.clamp.controlloop.runtime.config.messaging.Publisher;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
-
-public abstract class AbstractParticipantAckPublisher<E extends ParticipantAckMessage> implements Publisher {
-
- private TopicSinkClient topicSinkClient;
- private boolean active = false;
-
- /**
- * Method to send Participant message to participants on demand.
- *
- * @param participantMessage the Participant message
- */
- public void send(final E participantMessage) {
- if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
- }
- topicSinkClient.send(participantMessage);
- }
-
-
- @Override
- public void active(List<TopicSink> topicSinks) {
- if (topicSinks.size() != 1) {
- throw new IllegalArgumentException("Topic Sink must be one");
- }
- this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
- active = true;
- }
-
- @Override
- public void stop() {
- active = false;
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantPublisher.java
deleted file mode 100644
index 3c87b05b4..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantPublisher.java
+++ /dev/null
@@ -1,62 +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.runtime.supervision.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.ParticipantMessage;
-import org.onap.policy.clamp.controlloop.runtime.config.messaging.Publisher;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
-
-public abstract class AbstractParticipantPublisher<E extends ParticipantMessage> implements Publisher {
-
- private TopicSinkClient topicSinkClient;
- private boolean active = false;
-
- /**
- * Method to send Participant message to participants on demand.
- *
- * @param participantMessage the Participant message
- */
- public void send(final E participantMessage) {
- if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
- }
- topicSinkClient.send(participantMessage);
- }
-
-
- @Override
- public void active(List<TopicSink> topicSinks) {
- if (topicSinks.size() != 1) {
- throw new IllegalArgumentException("Topic Sink must be one");
- }
- this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
- active = true;
- }
-
- @Override
- public void stop() {
- active = false;
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java
deleted file mode 100644
index c40095bef..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java
+++ /dev/null
@@ -1,68 +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.runtime.supervision.comm;
-
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * Listener for ControlLoopStateChangeAck messages sent by participants.
- */
-@Component
-public class ControlLoopStateChangeAckListener extends ScoListener<ControlLoopAck> implements Listener<ControlLoopAck> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopStateChangeAckListener.class);
-
- private final SupervisionHandler supervisionHandler;
-
- /**
- * Constructs the object.
- */
- public ControlLoopStateChangeAckListener(SupervisionHandler supervisionHandler) {
- super(ControlLoopAck.class);
- this.supervisionHandler = supervisionHandler;
- }
-
- @Override
- public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
- final ControlLoopAck controlLoopStateChangeAckMessage) {
- LOGGER.debug("ControlLoopStateChangeAck received from participant - {}", controlLoopStateChangeAckMessage);
- supervisionHandler.handleControlLoopStateChangeAckMessage(controlLoopStateChangeAckMessage);
- }
-
- @Override
- public ScoListener<ControlLoopAck> getScoListener() {
- return this;
- }
-
- @Override
- public String getType() {
- return ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK.name();
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangePublisher.java
deleted file mode 100644
index 69d7b73d0..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangePublisher.java
+++ /dev/null
@@ -1,50 +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.runtime.supervision.comm;
-
-import java.util.UUID;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
-import org.springframework.stereotype.Component;
-
-/**
- * This class is used to send ControlLoopStateChangePublisher messages to participants on DMaaP.
- */
-@Component
-public class ControlLoopStateChangePublisher
- extends AbstractParticipantPublisher<ControlLoopStateChange> {
-
- /**
- * Send ControlLoopStateChange to Participant.
- *
- * @param controlLoop the ControlLoop
- * @param startPhase the startPhase
- */
- public void send(ControlLoop controlLoop, int startPhase) {
- var clsc = new ControlLoopStateChange();
- clsc.setControlLoopId(controlLoop.getKey().asIdentifier());
- clsc.setMessageId(UUID.randomUUID());
- clsc.setOrderedState(controlLoop.getOrderedState());
- clsc.setStartPhase(startPhase);
-
- super.send(clsc);
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java
deleted file mode 100644
index b8b5126ad..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java
+++ /dev/null
@@ -1,68 +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.runtime.supervision.comm;
-
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * Listener for ControlLoopUpdateAck messages sent by participants.
- */
-@Component
-public class ControlLoopUpdateAckListener extends ScoListener<ControlLoopAck> implements Listener<ControlLoopAck> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopUpdateAckListener.class);
-
- private final SupervisionHandler supervisionHandler;
-
- /**
- * Constructs the object.
- */
- public ControlLoopUpdateAckListener(SupervisionHandler supervisionHandler) {
- super(ControlLoopAck.class);
- this.supervisionHandler = supervisionHandler;
- }
-
- @Override
- public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
- final ControlLoopAck controlLoopUpdateAckMessage) {
- LOGGER.debug("ControlLoopUpdateAck message received from participant - {}", controlLoopUpdateAckMessage);
- supervisionHandler.handleControlLoopUpdateAckMessage(controlLoopUpdateAckMessage);
- }
-
- @Override
- public ScoListener<ControlLoopAck> getScoListener() {
- return this;
- }
-
- @Override
- public String getType() {
- return ParticipantMessageType.CONTROLLOOP_UPDATE_ACK.name();
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
deleted file mode 100644
index 24f60eafc..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
+++ /dev/null
@@ -1,91 +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.runtime.supervision.comm;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import lombok.AllArgsConstructor;
-import org.onap.policy.clamp.controlloop.common.utils.CommonUtils;
-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.ParticipantUpdates;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * This class is used to send ControlLoopUpdate messages to participants on DMaaP.
- */
-@Component
-@AllArgsConstructor
-public class ControlLoopUpdatePublisher extends AbstractParticipantPublisher<ControlLoopUpdate> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopUpdatePublisher.class);
- private final ServiceTemplateProvider serviceTemplateProvider;
-
- /**
- * Send ControlLoopUpdate to Participant.
- *
- * @param controlLoop the ControlLoop
- */
- public void send(ControlLoop controlLoop) {
- send(controlLoop, 0);
- }
-
- /**
- * Send ControlLoopUpdate to Participant.
- *
- * @param controlLoop the ControlLoop
- * @param startPhase the Start Phase
- */
- public void send(ControlLoop controlLoop, int startPhase) {
- var controlLoopUpdateMsg = new ControlLoopUpdate();
- controlLoopUpdateMsg.setStartPhase(startPhase);
- controlLoopUpdateMsg.setControlLoopId(controlLoop.getKey().asIdentifier());
- controlLoopUpdateMsg.setMessageId(UUID.randomUUID());
- controlLoopUpdateMsg.setTimestamp(Instant.now());
- ToscaServiceTemplate toscaServiceTemplate;
- try {
- toscaServiceTemplate = serviceTemplateProvider.getAllServiceTemplates().get(0);
- } catch (PfModelException pfme) {
- LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme);
- return;
- }
-
- List<ParticipantUpdates> participantUpdates = new ArrayList<>();
- for (ControlLoopElement element : controlLoop.getElements().values()) {
- CommonUtils.setServiceTemplatePolicyInfo(element, toscaServiceTemplate);
- CommonUtils.prepareParticipantUpdate(element, participantUpdates);
- }
- controlLoopUpdateMsg.setParticipantUpdatesList(participantUpdates);
-
- LOGGER.debug("ControlLoopUpdate message sent {}", controlLoopUpdateMsg);
- super.send(controlLoopUpdateMsg);
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java
deleted file mode 100644
index e92b6ee1b..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java
+++ /dev/null
@@ -1,45 +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.runtime.supervision.comm;
-
-import java.util.UUID;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
-import org.springframework.stereotype.Component;
-
-/**
- * This class is used to send ParticipantDeregisterAck messages to participants on DMaaP.
- */
-@Component
-public class ParticipantDeregisterAckPublisher extends AbstractParticipantAckPublisher<ParticipantDeregisterAck> {
-
- /**
- * Sent ParticipantDeregisterAck to Participant.
- *
- * @param responseTo the original request id in the request.
- */
- public void send(UUID responseTo) {
- var message = new ParticipantDeregisterAck();
- message.setResponseTo(responseTo);
- message.setMessage("Participant Deregister Ack");
- message.setResult(true);
- super.send(message);
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java
deleted file mode 100644
index b8b209bac..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java
+++ /dev/null
@@ -1,69 +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.runtime.supervision.comm;
-
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * Listener for ParticipantDeregister messages sent by participants.
- */
-@Component
-public class ParticipantDeregisterListener extends ScoListener<ParticipantDeregister>
- implements Listener<ParticipantDeregister> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantDeregisterListener.class);
-
- private final SupervisionHandler supervisionHandler;
-
- /**
- * Constructs the object.
- */
- public ParticipantDeregisterListener(SupervisionHandler supervisionHandler) {
- super(ParticipantDeregister.class);
- this.supervisionHandler = supervisionHandler;
- }
-
- @Override
- public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
- final ParticipantDeregister participantDeregisterMessage) {
- LOGGER.debug("ParticipantDeregister message received from participant - {}", participantDeregisterMessage);
- supervisionHandler.handleParticipantMessage(participantDeregisterMessage);
- }
-
- @Override
- public String getType() {
- return ParticipantMessageType.PARTICIPANT_DEREGISTER.name();
- }
-
- @Override
- public ScoListener<ParticipantDeregister> getScoListener() {
- return this;
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java
deleted file mode 100644
index 8cbaec8b1..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java
+++ /dev/null
@@ -1,50 +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.runtime.supervision.comm;
-
-import java.util.UUID;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.springframework.stereotype.Component;
-
-/**
- * This class is used to send ParticipantRegisterAck messages to participants on DMaaP.
- */
-@Component
-public class ParticipantRegisterAckPublisher extends AbstractParticipantAckPublisher<ParticipantRegisterAck> {
-
- /**
- * Send ParticipantRegisterAck to Participant.
- *
- * @param responseTo the original request id in the request.
- * @param participantId the participant Id
- * @param participantType the participant Type
- */
- public void send(UUID responseTo, ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType) {
- var message = new ParticipantRegisterAck();
- message.setParticipantId(participantId);
- message.setParticipantType(participantType);
- message.setResponseTo(responseTo);
- message.setMessage("Participant Register Ack");
- message.setResult(true);
- super.send(message);
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java
deleted file mode 100644
index fdf0bf3f7..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java
+++ /dev/null
@@ -1,69 +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.runtime.supervision.comm;
-
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
-import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * Listener for ParticipantRegister messages sent by participants.
- */
-@Component
-public class ParticipantRegisterListener extends ScoListener<ParticipantRegister>
- implements Listener<ParticipantRegister> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRegisterListener.class);
-
- private final SupervisionHandler supervisionHandler;
-
- /**
- * Constructs the object.
- */
- public ParticipantRegisterListener(SupervisionHandler supervisionHandler) {
- super(ParticipantRegister.class);
- this.supervisionHandler = supervisionHandler;
- }
-
- @Override
- public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
- final ParticipantRegister participantRegisterMessage) {
- LOGGER.debug("ParticipantRegister message received from participant - {}", participantRegisterMessage);
- supervisionHandler.handleParticipantMessage(participantRegisterMessage);
- }
-
- @Override
- public String getType() {
- return ParticipantMessageType.PARTICIPANT_REGISTER.name();
- }
-
- @Override
- public ScoListener<ParticipantRegister> getScoListener() {
- return this;
- }
-}
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
deleted file mode 100644
index 43a07e220..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
+++ /dev/null
@@ -1,68 +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.runtime.supervision.comm;
-
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
-import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * Listener for ParticipantStatus messages sent by participants.
- */
-@Component
-public class ParticipantStatusListener extends ScoListener<ParticipantStatus> implements Listener<ParticipantStatus> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusListener.class);
-
- private final SupervisionHandler supervisionHandler;
-
- /**
- * Constructs the object.
- */
- public ParticipantStatusListener(SupervisionHandler supervisionHandler) {
- super(ParticipantStatus.class);
- this.supervisionHandler = supervisionHandler;
- }
-
- @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.handleParticipantMessage(participantStatusMessage);
- }
-
- @Override
- public String getType() {
- return ParticipantMessageType.PARTICIPANT_STATUS.name();
- }
-
- @Override
- public ScoListener<ParticipantStatus> getScoListener() {
- return this;
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusReqPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusReqPublisher.java
deleted file mode 100644
index 69d598285..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusReqPublisher.java
+++ /dev/null
@@ -1,48 +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.runtime.supervision.comm;
-
-import java.time.Instant;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatusReq;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ParticipantStatusReqPublisher extends AbstractParticipantPublisher<ParticipantStatusReq> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusReqPublisher.class);
-
- /**
- * Send ParticipantStatusReq to Participant.
- *
- * @param participantId the participant Id
- */
- public void send(ToscaConceptIdentifier participantId) {
- ParticipantStatusReq message = new ParticipantStatusReq();
- message.setParticipantId(participantId);
- message.setTimestamp(Instant.now());
-
- LOGGER.debug("Participant StatusReq sent {}", message);
- super.send(message);
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java
deleted file mode 100644
index fcfa80a9f..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java
+++ /dev/null
@@ -1,69 +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.runtime.supervision.comm;
-
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
-import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * Listener for ParticipantUpdateAck messages sent by participants.
- */
-@Component
-public class ParticipantUpdateAckListener extends ScoListener<ParticipantUpdateAck>
- implements Listener<ParticipantUpdateAck> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdateAckListener.class);
-
- private final SupervisionHandler supervisionHandler;
-
- /**
- * Constructs the object.
- */
- public ParticipantUpdateAckListener(SupervisionHandler supervisionHandler) {
- super(ParticipantUpdateAck.class);
- this.supervisionHandler = supervisionHandler;
- }
-
- @Override
- public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
- final ParticipantUpdateAck participantUpdateAckMessage) {
- LOGGER.debug("ParticipantUpdateAck message received from participant - {}", participantUpdateAckMessage);
- supervisionHandler.handleParticipantMessage(participantUpdateAckMessage);
- }
-
- @Override
- public String getType() {
- return ParticipantMessageType.PARTICIPANT_UPDATE_ACK.name();
- }
-
- @Override
- public ScoListener<ParticipantUpdateAck> getScoListener() {
- return this;
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
deleted file mode 100644
index c6788f12c..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
+++ /dev/null
@@ -1,127 +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.runtime.supervision.comm;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import lombok.AllArgsConstructor;
-import org.onap.policy.clamp.controlloop.common.utils.CommonUtils;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * This class is used to send ParticipantUpdate messages to participants on DMaaP.
- */
-@Component
-@AllArgsConstructor
-public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<ParticipantUpdate> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdatePublisher.class);
-
- private final ServiceTemplateProvider serviceTemplateProvider;
-
- /**
- * Send ParticipantUpdate to all Participants.
- *
- * @param name the ToscaServiceTemplate name
- * @param version the ToscaServiceTemplate version
- */
- public void sendComissioningBroadcast(String name, String version) {
- sendCommissioning(name, version, null, null);
- }
-
- /**
- * Send ParticipantUpdate to Participant
- * if participantType and participantId are null then message is broadcast.
- *
- * @param name the ToscaServiceTemplate name
- * @param version the ToscaServiceTemplate version
- * @param participantType the ParticipantType
- * @param participantId the ParticipantId
- */
- public boolean sendCommissioning(String name, String version, ToscaConceptIdentifier participantType,
- ToscaConceptIdentifier participantId) {
- var message = new ParticipantUpdate();
- message.setParticipantType(participantType);
- message.setParticipantId(participantId);
- message.setTimestamp(Instant.now());
-
- ToscaServiceTemplate toscaServiceTemplate = null;
- Map<String, ToscaNodeType> commonPropertiesMap = null;
- try {
- var list = serviceTemplateProvider.getServiceTemplateList(name, version);
- if (!list.isEmpty()) {
- toscaServiceTemplate = list.get(0);
- commonPropertiesMap =
- serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(true, toscaServiceTemplate);
- } else {
- LOGGER.warn("No tosca service template found, cannot send participantupdate {} {}", name, version);
- return false;
- }
- } catch (PfModelException pfme) {
- LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme);
- return false;
- }
-
- List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
- for (var toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().entrySet()) {
- if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(),
- toscaServiceTemplate)) {
- CommonUtils.prepareParticipantDefinitionUpdate(
- ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()),
- toscaInputEntry.getKey(), toscaInputEntry.getValue(),
- participantDefinitionUpdates, commonPropertiesMap);
- }
- }
-
- // Commission the controlloop but sending participantdefinitions to participants
- message.setParticipantDefinitionUpdates(participantDefinitionUpdates);
- LOGGER.debug("Participant Update sent {}", message);
- super.send(message);
- return true;
- }
-
- /**
- * Send ParticipantUpdate to Participant after that commissioning has been removed.
- */
- public void sendDecomisioning() {
- var message = new ParticipantUpdate();
- message.setTimestamp(Instant.now());
- // DeCommission the controlloop but deleting participantdefinitions on participants
- message.setParticipantDefinitionUpdates(null);
-
- LOGGER.debug("Participant Update sent {}", message);
- super.send(message);
- }
-}
diff --git a/runtime-controlloop/src/main/resources/application.yaml b/runtime-controlloop/src/main/resources/application.yaml
deleted file mode 100644
index 3a3ada563..000000000
--- a/runtime-controlloop/src/main/resources/application.yaml
+++ /dev/null
@@ -1,67 +0,0 @@
-spring:
- security:
- user:
- name: runtimeUser
- password: zb!XztG34
- http:
- converters:
- preferred-json-mapper: gson
- datasource:
- url: jdbc:mariadb://${mariadb.host:localhost}:${mariadb.port:3306}/controlloop
- driverClassName: org.mariadb.jdbc.Driver
- username: policy
- password: P01icY
- hikari:
- connectionTimeout: 30000
- idleTimeout: 600000
- maxLifetime: 1800000
- maximumPoolSize: 10
- jpa:
- hibernate:
- ddl-auto: update
- naming:
- physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
- implicit-strategy: org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy
- properties:
- hibernate:
- dialect: org.hibernate.dialect.MariaDB103Dialect
- format_sql: true
-
-security:
- enable-csrf: false
-
-server:
- port: 6969
- servlet:
- context-path: /onap/controlloop
- error:
- path: /error
-
-
-runtime:
- participantParameters:
- heartBeatMs: 20000
- maxStatusWaitMs: 100000
- updateParameters:
- maxRetryCount: 4
- maxWaitMs: 20000
- topicParameterGroup:
- topicSources:
- -
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers:
- - ${topicServer:localhost}
- topicCommInfrastructure: dmaap
- fetchTimeout: 15000
- topicSinks:
- -
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers:
- - ${topicServer:localhost}
- topicCommInfrastructure: dmaap
-
-management:
- endpoints:
- web:
- exposure:
- include: health, metrics, prometheus
diff --git a/runtime-controlloop/src/main/resources/version.txt b/runtime-controlloop/src/main/resources/version.txt
deleted file mode 100644
index e11449e5b..000000000
--- a/runtime-controlloop/src/main/resources/version.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-ONAP Tosca defined control loop
-Version: ${project.version}
-Built (UTC): ${maven.build.timestamp}
-ONAP https://wiki.onap.org