summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src/main/java/org/onap
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2021-11-11 14:57:23 +0000
committerFrancescoFioraEst <francesco.fiora@est.tech>2021-11-25 13:25:48 +0000
commita41acc89a8c7177014d1377c4457cd402ed7ee93 (patch)
tree47eb78295c696d7281bc772e346ec260cd114ce1 /runtime-controlloop/src/main/java/org/onap
parent7443b9a5ddca988ad4338e2b6597d6fdce552909 (diff)
Add support transaction in CL and ServiceTemplate Providers
Add support transaction in ControlLoopProvider and ServiceTemplateProvider Issue-ID: POLICY-3798 Change-Id: I0ab79f28231e329e06c16e01427775077b3ac994 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-controlloop/src/main/java/org/onap')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java14
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/PolicyModelConfig.java45
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java55
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java63
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java18
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java6
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java9
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java2
8 files changed, 92 insertions, 120 deletions
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
index eac1ac305..7deba651f 100644
--- 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
@@ -103,7 +103,7 @@ public class CommissioningProvider {
}
synchronized (lockit) {
- serviceTemplateProvider.createServiceTemplate(serviceTemplate);
+ serviceTemplate = serviceTemplateProvider.createServiceTemplate(serviceTemplate);
List<Participant> participantList = participantProvider.getParticipants();
if (!participantList.isEmpty()) {
supervisionHandler.handleSendCommissionMessage(serviceTemplate.getName(), serviceTemplate.getVersion());
@@ -254,6 +254,16 @@ public class CommissioningProvider {
}
/**
+ * Get All the requested control loop definitions.
+ *
+ * @return the control loop definitions
+ * @throws PfModelException on errors getting control loop definitions
+ */
+ 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
@@ -363,7 +373,7 @@ public class CommissioningProvider {
* @return true if exists instance properties
*/
private boolean verifyIfInstancePropertiesExists() {
- return clProvider.getNodeTemplates(null, null).stream()
+ 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/PolicyModelConfig.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/PolicyModelConfig.java
deleted file mode 100644
index 8a151d886..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/PolicyModelConfig.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.parameters.ClRuntimeParameterGroup;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.provider.PolicyModelsProvider;
-import org.onap.policy.models.provider.PolicyModelsProviderFactory;
-import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class PolicyModelConfig {
-
- @Bean
- public PolicyModelsProviderParameters policyModelsProviderParameters(
- ClRuntimeParameterGroup clRuntimeParameterGroup) {
- return clRuntimeParameterGroup.getDatabaseProviderParameters();
- }
-
- @Bean
- public PolicyModelsProvider policyModelsProvider(PolicyModelsProviderParameters policyModelsProviderParameters)
- throws PfModelException {
- return new PolicyModelsProviderFactory().createPolicyModelsProvider(policyModelsProviderParameters);
- }
-}
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
index 40d9b249d..0d7d88803 100644
--- 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
@@ -27,7 +27,6 @@ import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -106,7 +105,7 @@ public class ControlLoopInstantiationProvider {
ControlLoop controlLoop = new ControlLoop();
Map<UUID, ControlLoopElement> controlLoopElements = new HashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getToscaServiceTemplate(null, null);
+ ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0);
Map<String, ToscaNodeTemplate> persistedNodeTemplateMap =
toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
@@ -155,7 +154,7 @@ public class ControlLoopInstantiationProvider {
Map<String, ToscaNodeTemplate> filteredToscaNodeTemplateMap = new HashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getToscaServiceTemplate(name, version);
+ ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0);
toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, nodeTemplate) -> {
if (!nodeTemplate.getName().contains(instanceName)) {
@@ -185,8 +184,8 @@ public class ControlLoopInstantiationProvider {
synchronized (lockit) {
for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- var checkControlLoop = controlLoopProvider.getControlLoop(controlLoop.getKey().asIdentifier());
- if (checkControlLoop != null) {
+ var checkControlLoopOpt = controlLoopProvider.findControlLoop(controlLoop.getKey().asIdentifier());
+ if (checkControlLoopOpt.isPresent()) {
throw new PfModelException(Response.Status.BAD_REQUEST,
controlLoop.getKey().asIdentifier() + " already defined");
}
@@ -195,7 +194,7 @@ public class ControlLoopInstantiationProvider {
if (!validationResult.isValid()) {
throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult());
}
- controlLoopProvider.createControlLoops(controlLoops.getControlLoopList());
+ controlLoopProvider.saveControlLoops(controlLoops.getControlLoopList());
}
var response = new InstantiationResponse();
@@ -218,7 +217,7 @@ public class ControlLoopInstantiationProvider {
if (!validationResult.isValid()) {
throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult());
}
- controlLoopProvider.updateControlLoops(controlLoops.getControlLoopList());
+ controlLoopProvider.saveControlLoops(controlLoops.getControlLoopList());
}
var response = new InstantiationResponse();
@@ -302,19 +301,18 @@ public class ControlLoopInstantiationProvider {
public InstantiationResponse deleteControlLoop(String name, String version) throws PfModelException {
var response = new InstantiationResponse();
synchronized (lockit) {
- List<ControlLoop> controlLoops = controlLoopProvider.getControlLoops(name, version);
- if (controlLoops.isEmpty()) {
+ var controlLoopOpt = controlLoopProvider.findControlLoop(name, version);
+ if (controlLoopOpt.isEmpty()) {
throw new PfModelException(Response.Status.NOT_FOUND, "Control Loop not found");
}
- for (ControlLoop controlLoop : controlLoops) {
- if (!ControlLoopState.UNINITIALISED.equals(controlLoop.getState())) {
- throw new PfModelException(Response.Status.BAD_REQUEST,
- "Control Loop State is still " + controlLoop.getState());
- }
+ var controlLoop = controlLoopOpt.get();
+ if (!ControlLoopState.UNINITIALISED.equals(controlLoop.getState())) {
+ throw new PfModelException(Response.Status.BAD_REQUEST,
+ "Control Loop State is still " + controlLoop.getState());
}
- response.setAffectedControlLoops(Collections
- .singletonList(controlLoopProvider.deleteControlLoop(name, version).getKey().asIdentifier()));
+ response.setAffectedControlLoops(
+ List.of(controlLoopProvider.deleteControlLoop(name, version).getKey().asIdentifier()));
}
return response;
}
@@ -354,17 +352,26 @@ public class ControlLoopInstantiationProvider {
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 controlLoop = controlLoopProvider.getControlLoop(id);
- controlLoop.setCascadedOrderedState(command.getOrderedState());
- controlLoops.add(controlLoop);
+ 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);
}
- BeanValidationResult validationResult = validateIssueControlLoops(controlLoops, participants);
if (!validationResult.isValid()) {
throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult());
}
- controlLoopProvider.updateControlLoops(controlLoops);
+ controlLoopProvider.saveControlLoops(controlLoops);
}
supervisionHandler.triggerControlLoopSupervision(command.getControlLoopIdentifierList());
@@ -473,8 +480,8 @@ public class ControlLoopInstantiationProvider {
synchronized (lockit) {
for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- var checkControlLoop = controlLoopProvider.getControlLoop(controlLoop.getKey().asIdentifier());
- if (checkControlLoop != null) {
+ 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");
}
@@ -482,7 +489,7 @@ public class ControlLoopInstantiationProvider {
toscaSavedNodeTemplate = controlLoopProvider.saveInstanceProperties(serviceTemplate);
- controlLoopProvider.createControlLoops(controlLoops.getControlLoopList());
+ controlLoopProvider.saveControlLoops(controlLoops.getControlLoopList());
}
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
index b65d3b784..d229e68cb 100644
--- 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
@@ -186,10 +186,10 @@ public class InstantiationController extends AbstractRestController {
// @formatter:on
public ResponseEntity<InstancePropertiesResponse> createInstanceProperties(
@RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ 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 {
+ throws PfModelException {
return ResponseEntity.ok().body(provider.createInstanceProperties(body));
}
@@ -249,13 +249,14 @@ public class InstantiationController extends AbstractRestController {
// @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 {
+ @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));
}
@@ -447,7 +448,7 @@ public class InstantiationController extends AbstractRestController {
@ApiParam(value = "Control Loop definition name", required = true) @RequestParam("name") String name,
@ApiParam(value = "Control Loop definition version") @RequestParam(
value = "version",
- required = false) String version)
+ required = true) String version)
throws PfModelException {
return ResponseEntity.ok().body(provider.deleteControlLoop(name, version));
@@ -559,16 +560,16 @@ public class InstantiationController extends AbstractRestController {
)
// @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 {
+ @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));
}
@@ -620,16 +621,16 @@ public class InstantiationController extends AbstractRestController {
)
// @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 {
+ @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/monitoring/MonitoringProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
index 802413a6a..cd9309422 100644
--- 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
@@ -174,9 +174,9 @@ public class MonitoringProvider {
try {
List<ControlLoopElement> clElements = new ArrayList<>();
// Fetch all control loop elements for the control loop
- var controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
- if (controlLoop != null) {
- clElements.addAll(controlLoop.getElements().values());
+ 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(),
@@ -203,9 +203,9 @@ public class MonitoringProvider {
public List<ToscaConceptIdentifier> getAllParticipantIdsPerControlLoop(String name, String version)
throws PfModelException {
List<ToscaConceptIdentifier> participantIds = new ArrayList<>();
- var controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
- if (controlLoop != null) {
- for (ControlLoopElement clElement : controlLoop.getElements().values()) {
+ var controlLoopOpt = controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(name, version));
+ if (controlLoopOpt.isPresent()) {
+ for (ControlLoopElement clElement : controlLoopOpt.get().getElements().values()) {
participantIds.add(clElement.getParticipantId());
}
}
@@ -224,9 +224,9 @@ public class MonitoringProvider {
public Map<String, ToscaConceptIdentifier> getAllClElementsIdPerControlLoop(String name, String version)
throws PfModelException {
Map<String, ToscaConceptIdentifier> clElementId = new HashMap<>();
- var controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
- if (controlLoop != null) {
- for (ControlLoopElement clElement : controlLoop.getElements().values()) {
+ 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());
}
}
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
index 7f0b85588..6af2788e6 100644
--- 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
@@ -114,7 +114,7 @@ public class SupervisionHandler {
superviseControlLoop(controlLoop);
- controlLoopProvider.updateControlLoop(controlLoop);
+ controlLoopProvider.saveControlLoop(controlLoop);
} catch (PfModelException pfme) {
throw new ControlLoopException(pfme.getErrorResponse().getResponseCode(), pfme.getMessage(), pfme);
}
@@ -269,7 +269,7 @@ public class SupervisionHandler {
var updated = updateState(controlLoop, controlLoopAckMessage.getControlLoopResultMap().entrySet());
updated |= setPrimed(controlLoop);
if (updated) {
- controlLoopProvider.updateControlLoop(controlLoop);
+ controlLoopProvider.saveControlLoop(controlLoop);
}
} else {
LOGGER.warn("ControlLoop not found in database {}", controlLoopAckMessage.getControlLoopId());
@@ -425,7 +425,7 @@ public class SupervisionHandler {
private int getFirstStartPhase(ControlLoop controlLoop) {
ToscaServiceTemplate toscaServiceTemplate = null;
try {
- toscaServiceTemplate = serviceTemplateProvider.getServiceTemplateList(null, null).get(0);
+ toscaServiceTemplate = serviceTemplateProvider.getAllServiceTemplates().get(0);
} catch (PfModelException e) {
throw new PfModelRuntimeException(Status.BAD_REQUEST, "Canont load ToscaServiceTemplate from DB", e);
}
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
index 5ebacdac7..01e035b87 100644
--- 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
@@ -130,11 +130,11 @@ public class SupervisionScanner {
}
try {
- var list = serviceTemplateProvider.getServiceTemplateList(null, null);
+ var list = serviceTemplateProvider.getAllServiceTemplates();
if (list != null && !list.isEmpty()) {
ToscaServiceTemplate toscaServiceTemplate = list.get(0);
- for (ControlLoop controlLoop : controlLoopProvider.getControlLoops(null, null)) {
+ for (ControlLoop controlLoop : controlLoopProvider.getControlLoops()) {
scanControlLoop(controlLoop, toscaServiceTemplate, counterCheck);
}
}
@@ -241,7 +241,7 @@ public class SupervisionScanner {
controlLoop.getOrderedState());
controlLoop.setState(controlLoop.getOrderedState().asState());
- controlLoopProvider.updateControlLoop(controlLoop);
+ controlLoopProvider.saveControlLoop(controlLoop);
// Clear missed report counter on Control Loop
clearFaultAndCounter(controlLoop);
@@ -254,8 +254,7 @@ public class SupervisionScanner {
: maxSpNotCompleted;
var firstStartPhase = ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())
- || ControlLoopState.PASSIVE2RUNNING.equals(controlLoop.getState()) ? defaultMin
- : defaultMax;
+ || ControlLoopState.PASSIVE2RUNNING.equals(controlLoop.getState()) ? defaultMin : defaultMax;
if (nextSpNotCompleted != phaseMap.getOrDefault(controlLoop.getKey().asIdentifier(), firstStartPhase)) {
phaseMap.put(controlLoop.getKey().asIdentifier(), nextSpNotCompleted);
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
index 32c0638af..24f60eafc 100644
--- 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
@@ -72,7 +72,7 @@ public class ControlLoopUpdatePublisher extends AbstractParticipantPublisher<Con
controlLoopUpdateMsg.setTimestamp(Instant.now());
ToscaServiceTemplate toscaServiceTemplate;
try {
- toscaServiceTemplate = serviceTemplateProvider.getServiceTemplateList(null, null).get(0);
+ toscaServiceTemplate = serviceTemplateProvider.getAllServiceTemplates().get(0);
} catch (PfModelException pfme) {
LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme);
return;