aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-controlloop/src/main')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java29
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java62
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java22
3 files changed, 111 insertions, 2 deletions
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 dc40cc274..28558cc02 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
@@ -47,6 +47,8 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
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;
@@ -389,6 +391,33 @@ public class ControlLoopInstantiationProvider {
/**
* 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
+ */
+ 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
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 91958f97a..b65d3b784 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
@@ -34,6 +34,7 @@ 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;
@@ -571,4 +572,65 @@ public class InstantiationController extends AbstractRestController {
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/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
index dbc2c4ea6..c4ca568f7 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
@@ -258,7 +258,8 @@ public class SupervisionHandler {
var controlLoop = controlLoopProvider.getControlLoop(controlLoopAckMessage.getControlLoopId());
if (controlLoop != null) {
var updated = updateState(controlLoop, controlLoopAckMessage
- .getControlLoopResultMap().entrySet());
+ .getControlLoopResultMap().entrySet())
+ || setPrimed(controlLoop);
if (updated) {
controlLoopProvider.updateControlLoop(controlLoop);
}
@@ -284,6 +285,23 @@ public class SupervisionHandler {
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.
*
@@ -410,7 +428,7 @@ public class SupervisionHandler {
var participant = new Participant();
participant.setName(participantStatusMessage.getParticipantId().getName());
participant.setVersion(participantStatusMessage.getParticipantId().getVersion());
- participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
+ participant.setDefinition(participantStatusMessage.getParticipantId());
participant.setParticipantState(participantStatusMessage.getState());
participant.setHealthStatus(participantStatusMessage.getHealthStatus());